Most probably I am not understanding something right.
Let's assume I've just loaded a model from a 3ds file and have a Node:
public Node loadModelX3D(String model)
{
try
{
X3dToJme converter = new X3dToJme();
URL objFile=TestX3DLoading.class.getClassLoader().getResource(model);
ByteArrayOutputStream BO=new ByteArrayOutputStream();
converter.convert(objFile.openStream(),BO);
Node r=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
return r;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
Now, I can attach this Node to the scenegraph all right. But what if I want a second ojbect shown in the scenegraph with the exact same model? Do I really have to load it again? Or is there some way of attaching the same node to the scenegraph twice but such that I can still have them at different locaitons? Or is there some way to duplicate a Node (there is no clone method in Node).
Another issue I have is that loading time is extraordinary long. For a simple box with 36 vertices is takes 850ms. Why is that? What happens if I start loading much larger models?
Try using SharedNodes, see the jmetest package for an example.
Cheers,
Normen
normen said:
Try using SharedNodes, see the jmetest package for an example.
Cheers,
Normen
Thanks, will try.
Tracked the long loading time to the native java DocumentBuilder in X3dToJme.java. This line:
doc = documentBuilder.parse(x3dIn);
Switched to 3ds instead and works like a charm. I don't get why this line takes so long though, since the x3d file was only 3KB. Strange.