General Physics Engine Questions
Hello again everyone
I've been working on my physics engine and I've run into some problems, so I'd like to ask some specific and general questions.
My engine only needs to work with convex, static 3D triangle meshes.
I was thinking that I'd compute axisaligned rectangular prisms (aligned along the world coordinates) for each object and all of its subobjects. By 'rectangular prisms', I just mean that I'm storing the length of lines from the center of the object to the maximum X, Y, and Z coordinates. I came up with my own penetration depth formula, like so (this one's for the Y penetration depth):
This code is meant to find the penetration depth between a moving object and a nonmoving object. It always returns a negative number, which I figured was fine; for moving it back out of the object I just find the time it takes to do so based on the new yvelocity of the object, like so:
Then we just move the object by multiplying the timeRequired by vectorY.
This seems to work fine, as long as vectorY isn't zero, and I think I can getting it working even if vectorY is zero.....but is this a good approach? Am I missing something critical here, or doing something that makes life harder than it should be?
I also need to have friction in the engine so that objects slow down and eventually stop when moving against another object. To find this, I figured I'd also compute axisaligned bounding rectangular prisms with the axis being aligned relative to the object. To calculate if friction should be applied instead of having the object bounce (which is what I'm doing with the penetration depth at the moment), I figured I would calculate the slopes of the two colliding lines of the colliding bounding prisms. If the slopes were close to being perpendicular, I would make the object bounce off of the other object, otherwise friction would be applied.
Is this a decent strategy?
When rotation is applied, I'm not quite sure how to find the new bounding coordinates relative to the world; is this what quaternions are for? How would I go about calculating when the bounding X coordinates have become the bounding Y coordinates (like when a 90 degree rotation about the z axis occurs)? Is this why people using bounding cubes instead of prisms?
Thank you,
wyrmmage
I've been working on my physics engine and I've run into some problems, so I'd like to ask some specific and general questions.
My engine only needs to work with convex, static 3D triangle meshes.
I was thinking that I'd compute axisaligned rectangular prisms (aligned along the world coordinates) for each object and all of its subobjects. By 'rectangular prisms', I just mean that I'm storing the length of lines from the center of the object to the maximum X, Y, and Z coordinates. I came up with my own penetration depth formula, like so (this one's for the Y penetration depth):
Code:
penetrationY = fabs(movingAnims[i]>getCenterY()  staticAnims[x]>getCenterY())  (movingAnims[i]>getMaxY()  movingAnims[i]>getCenterY())+(staticAnims[x]>getMaxY()  staticAnims[x]>getCenterY())  (movingAnims[i]>lastOffsetY  movingAnims[i]>offsetY);
Code:
timeRequired = 1 * penetrationY / fabs(movingAnims[i]>vectorY);
This seems to work fine, as long as vectorY isn't zero, and I think I can getting it working even if vectorY is zero.....but is this a good approach? Am I missing something critical here, or doing something that makes life harder than it should be?
I also need to have friction in the engine so that objects slow down and eventually stop when moving against another object. To find this, I figured I'd also compute axisaligned bounding rectangular prisms with the axis being aligned relative to the object. To calculate if friction should be applied instead of having the object bounce (which is what I'm doing with the penetration depth at the moment), I figured I would calculate the slopes of the two colliding lines of the colliding bounding prisms. If the slopes were close to being perpendicular, I would make the object bounce off of the other object, otherwise friction would be applied.
Is this a decent strategy?
When rotation is applied, I'm not quite sure how to find the new bounding coordinates relative to the world; is this what quaternions are for? How would I go about calculating when the bounding X coordinates have become the bounding Y coordinates (like when a 90 degree rotation about the z axis occurs)? Is this why people using bounding cubes instead of prisms?
Thank you,
wyrmmage
Worlds at War (Current Project)  http://www.awkwardgames.com/forum/
Ok, sorry for the previous post.....it was written late at night and is clearly not easy to read >.> Let me simplify and rephrase my question a bit:
I have a line, and the line has separate X, Y, and Z velocities. That line then hits a plane. This plane can be titled any which way in 3D space. How do I determine how the X, Y, and Z velocities of my line change when it hits the plane?
Thank you
wyrmmage
I have a line, and the line has separate X, Y, and Z velocities. That line then hits a plane. This plane can be titled any which way in 3D space. How do I determine how the X, Y, and Z velocities of my line change when it hits the plane?
Thank you
wyrmmage
Worlds at War (Current Project)  http://www.awkwardgames.com/forum/
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
Physics engine benchmark ideas.  Skorche  6  12,075 
Feb 28, 2011 06:36 AM Last Post: Skorche 

2D Physics Engine Philosophy  Shunter  11  12,511 
Jun 11, 2009 09:33 PM Last Post: Shunter 

Really stupid general library question...  WhatMeWorry  4  4,275 
Dec 15, 2006 03:22 PM Last Post: akb825 

Bullet Physics Library / COLLADA physics viewer  erwincoumans  14  18,909 
Aug 12, 2006 12:59 AM Last Post: Fenris 

Basic questions about rigid body physics  hangt5  15  10,111 
Jul 7, 2005 04:18 PM Last Post: hangt5 