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.

Dark GDK / Attaching/glueing objects together

Author
Message
Trullion
15
Years of Service
User Offline
Joined: 1st Oct 2009
Location:
Posted: 11th Mar 2010 18:58
Currently I am still learning DARK GDK, and as I am developing my program I would like to attach to object together. Right now its just a simple box and a triangle. The box is 1w x 1h x 5t and represents a man. The triangle is 24w and 6deep at its apex and represents a hang glider. How do I attach the cube to the triangle so that it rolls and pitches with the triangle.

Later I will be adding in .x models and I suppose the same will apply if I have a model of a man and a model of some flying thing like a dragon. I want to roll/pitch the flying thing and have the model of the man roll/pitch/move with it.
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 11th Mar 2010 20:12
Try this:
(from the DarkGDK documentation)

dbGlueObjectToLimb( int iObject, int iSecondObject, int iLimb )

So in your case that would be:

dbGlueObjectToLimb( trianlge_id, box_id, 0 );

(in case your wonder what the 0 means: this command glues an object to another objects limb (=bone), and limb 0 means the root limb of the model)

Hope this helps.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Mar 2010 20:32
Another way is to do it with coordinates only. For your hang-glider example: set the coordinates and rotation angles of the man to the same values as the glider, then move it below, e.g. with dbMoveObjectDown.
Trullion
15
Years of Service
User Offline
Joined: 1st Oct 2009
Location:
Posted: 12th Mar 2010 22:03
I will keep the coordinate idea in mind as it may be the only way to do what I want, however, I would like to pursue the GlueObject method. Unfortunately I cannot seem to get it to work. When I try to glue the cube to the triangle it moves the two away from each other. Do I need to make one or the other into a mesh first? If I do make it into a mesh then will it have texture data?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 14th Mar 2010 14:59 Edited at: 14th Mar 2010 15:29
I've never used dbGlueObject yet in a program, but I found a thread about this problem:

http://forum.thegamecreators.com/?m=forum_view&t=163732&b=1

If I understood correctly, it's saying that the world coordinates of the glued object are taken as offset after glueing, which makes it move away from the parent, so you should set the position (and rotation) of the child object before glueing to calculated offset values... I cannot confirm this, lacking any personal experience with this command, but have a look at the thread and experiment with the coordinates.

EDIT: I did a small experiment and it seems that what this thread is saying is true: before glueing, you need to move the child object to the coordinates where you want it to be relative to the parent object. If the child object sits at 0,0,0, then after glueing it will jump to the center of the parent.
Trullion
15
Years of Service
User Offline
Joined: 1st Oct 2009
Location:
Posted: 19th Mar 2010 21:19
Below is some code I wrote. Essentially, if you are running along the ground at full speed, while mounted on a flying mount, and you click the right mouse button to leap into the air, the mount object pitches up by 30 degrees and starts to move forward thereby taking off like an airplane. The break at the end if statement is because the if statement is embedded in a switch statement.

if (dbMouseClick() == 2 && charHeightAboveGround == 0)
{
if (charMount == noMount || charMount == grdMount)
charVelocityVertical = (charStrength/charWeight);
else if (charMount == 2 && charVelocityLongitudinal >= myMaxStep)
{
charMovementType = isFlying;
charPitchAngle = charPitchAngle + 30;
dbPitchObjectUp(myID_No, 30);
dbMoveObject(myID_No, charVelocityLongitudinal);
break;
}
}

I have all my character position and angle data posting to the screen as I am debugging, and what I have noticed is that as soon as the command dbPitchObjectUp() fires, the dbObjectAngleY changes radically. It may start at say 160 degrees, but changes to something like 20 degrees.

Any ideas?
Trullion
15
Years of Service
User Offline
Joined: 1st Oct 2009
Location:
Posted: 19th Mar 2010 21:37 Edited at: 19th Mar 2010 22:24
Oh that worked beautifully!!!

1) Position the Char at 0,0,0
2) Rotate the Char to 0,0,0
3) dbGlueObjectToLimb(Char, Triangle, 0) <- yes Char comes first

Thanks for the help all!!!

Login to post a reply

Server time is: 2024-10-02 01:23:07
Your offset time is: 2024-10-02 01:23:07