Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 16,232 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Earthball.C example ... PH_CYLINDER ? #137168
06/19/07 21:56
06/19/07 21:56
Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
Andreas C Offline OP
Senior Member
Andreas C  Offline OP
Senior Member

Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
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
Re: Earthball.C example ... PH_CYLINDER ? [Re: Andreas C] #137169
06/19/07 22:06
06/19/07 22:06
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
ODE only fully supports boxes and spheres.

Re: Earthball.C example ... PH_CYLINDER ? [Re: ventilator] #137170
06/20/07 09:00
06/20/07 09:00
Joined: May 2003
Posts: 567
Spain, Canary Islands
Felixsg Offline
User
Felixsg  Offline
User

Joined: May 2003
Posts: 567
Spain, Canary Islands
Quote:

ODE only fully supports boxes and spheres.




The ODE version used in gamestudio?

A long time ago (january and Febrary 2006) the ODE oficial
are update and have more primitives one special for wheels (The full cilindre support)

Why Gamestudio not use the last ODE is a mistery

Last edited by Felixsg; 06/20/07 09:04.
Re: Earthball.C example ... PH_CYLINDER ? [Re: ventilator] #137171
06/20/07 19:32
06/20/07 19:32
Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
Andreas C Offline OP
Senior Member
Andreas C  Offline OP
Senior Member

Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
Quote:

ODE only fully supports boxes and spheres.




Seriously ? Bad news ... as was mentioned ... the current ODE does support more shapes.

So, I guess the solution would be to use Newton ?

Cheers,
Andreas


____________________________________________________
GameCore / Unity / UDK
Lightwave 9.6 / Blender / Fragmotion / ZBrush 3.5
TextureMaker / PSP-X
Re: Earthball.C example ... PH_CYLINDER ? [Re: Andreas C] #137172
06/20/07 19:38
06/20/07 19:38
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
as far as i know the current ODE also doesn't support cylinders without flaws.

ODE is kind of dead since a long time and i think the only chance for improvement is erwin coumans. he plans to integrate the collision system of his physics engine [bullet] into ODE but who knows when this will happen.

i would use newton!

Re: Earthball.C example ... PH_CYLINDER ? [Re: ventilator] #137173
06/22/07 05:08
06/22/07 05:08
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30...
Frederick_Lim Offline
User
Frederick_Lim  Offline
User

Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30...
I guess Gamestudio is using ODE version 0.5

Re: Earthball.C example ... PH_CYLINDER ? [Re: ventilator] #137174
06/22/07 16:36
06/22/07 16:36
Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
Andreas C Offline OP
Senior Member
Andreas C  Offline OP
Senior Member

Joined: Sep 2001
Posts: 375
Hamburg, Germany / Springfield...
Quote:


i would use newton!




Yes ... that sounds like good advice and thanks to your efforts, it's possible.

Cheers,
Andreas


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

Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1