Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Creating a vector of three rot components; I can`t get it work
Topic Started: Nov 16 2007, 03:52 PM (494 Views)
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]
Hi there!

I`m trying to create a vector of three rotation components( rotx,roty, rotz).
To be more accurate I`m using a length variable, to get the position in 3d of a point, relative to these rotations and with the correct length offset.

I`s needed to create a bone chain in U3d, and when the main bone rotates, all the chid bones to rotate, but for now it`s a real mess...

Help.... :sad:


ANY IDEAS? :wub:



EDIT: I`m looking for some formulaes like those x+sin(..., but including rotx,y and z
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
My guess is that you will need to represent each bone with a matrix, describing its orientation & position. Then you transform the matrices representing the child bones with the matrix that represents the parent bone. Just thinking out loud ^_^.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]
WIll it be CPU expensive?

I`m creating a U3d bone system, in which the bone`s oriebtation is in the rotx,y,z=0 and the origin of the bone is in the x,y,z and particular length. So how could I place the child bone in the correct position in space?
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
Bami
Member Avatar
Guess the character, win a prize
[ *  *  *  *  * ]
Protip: Look at the Move() script.
Here are the thrill seekers, corrupt and immoral.
Posted Image
Offline Profile Quote Post Goto Top
 
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]

@ Bami:

Currently I`m using the same formula, but it`s using rotx and roty ,not including rotz, so I get proper result only for the first child bone. The next are doing whatever they want <_<
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]

I`ve tried finding the coordinates of the vertex at the tip of the bone too, but furfile...
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
That's why I suggested using matrices; for 1st-level child bones, the formula in the Move() script does work, but the problem with child bones further down the hierarchy chain, is that their orientation needs to be transformed by that of their parent, so it comes down to getting the correct rotx/y(/z) values for these child bones. And the easiest way to do that (IMHO) would be by retrieving them from a transformed matrix using ComputeMatrixRotationAngles(...).
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]
If I send you cutted version of my example, will you take a look? :rolleyes:
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Sure thing, man :)!
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Since I have implemented a bone architecture for Ultimate 3D I can tell you how this can be done very precise. A warning in advance: Since in GM everything is slow this will be especially slow ;) .

First you need to code the hierarchy itself. Every bone has it's parent bone (despite the root). From these parent bone indices a list of children and siblings can be computed for every bone. If you do this you can cycle through the bone hierarchy recursively. You start at the root. If the root has a sibling, the same computations are done for this. If the root has a child the same computations are done for this. The most elegant way to implement this is the use of arrays and a script that calls itself recursively. The nice thing about this method is that you can be sure that bones with a higher position in the hierarchy get computed first, which is important.

Anyway, this was just a hint, lets go for your actual question. The solution is quite simple. From the rotation keys (or whatever you have) you can compute a transformation matrix for the bone in relation to it's parent (bone to parent space matrix without offset). Next you create a very simple translation matrix, which has two components set to zero and the third one set up as the length of the parent bone. You can chose an arbitrary axis for the length component, it just depends on how you define things. E. g. for Anim8or models the z-axis is used for this purpose. Now you transform the bone to parent space matrix by this translation matrix. The translation matrix has to be the second matrix in the parameter list of the function (alternatively you can create the complete transformation matrix with offsets immediately using CreateTransformationMatrix(...). The result is the bone to parent space matrix with offset. Since you have already done the same for the parent bone (see above ;) ) you have a parent space to world space matrix. So now all you need to do is multiplying the bone to parent space matrix with offsets by the parent space to world space matrix to get the bone to world space matrix.

Note that this solution doesn't need any trigonometry. All the trigonometry you need is part of the implementation of CreateRotationMatrix(...). Once the rotation matrices have been computed this is a pure linearly problem.

Easy :D ?
I'm ready for any further questions ^_^ .
Offline Profile Quote Post Goto Top
 
shadowslair
Member Avatar
mourning soul
[ *  *  *  * ]
Thanks, Dr Best.
Actually I`m not trying to implement any new bone system, I didn`t found the correct words- I`m trying to continue the project I`ve been working on some months ago, which I stopped because of the low fps. I just needed some information about the use of those matrixes... :D IMysteriXYZ did it....The only thing I`m afraid of for now is will it be sufficiently optimised to be used in serious game :think: .Anyway: Thanks!!!


:clapping: :clapping: :clapping: SOLVED BY MysteriXYZ !!! :clapping: :clapping: :clapping:


:music: :music: :music:
And if I bleed I`ll bleed, knowing you don`t care... And if I sleep just to dream of you I`ll wake without you there... Isn`t something missing?..
Offline Profile Quote Post Goto Top
 
Bami
Member Avatar
Guess the character, win a prize
[ *  *  *  *  * ]
Problem with GM's speed lies in it's slow lookup in sin, cos and tan() tables, not many people realise this, btu thats what's really bogging down GM games involving large amounts of trig.

A way to improve it is to do this:

initTrig()
Code:
 
for(i=0;i<=360;i++){
global._sin[i] = sin(degtorad(i));
}
for(i=0;i<=360;i++){
global._cos[i] = cos(degtorad(i));
}
for(i=0;i<=360;i++){
global._tan[i] = tan(degtorad(i));
}

fastSin(degrees)
Code:
 
return global._sin[(argument0)mod(360)]

fastCos(degrees)
Code:
 
return global._cos[(argument0)mod(360)]

fastTan(degrees)
Code:
 
return global._tan[(argument0)mod(360)]


2 advantages:
1) It pulls the values from a table, instead using the sin/cos/tan command (which actually calculates it on-the-fly), although its a bit less precise
2) You dont need to calculate from degrees to radians.
Here are the thrill seekers, corrupt and immoral.
Posted Image
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Thanks for that code, although something like "i++" might cause problems in Game Maker ^_^. C++ habits, I presume ;)?

What I find to be very slow in GM, is the drawing of text - probably because fonts are like vector objects, which need to be calculated every step?
Good idea by Dr. Best to turn them into bitmaps, then :thumb_up: .
Sorry for the off-topic :D.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply