//------------------------------------------------------------------------------ //! int groupVM( VMState* vm ) { WorldContext* context = getContext(vm); EntityGroup* group = new EntityGroup(); context->_world->addGroup( group ); // Load parameters. Reff ref = Reff::identity(); VM::get( vm, -1, "position", ref.position() ); Quatf q = Quatf::identity(); VM::get( vm, -1, "orientation", q ); ref.orientation( q ); // Brain. // User attributes. // Objects (read and transform). if( VM::get( vm, -1, "object" ) ) { for( uint i = 1; VM::geti( vm, -1, i ); ++i ) { Entity* e = (Entity*)VM::toPtr( vm, -1 ); group->addEntity( e ); e->referential( ref * e->referential() ); VM::pop( vm, 1 ); } VM::pop( vm, 1 ); } // Groups. for( uint i = 1; VM::geti( vm, -1, i ); ++i ) { group->addGroup( (EntityGroup*)VM::toPtr( vm, -1 ) ); VM::pop( vm, 1 ); } VM::push( vm, group ); return 1; }