nnpa
May 3, 2017, 12:38pm
1
code:
characterModel = (Spatial)assetManager.loadModel("Models/player.j3o");
characterModel.move(new Vector3f(10.0f,10.0f,10.0f));
characterModel.addControl(player);
characterModel.setLocalTranslation(3.0f, 3.0f, 3.0f);
characterModel.rotate(5.0f, 5.0f, 5.0f);
rootNode.attachChild(characterModel);
How to move model inside control? Current code not work.
characterModel.setLocalTranslation(3.0f, 3.0f, 3.0f);
characterModel.rotate(5.0f, 5.0f, 5.0f);
I need down model. And move to center of capsule.
And how rotate model with mouse Z coordinates like counter strike? ( camera - vector, rotate - Degrees).
The code you supplied isn’t the code of the control (player?).
You must move/rotate it inside your control’s void controlUpdate(float)
method in player. You have more information in the wiki .
SetViewDirection or Wiki (Hello Physics)
Yes, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki …
And maybe better to start using JME 3.1 instead of 3.0. Especially if you are just starting out. It doesn’t fix this, but it sure as hell is nicer and newer
nnpa
May 5, 2017, 12:48am
8
Have this:
float cX = player.getPhysicsLocation().x;
float cY = player.getPhysicsLocation().y;
float cZ = player.getPhysicsLocation().z;
float mX = characterModel.getWorldTranslation().x;
float mY = characterModel.getWorldTranslation().y;
float mZ = characterModel.getWorldTranslation().z;
float difX = cX - mX;
float difY = cY - mY;
float difZ = cZ - mZ;
characterModel.move(difX, difY- 2, difZ+2);
I think need write custom methods for synchronize capsule and model.
Again, please go through the tutorials. Everything is explained there. Just read and learn. This what you want to do is actually much easier to implement when you read the relevant wiki entries.
nnpa
May 5, 2017, 8:03am
10
Thanks re-read manual. And next my “invention”
if(!camOld.equals(cam.getLeft())){
camOld = cam.getLeft();
Quaternion camRotation = new Quaternion();
camRotation.set(-0.173f, cam.getRotation().getY(), cam.getRotation().getZ(), 0.9830f);
characterModel.setLocalRotation(camRotation); }
nnpa:
camRotation.set(
Any time you are calling set() on a Quaternion then you are probably doing something wrong.
Usually this is a sign of a barely noob Java developer who doesn’t know where the javadoc is. Hopefully you know where the javadoc is.
nnpa
May 8, 2017, 5:10pm
12