Surely, the equivalent (I'm porting code from the old irrlicht engine) isn't:
someObject3D.rotateX(sv.x);
someObject3D.rotateY(sv.y);
someObject3D.rotateZ(sv.z);
Is it?
No idea. For that, i would have to know what the irrlicht method does.... ???
It goes like the following (whatever the equivalent irrlicht objects were):
nativeRotation.set(mesh.getRotation().x, mesh.getRotation().y + rotationY, mesh.getRotation().z);//nativeRotation WAS A vector3df (just a SimpleVector)
node.setRotation(nativeRotation);//NODE WAS SORT OF Object3D
The setRotation documentation:
http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_scene_node.html#adb6ff54f52d3a9e1514cd487a550935c (http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_scene_node.html#adb6ff54f52d3a9e1514cd487a550935c)
Judging from the sparse documentation, i would think that your port is correct (maybe with different signs depending on the coordinate system), but looking at the code, i totally don't get the +yrotation part. Are you sure that this code comes from the method that takes a vector3?
Yes. Why?
From what I gather, irrlicht's orientation is jpct's rotated PI around Y...
Quote from: AGP on March 27, 2014, 07:47:13 AM
Yes. Why?
Because i don't get it. Either add some stuff to all components or to none, but adding something to y only seems to make no sense when looking at it from the outside.
What do you mean? The way I see it, this code is producing a SimpleVector that holds an object's current rotation on all axis (and the object is currently only being rotated around y).
What do I do if I'm right about irrlicht's orientation? Is it still someObject3D.rotateX(sv.x), someObject3D.rotateY(sv.y), someObject3D.rotateZ(sv.z)?
Quote from: AGP on March 27, 2014, 08:27:59 AM
What do you mean?
I mean this:
nativeRotation.set(mesh.getRotation().x, mesh.getRotation().y + rotationY, mesh.getRotation().z);Apart from that, i really can't tell. In theory, your idea looks fine. It depends on how Irrlicht applies the rotations (i.e. in which order). I suggest to just try it and see what happens.
I know that's that to which you were referring; that's what I wrote about.
I'll go with my code for now, but I can't test it for a while: I'm working down from 1500 compilation errors across dozens of classes. I'm currently just under 1000 errors!
Too often do I need to get a Texture's name with only the texture instance in this port. Could I either get a Texture.getName() or a TextureManager.getNameByInstance(Texture)? I realize that I could use getNameByID(Texture.getExternalID()), but in my experience getExternalID() isn't always filled.
Is that a "no" or is it your day job again? :- )
No, it's rather some strange concept called "sleep". Texture.getName() isn't possible, because a texture instance has no name. getExternalID() is something completely different and not suitable for this. TextureManager.getNameByInstance(Texture) sounds reasonable. I'll add it this evening.
It's very strange indeed. But I did post this during what must be your afternoon... Thanks very much, pal. Have you had a chance to read my e-mail?
Please try this jar: http://jpct.de/download/beta/jpct.jar (http://jpct.de/download/beta/jpct.jar)
I had to decompile to find out the name of the method. :- )
Thanks a lot.
Quote from: AGP on March 28, 2014, 11:23:37 PM
I had to decompile to find out the name of the method. :- )
Why not start using a decent IDE (Eclipse, Netbeans...) instead... ???
I only use eclipse when I absolutely have to. My proprietary notepad is FAR better and never causes any problems, unlike eclipse which gets confused way too often.
What do you suppose is Irrlicht's emissive color? Object3D.setAdditionalLight? http://irrlicht.sourceforge.net/docu/classirr_1_1video_1_1_s_material.html#a005f9acf8855681c21b3e3e7de67306f (http://irrlicht.sourceforge.net/docu/classirr_1_1video_1_1_s_material.html#a005f9acf8855681c21b3e3e7de67306f)
Also, how do I convert between vecmath's Vector3f to SimpleVector?
Quote from: AGP on March 29, 2014, 07:22:12 PM
What do you suppose is Irrlicht's emissive color? Object3D.setAdditionalLight? http://irrlicht.sourceforge.net/docu/classirr_1_1video_1_1_s_material.html#a005f9acf8855681c21b3e3e7de67306f (http://irrlicht.sourceforge.net/docu/classirr_1_1video_1_1_s_material.html#a005f9acf8855681c21b3e3e7de67306f)
Maybe. I would take treat it as such until it turns out that it's not.
Quote from: AGP on March 29, 2014, 07:44:46 PM
Also, how do I convert between vecmath's Vector3f to SimpleVector?
They should basically be the same thing. You might have to convert between the coordinate systems by negating some components.
Which ones should I negate? I'm not asking because I'm lazy, I'm asking because I really don't know...
I don't know either. It depends on coordinate system that irrlicht uses. Just draw that one and the one that jPCT uses, draw three point in the irrlicht one (1,0,0), (0,1,0) and (0,0,1) and see which sign points on the same positions in the jPCT coordinate system would have. Those where the sign differs are the ones that you have to negate.
Irlicht has a getRotation() for its objects which returns a vector. Is that possible either on SimpleVector or on Matrix? I noticed there's a get_Axis(). If I rotated by the result of these three methods, would the result be that it clears the rotation matrix, then sets the rotation to a vector that would be the result of getRotation()?
Would this probably be the same thing?
nativeRot = ball.getRotationMatrix().getXAxis();
nativeRot.add(ball.getRotationMatrix().getYAxis());
nativeRot.add(ball.getRotationMatrix().getZAxis());
No, it's more likely something like this:
public static SimpleVector deriveAngles(Matrix mat) {
SimpleVector s = new SimpleVector();
float[] m = mat.getDump();
s.x = (float) Math.atan(m[9] / m[10]);
s.y = (float) Math.asin(-m[2]);
s.z = (float) Math.atan(m[4] / m[0]);
return s;
}
Thank you very much, buddy. The other end of this question is that I need to actually build a new Matrix. The following is the original code. The first block calls the second block.
float rotAngle = distance / radius * 0.5f; //rotSpeed;
Vector3f v = new Vector3f(vel.z, 0, -vel.x);
MathTools.normalize(v);
MathTools.buildRotationMatrix(rotAngle, v, matrix)l
public static void buildRotationMatrix(float phi, Vector3f axis, matrix4 mRet) {
float u = axis.x;
float v = axis.y;
float w = axis.z;
float rcos = (float) Math.cos(phi);
float rsin = (float) Math.sin(phi);
float m[] = new float[16];
//(*this)(0,0) = rcos + u*u*(1-rcos);
//mRet.setM(0, rcos + u*u*(1-rcos));
m[0] = rcos + u*u*(1-rcos);
//(*this)(1,0) = w * rsin + v*u*(1-rcos);
//mRet.setM(1, w * rsin + v*u*(1-rcos));
m[1] = w * rsin + v*u*(1-rcos);
//(*this)(2,0) = -v * rsin + w*u*(1-rcos);
//mRet.setM(2, -v * rsin + w*u*(1-rcos));
m[2] = -v * rsin + w*u*(1-rcos);
//(*this)(3,0) = 0;
//mRet.setM(3, 0);
m[3] = 0;
//(*this)(0,1) = -w * rsin + u*v*(1-rcos);
//mRet.setM(4, -w * rsin + u*v*(1-rcos));
m[4] = -w * rsin + u*v*(1-rcos);
//(*this)(1,1) = rcos + v*v*(1-rcos);
//mRet.setM(5, rcos + v*v*(1-rcos));
m[5] = rcos + v*v*(1-rcos);
//(*this)(2,1) = u * rsin + w*v*(1-rcos);
//mRet.setM(6, u * rsin + w*v*(1-rcos));
m[6] = u * rsin + w*v*(1-rcos);
//(*this)(3,1) = 0;
//mRet.setM(7, 0);
m[7] = 0;
//(*this)(0,2) = v * rsin + u*w*(1-rcos);
//mRet.setM(8, v * rsin + u*w*(1-rcos));
m[8] = v * rsin + u*w*(1-rcos);
//(*this)(1,2) = -u * rsin + v*w*(1-rcos);
//mRet.setM(9, -u * rsin + v*w*(1-rcos));
m[9] = -u * rsin + v*w*(1-rcos);
//(*this)(2,2) = rcos + w*w*(1-rcos);
//mRet.setM(10, rcos + w*w*(1-rcos));
m[10] = rcos + w*w*(1-rcos);
//(*this)(3,2) = 0;
//mRet.setM(11, 0);
m[11] = 0;
//(*this)(0,3) = 0;
//mRet.setM(12, 0);
m[12] = 0;
//(*this)(1,3) = 0;
//mRet.setM(13, 0);
m[13] = 0;
//(*this)(2,3) = 0;
//mRet.setM(14, 0);
m[14] = 0;
//(*this)(3,3) = 1;
//mRet.setM(15, 1);
m[15] = 1;
mRet.setM(m);
}
Well...then just do that. You can either set each element directly in the matrix or fill a float[16]-array and set that. As usual, you have to make sure that the formats match. Matrices in jPCT are row major, i don't know about Irrlicht.
Irrlicht's documentation says "4x4 matrix. Mostly used as transformation matrix for 3d calculations. The matrix is a D3D style matrix, row major with translations in the 4th row." I suppose that means that they're the same as jpct's, right, and that my work is done?
Most likely....