[hlcoders] Someone please help me understand Physics...

2005-03-17 Thread Imperio59
...in the HL2 DSK.
I've been trying to get a round model entity (based off CBaseAnimating)
to have collision based on the model, and not on the bounding box (it's
round, so a radial/spherical collision would work too!).
Setting my solid type to SOLId_VPHYSICS alone doesn't work, doing that +
calling VPhysicsInitStatic() works but uses the bounding box for
collision + if the entity gets shot the model disappears (?!!!).
Also, when i use the above method, after the entity gets shot and
dissapeared, if i set it to SOLID_NONE the game crashes (haven't been
able to trace it down precisely enough, but it calls a bad pointer
somewhere down the chain of my SetSolid call, I'm assuming it has to do
with the fact that i should be using a VPhysics function to make it
passable instead of the solid type...
I've been trying for a week now to get this entity working, no one seems
to be able to tell me anything and there are any examples in the SDK
that i could find of an entity derived from CBaseAnimating that
implements it's own physics collision, nor anything that implements
separate collision handling for traces and for collisions (behave
differently if you got it by a solid or by a raytrace...).
I know i'm supposed to create some sort of attached physics object with
my entity, but i just have no clue where to start looking, and after a
week, i'm frankly tired of browsing files without finding a SIMPLE
example anywhere... :(
So if anyone knows ANYHTING that can help me, the beginning of a lead, a
tutorial somewhere, the name of a function or an entity, please reply...
Thanks in advance
Imperio59
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 15/03/2005

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


RE: [hlcoders] Someone please help me understand Physics...

2005-03-17 Thread Jay Stelly
 ...in the HL2 DSK.
 I've been trying to get a round model entity (based off
 CBaseAnimating) to have collision based on the model, and not
 on the bounding box (it's round, so a radial/spherical
 collision would work too!).

You can definitely do this.

 Setting my solid type to SOLId_VPHYSICS alone doesn't work,
 doing that + calling VPhysicsInitStatic() works but uses the
 bounding box for collision +


It sounds like you haven't got a collision model stored in the model.
Is this a model you created?  If so, the easiest solution is to add a
$collisionmodel {} statement to the qc file.  You can just use the same
SMD you use for rendering.  Recompile the model, and
VPhysicsInitStatic() should work fine.  It's assuming your model has a
.phy file on disk.  You can also create a collision model dynamically
with code using the physcollision interface, but you'll have to do a bit
more work.  By default, if you have no collision model it will create
one dynamically using the bounding box (if you step through the code
you'll see this).

If you want a spherical collision model, you can start with the code in
props.cpp for the debug sphere entity:
// Debug sphere
class CPhysSphere : public CPhysicsProp
{
DECLARE_CLASS( CPhysSphere, CPhysicsProp );
public:
virtual bool OverridePropdata() { return true; }
bool CreateVPhysics()
{
SetSolid( SOLID_BBOX );
SetCollisionBounds( -Vector(12,12,12), Vector(12,12,12)
);
objectparams_t params = g_PhysDefaultObjectParams;
params.pGameData = static_castvoid *(this);
IPhysicsObject *pPhysicsObject =
physenv-CreateSphereObject( 12, 0, GetAbsOrigin(), GetAbsAngles(),
params, false );
if ( pPhysicsObject )
{
VPhysicsSetObject( pPhysicsObject );
SetMoveType( MOVETYPE_VPHYSICS );
pPhysicsObject-Wake();
}

return true;
}
};

LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere );

But that only handles vphysics simulation, not raytracing (so ray traces
won't actually be hitting a sphere)

if the entity gets shot the
 model disappears (?!!!).

I'd guess you have some health set and its dying.  This could be a lot
of things though, and there isn't enough information here to know which
it is.

 call, I'm assuming it has to do with the fact that i should
 be using a VPhysics function to make it passable instead of
 the solid type...

You should use AddSolidFlags( FSOLID_NOT_SOLID ) to make something
passable.

 I've been trying for a week now to get this entity working,
 no one seems to be able to tell me anything and there are any
 examples in the SDK that i could find of an entity derived
 from CBaseAnimating that implements it's own physics
 collision, nor anything that implements separate collision
 handling for traces and for collisions (behave differently if
 you got it by a solid or by a raytrace...).

For these you just add FSOLID_CUSTOM_RAYTEST and FSOLID_CUSTOM_BOXTEST,
then implement your own TestCollision() function - just check
ray.m_IsRay on the ray that gets passed in and do whatever you want.
Note that it's the mod's responsibility to share/implement custom
ray/box tests on the server  client if you need prediction of them.


Jay


___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders