Bones - Skeletal and Pose Animations for jPCT/jPCT-AE > Bones

Help adding movement to the Ninja demo

(1/1)

neo187:
Hello

Sorry for what could seem like an extremely noob question. I have just discovered jPCT AE which seems perfect for my Android project. I am playing with the Ninja demo as I will be needing to have a skeletal model in, I am just trying to test mesh movement.

So in the addNinja method (the button for adding extra copies of the model) the mesh is placed with:

ninja.getRoot().translate((float)(Math.cos(angle) * radius), 0, (float)(Math.sin(angle) * radius));

Under that I am testing moving the model a bit on the Y axis everytime a new one is added:

ninja.getRoot().translate(new SimpleVector(0.0f,3.0f,0.0f));

I've actually tried any coordinates but i don't see any changes...am I looking at the right method for translating meshes in world space?

Thanks a lot!

MrM:
Taken from DOC, Object3D:

--- Quote ---translate

public void translate(float x,
                      float y,
                      float z)

    Translates ("moves") the object in worldspace by modifying the translation matrix. The translation will be applied the next time the object is rendered.
--- End quote ---
Trust me, the DOC will help you A LOT when beginning with JPCT, it's very thorough and well made.
http://www.jpct.net/doc/

I guess it's the right method, although I don't know it's being rendered since I haven't seen the demo.
Keep in mind that:
http://www.jpct.net/wiki/index.php/Coordinate_system

Sine and Cosine have really small values (from -1 to 1), and depending on the radius, I guess (Math.cos(angle) * radius) or (Math.sin(angle) * radius) would still give a really small value.
So, try translating to really small values, like ninja.getRoot().translate(new SimpleVector(0, 0.3f ,0.)); or even 0.03f, just to check that the ninja isn't moved too far away to see.

raft:
@neo187, if you want to move the model around, you should translate it every frame, not when a new ninja is added.

AnimatedGroup.getRoot().translate(..) is the correct and recommended way of this.

neo187:
Thanks guys. That did work ok if called at every frame.... Any suggestions on how to make the character move in relation to the camera position? So that if the camera rotates and you press forward the character moves in that forward direction?

Thanks all for your great help, love this forum!

raft:
something like this:


--- Code: ---SimpleVector d = Camera.getDirection();
d.scalarMul(..);
AnimatedGroup.getRoot().translate(d);
--- End code ---

Navigation

[0] Message Index

Go to full version