advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Reviews : Java Books : 3D User Interfaces with Java 3D :


Title: 3D User Interfaces with Java 3D
ISBN: 1884777902
US Price: $49.95
© Manning Publications Co.

13.1.4 Inverse getLocalToVworld

Situations can arise where you need the Vworld-to-local transform, instead of the local-to-Vworld transform returned by a node. In such case, you can use the inverse method of Transform3D to convert the transform. Because this situation comes up fairly often when performing in-scene manipulation and the pseudo-overlay visualization techniques, it is worth exploring this subject in more detail.

For example, using world-relative mapping (WRM) control you may want to slide a desk in a room toward a window, which is north of the desk. Normally, the world-relative output from the WRM technique would be used to manipulate the desk's "actuator" transform group directly. If, however, the desk is a member of a group, such as in a suite of furniture, then the group itself is likely to have an actuator transform allowing the group as a whole to slide and rotate. Because the desk's actuator is not in the world space but in the local space of the group, you can't simply apply the world-relative movement from WRM to the desk's actuator. Instead, you have to first convert the world-relative movement, a vector pointing north, into a group-relative movement. This requires getting the desk actuator's local-to-Vworld transform, inverting it into a Vworld-to-local transform, and transforming the north-pointing vector with it. The result is a north-pointing vector expressed in terms of the desk actuator's local space, which is defined by the group's actuator. Because the coordinate space of the vector and the desk's actuator now match, they can be multiplied together to update the desk actuator's transform state while leaving the rest of the group alone.

The following code fragment illustrates the salient points of this example:

	// build a desk and group with actuators 
	/// create the desk object 
	MyDesk desk = new MyDesk(); 

	/// create a desk actuator and add the desk to it 
	TransformGroup deskAct = new TransformGroup(); 
	deskAct.addChild(desk); 

	/// create a group actuator and add the desk actuator to it 
	TransformGroup groupAct = new TransformGroup(); 
	groupAct.addChild(deskAct); 

	/// add the desk to the world's root node 
	root.addChild(groupAct); 

	// arbitrarily manipulate the group and desk 
	... 

	// move the desk north in the world by 10 meters 
	Vector3d northward = new Vector3d(0, 0, -10); 

	/// get the desk actuator's local transform 
	Transform3D xform = new Transform3D(); 
	deskAct.getLocalToVworld(xform); 

	/// transform the northward vector from world to local space
	xform.invert(); 
	xform.transform(northward); 

	/// get the current desk actuator state 
	Transform3D current = new Transform3D();
	deskAct.getTransform(current); 

	/// apply the change vector to the desk actuator state 
	Transform3D change = new Transform3D(); 
	change.set(northward); 
	current.mul(change); 

	/// don't forget to set the new transform 
	deskAct.setTransform(current); 

13.1.5 Local-to-local

The most general case of coordinate-space transformation, conversion is needed to go from one local space to another. A simple example would be DRM control of a target object in a group, where display-relative local space inputs are translated into their world-relative equivalents, which are then converted for use in the local space of the target object actuator. To perform this two-legged coordinate-space transformation, imagine combining the two previous coding examples into one, with the first half going from local to world space, and the second half going from world to local space. Generalized versions of local-to-local transformation— from a source space to a target space— are provided by the j3dui.control.mappers.Mapper. toTargetSpace methods in the UI framework. One method is for point transformation and the other is for vectors.

Stop by in one week for the next installment!

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs