The code works fine with the ms3d, but not with 3ds. I haven't changed the code, but
manager.setGeometry((Geometry)(node.getChild(0))); gives me an error.
What can I do to use 3ds instead of ms3d. what is the problem?
Thanks
Try manager.setGeometry((Geometry)node.getChild(0));.
Jedimace1 said:
Try manager.setGeometry((Geometry)node.getChild(0));.
You gotta be kidding!! :(
About the problem:
Can you paste the error here?
22.09.2008 22:55:57 com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
22.09.2008 22:55:57 com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
22.09.2008 22:55:57 com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W: 640H: 480
22.09.2008 22:55:57 com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
22.09.2008 22:55:58 com.jmex.audio.openal.OpenALSystem setupSourcePool
INFO: max source channels: 64
22.09.2008 22:55:58 com.jmex.game.state.GameStateManager create
INFO: Created GameStateManager
22.09.2008 22:55:58 com.jme.util.lwjgl.LWJGLTimer <init>
INFO: Timer resolution: 1000 ticks per second
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:58 com.jme.scene.Node attachChild
INFO: Child (Text) attached to this node (TextNode)
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:58 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.scene.Node attachChild
INFO: Child (default##0) attached to this node (default)
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.scene.Node attachChild
INFO: Child (default) attached to this node (TDS Scene)
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.util.TextureManager loadImage
WARNUNG: loadImage(String fileExt, InputStream stream, boolean flipped): no imageData found. defaultTexture used.
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
22.09.2008 22:55:59 com.jme.scene.Node <init>
INFO: Node created.
Exception in thread "main" java.lang.ClassCastException: com.jme.scene.Node
at game.bin.effects.Effect_Fire.<init>(Effect_Fire.java:49)
at game.bin.loader.Mesh.<init>(Mesh.java:113)
at game.bin.objects.BackgroundMenu.<init>(BackgroundMenu.java:31)
at Main.main(Main.java:95)
The funny thing is, that I have no problems, when I use the milkshape object, but 3DS is loading only, without the flame effect.
The error messages tells you that there is a Node and not a Geometry. Have a look at the scenegraph basics in the wiki if you don't know what that means. It's probably enough for you to cast to Node and take the first child of that again. But it might as well be likely that you need to use multiple geometries for that exporter. (No idea what that "manager" is, btw)
As Irrisor wrote, the result of a model loading in your case is a node not a geometry.
We cannot see what this manager in the code does, but maybe you can change it to accept a Spatial (the super class of both Node and Geometry)? In that case you dont care whether there is one mesh or multiple.
Its the TestFireMilk.java example!
I want to run it with a 3ds file, but it doesn't work!
manager.setGeometry((Spatial)(object.getChild(0))); didn'T work
How can I get one Child more?
object.getChild(0).getChild(0)??? That's not it right?
StraightForward solution
The model should not be nested that deep.
Use the Debugger to see how the tree of the model is constructed after import.
Then extract the model from the Node at the required point.
How can I use the debugger?
Where is the required point?
When I use the milkshape model it works fine!
When I use my 3ds model it doesn't
The loader is the same (read the necessary format)
The milkshape loader produces a hierarchy of JointMeshes.
JointMesh extends TriMesh which extends Geometry.
The 3DS loader produces a hierarchy of Nodes. Node extends Spatial and is not a form of Geometry.
That is why one works and not the other.
However, each of the Nodes has attached to it a Trimesh. You could add these to the particle manager.
Something like this ought to work:
Node cn = (Node)object.getChild(0);
manager.setGeometry((Geometry)(cn.getChild(0)));
But it is ugly and incomplete. I suppose you might have to walk through the Nodes and add each TriMesh to set the whole thing alight.
Thanks, it's a solution I can live with
And the best! It's working!
Thank you very much!!!