java3d


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: java3d

Hybrid View

  1. #1
    PoTTy Guest

    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;
    }


  2. #2
    MarkN Guest

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center