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.
| | | #include "cbase.h" #include "physics_prop_ragdoll.h" #include "vphysics/constraints.h" class CStaticRagdoll : public CRagdollProp { public: virtual void SetupModel( void ) { } void Spawn( void ) { AngularImpulse m_pAngles; QAngleToAngularImpulse( GetAbsAngles(), m_pAngles );
SetupModel(); CRagdollProp::Spawn();
constraint_ragdollparams_t ragdoll; ragdoll.Defaults();
MatrixSetColumn( GetAbsOrigin(), 3, ragdoll.constraintToReference );
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...
| | | 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" [] |
|
User Comments
Showing comments 1-1
|
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.
|