Class | ODE::JointGroup |
In: |
ext/body.c
(CVS)
lib/ode/jointgroup.rb (CVS) |
Parent: | Object |
Ruby half of the ODE::JointGroup class.
factoryClass | [R] | The ODE::Joint class to instantiate with createJoint. |
factoryWorld | [R] | The ODE::World to create new joints in |
allocate() — Allocate a new ODE::Joint object.
/* * allocate() * -- * Allocate a new ODE::Joint object. */ static VALUE ode_jointGroup_s_alloc( klass ) { debugMsg(( "Wrapping an uninitialized ODE::JointGroup pointer." )); return Data_Wrap_Struct( klass, ode_jointGroup_gc_mark, ode_jointGroup_gc_free, 0 ); }
initialize( jointType=nil, world=nil ) — Create and return a new ODE::JointGroup. If the optional jointType argument (an ODE::Joint derivative class object) is given, joints created via newJoint will be of the specified type. If it is not set, newJoint raises an exception.
/* * initialize( jointType=nil, world=nil ) * -- * Create and return a new ODE::JointGroup. If the optional <tt>jointType</tt> * argument (an ODE::Joint derivative class object) is given, joints created via * #newJoint will be of the specified type. If it is not set, #newJoint raises * an exception. */ static VALUE ode_jointGroup_init( argc, argv, self ) int argc; VALUE *argv, self; { ode_JOINTGROUP *ptr; VALUE factoryClass, factoryWorld; DATA_PTR(self) = ptr = ode_jointGroup_alloc(); ptr->id = dJointGroupCreate( 0 ); ptr->jointList = NULL; /* Initialize instance variables */ rb_iv_set( self, "@factoryClass", Qnil ); rb_iv_set( self, "@factoryWorld", Qnil ); if ( rb_scan_args(argc, argv, "02", &factoryClass, &factoryWorld) ) { if ( RTEST(factoryClass) ) rb_funcall( self, rb_intern("factoryClass="), 1, factoryClass ); if ( RTEST(factoryWorld) ) rb_funcall( self, rb_intern("factoryWorld="), 1, factoryWorld ); } return self; }
Create a new joint in the receiving JointGroup with the specified arguments. If the jointClass and world arguments weren’t specified in this JointGroup’s constructor, an exception is raised.
# File lib/ode/jointgroup.rb, line 75 def createJoint( *arguments ) raise RuntimeError, "Not a factory JointGroup" unless self.factory? arguments.push( self ) return @factoryClass.new( @factoryWorld, *arguments ) end
empty() — Remove all the member joints from this group, marking them as obsolete.
/* * empty() * -- * Remove all the member joints from this group, marking them as obsolete. */ static VALUE ode_jointGroup_empty( self ) VALUE self; { ode_JOINTGROUP *ptr = get_jointGroup( self ); /* If the joint list has joints in it (ie., isn't NULL), get the joint group struct and clear the joints in it after marking them as obsolete. */ if ( ptr->jointList ) { ode_jointList_iterate( ptr->jointList, ode_jointList_obsolete ); ode_jointList_iterate( ptr->jointList, ode_jointList_free ); ptr->jointList = NULL; dJointGroupEmpty( ptr->id ); } return Qtrue; }
empty?() — Returns true if the joint group is empty.
/* * empty?() * -- * Returns <tt>true</tt> if the joint group is empty. */ static VALUE ode_jointGroup_empty_p( self ) VALUE self; { ode_JOINTGROUP *ptr = get_jointGroup( self ); return ( ptr->jointList == NULL ? Qtrue : Qfalse ); }
Returns true if the JointGroup can act as a factory for member joints.
# File lib/ode/jointgroup.rb, line 67 def factory? return ! @factoryClass.nil? && ! @factoryWorld.nil? end
Set the factory class for this JointGroup.
# File lib/ode/jointgroup.rb, line 52 def factoryClass=( jointClass ) raise TypeError, "No implicit conversion of #{jointClass.class.name} to Class" unless (jointClass.nil? || jointClass.kind_of?( Class )) @factoryClass = jointClass end
Set the factory world for this JointGroup
# File lib/ode/jointgroup.rb, line 59 def factoryWorld=( world ) raise TypeError, "No implicit conversion of #{world.class.name} to ODE::World" unless (world.nil? || world.kind_of?( ODE::World )) @factoryWorld = world end