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 / Can I restrict the X, Y, or Z planes on a 3D Physics object?

Author
Message
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Nov 2015 05:58 Edited at: 2nd Nov 2015 06:03
Hey all,

I'd like to restrict my 3D Physics objects to one or two planes at most but I can't seem to find a way or command to do that. For example if two spheres fall on top of each other, I'd like them to roll on the X axis and not the Z axis. Any ideas?

Most of the 3D Physics documentation is woefully inadequate (just a single sentence doesn't always cut it).

Thank you!

EDIT:

One way I'm thinking of is creating invisible static "walls" in front and behind. This *should* stop the objects from moving toward or away from the camera. Not sure if an invisible object can still have physical properties, though.
Senior Software Engineer - RotoGrinders
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 2nd Nov 2015 08:40
You might be better off using the BOX2d commands otherwise you'll be consuming a huge amount of CPU on 3D physics only to restrict the calculations back to 2D.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Nov 2015 08:52
I've used CJB's recommendation in the past and created a 2D simulation off screen, and transposed the results onto 3D objects.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Nov 2015 23:25
Well I want to switch the restrictions on the fly. Right now I'm working on a 2D puzzle game with blocks that fall, but on Game Over I want the blocks to have full 3D freedom, and for some powerups I want the block to be able to fly in all directions too.
Senior Software Engineer - RotoGrinders
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 3rd Nov 2015 01:50
FYI - If you set the SetObjectVisible(obj, 0) after you've assigned it 3D Physics properties, the object will be invisible but it will still work in physics space. This neat trick is what I'll use to make invisible walls to stop the pieces from flying in the directions I don't want, and I can turn off their physical properties on the fly for when I want to pieces to fly toward the camera and whatnot. Awesome
Senior Software Engineer - RotoGrinders
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Nov 2015 06:10
nice
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 09:14
Sounds like an interesting project! Can't wait to see a demo
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 3rd Nov 2015 10:05
I have not tried the 3D physics yet, in PhysX you could freeze a certain axis to get the behaviour you require, I'm sure Bullet will have the same and it will probably be added at some point, it's still early days I think.

You could also get this behaviour with joints. Again, I don't know what is available but if joints are implemented then there is a chance they will do the trick if your current method does not work as expected. PhysX had a 6DOF joint and you could attach an object to the global space and turn on/off each degree of freedom as you see fit.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 10:15
6dof joints are in the the new 3d command set

integer Create3DPhysics6DOFJoint( objA, objB, positionVec3, rotationVec3 )
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 3rd Nov 2015 12:10
Quote: "6dof joints are in the the new 3d command set "


Great, this should be able to do it.

In PhysX you could leave objB as 0 or null and it would attach to the world rather than another object. If this is not an option then create a dummy object at the centre of the world and attach everything to that with only the degrees of freedom you require, then delete the joint to release the objects into full 3D.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Nov 2015 12:24
if you not have a movement at z axis the z position stay there.
means if u memory the z coord and set it again and again you overwrite the physics so the movement is limited.
not the fine art but maybe it works.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 4th Nov 2015 00:54
Thanks for all your input!

Quote: "if you not have a movement at z axis the z position stay there.
means if u memory the z coord and set it again and again you overwrite the physics so the movement is limited.
not the fine art but maybe it works."


Something feels wrong about overwriting the physics engine's rotation, but it's not a completely terrible idea to try
Senior Software Engineer - RotoGrinders
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Nov 2015 11:28
if you overwrite the z position its more a wall without friction.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 4th Nov 2015 21:30
@Markus - You have a great point there. When I put an invisible wall in there, the blocks seems to not move naturally. I might just abandon the whole 3D Physics thing and use tweening instead.
Senior Software Engineer - RotoGrinders
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 5th Nov 2015 09:01
Using joints is the proper solution since the whole point of joints is to restrict movement/rotation as you see fit. I know it seems counter intuitive since you may normally consider joints to always restrict movement, but this is not the case. A joint can just restrict z rotation or movement in one direction or any combination of the 6 degrees of freedom our objects have.

The only other good solution I see here is using box2D. Then when your game ends simply override it and program the 3d movement manually, not too hard for simple situations like explosions but you do lose collisions etc.

Login to post a reply

Server time is: 2024-11-25 15:52:42
Your offset time is: 2024-11-25 15:52:42