The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
Physics & A.I. / Distance Joint

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
luke810

User


Joined: Mon Sep 4th 2006
Location: United States
Posted: 4th Nov 2009 18:08           | link | toggle

Can't get them to work at all, no matter what I try. Not even changing the example programs code by replacing sphere joints with distance joints. I would really appreciate an example or a snippet to work with for DarkGDK.

Back to top
Report this message as abusive
HowDo

3DMaster - Champion


Joined: Thu Nov 28th 2002
Location: United Kingdom
Posted: 5th Nov 2009 05:16           | link | toggle

here you are some code on nearly all the joints, almost the same as the one in the SDK. exe in the download button.

+ Code Snippet
Rem Project: samplejoints
Rem Created: 16/03/2009 08:16:19

Rem ***** Main Source File *****
set window on
set window title "Smaple Joints"
sync on
sync rate 60
autocam off
phy enable debug
position camera -20,10,10

point camera -10,0,0
`rotate camera 20,0,0
phy start
phy set Gravity 0.0, -1.0, 0.0
ground=1
PENDULUM_COUNT = 5
BALL_COUNT = 6
hammer=9
wheelPivot=10
rodPivot=11
dim pendulum(PENDULUM_COUNT)
driveJoint=12
pushbacksphere=13
pushbackcube=14
movefree=1
locked=0
firstobject=0
secondobject=1
dim ball(BALL_COUNT)
rem make material for ground
PHY MAKE MATERIAL 1, "defaultMaterial"
PHY SET MATERIAL RESTITUTION 1,0.0
PHY SET MATERIAL STATIC FRICTION 1, 0.5
PHY SET MATERIAL DYNAMIC FRICTION 1, 0.5
rem the ground
make object box ground,100,1,100
position object ground,0,-1,0
color object ground,RGB(0,128,255)
phy make rigid body static box ground,1


rem center cube that rotate on x axis
make object cube pushBackcube,1
position object pushbackcube,0,.2,0
phy make rigid body dynamic box pushBackcube
PHY SET RIGID BODY MASS pushBackcube, 10.0

rem outside cube the is fixed and rotate with first object
make object cube wheelPivot,1
position object wheelPivot, 0,2,0
phy make rigid body dynamic box wheelPivot
rem stop it turning
PHY SET RIGID BODY KINEMATIC wheelPivot,1
rem link them together
PHY MAKE FIXED JOINT 1,wheelPivot ,pushBackcube


rem link sphere
make object sphere rodPivot,1
position object rodPivot,0,0,-10
phy make rigid body dynamic sphere rodPivot

rem link outside cube to sphere
phy make distance joint 2, pushBackcube,rodPivot
phy set distance joint min 2, 10.0: rem keeps the distance
phy set distance joint max 2, 10.0 :rem keeps the distance
phy build distance joint 2

rem make the hammer
make object cube hammer,1
position object hammer,0,0,-15
phy make rigid body dynamic box hammer
PHY MAKE FIXED JOINT 3,rodPivot,hammer
PHY MAKE FIXED JOINT 4,hammer,rodPivot

rem counting vars d=distance
rem j joint numbers
`phy make cylindrical joint 30, rodPivot,hammer, object position x ( rodPivot), object position y (rodPivot ), object position z (rodPivot ), 0, 5, 0
phy make prismatic joint 5, rodPivot,hammer,locked,locked,locked, object position x (rodpivot), object position y (rodpivot), object position z (rodpivot)
phy make prismatic joint 6, hammer,rodpivot,locked,locked,locked, object position x (hammer), object position y (hammer), object position z (hammer)

`prismatic
d=1
j=40
distance#=10.0
for c= 15 to 25 step 2
    rem make swing boxes anchor
    of=rnd(200)/100
    make object sphere c, 1
    position object c, -.5+of, 5,-18-(d*4)
    phy make rigid body static sphere c
    rem make boxes to swing
    make object cube c+1, 1
    position object c+1, -.5+of, 0.5,-18-(d*4)
    phy make rigid body dynamic box c+1
    PHY SET RIGID BODY MASS c+1, -2

    `phy make sphere joint j, c, c+1
    phy make sphere joint j, c, c + 1, object position x ( c ), object position y ( c ), object position z ( c )


rem add one
inc d
inc j
    next c
rem load object numbers into varable
for i=1 to 6
ball(i)=99+i
next i
rem set count
count=1
do
phy update 1
text 0,0,"arrow keys to move view about."
rem keep shphere and box straight.
phy set rigid body position hammer,0,0,object position z(hammer)
phy set rigid body position rodPivot,0,0,object position z(rodpivot)
rem rotate box
PHY SET RIGID BODY ROTATION wheelPivot,wrapvalue(object angle x(wheelpivot)+1),0,0
`inc x#,2
rem put a sphere on screen when box pulls bac k
if object position z(hammer)>-13.0 and hold<>1
    hold=1
    if object exist(ball(count))<>1
        make object sphere ball(count),1
        position object ball(count),0,0,-15
        phy make rigid body dynamic sphere ball(count)
        PHY SET RIGID BODY MASS ball(count), 30
PHY SET RIGID BODY LINEAR DAMPING ball(count),.10

        inc count,1
    endif
    if object exist(ball(count))=1
    rem position object
        phy set rigid body position ball(count),0,.5,-15
        inc count,1
    endif
        if count>4
            count=1
        endif
    endif
if object position z(hammer)<=-16.0
    hold=0
endif
PHY SET RIGID BODY ANGULAR MOMENTUM rodPivot, 0,PHY GET RIGID BODY ANGULAR MOMENTUM Y(rodPivot),PHY GET RIGID BODY ANGULAR MOMENTUM z(rodPivot)


rem draw connecting lines
line object screen x(pushBackcube),object screen y( pushBackcube),object screen x(rodPivot),object screen y( rodPivot)
line object screen x(rodPivot),object screen y( rodPivot),object screen x(hammer),object screen y(hammer)
for k=15 to 25 step 2
    line object screen x(k ),object screen y(k ),object screen x(k+1 ),object screen y(k+1 )
next k
text object screen x(wheelPivot)-150,object screen y(wheelPivot)-15,"Rotation point"
center text object screen x(pushBackcube),object screen y(pushBackcube)-15,"Fixed Joint"
center text object screen x(rodPivot),object screen y(rodPivot)+15,"distance Joint"
text object screen x(hammer)+10,object screen y(hammer)," <- prismatic joint"
center text object screen x(15),object screen y(15)-25,"sphere Joint"
rem
control camera using arrowkeys 0,.1,.1

phy update 0
sync
loop


Dark Physics makes any hot drink go cold.
Back to top
Download: samplejoints.exe Size: 5967849 bytesReport this message as abusive
Google Ad
Back to top
 
luke810

User


Joined: Mon Sep 4th 2006
Location: United States
Posted: 5th Nov 2009 09:16     Edited: 5th Nov 2009 09:18     | link | toggle

OK, I got it to work to some degree now, but whats with setting the spring constant? It appears to be using its own special units because I need to set it to around 10^6 before I get the spring to have enough force to hold itself up against gravity, even when the target distance is something as ridiculously small. Is this function even supported or am I doing something wrong?

Back to top
Report this message as abusive
HowDo

3DMaster - Champion


Joined: Thu Nov 28th 2002
Location: United Kingdom
Posted: 5th Nov 2009 11:44           | link | toggle

when I can't get physX to work I look up the same command or nearest to it and see how the SDK do it in c++ and go from there.

Dark Physics makes any hot drink go cold.
Back to top
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Search the Forum

You must be logged-in to post messages to this forum. You can register an account for free. Or click here to login.
Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Game Creator Store
Privacy Policy AUP Top of Page