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 / How to add a force to a 3D physics object?

Author
Message
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 7th Jan 2016 16:40 Edited at: 7th Jan 2016 17:00
Searched through the whole commands and through the help but found nothing regarding applying a force to a 3d object....!?
Please don't tell me there is no command yet, would be totally needless to have 3d physics without the possibility of applying forces to objects....
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2016 17:08
SetObject3DPhysicsLinearVelocity() and SetObject3DPhysicsAngularVelocity()
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 7th Jan 2016 17:54
That's setting a speed not a force
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2016 18:06 Edited at: 7th Jan 2016 18:08
That's all we've got right now I'm afraid. Hopefully we'll see ApplyForce / ApplyTorque functions as it matures. Add it to the requests board
In the meantime, you'll have to roll your own.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 7th Jan 2016 21:43
Space Dream Studios

Are you working in Tier 1 or Tier 2?
Tier 1 does not currently have commands for force.
It is possible to access it in Tier2.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 8th Jan 2016 11:25
Unfortunatelly I'm working in Tier 1... Any idea for a workarround?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jan 2016 11:33
You can code your own AddForce function by getting the linear and angular speeds, add on your 'force', and set the new speed to the object. You could also get the mass of the object if you want to build in some inertia calculation too.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 8th Jan 2016 11:48 Edited at: 8th Jan 2016 11:51
Yeah, that's what I wanted not to do, but on the other hand it has a big learning curve and many benefits doing it.... I already thought about and think I will go this way
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 8th Jan 2016 12:26
OK, seems to be easier than expected. Will come up with a ready to use function soon
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jan 2016 13:03
Good job! I'd love to see what you come up with (if you don't mind sharing ).
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 8th Jan 2016 15:07 Edited at: 8th Jan 2016 15:09
Oki doki, here comes the final function which works perfectly her. I'm accelerating a rocket with it...
Define the direction of force by _vecx#, _vecy# and _vecz# values. If you want to have an effect along the local y-axis of the object, just asign _vecy# value 1.0 and x/z with 0.0.
By the way in my AppGameKit world one AppGameKit unit is equal to 1 m in real world.

Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 8th Jan 2016 15:32
Quote: "By the way in my AppGameKit world one AppGameKit unit is equal to 1 m in real world."


Then you will need to adjust the scale factor for the world to keep the Bullet physics solver calculations accurate.

Create3DPhysicsWorld Creates the physics world using the default scale factor of 40. This function will create the physics world with a different scale factor. The scale is not the size of the world, it is the factor by which all the data passed in is scaled down by to convert it to the Bullet Physics scale for the physics calculations. Then the data from Bullet is scaled up before it is passed to the AppGameKit 3D world. The default scale factor will be correct if your average character size is 72 AppGameKit units tall. Then the default gravity of -10.0 meters per second on the Y axis will give the correct visual result. The Bullet Physics solver has a minimum size for objects. Objects below this size will cause instability with the solver. At the default scale factor of 40 the smallest dimension that the solver can handle is about 3.5 AppGameKit units. To calculate the scale factor first determine your character's height in meters, a character of 72 units tall would be 1.8288 meters (or 6ft). Then divide the character's height in units by the characters height in meters, for this example the scale factor would be (72 / 1.8) = 40.
The coffee is lovely dark and deep,and I have code to write before I sleep.

Login to post a reply

Server time is: 2024-11-17 02:27:41
Your offset time is: 2024-11-17 02:27:41