Welcome, Guest! Login | Register

Static Ragdolls [Print this Article]
Posted by: ts2do
Date posted: Feb 07 2005
User Rating: N/A
Number of views: 4930
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 03 2005 at 05: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 26 2005, 04: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 05 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
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Persuter | Aug 02 2009
 

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

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!