[JME 2.0pre-a] Best method to rotate efficiently a node and children? [SOLVED]

:smiley: again a new question that should have been asked again and again :slight_smile:

By the way what is the most efficient way to rotate a node (and thus its children):

-1- given an angle and a vector?

-2- given an angle and a vector and a framerate (i.e. 10 degree per seconds for example)?

Thanks for your patience with the newbie I am  :slight_smile:

What do you mean with 'efficient'? It really depends on your use case whether you need a time/framerate or not…

By efficient I mean: quaternion or transformation matrix or a misc JME class?

By efficient I mean also: easy to understand, to maintain and to reuse :slight_smile:

My use case: firstly rotate a node by an angle along a vector/axis (direction) and secondly if I want to periodically rotate a node

Note that we could discuss all the possibilities, consider all the use cases and then make pro/cons according to different usecases.

Finally, considering the new version of JME, are there any new features in this release (regarding the previous questions)?

I hope I'm clear  :expressionless:

  • As jME stores rotation in a quaternion, the fastest way should be doing the same: using a quaternion.
  • If you frequently rotate a node, store the quaternion for the rotation, if you can.
  • If you need to obtain rotation from axis and angle, use a normalized axis (and store it to avoid frequent normalization)
  • multiplying two quaternions is not that costly, so rotation shouldn't be a performance issue actually
  • no new rotation features afaik

Thanks for your answers!

What do you think about


?  :?

SpatialTransformer is for more complex Animations. In case you just want to rotate and transform, do it manually, since SpatialTransformer does nothing else internally with a few indirections.

As we can say: "He who can do more can do less." so this SpatialTransformer seems perfect though.

If now, I have several nodes that need the same transformations, I surely must use this then, right?

you sure can  :wink:

try to move the super.update(tpf) call to the end of your update Method, and see if it makes a difference.

:frowning: no difference

I've even tried all possibilities regarding setNormalsMode(Spatial.NormalsMode.*); and nothing works :frowning:

I've run your code here and the problem seems to be with your use of float buffers… There's something wrong with the normals from the beggining. Why didn't you model that fan in something like blender or max and then import to JME?

I just commented the update to check that, because when I saw that you were programmatically building your fan from vertex buffers and normal buffers I suspected that this was your problem: wrong normals.

In fact, the object has been created using Blender and I'm using the values I get directly from the .blend file.

There is maybe some problem indeed.

It seems I'll have to deal with my importing tool :slight_smile:


Hum… You can export the individual models to OBJ format… The JME importer for it Works great for this kind of static mesh.

The OBJ format seems to contain face normals, not vertex normals.

How does JME uses normals? Can I work with face normals or vertex normals or only one of these two types?

Oh I just remarked my mesh is defined as two sided in blender, maybe it is the problem!

To close this thread my problems regarding normals are distinct from the rotation concept. The previous answer with the Quaternion is (in my opinion) the easiest way. Although I don't get why I must work with radians to end up in open GL with degrees… (or did I read incorrectly?).

Quaternions are the more stable way of storing cumulative rotation. All 3D game or visualisation engines use them in one way or another. To dig a little bit more on real-time computer graphics related concepts such these (normals, quaternions, matrixes, etc) I suggest reading the book Real Time Rendering, by Thomas M

I note the book reference! Thanks.

By the way yes, I tried to import OBJ objects. But I was disappointed by the normals imported. I didn't get smoothing through normals.

Oh and for your information, I coded the example just for testcase purpose. In fact, I'm currently implementing a .blend file reader and now, it works pretty well: http://oraclefun.blogspot.com/

Thanks again!