aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes VIEWING VRML FILES IN JAVA3D. URGENT!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "VIEWING VRML FILES IN JAVA3D. URGENT!!!" Watch "VIEWING VRML FILES IN JAVA3D. URGENT!!!" New topic
Author

VIEWING VRML FILES IN JAVA3D. URGENT!!!

prashantpotnis
Greenhorn

Joined: Jun 03, 2002
Posts: 1
dear friends,
i want to load vrml files into java 3d so that i can have some control on the VRML code.
But following program doesn't load the vrml file.
Can anyone help me with this problem.
IT IS REALLY URGENT.
Thanks in Advance.
Regards,
Prashant.
import java.awt.*;
import java.applet.*;
import java.util.*;
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.loaders.vrml97.VrmlLoader;
import com.sun.j3d.loaders.Scene;
public class VView extends Applet
{
SimpleUniverse universe;
Scene scene = null;
public VView(String avatar)
{
setLayout(new BorderLayout());
Canvas3D canvas = new Canvas3D(null);
add("Center",canvas);

universe = new SimpleUniverse(canvas);
ViewingPlatform viewingPlatform = universe.getViewingPlatform();
View view = (universe.getViewer()).getView();

VrmlLoader loader = new VrmlLoader();
try
{
scene = loader.load(avatar);
}
catch(Exception e)
{
System.out.println("exception in loading the file");
System.exit(1);
}
BranchGroup sceneGroup = scene.getSceneGroup();
sceneGroup.setCapability(BranchGroup.ALLOW_DETACH);
sceneGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);

universe.addBranchGraph(sceneGroup);
BoundingSphere sceneBounds = (BoundingSphere)sceneGroup.getBounds();
double radius = sceneBounds.getRadius();
Point3d center = new Point3d();
sceneBounds.getCenter(center);
Vector3d temp = new Vector3d(center);
temp.z=1.4*radius/Math.tan(view.getFieldOfView()/2.0);

Transform3D viewTransform = new Transform3D();
viewTransform.set(temp);
TransformGroup.setTransform(viewTransform);
}
public static void main(String p[])
{
new MainFrame(new VView(p[0]),400,400);
}
}
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Hi "prashantpotnis", Welcome to JavaRanch!
Please change your name to comply with the naming policy to which you agreed when you registered here..

For your publicly displayed name,
use a first name, a space, and a last name.

You can change your name:
here

You can also find the naming policy:
here
Thank You!
Also, please note that people on JavaRanch are generally friendly and helpful, and will try to answer your questions as best they can, when they can. Marking your message as "URGENT" will NOT make anyone answer any faster, in fact, it will probably make people ignore you. If you like, you can edit your message to change your subject by clicking the little paper & pencil icon above your message.


Rob
SCJP 1.4
 
jQuery in Action, 2nd edition
 
subject: VIEWING VRML FILES IN JAVA3D. URGENT!!!