nnpa
July 16, 2017, 7:18pm
1
I have model in vertical position.
I need to rotate model turn about axis, when mouse move left or right. (by left right axis)
My try…
get camera
create quaternion.
rotate.
Quaternion localRotation = new Quaternion(-0.173f, camRotationY, -0.002364515f, 0.9830f);
characterModel.setLocalRotation(localRotation);
Work if i move mouse horizontal.
Not work if i move mose by X Z
How to rotate model only by mouse Y axis
1 Like
nnpa
July 16, 2017, 8:18pm
2
I nee convet vector to qiaterinion?
1 Like
I think, looking at your trial, that you have no clue what a quaternion is. It is just simply a compact form to store a rotation. The values of a quaternion have no meaning in the sense you think. I would read the math for dummies if I were you, the link is in the head of this forum…
try fromAngles method of Quaternion object and place there the y rotation in radians…
1 Like
nnpa
July 17, 2017, 1:03pm
9
translate vector 3d to simple vector
rotate
get new vector 3d translate to simple vector
get angle
vector1 (z1,x1)
vector2(z2,x2)
Vmod = z1x1 + z2 x2
V1 = sqrt(z1z1 + x1 x1)
V2 = sqrt(z2z2 + x2 x2)
cos = Vmod/V1*V1
cos to radians
1 Like
nnpa
July 17, 2017, 1:35pm
11
I have varibles:
camRotation.getX()
camRotation.getY()
camRotation.getZ()
camRotation.getW()
camDir.getX();
camDir.getY()
camDir.getZ()
camLeft.getX()
camLeft.getY()
camLeft.getZ()
can i rotate model with this variables?
characterModel.rotate(0.0f, camRotationY, 0.0f);
1 Like
pspeed
July 17, 2017, 1:36pm
12
Quaternion values are magic. Do not try to interpret meaning from them.
Quaternion values are magic. Do not try to interpret meaning from them.
Quaternion values are magic. Do not try to interpret meaning from them.
Quaternion values are magic. Do not try to interpret meaning from them.
Quaternion values are magic. Do not try to interpret meaning from them.
Repeat as needed.
But since you don’t know where the javadoc is… I’m not sure I want to be your google.
1 Like
nnpa
July 17, 2017, 1:37pm
14
Method
/**
* Retun radian angle between two 2 vectors (get from Vector 3d)
* @param x1
* @param y1
* @param x2
* @param y2
* @return
*/
public float getRotation(float x1,float y1,float x2,float y2){
float Vmod = x1*y1 + x2*y2;
float V1 = (float) Math.sqrt(x1*x1 + y1*y1);
float V2 = (float) Math.sqrt(x2*x2 + y2*y2);
float cos = Vmod/V1*V2;
float radian = (float) (cos * Math.PI / 180);
return radian;
}
1 Like
pspeed
July 17, 2017, 1:40pm
15
mySpatial =…
float moustMovedLeftRight = …
mySpatial.rotate(0, moustMovedLeftRight * turnSpeed, 0);
1 Like
nnpa
July 17, 2017, 1:43pm
16
I need get angles for character model from camera rotation and direction.
float moustMovedLeftRight = …
angle… but witch formula
1 Like
pspeed
July 17, 2017, 1:54pm
17
nnpa:
angle… but witch formula
float mouseMovedLeftRight = mousePosition.x - lastMousePosition.x
I think one of two things are happening:
you are making this WAY more complicated than it needs to be.
you have not provided enough information.
I know for a fact that number (2) is true. I don’t know about number (1), though.
1 Like
nnpa
July 17, 2017, 2:11pm
18
I have variables this is camera vectors.
nnpa:
camRotation.getX()
camRotation.getY()
camRotation.getZ()
camRotation.getW()
camDir.getX();
camDir.getY()
camDir.getZ()
camLeft.getX()
camLeft.getY()
camLeft.getZ()
and
camLeftOld = camLeft;
camRotation = new Quaternion(camRotationX, camRotationY, camRotationZ, camRotationW);
camDir = new Vector3f(camDirectionX, camDirectionY, camDirectionZ);
camLeft = new Vector3f(camLeftX, camLeftY, camLeftZ);
and this
characterModel.rotate(0.0f, camRotationY, 0.0f);
1 Like
nnpa
July 17, 2017, 2:18pm
19
not mouse move
character model rotation by camera (mouse)
if i oldMouse.x - newMuse.x = number
i need angle between vectors
1 Like
nnpa
July 17, 2017, 2:28pm
20
I think
float[] camAngles = camRotation.toAngles(null);
float rotationY = camAngles[1];
//localRotation.multL
characterModel.rotate(0.0f, rotationY, 0.0f);
1 Like
pspeed
July 17, 2017, 2:30pm
21
We don’t know what you are trying to do or why you have to go through 20 strange steps to do it.
Maybe you are trying to reuse too much. It seems really strange to me to use camera movement to rotate your spatial when you could just hook it up directly and avoid the 20 different math steps between you and the mouse.
1 Like
nnpa
July 17, 2017, 2:37pm
22
i need rotate model with camera left right move.
rotate variables:
Quaternion
angles
1 Like
nnpa
July 17, 2017, 2:50pm
23
Work this
float[] camAngles = camRotation.toAngles(null);
float rotationY = camAngles[1];
float rotateCharacter = rotationYOld - rotationY;
rotationYOld = rotationY;
//Quaternion localRotation = new Quaternion(-0.173f, rotationY, -0.002364515f, 0.9830f);
//localRotation.multL
characterModel.rotate(0.0f, rotateCharacter, 0.0f);
But character must be rotate with camera direction
1 Like