Welcome, Guest! Login | Register

Static Ragdolls [Print this Article]
Posted by: ts2do
Date posted: Feb 07 2005
User Rating: N/A
Number of views: 2565
Number of comments: 1
Description: Ragdolls attached to their spawnpoint by a ragdoll constraint
The basic reason I made this classname is to make it easier to make many constrainted ragdoll props of the same type with ease. Using this code means that the prop you use for this must have the joint you want constrainted at point 0 0 0 in the local model. This code is pretty useless if you make no child classnames, like the prop_grass demonstrated below.

 CODE (C++) 
#include "cbase.h"
#include "physics_prop_ragdoll.h"
#include "vphysics/constraints.h"
class CStaticRagdoll : public CRagdollProp
{
public:
    virtual void SetupModel( void )
    {
        //  Not implemented in parent class
        //  The model is set by the bsp on spawn
    }
    void Spawn( void )
    {
        //  Get the angles before ragdoll is initialized,
        //    because default ragdoll code sets abs angles to NULL
        AngularImpulse m_pAngles;
        QAngleToAngularImpulse( GetAbsAngles(), m_pAngles );


        //  Initialize Basic Ragdoll
        SetupModel();
        CRagdollProp::Spawn();

        //  Use Default Constraint Settings
        constraint_ragdollparams_t ragdoll;
        ragdoll.Defaults();

        //  Tie Constraint to Origin of Ragdoll
        MatrixSetColumn( GetAbsOrigin(), 3, ragdoll.constraintToReference );


        //  Tie Constraint to Angles of Ragdoll
        for(int a=0;a<=2;a++)
        {
            ragdoll.axes[a].minRotation = ragdoll.axes[a].maxRotation = m_pAngles[a];
        }

        physenv->CreateRagdollConstraint( g_PhysWorldObject, VPhysicsGetObject(), NULL, ragdoll );
    }
};
LINK_ENTITY_TO_CLASS( prop_ragdoll_static, CStaticRagdoll )

@PointClass base(prop_ragdoll) studioprop() = prop_ragdoll_static : "Ragdoll that's tied to its origin." []

To make a child class of this one...
 CODE (C++) 
class CGrass : public CStaticRagdoll
{
public:
    void SetupModel( void )
    {
        PrecacheModel ("models/props/grass.mdl");
        SetModelName ( AllocPooledString("models/props/grass.mdl") );
    }
};
LINK_ENTITY_TO_CLASS( prop_grass, CGrass )

@PointClass base(prop_ragdoll) studioprop("models/grass.mdl") = prop_grass : "Grass" []

Rate This Article
This article has not yet been rated.

You have to register to rate this article.
User Comments Showing comments 1-1

Posted By: ts2do on Feb 02 2005 at 23:25:32
for things flat like grass, you might want to add a 2 unit cube so you have corner tabs so you can rotate it with easeEdited by ts2do on Feb 25 2005, 22:42:42


You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 
Debugging your half-life 2 mod
Half-Life 2 | Coding | Articles
By: blackshark | Aug 17 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (13 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!