Esempio n. 1
0
Matrix3 FormationBhvr::GetFollowerMatrix(TimeValue t,int which)
{
	//we are using 4 Point3's to represent the matrix..
	Point3 point;
	Matrix3 matrix;
	
	pblock->GetValue(follower_matrix1,	0,point,FOREVER,which);
	matrix.SetRow(0,point);
	
	pblock->GetValue(follower_matrix2,	0,point,FOREVER,which);
	matrix.SetRow(1,point);

	
	pblock->GetValue(follower_matrix3,	0,point,FOREVER,which);
	matrix.SetRow(2,point);
	
	pblock->GetValue(follower_matrix4,	0,point,FOREVER,which);
	matrix.SetRow(3,point);

	matrix.ValidateFlags();
	return matrix;

	//Note that when this code was written that the Matrix3 paramblock
	//parameter wasn't working correctly in R4 at the time this was written.
	/*
    if(which<0||which>=GetFollowerCount(t))
		return NULL;

	Matrix3 mat;
	pblock->GetValue(follower_matrix,t,mat,FOREVER,which);
	return mat;
	*/
}
Matrix3 plMaxNodeBase::GetOTM(TimeValue t)
{
    // objectTM = otm * nodeTM
    // otm = objectTM * Inverse(nodeTM)
    Matrix3 objectTM = GetObjectTM(t);
    Matrix3 nodeTM = GetNodeTM(t);
    Matrix3 otm = objectTM * Inverse(nodeTM);
    otm.ValidateFlags();
    return otm;
}
Esempio n. 3
0
BOOL plDistributor::ISetupNormals(plMaxNode* node, Mesh* mesh, BOOL radiateNorm) const
{
    const char* dbgNodeName = node->GetName();

    UVVert *normMap = mesh->mapVerts(kNormMapChan); 
    int numNormVerts = mesh->getNumMapVerts(kNormMapChan);
    if( !mesh->mapSupport(kNormMapChan) || !mesh->mapVerts(kNormMapChan) || !mesh->mapFaces(kNormMapChan) )
    {
        mesh->setMapSupport(kNormMapChan);

        mesh->setNumMapVerts(kNormMapChan, mesh->getNumVerts());
        mesh->setNumMapFaces(kNormMapChan, mesh->getNumFaces());
    }

    int i;
    if( radiateNorm )
    {
        Matrix3 otm = node->GetOTM();
        Matrix3 invOtm = Inverse(otm);
        invOtm.SetTrans(Point3(0,0,0));
        invOtm.ValidateFlags();

        for( i = 0; i < mesh->getNumVerts(); i++ )
        {
            Point3 pos = mesh->getVert(i) * otm;
            pos = pos * invOtm;

            mesh->setMapVert(kNormMapChan, i, pos);
        }
    }
    else
    {
        mesh->checkNormals(true);

        for( i = 0; i < mesh->getNumVerts(); i++ )
        {
            Point3 norm = mesh->getNormal(i);

            mesh->setMapVert(kNormMapChan, i, norm);
        }
    }

    TVFace* mapFaces = mesh->mapFaces(kNormMapChan);
    Face* faces = mesh->faces;
    for( i = 0; i < mesh->getNumFaces(); i++ )
    {
        mapFaces[i].setTVerts(faces[i].getVert(0), faces[i].getVert(1), faces[i].getVert(2));
    }

    return true;
}