I started "discovering" physics again with Lite-C and used the EARTHBALL.C example as a starting point.

I created three "rooms" with connecting doorways. Also added a large hollow cube around everything.

I changed the code to load a tire.mdl model. Everything worked fine. The tire bounced and reacted properly to the "kick" from pressing the spacebar.

Next, I decided to change the phent_settype to PH_CYLINDER (I read that PH_POLY is not good for moving entities), since it never really seemed to "rest on the ground" and a tire seems more like a cylinder than a sphere.

And now, the tire doesn't bounce nicely around. It partially "falls" through the floor and "bounces" ... as if it's stuck in the floor.

I changed the model in MED several times to see if changing the pivot point (origin point) would help, but it did not. I even included a phent_setmaxspeed to limit speed and acceleration.

I also tried setting phent_setmass to use different hulltypes(PH_CYLINDER, PH_SPHERE).


Here's the modified code ...

Code:
void main()
{
// Activate stencil shadows - they are a 'redefine' variable
// that has to be set before the first wait() -
// and set the sound at full volume.

shadow_stencil = ON;
sound_vol = 100;
fps_max = 75;
video_mode = 8;

// Scale the panel by the screen to bmap size ratio
// in order to fit the screen, and make it visible.

pSplash.scale_x = screen_size.x / bmap_width(pSplash.bmap);
pSplash.scale_y = screen_size.y / bmap_height(pSplash.bmap);
set(pSplash,VISIBLE);

// After a panel is set to VISIBLE, we have to wait 3 frames
// until we can really see it on the screen.
// The first frame paints it into the background buffer,
// two more frames are needed until the background buffer
// is flipped to the front in a triple buffer system.

wait(3);

// Before we can create level entities, a level must be loaded.
// We'll use the small terrain from the techdemo for a level.
// We have to wait one more engine frame to ensure that the level
// exists and is ready to be filled with level entities.

level_load("sample.wmb");
wait(1);

// Let's now create a ball at position (0,0,100).
// The _vec function converts 3 floats to a temporary var vector
// for passing positions to engine functions.

eBall = ent_create("tire.mdl",vector(0,0,70),NULL);

// Now let's set the ball's physical properties.
// We add a small speed to give it a little sidewards kick.

phent_settype(eBall,PH_RIGID,PH_CYLINDER);
phent_setmaxspeed( eBall, 600, 1000);

phent_setmass(eBall,1,PH_SPHERE);
phent_setfriction(eBall,90);
phent_setelasticity(eBall,50,100);
phent_setdamping(eBall,30,5);
phent_addvelcentral(eBall,vector(2,2,0));

// A ball game would be no fun without gravity.

ph_setgravity(vector(0,0,-500));

// We are setting two entity flags in order to cast, but not receive
// dynamic shadows for the ball

set(eBall,SHADOW|CAST);

// We want to kick the ball by pressing the space key. For this we could scan
// the key state in the main loop; however a more elegant way is a key event.
// We can assign functions to certain events like hitting a key, or a
// collision in the game.

on_space = Kick;

// Another event: if the ball hits something, a sound shall be played.
// We set the event function and the enable_friction mask for triggering
// the event at physics collisions. Note that the minimum speed -
// the third parameter of phent_setelasticity - determines the
// sensitivity of this event.

eBall.event = Plop;
eBall.emask |= ENABLE_FRICTION;

// Now that everything is set up, remove the splash screen.

pan_remove(pSplash);

// During the main loop we're just moving the camera, as before.

while (1)
{

// For the camera movement we use the
// vec_accelerate() function. It accelerates a speed and
// is not dependent on the frame rate - so we don't need to
// limit the fps in this example. This code is equivalent
// to the built-in camera movement, but uses different keys.

VECTOR vForce, vMove;

vForce.x = -5*(key_force.x + mouse_force.x); // pan angle
vForce.y = 5*(key_force.y + mouse_force.y); // tilt angle
vForce.z = 0; // roll angle
vec_accelerate(vMove,vAngularSpeed,vForce,0.8);
vec_add(camera.pan,vMove);

#define iSpeed 6
vForce.x = iSpeed * (key_w - key_s); // forward
vForce.y = iSpeed * (key_a - key_d); // sideward
vForce.z = iSpeed * (key_home - key_end); // upward
vec_accelerate(vMove,vSpeed,vForce,0.5);
vec_rotate(vMove,camera.pan);
vec_add(camera.x,vMove);
wait(1);
}

// We don't need to free our created entities, bitmaps and sounds.
// The engine does this automatically when closing.
}



Any clue ?

Cheers,
Andreas

P.S.: I'm using A7.03(Beta)

Last edited by Andreas C; 06/19/07 21:57.

____________________________________________________
GameCore / Unity / UDK
Lightwave 9.6 / Blender / Fragmotion / ZBrush 3.5
TextureMaker / PSP-X