I know, that this theme was discribed a lot of times (I spent more then month for this and also read a lot of forum topics about this), but nothing can help me to understand.
My goal is to rotate a spatial (which locates in (0,2,0), for example) around the line that starts from cam.getLocation() and finishes in cam.getLocation().add(getDirection()). And all that I try, in result, performs rotation around a vector which starts in (0,0,0) and finishes in cam.getLocation().add(getDirection()). Like this:
[java]rotVector = cam.getLocation().add(cam.getDirection());
Quaternion quat = new Quaternion();
quat.fromAngleAxis(FastMath.QUARTER_PI, rotVector);
node.rotate(quat);[/java]
I know, that my question is very stupid, but I already have no strength for this. My nerves are on edge! I really need your help. That’s forced me to write on this forum.
Thanks in advance
P.S. And also sorry for my poor english! So it was very difficult for me to write this post (in all senses), also because this is my first note on this forum!
And also for understanding 3D conception:
How can I operate the vectors, which starts not in origin (0,0,0)? Or what kind of transformation I have to perform with «regular» vectors (or spatials) to manipulate (rotation, translation) in this style?
Normally, any object do rotate around its origin. If you want to rotate around some point, you need to add a node to that point, attach your object (child of that node) and then rotate the node.
The only other way would be to alter the mesh directly, but this may not be what you’re looking for either…
Nodes are the tools provided to do this to be honest, no need to do all the steps husky suggests. Just attach the model with a local translation to a node. Rotate that node to move the model in a circle. Rotate the model inside its node to face it where you want.
The scene graph for dummies tutorial has examples which covers this case if you combine them…
Yeah, but then you still have to move the node to the camera axis. But indeed, creating a node at the camera location, adding the object as a child, rotating the newly created node (after moving it to (0,0,0)?) and moving it back to the camera location should work.
Or could you perform only a local rotation of the object, once it is attached to the new node? Will it then rotate around the new nodes position?
I have one more question to you:
I have a model which I have exported from Blender (through OgreXML script). It looks like:
This model contains a group of meshes (human body parts) which were organized in Blender (according to human anatomy). When I imported this model into my JME project (and also added into my Scene Graph), I got a node with GlobalTranslation (0,0,0), but the meshes are still organized like it was in Blender. So, how can I get its “real” coordinates (like it looks like on a screen)?
I have one more question to you:
I have a model which I have exported from Blender (through OgreXML script). It looks like:
[snipped]
The above statements suggest your first problem has been solved. I do understand how nice it feels to have things working after you’ve worked hard and failed and ask for a bit of help and got a solution (and hopefully an understanding of the problem and its solution). Problem here is if you’re not updating others on your progress and how it was solved, then nobody can benefit.
Anyway. Long story short, do everyone a favor and tell us which solution worked for you so if someone else has a similar problem your solution can be found by the search engine.
@madjack said:
The above statements suggest your first problem has been solved. I do understand how nice it feels to have things working after you've worked hard and failed and ask for a bit of help and got a solution (and hopefully an understanding of the problem and its solution). Problem here is if you're not updating others on your progress and how it was solved, then nobody can benefit.
Dear madjack,
I’m still in the process of resolving my problem and my second question relates directly to the problem.
According to zarch’s post, I understand, that I have to:
Move «rotatable» node to the point of ratation
Move «rotatable» spatial back to the original location
Perform node rotation
Now, I have to determine point of ratation (on the line) where I have to translate my node. To do this, I define a triangle:
Where A — center of the spatial, that I have to rotate, BC — line, around which I have to rotate, AD — altitude of the ABC triangle, D - point of rotation.
I define a method, that gets coordinates of the triangle vertex and returns altitude coordinates
[java]
public static Point3d getAltitude (Point3d a, Point3d b, Point3d c) {
double Xa, Ya, Za, Xb, Yb, Zb, Xc, Yc, Zc;
double S,sideBC,sideAD,sideBD, altitudeX, altitudeY, altitudeZ,t1,t2,t3,t4;
Point3d altitude;
}
[/java]
To solve this task (find D point coordinates), I need coordinates of the triangle vertex.
There is no problem for me to get B and C points coordinates, but now I need coordinates of the A point.
@zarch said:
Take a look at the geometries inside the node. You can use the scene explorer to do that...
When I try to do this, I still get (0,0,0):
[java]
for (Spatial currentChild : selected.getChildren()) {
System.out.println(currentChild.getName());
System.out.println(currentChild.getClass());
Geometry geometry = (Geometry) currentChild;
System.out.println(geometry.getWorldTranslation());
System.out.println(geometry.getLocalTranslation());
}
[/java]
Output:
Head-geom-1
class com.jme3.scene.Geometry
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
@wezrule said:
Thats probably because all your meshes have origin at (0, 0, 0). Move them in blender
Can you explain in more detail?
I cant understand, why on a screen it looks like an objects with some coordinates different from each other (and not in (0,0,0)), but getLocalTranslation/getWorldTranslation returns me an origin!? Can I get a coordinates “like it looks like”?