Concatenating transforms to scale positions but not objects
org.openjdk at io7m.com
Tue Aug 6 18:11:42 UTC 2019
I realize the subject is somewhat convoluted. I'm putting together
something that bears a passing resemblance to a DAW such as Ardour:
Mine doesn't look like that, but the principle is basically the same: I
have regions (the blocks containing waveform images above) placed on a
timeline. The timeline is scalable on both axes independently; scaling
the timeline vertically gives you more space to work with when
adjusting automation curves (visible in the "Fader" lane above), and
scaling/translating the timeline horizontally allows you to move
forwards and backwards in time, and to focus more clearly on a
particular region of time. For the sake of simplicity, let's act as if
I have just a single timeline instead of the multiple stacked timelines
shown in that image.
My application expresses the positions of regions on the timeline in
terms of "ticks" (small units of time). For the (obviously
JavaFX-based) GUI, I'd like to be able to specify a single
transform on the timeline view such that I can specify the coordinates
of region nodes in terms of ticks and the transform will determine
their onscreen pixel positions appropriately. This isn't too hard to
do; I can specify an x-axis scale such that 1 pixel = 128 ticks, and I
can then specify an x-axis translation in terms of ticks that will be
scaled appropriately for the screen. The problem then, however, is that
the the nodes within region nodes are also scaled up hugely; if I try
to put labels in the regions, the labels will appear 128 times larger
than they normally would. :)
I want to specify the *positions* of regions in one coordinate system,
but work in ordinary "scene pixels" inside those regions.
I can't quite work out how to express the transforms I need to JavaFX.
I feel like what I need to do is, for each region node, add *another*
node inside the node that fills the region entirely, and specify an
inverse of the transform applied to the parent region node... If that
makes any sense.
Is there a sensible way to do what I'm trying to do?
[I've developed a 3D renderer, so I'm familiar with how transforms are
concatenated using matrices. I don't have an intuitive understanding of
how transforms are applied inside JavaFX, and there doesn't appear
to be much documentation on this.]
Mark Raynsford | http://www.io7m.com
More information about the openjfx-dev