-
java3d
hi been trying to get some answers for ages now
and im hoping some one here can help me
im writing a 3d first person game using java3d.
i need to know how to attach an object to the camera
the camera position is moved with a keyboard behaviour.
also i have a problem with the rotationInterpolator class...
i have an object that rotates but when i try to move the object into position
it dosent move unless the position specified is outside the behaviour bounds..
any help would be great!!
below is the code im playing with at the mo....
////// code used to rotate an object
///// but how do i move the object into position in the universe??
filename = "c:\\windows\\desktop\\3d\\models\\face.ms3d";
java.io.File file1 = new java.io.File(filename);
if (file1.getParent().length() > 0) // figure out the base path
loader.setBasePath(file1.getParent() + java.io.File.separator);
Scene object2 = loader.load(file1.getName());
Transform3D rotateCube = new Transform3D();
TransformGroup rotationGroup = new TransformGroup(rotateCube);
rotationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Alpha rotationAlpha = new Alpha(-1,Alpha.INCREASING_ENABLE,0,0,4000,0,0,0,0,0);
Transform3D yAxis = new Transform3D();
RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,rotationGroup,yAxis,0.0f,(float)Math.PI
* 2.0f);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
rotator.setSchedulingBounds(bounds);
BranchGroup obj2 = new BranchGroup();
obj2.addChild(rotationGroup);
rotationGroup.addChild(object2.getSceneGroup());
rotationGroup.addChild(rotator);
group.addChild(obj2);
/////////// how can i attach an object to the camera
////////// so that the object moves with it
///////// for example if i wanted to have a gun model move
///////// with the player
private BranchGroup setupCamera() throws Exception
{
BranchGroup scene = new BranchGroup();
//Set user interaction////////////
KeyNavigatorBehavior navigator = new KeyNavigatorBehavior(u.getViewingPlatform().getViewPlatformTransform());
navigator.setSchedulingBounds(new BoundingSphere(new Point3d(), 10000.0));
scene.addChild(navigator);
//////////////////////////////////
//Set camera position/////////////
TransformGroup vtg = u.getViewingPlatform().getViewPlatformTransform();
Transform3D moveUp = new Transform3D();
moveUp.setTranslation(new Vector3f(0.0f, 10.0f, 0.0f));
vtg.setTransform(moveUp);
//////////////////////////////////
return scene;
}
-
-
hi, i want a source code java3d chage a photo 2D to 3D and edit it means change eyes colors...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks