Revealing text as on a scroll

Hi Thaumaturge :slight_smile:,

A simple (although perhaps not the most efficient/straightforward) solution would be to use clipping planes:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from direct.interval.IntervalGlobal import *


class App(ShowBase):

  def __init__(self):

    ShowBase.__init__(self)

    text = TextNode("unrolled_scroll_text")
    text.setText("Text revealed as if by unrolling a scroll.")
    text_np = aspect2d.attachNewNode(text)
    p1, p2 = text_np.getTightBounds()
    x1 = p1.x
    x2 = p2.x
    x_center = (x1 + x2) / 2.
    scale = .07
    text_np.setScale(scale)
    
    text_np.setX(-x_center * scale)
    clip_plane_l = PlaneNode("clip_plane_left", Plane(Vec3(1., 0., 0.), Point3()))
    clip_plane_l.setClipEffect(1)
    clip_np_l = text_np.attachNewNode(clip_plane_l)
    clip_np_l.setX(x_center)
    text_np.setClipPlane(clip_np_l)
    clip_plane_r = PlaneNode("clip_plane_right", Plane(Vec3(-1., 0., 0.), Point3()))
    clip_plane_r.setClipEffect(1)
    clip_np_r = text_np.attachNewNode(clip_plane_r)
    clip_np_r.setX(x_center)
    text_np.setClipPlane(clip_np_r)
    
    interval_l = LerpPosInterval(clip_np_l, 3., Point3(x1, 0., 0.), blendType="easeOut")
    interval_l.loop()
    interval_r = LerpPosInterval(clip_np_r, 3., Point3(x2, 0., 0.), blendType="easeOut")
    interval_r.loop()


App().run()

However, if you are going to use several of these texts at the same time, beware that your graphics card might not support that many clipping planes.

Anyway, I hope this helps :slight_smile: .