Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Object pivot point/origin

Author
Message
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 23rd Apr 2003 04:07
Any way to change the center of rotation on an object (specifically a model) without remodeling it?
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 23rd Apr 2003 21:03
Guess not?
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 23rd Apr 2003 23:13 Edited at: 23rd Apr 2003 23:15
hmmm in fact no...but you can use some trick..

like using a little plain..of 1by1 and add a limb...to it... i mean..
or simply glue it...

ive made a 3 little demo who use this technique:

simple one:


a little more complex:

still more complex:
arras
23
Years of Service
User Offline
Joined: 3rd Feb 2003
Location: Slovakia
Posted: 24th Apr 2003 13:34
You can do it, check my walker mech post, I am doing it to make mech model.

What you need to do is to use make mesh command.
1. position model that world 0,0,0 will be where you want your new centre to be.
2. make mesh from your model using -make mesh command-
3. delete old model
4. make new model from mesh using -meke object command-
5. delete mesh if you dont need it anymore

...woalaa... your model is recentered now.
of corse you have to retexture it by -texture object command-


What Chiwawa propose is also good way, but doing so, you cant use rotation comands and collision detecting correctly in some situstions.
Funky Frank
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Apr 2003 13:45
Hell IVIonkey:
You don't say how you came by your model.

However if you have created the model yourself, or have access to a modelling package, you can move the pivot point without having to re-model it, or lose all its textures / maps :-

The pivot point for your object is set at 0,0,0 in the modelling packages coordinate system.
So, if you can, load your model up in the modelling package, then reposition it so that your desired pivot point is at 0,0,0, and finally export it back out again.
Now when you bring the model into DB, it will pivot around your chosen pivot point.

Funky Frank
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 24th Apr 2003 19:44
wow..Arras..it really work? i did not tested it..but if it work...
OOOOOOOOO YAAAAAAAAAAAAAAA
it will me really easier...to model into DB.. thx i was really not knowing that.......

how did you discovered it?
arras
23
Years of Service
User Offline
Joined: 3rd Feb 2003
Location: Slovakia
Posted: 24th Apr 2003 21:48
)...of course it works, look at my mech demo again, each limb is made like that...

And hove I discovered it? Once I was posting question about that on this forum. Somebody was recomending me to offset limb n.0 of object. It sounded good but it worked only until moment I tryed to change position or angle of object, DB simple reoffseted it again, so it was not working.
Then I was just trying this and that and tryed to making mesh from object afther I offseted limb 0 and woalaa...it made the job. Dont ask me hove I got idea to do it this way, I dont know myself
Later I found out that you need not to offset limb 0 position but that it takes world 0,0,0 like centre at the moment you make mesh.

Glad to share it with you now...
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 24th Apr 2003 23:20 Edited at: 24th Apr 2003 23:21
I had a feeling it had something to do with meshes. Very cool, arras! I'll implement this soon.

Chiwawa, thank you also. Your idea seems like a good idea. I may try it also. I don't have to worry about DBC collision detection because I wrote my own math collision detection method (which, btw, is much cleaner, faster, and more precise than the DB one ).

Oh yeah, Funky Frank, I made the model myself, but I don't want to change the origin point. I need a variable origin point. In the opening scene, I want my "sky car" to rotate about the center of mass which isn't in the same spot as the absolute center. During the game, it should have an origin (as it currently does) in the mathematical center of the object.
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 25th Apr 2003 01:51
hmm...just try my little demo to see that it work well

and ..with what you describe... my method should be esier..i think..
just glue your "sky car" to a little plain.... and instead of rotating/moving your car..rotate/move the plain.... and when you need to change the rotation point... then just move the car...from the plain.. should be done easyly....or easily ou easili .....or something like that..... sorry..im french

ive thinked to this trick ..... cause of the tank demo...wich ive modificated cause i was not understanding how the original formula can give..the right angle to rotation then ive made one..by myself..and it give EXACTLY the ...SAME SAME SAME result..but i cant .....understand how it can give the same thing..

original one:


Mine:


i think im a little bit out of the...subjet...but in fact i found this idea (to glue the model to change his rotation point) cause i was cheking how they were able to do beautiful rotation..on the 3 axis.....and ive seen that they were using a little cone under the tank ..to fix the problem of...rotation..... XZ+Y ..i dont know if you understand what i mean..anyway ..this is not important...you got the trick..lol..
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 25th Apr 2003 01:58
and.....my optimizing..problem..i mean im not able to understand how the 2 "upper" formula can give the same result..can maybe resolved...

then i ask:

how they made the Sin/Cos/Tan/Asin... formulas?
.....it should be..math formula..or something....who ..give the answer.... i mean how can i make my own Sin function...
ill search in the Math library...for C++ if i can find it..but i dont know c++..but ill try to understand the code..but if you know how..the sin.. formula work... ill be happy

if you dont know ...and i cant understand the code..ill make a post on that.. thx
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 25th Apr 2003 02:27 Edited at: 25th Apr 2003 03:38
Wow!

Ok I get your point, well at least the top 10% of your point. I didn't know much of what you were talking about by the middle if your first post, but as for SIN() and the likes, it's probably made with a pre-made table of solutions for the entire domain of sin (at least from 0 to 2pi (or 360 deg). I don't think they'd do something with complex numbers (which is how you really define sin), because that's much slower.
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 25th Apr 2003 03:02
anyway....what i was saying in the first..post was not important

hmmm but they ....should have a REAL BIG..list....of ..Sin cos..
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 25th Apr 2003 03:45 Edited at: 25th Apr 2003 03:46
Nor really. To get COS, just use the table from SIN and offset everything by 270deg (or -90). TAN will be just SIN/COS. For the inverse functions, just look up the value from the table and find the corresponding angle. As for hyperbolic functions, I'm not sure if there's a relationship to trig's or if they need a new table.

And remember, on the unit circle, you only need the values between 0 and 90 defined in a table since the rest of the quadrants are proportional to the first.
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 25th Apr 2003 04:32
yeah...ive not thinked to that..
arras
23
Years of Service
User Offline
Joined: 3rd Feb 2003
Location: Slovakia
Posted: 25th Apr 2003 16:42
Hey Chiwawa, when I was making movement and rotation of my ship I run to problem similar like yours may be. I needed to rotate object around y axis first. Command rotate object was not helpful because it rotated object around x (or z if you change rot. order) and then y, but I needed to turn ship on y to give general direction and then to implement wave inpact on ship on x and z axis.

First I looked at that tank demo and I find the same like you -they used smal parent object and glued main onto it. So I did the same
and rotated paretnt on y and main at x/z, but... then I started to make code for limb colision detection and I needed to know rotation of limbs -here come the problem -you cant find out real rotation of limbs and even object if its glued to something else.

I was making my own function for yxz rotation in ordr to not need of parent object, which took me more than week. Was full of sin, cos, tan functions but at the end it worked perfectly. And then I found out that:

Its simplier to use free flight rotation comands:
to totate x axis you need to pitch object
y -turn object
z -roll object

you can place comands in order you need: for yxz rotation it stays:

rotate object objectnum,0,0,0
turn object right objectnum,angle
pitch object down objectnum,angle
roll object right objectnum,angle

You should reset rotation at the begining othervise it will cumulate rotation with actual rotation, so if object is already rotated it will not give you right results.

Like this you can do what they did in tank demo without that small cone.
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 25th Apr 2003 20:30
hmmmm i really dont like..commande like: move object,turn object,pitch object... you know..command who do the work..for you

can i have a look to your rotating code..without glued object?
i dont need someting similar for now..but for furter developpement...
if you wont give the code..i will understand..it should be really long to acheive...next time that i make a game with car or something like that ill make my own ...xyz rotation calcul.. witout glued object...it will be a real challenge
arras
23
Years of Service
User Offline
Joined: 3rd Feb 2003
Location: Slovakia
Posted: 29th Apr 2003 14:00
Yes it was some work to do but you can have it if you will send me your e-mail adress and not give it to thirth person without my permition. My email should be listed in my profile.

And for commands which do work for you, -turn and pitch object do nothing else just rotate object around one axis so are the same like rotate object command, just if you use them they dont reset current rotation of object, so you can decide around which axis to rotate first.
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 29th Apr 2003 18:29
ok ill email you


and ..yeah turn and pitch..are..usefull...but i would know how to do it..without..then..
arras
23
Years of Service
User Offline
Joined: 3rd Feb 2003
Location: Slovakia
Posted: 29th Apr 2003 19:51
Its on the way
e-mail me if its not working for you
If its too quick, just change sync rate
Chiwawa
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 30th Apr 2003 00:01
thx when i will have enough time to check the whole code...ill try to understand ..but im confident that ill be able to understand..

thx again

Login to post a reply

Server time is: 2026-06-12 06:56:47
Your offset time is: 2026-06-12 06:56:47