Sign in to follow this  
HarrisonPloeg

PhysX buildings

Recommended Posts

Buildings are not supposed to collapse in my game when they are placed down. Building I use PhysX and I would like to know how I could hold this building together, they start collapsing immediately after being created. They need to be able to collapse, just not when they are placed on the map. [Edited by - HarrisonPloeg on May 25, 2007 3:13:24 AM]

Share this post


Link to post
Share on other sites
I couldn't tell you how to solve the problem your having with the building falling apart(never used the library) but I don't think there's much optimizing you can do without going low level into the library code and you'd have to know alot about physics which if that was the case you could just write your own physics library.

Share this post


Link to post
Share on other sites
I haven't used physX yet myself, but you would have to do something along the lines of setting those objects to 'frozen' or something similar

A low framerate would be expected with that many physics objects all coliding at once (especially if you have a low end machine or you're running in debug mode)

Share this post


Link to post
Share on other sites
Just quick stupid question, but it is a physics library, are you creating your buildings in a physically correct way? It seems in that photo that you have a bunch of square building blocks. If a seam between 2 blocks is not supported, they will fall. Maybe you can add temporary joints between 2 blocks to hold it together (not sure if thats possible with your lib, as I have never used it) and remove the joints to let it collapse (kinda what happens in real life anyways).

Or a quicker way I suppose, have a model of the building and when it is supposed to collapse, stop drawing the model. And put this current version in.

Have a good one!

Share this post


Link to post
Share on other sites
As has been suggested, you could try freezing the actors and maybe even make them kinematic. Then, when a collision occurs, you can change them to back to dynamic and unfreeze them.

As for performance, one of the most important things to do when using PhysX is to make sure you are using the correct values for sleep linear velocity and sleep angular velocity, as well as the skin width. This allows PhysX to put actors to sleep when they are not part of the action and will greatly improve performance.

Have a read through all of Chapter 0 on devsupport.ageia.com and also Lesson 106.

Regards,
ViLiO

Share this post


Link to post
Share on other sites
I might use breakable joints to hold it together, the buildings are created in a seperate editor, how can I test if I should create a joint between two blocks?
I use the default sleep values.

Share this post


Link to post
Share on other sites
Quote:

Can the weight of the building cause breakable joints to break?


Sure it can. Building a big struture in real life that can support its own weight in an optimized way is a non trivial task. The same goes for simulations. If you want your houses to break the same way real buildings break you're either going to have to build your house models the same way real structures are constructed or cheat (have a static model while your house isnt falling apart, and then replace it with some fysical model when it does).

The former problem actually makes for some great gameplay. See Pontifex II (though they seem to have renamed it to bridge construction set). Basically you design a bridge and see if it can support its own weight and the weight of trains/cars. Very fun puzzle game.

Well, hope this leads to some insight :)

//Emil

Share this post


Link to post
Share on other sites
Quote:
Original post by cannonicus

The former problem actually makes for some great gameplay. See Pontifex II (though they seem to have renamed it to bridge construction set). Basically you design a bridge and see if it can support its own weight and the weight of trains/cars. Very fun puzzle game.

//Emil

I am not even a physics kinda guy, but that is a GREAT GAME!

Quote:

how can I test if I should create a joint between two blocks


Well, you can do what the professionals do and run it in your simulation (as I have seen on Discovery/History channel). If it fails, your joint/structure is not strong enough.

EDIT: As I look more at your screen shot, I see your outside walls more or less intact, its the interior that is failing (your building seems to be imploding), maybe some interior support would help.

Share this post


Link to post
Share on other sites
I will use joints to hold the building together, how can I test the bounding boxes of objects against the bounding boxes of other objects(if they intersect I create a joint between them)?

Share this post


Link to post
Share on other sites
This is some code ive got in a team project of mine (its c# but you get the idea), note the use of 'raycast' on the NXShape

public bool getRayInsersectionPoint(Ray ray, out Vector3 point,float maxDist)
{
NxRay nxRay = new NxRay(ray.Position.X, ray.Position.Y, ray.Position.Z,
ray.Direction.X, ray.Direction.Y, ray.Direction.Z);
NxRaycastHit nxRCH;

NxShape[] shapes = terrainAct.getShapes(); //terrainAct is an NxActor

if (shapes == null)
{
point = Vector3.Zero;
return false;
}

if (shapes[0] == null)
{
point = Vector3.Zero;
return false;
}

if (!shapes[0].raycast(nxRay, maxDist, 0, out nxRCH, false))
{
point = Vector3.Zero;
return false;
}

Vector3 rayInO = ray.Position;
Vector3 rayInD = ray.Direction;
point = new Vector3((nxRCH.distance * rayInD.X) + rayInO.X,
(nxRCH.distance * rayInD.Y) + rayInO.Y,
(nxRCH.distance * rayInD.Z) + rayInO.Z);
return true;
}

To use a function like this you would fire a Ray (you specify its direction & location) and it will check for an intersection up to maxDist away, then to check that it turned out ok check that the point it returns is valid.

You could also experiment with having different weighted boxes (i.e the weight of the box is a function of the y dist)

Share this post


Link to post
Share on other sites
You can think of the NxActors in the physics engine as bounding boxes, hence when you execute shapes[0].raycast(nxRay, maxDist, 0, out nxRCH, false)) your effectively doing a bounding box intersection.

Share this post


Link to post
Share on other sites
I need a building to collapse properly, once it starts it shouldn't stop collapsing, but I don't want it to collapse as soon as it is placed on the map. I also don't want it to bend. What strength should I make the joints? And how do I stop the building from bending(I use fixed joints)? maxForce currently = 100000000 for every fifty units of height the building is, maxTorque is 1/10 of that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this