#include <OMKMKMHumano.h>
Inheritance diagram for OMK::MKMHumano:
Public Attributes | |
mkm::CHumanSkeletonMesh | _treehMesh |
mkSystem::COgreAvatarMeshMaster | _avatarMaster |
mkm::CHumanControl | _controlMesh |
Protected Member Functions | |
virtual void | finish () |
The pre destruction. | |
virtual void | computeParameters () |
This part of the compute methods computes the associated data. | |
Private Member Functions | |
DECLARE_OBJECT_FACTORY (MKMHumano) |
Definition at line 20 of file OMKMKMHumano.h.
OMK::MKMHumano::DECLARE_OBJECT_FACTORY | ( | MKMHumano | ) | [private] |
void MKMHumano::finish | ( | ) | [protected, virtual] |
The pre destruction.
Delete all the extensions of the object.
Reimplemented from OMK::ExtensibleSimulatedObject.
Definition at line 34 of file OMKMKMHumano.cpp.
References _avatarMaster.
00035 { 00036 _avatarMaster.close() ; 00037 }
void MKMHumano::computeParameters | ( | ) | [protected, virtual] |
This part of the compute methods computes the associated data.
Reimplemented from OMK::BasicHumano.
Definition at line 39 of file OMKMKMHumano.cpp.
References _avatarMaster, _controlMesh, OMK::BasicHumano::_initDone, OMK::MovingHumano::_initialisationSequence, OMK::BasicHumano::_position, OMK::MovingHumano::_posture, _treehMesh, OMK::BasicHumano::computeParameters(), OMK::Vis::convert(), OMK::ParametersAccessor::get(), OMK::SimulatedObject::getConfigurationParameters(), OMK::GroundService::getGround(), OMK::SimulatedObject::getName(), OMK::SimulatedObject::getObjectDescriptor(), OMK::Name::getString(), OMERROR, HBT::PostureData::rootPos, HBT::PostureData::rootQuat, and OMK::IAttributeT< PrmType, ModelType, AccessorType >::set().
00040 { 00041 if( !_initDone ) 00042 { 00043 bool ok = true ; 00044 00045 // Retrieve parameters 00046 const ConfigurationParameterDescriptor* node = getConfigurationParameters() ; 00047 ok = ok && ( node != 0 ) ; 00048 00049 if( !_position.get().isUniformScale() ) OMERROR( "Scale must be uniform" ) ; 00050 std::string name = getName().getString() ; 00051 ParametersAccessor::get( node, "Name", name ) ; 00052 00053 std::string meshFile ; 00054 ok = ok && ParametersAccessor::get( node, "Mesh", meshFile, this ) ; 00055 00056 std::string nodeAssociationFile ; 00057 ok = ok && ParametersAccessor::get( node, "NodeAssociation", nodeAssociationFile, this ) ; 00058 00059 mkSystem::COgreAvatarMeshMaster::ESoftAxis axis = mkSystem::COgreAvatarMeshMaster::EAxis_Default ; 00060 std::map< std::string, mkSystem::COgreAvatarMeshMaster::ESoftAxis > softAxisMapping ; 00061 softAxisMapping[ "Default" ] = mkSystem::COgreAvatarMeshMaster::EAxis_Default ; 00062 softAxisMapping[ "UserDefined" ] = mkSystem::COgreAvatarMeshMaster::EAxis_UserDefined ; 00063 softAxisMapping[ "BipedeMax" ] = mkSystem::COgreAvatarMeshMaster::EAxis_BipedeMax ; 00064 softAxisMapping[ "BipedeQuidam" ] = mkSystem::COgreAvatarMeshMaster::EAxis_BipedeQuidam ; 00065 00066 ParametersAccessor::get( node, "Axis", axis, softAxisMapping ) ; 00067 00068 bool useShadows = true ; 00069 ParametersAccessor::get( node, "UseShadows", useShadows ) ; 00070 00071 bool footPrint = true ; 00072 ParametersAccessor::get( node, "FootPrint", footPrint ) ; 00073 00074 float heightCorrection = footPrint ? 0.0f : -1.0f ; 00075 ParametersAccessor::get( node, "HeightCorrection", heightCorrection ) ; 00076 00077 float footPrintResistance = 0.5f ; 00078 ParametersAccessor::get( node, "FootPrintResistance", footPrintResistance ) ; 00079 00080 bool stackBlending = false ; // true = stack, false = dynamic, default dynamic 00081 std::map< std::string, bool > blendingMapping ; 00082 blendingMapping[ "Stack" ] = true ; 00083 blendingMapping[ "Dynamic" ] = false ; 00084 ParametersAccessor::get( node, "StackBlending", stackBlending, blendingMapping ) ; 00085 00086 if( ok ) 00087 { // All parameters are ok 00088 // Initialisation 00089 _treehMesh.init() ; 00090 _initialisationSequence = _avatarMaster.init( _treehMesh, meshFile, 00091 name, true, 00092 nodeAssociationFile, 00093 useShadows, axis, 1.0f/_position.get().getScale().X(), 00094 0.0f ) ; 00095 _controlMesh.init( _treehMesh ) ; 00096 // Configuration 00097 _controlMesh.setPosition( -_position.get().getTranslate().X(), _position.get().getTranslate().Z(), _position.get().getTranslate().Y() ) ; 00098 _controlMesh.enableFootprint( footPrint ) ; 00099 _controlMesh.setHeightCorrection( heightCorrection ) ; 00100 _controlMesh.setFootprintResistance( footPrintResistance ) ; 00101 _controlMesh.enableConstraints( false ) ; 00102 00103 GroundService* groundService = OBT::getService< GroundService >( 'Grnd' ) ; 00104 if( groundService ) 00105 { 00106 _controlMesh.getControlFootprint().setGroundClass( &groundService->getGround() ) ; 00107 } 00108 if( stackBlending ) 00109 _controlMesh.setStackBlending() ; 00110 else 00111 _controlMesh.setDynamicBlending() ; 00112 // Need at least one update 00113 _controlMesh.update( 1e-9f ); 00114 } 00115 else 00116 { 00117 OMERROR( "Unable to initialise MKM" ) ; 00118 } 00119 } 00120 // Call the ancestor to send the intialisation data 00121 MovingHumano::computeParameters() ; 00122 // The avatar master is initialised => update the posture 00123 if( _avatarMaster.isInitialized() ) 00124 { 00125 _controlMesh.update( 1.0f / getObjectDescriptor().getFrequency() ); 00126 _controlMesh.getPosture().computeToRelative( _avatarMaster ); 00127 HBT::PostureData* posture = _avatarMaster.computeAndGetPostureDatas() ; 00128 _posture.set( *posture ); 00129 Transform pos( _position.get() ) ; 00130 pos.setTranslate( convert( posture->rootPos ) ) ; 00131 pos.setRotate( convert( posture->rootQuat ) ) ; 00132 _position.set( pos ) ; 00133 } 00134 }
mkm::CHumanSkeletonMesh OMK::MKMHumano::_treehMesh |
mkSystem::COgreAvatarMeshMaster OMK::MKMHumano::_avatarMaster |
mkm::CHumanControl OMK::MKMHumano::_controlMesh |
Definition at line 26 of file OMKMKMHumano.h.
Referenced by computeParameters(), OMK::MKMMoveToTaskExtension::preComputeParameters(), and OMK::MKMHeadToTaskExtension::preComputeParameters().
Documentation generated on Mon Jun 9 11:46:04 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |