Simeon, I have done things similar to this. Every time a frame is rendered a Behavior updates a TransformGroup as needed. In your case, add a Behavior to the scene graph right above your cursor that WakeupOnElapsedFrames( 0, true ). In this behavior find the distance from the ViewPlatform to the cursor. The scale of the Transform3D just above the cursor should be inversely proportional to that distance (or perhaps you need to take into consideration field of view and other parameters -- you decide the algorithm).
This should solve the problem but there will be another one. You will have to guarantee that this Behavior processes after the Behavior that caused the distance to change has processed. Otherwise your scale updates may not be in sync with other scenegraph changes. Java3D provides Behavior.setSchedulingInterval() for ordering behaviors but it only applies to behaviors that WakeupOnElapsedFrames. If your scenegraph is changing in response to some other criteria (such as a mouse drag) the scheduling order will not work. I have developed a class that allows you to define a behavior that wakes up on any arbitrary condition and have java3D process it as a behavior that wakes on WakeupOnElapsedFrames for this very reason. If this is an issue for you I MIGHT be able to release the code for that. I have used these techniques for Raster text labels that are always aligned (jitter-free) to my Shape3Ds according to my preferences no matter how I drag the ViewPlatform around. I have never used OrientedShape3D because I have always assumed that there would be jitters from lack of guaranteed scheduling order. But I might be wrong about that and I see that OrientedShape3D has constant scale options. If it works for you, it's probably the better route to take. Raffi -----Original Message----- From: Simeon H.K. Fitch [mailto:[EMAIL PROTECTED]] Sent: Friday, March 29, 2002 9:26 AM To: [EMAIL PROTECTED] Subject: [JAVA3D] Preserving relative size after transform I have a requirement for a class, similar to OrientedShape3D, that preserves object size in screen coordinates rather than direction. Call it "FixedSizeShape3D". Given the following scene graph: . | BranchGroup | +----------+----------+ | | TransformGroup <--- MouseZoomBehavior | +-----+--------+ | | Shape3D FixedSizeShape3D ...changes to the TransformGroup which cause a perceived increase in size of the Shape3D (either via the ViewPlatform getting closer to the Shape3D in perspective mode, or the TransformGroup being scaled) are inverted for FixedSizeShape3D. The location of FixedSizeShape3D relative to Shape3D stays the same, but as Shape3D gets "larger" or "smaller" in screen coordinates, FixedSizeShape3D occupies the same number of pixels on the screen. I basically want to use this capability for a 3D cursor, where I select points on the surface of my 3D model and the cursor remains the same size in screen coordinates regardless of the scale transformations that are made between the Shape3D and the ViewPlatform. Again, just like OrientedShape3D, but for size. Anyone have any recommendations on how to approach this? Or does anyone have any insight into how OrientedShape3D works, and how that technique can be applied to scaling? Do I basically create a Behavior (like Billboard) with a "WakeupOnTransformChange" WakeupCriterion, and then "reverse-out" any scale change? If I do that, am i garaunteed to be able to affect the transform before the next rendering pass, or is there a chance that the viewer will see the shape "jiggle" in size? Thanks, Simeon /** * @author Simeon H.K. Fitch * @organization Mustard Seed Software * @web http://www.mustardseedsoftware.com * @email [EMAIL PROTECTED] * @voice 210.867.1616 * @fax 309.424.4982 */ =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
