> ...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_cast<void *>(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

Reply via email to