Help with object rotation and object sizing

Hey everyone, I’ve just stared coding my first major project with this engine, and I’ve come across a couple problems that I don’t really know how to approach.

Problem 1: I Understand how to rotate objects in general, but I need to rotate a cylinder about its base, which I cannot figure out how to do.

Problem 2: The project involves the real-world measurements of a hand, so I want to be able to scale the “fingers” very precisely. From the looks of it, the scaling feature for objects is integer based, as is the size of the objects. Is there any way to make the segments of the hand more closely reflect their real-world counterparts?

Any help is appreciated.

Thanks,

-Alex Berliner

monorail said:
Problem 1: I Understand how to rotate objects in general, but I need to rotate a cylinder about its base, which I cannot figure out how to do.

This depends first on which axis is up in your project. The default is Y, so I post this code with that in mind.
``` myObject.setLocalRotation(Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD*47, new Vector3f(0,1,0))); ```

This rotates your object 47 degrees about the Y-Axis. We know it is the Y-axis because of the Vector3f we have passed in (and can be changed accordingly)

monorail said:
Problem 2: The project involves the real-world measurements of a hand, so I want to be able to scale the “fingers” very precisely. From the looks of it, the scaling feature for objects is integer based, as is the size of the objects. Is there any way to make the segments of the hand more closely reflect their real-world counterparts?

This is more a problem in your head than anything. Units in jME, as in any other 3D engine or modeling tool, are completely arbitrary until you (or the software) assigns a value to it. If you're working in terms of a hand, or even the full human body, then your desired working unit may be centimeters. If, however, your project is to create a mountain range, then meters would likely fit the bill better.

Making this happen on a technical level is quite easy, as it is simply a matter of saying to yourself "I will model this hand in Blender to be x number of units large and when I import it into jME, it will still be x number of units". Bear in mind that this process may be different depending on your modeling tool as Maya, for example, assigns units from the outset (its default is centimeters and depending on exporter, will export to either centimeter units or the selected working unit value)

I hope this has helped some :)

First, thank you for helping me I really appreciate it.

I still have a couple of questions though.

sbook said:
This depends first on which axis is up in your project. The default is Y, so I post this code with that in mind.
`
`

This rotates your object 47 degrees about the Y-Axis. We know it is the Y-axis because of the Vector3f we have passed in (and can be changed accordingly)

Sorry I should have clarified this. I made a picture to explain what I need to do.
http://i52.tinypic.com/28l0qo.jpg
From my understanding, "myObject.setLocalRotation(...)" performs a rotation around the middle. I need to rotate my object around the base. I have a feeling that I need to set a node to that position and bind the object to the node, but I'm not sure of how to do that either. It's as if your finger was moving; it moves from the joint connected to your hand, not from the point in between the two joints.

sbook said:
This is more a problem in your head than anything. Units in jME, as in any other 3D engine or modeling tool, are completely arbitrary until you (or the software) assigns a value to it. If you're working in terms of a hand, or even the full human body, then your desired working unit may be centimeters. If, however, your project is to create a mountain range, then meters would likely fit the bill better.
Making this happen on a technical level is quite easy, as it is simply a matter of saying to yourself "I will model this hand in Blender to be x number of units large and when I import it into jME, it will still be x number of units". Bear in mind that this process may be different depending on your modeling tool as Maya, for example, assigns units from the outset (its default is centimeters and depending on exporter, will export to either centimeter units or the selected working unit value)

I hope this has helped some :)

I was thinking about just creating cylinders from inside JME, not by exporting models. If I were to make objects in JME that had a size of 300 instead of 3, they would take up the entire screen. Is there a way to edit the scope of the camera so that I can fit more things on the screen and they appear smaller?

Thanks again.
monorail said:
From my understanding, "myObject.setLocalRotation(...)" performs a rotation around the middle. I need to rotate my object around the base. I have a feeling that I need to set a node to that position and bind the object to the node, but I'm not sure of how to do that either. It's as if your finger was moving; it moves from the joint connected to your hand, not from the point in between the two joints.

Ah ok, I see what you mean... Like a pivot point :) Yes, you're correct in your thinking, the implementation would look something like:
``` // assuming you have the finger already made called "finger" Node fingerNode = new Node("fingerNode"); fingerNode.attachChild(finger); // this is the offset that you would like to use (the obvious way would be cutting the 300 unit size in half) finger.setLocalTranslation(new Vector3f(150,0,0)); // This is a guess that you would be using the x-axis // Now we rotate the entire finger node (you will also do your translations from here) fingerNode.setLocalRotation(Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD*47, new Vector3f(0,1,0))); ```

monorail said:
I was thinking about just creating cylinders from inside JME, not by exporting models. If I were to make objects in JME that had a size of 300 instead of 3, they would take up the entire screen. Is there a way to edit the scope of the camera so that I can fit more things on the screen and they appear smaller?

This is just a matter of setting up the rest of your scene to match the scale you've used for the cylinder. If your camera is starting 1 unit away, have it start 100 units away... if the move speed is set to 10 units per update, try setting it to .1f units. It all comes down to consistency and tricking the user into thinking that the scale is accurate!

Alright. Everything I wanted to know has been straightened out. Thank you

And what if I then do .getBuffer(Type.Position…) - will all vertex coordinates change after space transformation?

KayTrance said:
And what if I then do .getBuffer(Type.Position....) - will all vertex coordinates change after space transformation?

Nope, the transformation you apply to the geometry does not effect the mesh.
If you wanted to convert a position to world space, you can use the Spatial.localToWorld() method.