Author Topic: Adding Rotations  (Read 13827 times)

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #15 on: February 16, 2007, 06:29:04 pm »
So I have to rotate everything?

If everything is using a different coordinate system, then
shouldnt it work fine, but the whole model will be upside down?

Apologies for my ignorance:)

EDIT:
Also, given that the coordinate system is affected in object space,
why is it that only the keyframes are wrong, yet the mesh, and the rest pose of the bones work? I think I'm at the very pinnacle of confusion now :wink:
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Adding Rotations
« Reply #16 on: February 16, 2007, 06:41:32 pm »
there is one more point to consider: Object3D.rotateX,Y,Z methods behave differently. rotateX and rotateZ rotates object counter-clockwise while rotateY rotates clockwise

egon you will remember, i once discovered this and you said you didnt noticed it before. it was also strange to discover that 3d max does the same too. so it may be some sort of standard

this may be relevant to the case
Code: [Select]
r a f t

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #17 on: February 16, 2007, 06:45:09 pm »
Interesting:)

Yeh, I do not believe it would affect the model in the way it seems to be.

Even without applying any object3D rotations, it does the same trick.
I wonder if its a blender export issue.
I think id be wise to try someone elses model.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Adding Rotations
« Reply #18 on: February 16, 2007, 07:53:10 pm »
Quote from: "raft"
egon you will remember, i once discovered this and you said you didnt noticed it before. it was also strange to discover that 3d max does the same too. so it may be some sort of standard
Yes. I've recently (re-)discovered the corresponding parts in the Javadocs and thought by myself what causes this and if it's really a correct behaviour. I came to the conclusion that it's caused by the way the rotations matrices are build. I'm not doing anything special there, so i doesn't make me wonder that 3ds shows the same effect...but it eases me off... :wink:

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #19 on: February 16, 2007, 07:54:26 pm »
Still nothing.

It is most strange how only keyframes are being affected.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #20 on: February 16, 2007, 10:14:08 pm »
Fixed it!
It was blender :shock:  :?  :roll: !

Its still a bit wrong, but it moves pretty well now.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Adding Rotations
« Reply #21 on: February 16, 2007, 10:33:06 pm »
What exactly was it?

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #22 on: February 16, 2007, 10:55:50 pm »
I cannot explain very well.

Apparently, some of the scaling, and translations were done in world space, when they were supposed to be done in object space.

To fix it, you must enter Object Mode, select the object(skeleton), and press CTRL+A.

This makes all translations and scales local(object space).

Apparently it is a bit source of confusion for people.
I was convinced id only used object space, but, reality begs to differ.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #23 on: February 16, 2007, 11:53:24 pm »
Quote from: "raft"
there is one more point to consider: Object3D.rotateX,Y,Z methods behave differently. rotateX and rotateZ rotates object counter-clockwise while rotateY rotates clockwise

egon you will remember, i once discovered this and you said you didnt noticed it before. it was also strange to discover that 3d max does the same too. so it may be some sort of standard

this may be relevant to the case
Code: [Select]
r a f t


Wait, this is affecting it! It must be! Only the Y axis is inverted now!
Thanks raft;) No idea how ill "hack" it into an inverted axis.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #24 on: February 17, 2007, 12:39:38 am »
It seems to work better now. Granted, it isnt an identical copy of the Blender version, but it is pretty good.

Edit:

Nope, still broken :roll:

Egon, is your implementation of matrices standard? I know the loader
im basing this all from uses a different matrix format to you, as you said.

I just wonder if there is something in the matMul that is different in jPCT to c++.

I really want this fixed. I have so much to finish on my FutureRP project.
The annoying thing is that the hardest, most perplexing problem, is the most documented, fundamental skeletal construct.

the c++ model doesnt use ANY invert3x3 on the transforms.
It uses it once, on the vertices, but the keyframe rotations are not subject to rotations.

http://rsn.gamedev.net/tutorials/ms3danim.asp

Thats the website.

The c++ version seems to be column major...
Code: [Select]

// Matrix data, stored in column-major order

float m_matrix[16];



Whoever provides the solution to my problem, will be held in very high regard by me:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Adding Rotations
« Reply #25 on: February 17, 2007, 11:02:08 am »
Order differs from row to column major. Maybe this causes some of the problems. Have look here: http://steve.hollasch.net/cgindex/math/matrix/column-vec.html

Quote
Egon, is your implementation of matrices standard?
Yes, standard for row major.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Adding Rotations
« Reply #26 on: February 17, 2007, 11:08:05 am »
Maybe you can write a small test case, i.e. something that does the same thing like your skeletal code on one or two SimpleVectors and that compares the outcome to what was actually expected as a result.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #27 on: February 17, 2007, 12:28:47 pm »
Okay, I will do that:).

I am currently converting the matrix class into java.
Interestingly, there is a similar problem with this too.

I think I had better add support for multiple bone assignments,
because the strange effects *may* be related.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Adding Rotations
« Reply #28 on: February 17, 2007, 03:42:20 pm »
cyberkilla, i just wanna be sure what you're doing exactly: you load both mesh and skeleton from ogre's xml format right ? (you dont use any of jPCT's loaders) then i guess you're right: coordinate system and clockwise/counter-clockwise issue shouldnt matter since all are in the same object space. all mechanism should work, possibly in wrong direction/axis, but it should work, isnt it?

so may it be that you miss-interpret ogre3d format ? for instance something related to quaternion-matrix issue ?

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Adding Rotations
« Reply #29 on: February 17, 2007, 04:17:07 pm »
Yes, you understand perfectly;).
I do not think it could be a problem either.

I have managed to make it move in the "general" correct direction, but it is  bu no means accurate.

I think I will use quaternions too, because the euler to matrix, to rotation vector is subject to a strange 90 degree issue(flips axis after a certain rotation).

EDIT:
Yup, im going to use quaternions with angle axis, because it looks like im being hit be "gimbal lock". I wondered what this meant, so I read about it, and it looks familiar.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG