concave dynamic phys object

Posted By: tex

concave dynamic phys object - 04/22/16 04:16

I am preparing a really simple driven car prac for my 3D students. I need to create a space for their character (babushka doll for now) to sit 'in' a little car's cabin (open at the top) - so that when the car collides with other objects in the scene the character gets flung out. I am proto-ing with some simple blocks for now. I can't use concave objects for dynamic phys interactions so i need to set up a collection of objects (for the sides of the cabin) acting as a single entity but with their own collision boxes. I've tried pXent_setgroup(entity, 2); but this seems to just instantiate a single bounding box over the group of objects. Now I am using pXent_addshape(); but it just seems to make the added shapes passable...

Is there a way to get the extra blocks to be individually collidable?

I am using 3DGS 8.45

here is a code snippet of whot I am using:

function main()
{
ENTITY* car = ent_create("base.mdl",vector(0,0,100),NULL);
pXent_settype(car,PH_RIGID,PH_BOX);

ENTITY* cabinFrontShape = ent_create("front.mdl",vector(0,0,0),NULL);
ENTITY* cabinBackShape = ent_create("back.mdl",vector(0,0,0),NULL);
pXent_addshape(car,cabinFrontShape,PH_BOX);
pXent_addshape(car,cabinBackShape,PH_BOX);

ENTITY* FLwheel = ent_create("wheelObj.mdl",vector(15,25,100),NULL);
ENTITY* FRwheel = ent_create("wheelObj.mdl",vector(15,-25,100),NULL);
ENTITY* RLwheel = ent_create("wheelObj.mdl",vector(-15,25,100),NULL);
ENTITY* RRwheel = ent_create("wheelObj.mdl",vector(-15,-25,100),NULL);

pXcon_add ( PH_WHEEL, FLwheel, car, 0 );
pXcon_add ( PH_WHEEL, FRwheel, car, 0 );
pXcon_add ( PH_WHEEL, RLwheel, car, 0 );
pXcon_add ( PH_WHEEL, RRwheel, car, 0 );

ENTITY* Dummy = ent_create("babushka02.mdl",vector(3,0,125),NULL);
pXent_settype ( Dummy, PH_RIGID, PH_BOX);

while(1)
{
var speed=0;
if(key_w)
{
speed+=1; // speed for car
}

pXcon_setwheel (FLwheel,0,0,0);
pXcon_setwheel (FRwheel,0,0,0);
pXcon_setwheel (RLwheel,0,speed,0);
pXcon_setwheel (RRwheel,0,speed,0);
pXent_addvelcentral(car,vector(speed,0,0)); // adds initial speed to body of car
Posted By: tex

Re: concave dynamic phys object - 04/26/16 12:04

I'm kind of surprised that this query didn't get answered. But after trawling through lots of posts it looks like it simply isn't possible in 3DGS. For others who may find the same query solution useful I will try to explain here:

Basically, use a PH_HINGE between the walls/panels that you want to use to create the concave shape (see figure 1). Set the swing angle for the hinge to -1/1 - so it can't move much. But you need to avoid internal collisions with other parts of the car body - so leave a gap between each entity. Then make the walls or panels INVISIBLE and use the addshape for the actual car body (see figure 2).


Posted By: Reconnoiter

Re: concave dynamic phys object - 04/26/16 13:40

Dont know if it helps much, but you can use pXent_setcollisionflag and EVENT_FRICTION to set up an event function for collision of physics entities to other objects. Than you could manually write something where the if the car collides with something else, the drivers is throwed forwards through e.g. pXent_addforcecentral.

But my quess is also that the physics part of GS3d is outdated, so difficult to use for more complex situations like of this thread.
Posted By: tex

Re: concave dynamic phys object - 04/26/16 14:09

thanks Reconnoiter you beat me to it again...

I can see your idea for the pXent_setcollisionflag etc but having the doll flung out of the car is not the main purpose. Rather I was interested in a more authentic toycar with a driver exposed.

It is interesting that most car race sims I see just skip over this by making the driver fixed or the car is covered so you can't see the driver inside. I am doing something more super mario/toycar ish...

In fact its nearly finished - little toy car races around on a red and white table cloth trying to hit sugar cubes... includes dust trails...
Posted By: Reconnoiter

Re: concave dynamic phys object - 04/26/16 19:37

Originally Posted By: tex
thanks Reconnoiter you beat me to it again...
tongue

Anyway, I thought you wanted to throw the driver out of the car on collision, cause this was in your first post ->
Quote:
- so that when the car collides with other objects in the scene the character gets flung out.


Or do you want to let the driver move a bit with his arms, torso and/or head etc.? Cause if you want the latter, just give the driver bones and animate it.

Cheers
© 2024 lite-C Forums