コード例 #1
0
ファイル: tsTransform.cpp プロジェクト: 03050903/Torque3D
QuatF Quat16::getQuatF() const
{
   return QuatF ( F32(x) / F32(MAX_VAL),
                  F32(y) / F32(MAX_VAL),
                  F32(z) / F32(MAX_VAL),
                  F32(w) / F32(MAX_VAL) );
}
コード例 #2
0
ファイル: rigidBody.cpp プロジェクト: Duion/GuideBot
RigidBody::RigidBody()
{

	mNetFlags.set(Ghostable);


	mDataBlock = 0;
	mTypeMask |= VehicleObjectType;

	mDelta.pos = Point3F(0,0,0);
	mDelta.posVec = Point3F(0,0,0);
	mDelta.dt = 0.f;
	
	mPhysShape = NULL;
	mPhysPosition	= Point3F::Zero;
	mPhysRotation	= QuatF(0,0,0,1);
	mForce			= VectorF::Zero;
	mTorque			= VectorF::Zero;
	mLinVelocity	= VectorF::Zero;
	mAngVelocity	= VectorF::Zero;
	
	m_haveContact = false;
	m_contactPos = VectorF::Zero;
	m_contactVel = 0.f;
	m_contactNormalVelDot = 0.f;

	mPhysPivot.identity();
	mPhysPivotInv.identity();
}   
コード例 #3
0
void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSequence* appSeq)
{
   seq.firstGroundFrame = shape->groundTranslations.size();
   seq.numGroundFrames = 0;

   if (!boundsNode)
      return;

   // Check if the bounds node is animated by this sequence
   seq.numGroundFrames = (S32)((seq.duration + 0.25f/AppGroundFrameRate) * AppGroundFrameRate);

   seq.flags |= TSShape::MakePath;

   // Get ground transform at the start of the sequence
   MatrixF invStartMat = boundsNode->getNodeTransform(appSeq->getStart());
   zapScale(invStartMat);
   invStartMat.inverse();

   for (int iFrame = 0; iFrame < seq.numGroundFrames; iFrame++)
   {
      F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numGroundFrames - 1);

      // Determine delta bounds node transform at 't'
      MatrixF mat = boundsNode->getNodeTransform(time);
      zapScale(mat);
      mat = invStartMat * mat;

      // Add ground transform
      Quat16 rotation;
      rotation.set(QuatF(mat));
      shape->groundTranslations.push_back(mat.getPosition());
      shape->groundRotations.push_back(rotation);
   }
}
コード例 #4
0
ファイル: VPathNode.cpp プロジェクト: AnteSim/Verve
bool VPathNode::fromString( const String &pString )
{
    // Split Data.
    // {Position} {Rotation} {Weight}
    const char *baseData = StringUnit::getUnit( pString.c_str(), 0, "\t" );

    Point3F  pos;
    AngAxisF aa;
    F32      weight;

    // Scan Base.
    dSscanf( baseData, "%g %g %g %g %g %g %g %g", &pos.x, &pos.y, &pos.z,
                                                  &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle,
                                                  &weight );

    // Apply Changes.
    setLocalPosition( pos );
    setLocalRotation( QuatF( aa ) );
    setWeight( weight );

    // Fetch Orientation Data.
    String orientationData = StringUnit::getUnit( pString.c_str(), 1, "\t" );

    // Fetch Orientation Type.
    String orientationTypeString = orientationData;
    if ( orientationData.find( " " ) )
    {
        // Use First Word.
        orientationTypeString = orientationData.substr( 0, orientationData.find( " " ) );
    }

    // Set Orientation Type.
    const eOrientationType &orientationType = getOrientationTypeEnum( orientationTypeString.c_str() );
    switch( orientationType )
    {
        case k_OrientationFree : 
            {
                // Apply Mode.
                setOrientationMode( orientationType );

            } break;

        case k_OrientationToPoint:
            {
                // Fetch Point.
                Point3F lookAtPoint;
                // Buffer String.
                dSscanf( orientationData.c_str(), "%*s %f %f %f", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z );

                // Apply Mode.
                setOrientationMode( orientationType, lookAtPoint );

            } break;
    }

    return true;
}
コード例 #5
0
ファイル: VPathNode.cpp プロジェクト: AnteSim/Verve
VPathNode::VPathNode( void ) :
        mPath( NULL ),
        mLocalPosition( Point3F( 0.f, 0.f, 0.f ) ),
        mLocalRotation( QuatF( 0.f, 0.f, 0.f, 1.f ) ),
        mWorldPosition( Point3F( 0.f, 0.f, 0.f ) ),
        mWorldRotation( QuatF( 0.f, 0.f, 0.f, 1.f ) ),
        mWeight( 10.f ),
        mLength( 0.f )
{
    // Init.
    mOrientationMode.Type   = k_OrientationFree;
    mOrientationMode.Point  = Point3F::Zero;

    // Set the initial mask.
    mNetState.setMaskBits( k_StateInit );

    VECTOR_SET_ASSOCIATION( mNetState );
}
コード例 #6
0
ファイル: softBody.cpp プロジェクト: Bloodknight/GMK
void SoftBody::onEditorEnable()
{
	m_stopSimulation = true;
	//recalc obj box by init mesh;
	mObjBox = getShape()->bounds;
	setTransform(m_initTransform);
	mDelta.pos = m_initTransform.getPosition();
	mDelta.rot[0] = QuatF(m_initTransform);
	mDelta.rot[1] = mDelta.rot[0];
}
コード例 #7
0
ファイル: rigidBody.cpp プロジェクト: Duion/GuideBot
void RigidBody::setTransform(const MatrixF& newMat)
{
	Parent::setTransform(newMat);
	
	// for GMK editor, when physics simulation is frozen
	//if(gFreezeSim)
	{
		if(mPhysShape) 
			mPhysShape->setTransform(newMat);
		
		mDelta.pos = newMat.getPosition();
		mDelta.rot[0] = QuatF(newMat);
		mDelta.rot[1] = mDelta.rot[0];
		mPhysPosition = mDelta.pos;
		mPhysRotation = mDelta.rot[0];
	}
}
コード例 #8
0
ファイル: softBody.cpp プロジェクト: Bloodknight/GMK
void SoftBody::setTransform(const MatrixF& mat)
{

	PhysBody::setTransform(mat);
	if(gFreezeSim || m_stopSimulation)
	{
		m_initTransform = mat;
		if(mPhysShape) 
			mPhysShape->setTransform(mat);

		mDelta.pos = mat.getPosition();
		mDelta.rot[0] = QuatF(mat);
		mDelta.rot[1] = mDelta.rot[0];
		mPhysPosition = mDelta.pos;
		mPhysRotation = mDelta.rot[0];
		mDelta.posVec = VectorF::Zero;
	}
}