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.

AppGameKit Classic Chat / grouping 3d objects and then rotating them as one

Author
Message
haliop
User Banned
Posted: 9th Nov 2013 18:08
in Dgdk i could use limbs options and it was very easy to rotate a center object and see all the other rotate towards or with it ..
but now i kinda get it hard to do it ... any sample here? im sorry i cannot afford searching for it myself cause i dont have internet and im using a friend pc and will check it later when i'll be able to..


thank you in advance.
nadav.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 9th Nov 2013 19:48 Edited at: 9th Nov 2013 19:52
You have to do this manually with AGK. 3d rotation maths can be difficult so your easiest approach is to use the move local and rotate local commands.

If you have an object and want to attach an object to it, use this approach to figure out how to place it. Make a little app and ...
1. Put your parent object at 0,0,0 rotated to 0,0,0
2. Put your child object here too with the same rotation.
3. Move and rotate the child object with the local commands until its in the position you want relative to the parent object

You now have the steps required to orient your child object to the parent object. So it may be:
Rotateobjectlocalx(child,45)
Moveobjectlocalz(child,5)
Moveobjectlocalx(child,-6)

Now all you have to do in your actual game code is:
Set the child position to the parents position
Set the child rotation to the parents rotation
Run through the steps you've figured out above to position it correctly relative to the parent.

The parent can be any angle or position and the child will be correctly placed. Hope that makes sense.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Nov 2013 20:37
Combining object rotations is pretty simple, but it partly depends on whether you are using tier 1 or tier 2.

You simply construct two quaternions and multiply them together.

Tier 2 programs can utilise the AGKQuat structure while you would need to write the quat*quat function yourself for tier 1, you will find it online.

haliop
User Banned
Posted: 9th Nov 2013 20:52
Im using tier 1
What should i search for ? Cause i kinda understand but i kinda losing focus to achivd that ..
Can someone please write a small example ?

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Nov 2013 22:39 Edited at: 9th Nov 2013 22:40
It's tougher in tier 1 since you don't have a math library, they should really add one like DBPro did, in fact they already have one, they just need to wrap it up for tier 1 users.

The multiplication formula is here:
http://www.mathworks.co.uk/help/aeroblks/quaternionmultiplication.html

You get the four values for each object with GetObjectQuatX/Y/Z/W(), multiply them together then you have combined rotation, they need to be multiplied in correct order.

If you get that working you are nearly there, you still need to rotate the position also.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 10th Nov 2013 00:22
Would be very interested to see an example of this if you get it working. I know nothing about quaternions.
haliop
User Banned
Posted: 10th Nov 2013 08:51
Ok i will do my best to study this if i wont suced i,ll do a fake 3d racing using the cameras

haliop
User Banned
Posted: 10th Nov 2013 10:50
If someone will make a very small example with objects connected it will help me alot.

haliop
User Banned
Posted: 10th Nov 2013 20:00
Fallout can you give me a working example of what your saying cause i tried to do what upu said but that dosent work well at all...

And matthy i tried to understand the math thing but couldnt understand it at all...


Thank you for your time

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Nov 2013 21:26
What do you have so far, have you wrote the quat multiplication formula in basic?

I'm struggling for time over the next few days but I will try to help if I can.

haliop
User Banned
Posted: 11th Nov 2013 06:25
I havent touchd the quad math yet just what fallout suggested
I have found several ways to fake the 3d idea into sprites.
I just need one example of the working even with 2 objects connected then i will edit it with my game

haliop
User Banned
Posted: 11th Nov 2013 07:13
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 11th Nov 2013 08:33 Edited at: 11th Nov 2013 08:33
Here you go. This is a T shape. I've worked out that when the base of my T is at 0,0,0 rotated 0,0,0 I want to move the top part of my T up by 4.5 and rotate it locally by 90 degrees to make it sit on top of the base of the T. So I just set it to the location and rotation of the base of the T, then perform those movements 'locally', then it always sits on top of the T.

haliop
User Banned
Posted: 11th Nov 2013 09:23 Edited at: 11th Nov 2013 09:32
thank you chekcing it right now


FALLOUT YOU ARE AWESOME THANK YOU!
i think you guys will be very pleased with what im trying to do cause im not using any additional content rather then agk commands. and it looks kinda childish but cool and simple.

haliop
User Banned
Posted: 11th Nov 2013 11:15
Not only that it works its flawless using floats and very fun to play with im just afraid that if ill multiply iy to multiplayer there will be a huge fps lost

haliop
User Banned
Posted: 12th Nov 2013 09:21
I guess i can express how greatfull i am , thank you fallout.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 12th Nov 2013 09:57
No probs. Glad I could help. As Matty said, combining rotations would be better, but in the absence of technical/mathematical knowledge, use what you've got! That's what I do.
haliop
User Banned
Posted: 12th Nov 2013 14:36
Im planning on a 4 player multiplayer so i hope it will be ok ..
Trying to keep it simple and fun mostly fun each car have about 10 objects so its 10 * 4 + minor scenery but also its 10 * 4 * assigning rotation and position every frame.. So you obvioudly from the net side its only xyz positioions of the cars but grapghic/cpu side it might be a bit laggy

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 12th Nov 2013 23:02
AGK should be able to handle that. 40 objects isnt that much compared to what some people are doing in their projects.

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy

Login to post a reply

Server time is: 2024-05-20 10:13:15
Your offset time is: 2024-05-20 10:13:15