Author Topic: How do I do Object3D.rotate(SimpleVector)  (Read 2286 times)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
How do I do Object3D.rotate(SimpleVector)
« on: March 27, 2014, 03:40:47 am »
Surely, the equivalent (I'm porting code from the old irrlicht engine) isn't:
Code: [Select]
someObject3D.rotateX(sv.x);
someObject3D.rotateY(sv.y);
someObject3D.rotateZ(sv.z);

Is it?
« Last Edit: March 27, 2014, 03:48:17 am by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #1 on: March 27, 2014, 07:14:26 am »
No idea. For that, i would have to know what the irrlicht method does.... ???

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #2 on: March 27, 2014, 07:25:52 am »
It goes like the following (whatever the equivalent irrlicht objects were):

Code: [Select]
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #3 on: March 27, 2014, 07:39:39 am »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #4 on: March 27, 2014, 07:47:13 am »
Yes. Why?

From what I gather, irrlicht's orientation is jpct's rotated PI around Y...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #5 on: March 27, 2014, 08:21:11 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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #6 on: March 27, 2014, 08:27:59 am »
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)?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #7 on: March 27, 2014, 08:53:12 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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #8 on: March 27, 2014, 08:58:26 am »
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!

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #9 on: March 27, 2014, 06:44:27 pm »
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.
« Last Edit: March 27, 2014, 08:35:42 pm by AGP »

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #10 on: March 27, 2014, 10:42:29 pm »
Is that a "no" or is it your day job again? :- )

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #11 on: March 28, 2014, 07:18:35 am »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #12 on: March 28, 2014, 07:40:49 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #13 on: March 28, 2014, 09:15:10 pm »

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: How do I do Object3D.rotate(SimpleVector)
« Reply #14 on: March 28, 2014, 11:23:37 pm »
I had to decompile to find out the name of the method. :- )

Thanks a lot.