This seems a confuse question i guess.
I have a node with 2 geometry, corresponding to an object.
My main character has a character control
[java]control = new CharacterControl(new SphereCollisionShape(0.8f), .9f);
control.setPhysicsLocation(model.getLocalTranslation());
control.setFallSpeed(10f);
masterNode.addControl(control);
control.setPhysicsLocation(new Vector3f(0f, 10f, 0f));[/java]
Now, ive added that node, with 2 geometry into the scene. The character cant get pass thro it.
If i move the node , the object physics keep still in place, so i cant pass the original place the object was.
If i add a RigidBodyControl to the Node, its bounds get too big. If i add to those geometry separated, it works fine however ll have to use setPhyisicsLocation() to move it, and it looks like its a ‘global’ range not inside the node.
I wish i could move the node, and those geometry physics update as the node moves.
Im sorry if i wasnt so clear.
Thanks for the attention !
look at TestLocalPhysics
hmm thanks
so you just have to add the rigid body to the node ? However, how can i get the exact shape of my 2 geometryes so i can make a control with that exact shape ?
I cant batch them together because they have separate data on userData.
Thanks alot for thy attention !
Make a compound shape and set it to the node instead of the leafs
Ive searched for CompoundShape, i see that is what i need to do.
However i couldnt manage to it. Will i have to add a control to each Geom separately or only for the node ?
This is the cosest ive reached , but still, it doesnt work (i can get pass thro the object, however i cant get pass thro its leaves… im really confused.
this is the code im using to create the tree
http://code.google.com/p/the-dungeon/source/browse/Epiczz/src/Scenery/Thing/Things/TreeEntity.java
Thanks for the attention normen ! Ur very patient with me ^^
make the compound shape (e.g. by using the CollisionShapeFactory with the node) and then attach the control to the node yeah.
but the factory doesnt returns me a Compound Couldnt find any example code doing this
Im doing with the node but with a normal CollisionShape, how can i get the Compound ? Will i have to create collision for both geometryes and then add to a new compound everytime a tree is created ?
Thanks for the attention.
createDynamicMeshShape does return a compound if you use it on a node with geometry children, yes
Sorry to bother you man, but it didnt work
[java]CompoundCollisionShape compound = (CompoundCollisionShape) CollisionShapeFactory.createDynamicMeshShape(getEntityMasterNode());
RigidBodyControl body = new RigidBodyControl(compound, 0);
getEntityMasterNode().addControl(body);[/java]
the masternode is the node witch contains the 2 geometryes
am i missing something ? im very confused about physics.
Thanks for your attention normen, ur the man !
This is the whole tree creation method if you want to take a look
[java]Sphere d = new Sphere(16,16, 1.3f);
Geometry leaves = new Geometry("leaves",d);
leaves.setLocalTranslation(0,6,0);
leaves.setMaterial(Main.getHandler().getAssetManager().loadMaterial("Materials/Leaves.j3m"));
this.getEntityMasterNode().attachChild(leaves);
Cylinder log = new Cylinder(10, 10, 0.4f,6f);
Geometry gLog = new Geometry("log", log);
gLog.setLocalRotation(DumbMath.PITCH090);
gLog.setLocalTranslation(0,2,0);
gLog.setMaterial(Main.getHandler().getAssetManager().loadMaterial("Materials/couro.j3m"));
this.getEntityMasterNode().attachChild(gLog);
CompoundCollisionShape compound = (CompoundCollisionShape) CollisionShapeFactory.createDynamicMeshShape(getEntityMasterNode());
RigidBodyControl body = new RigidBodyControl(compound, 0);
getEntityMasterNode().addControl(body);
Main.getHandler().getSpace().add(getEntityMasterNode());[/java]
so i kinda got this working, i was moving the Node itself instead of the physics location, that caused the bug
however i still cant move the tree.
Its bounding area works fine, however if , for example, i rotate the tree in a loop:
[java]rot.fromAngleAxis(speed, Vector3f.UNIT_X);
tree.getControl(RigidBodyControl.class).setPhysicsRotation(rot);[/java]
The bounding areas doesnt rotate as well, so i think im back into the same step i was
thanks for the attention