当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix3::SetRow方法代码示例

本文整理汇总了C++中Matrix3::SetRow方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3::SetRow方法的具体用法?C++ Matrix3::SetRow怎么用?C++ Matrix3::SetRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix3的用法示例。


在下文中一共展示了Matrix3::SetRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFollowerMatrix

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;
	*/
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:33,代码来源:formation.cpp

示例2: UnwrapMatrixFromNormal

static void UnwrapMatrixFromNormal(Point3& normal, Matrix3& mat)
	{
	Point3 vx;
	vx.z = .0f;
	vx.x = -normal.y;
	vx.y = normal.x;	
	if ( vx.x == .0f && vx.y == .0f ) {
		vx.x = 1.0f;
		}
	mat.SetRow(0,vx);
	mat.SetRow(1,normal^vx);
	mat.SetRow(2,normal);
	mat.SetTrans(Point3(0,0,0));
	mat.NoScale();
	}
开发者ID:2asoft,项目名称:xray,代码行数:15,代码来源:ToolUnfold.cpp

示例3: _UpdatePose

Void SoftBody::_UpdatePose()
{
    if ( !(m_hPose.bIsFrame) )
        return;

    // Update COM
    m_hPose.vCenterOfMass = _ComputeCenterOfMass();

    // Update Rotation & Scaling
    const Node * pNode;
    UInt iNodeIndex;

    Vector3 vTmpRow, vWeigthedDelta;
    Matrix3 matRotScale;
    matRotScale.MakeNull();
    matRotScale.m00 = SCALAR_EPSILON;
    matRotScale.m11 = SCALAR_EPSILON * 2.0f;
    matRotScale.m22 = SCALAR_EPSILON * 3.0f;

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        iNodeIndex = pNode->GetIndex();
        const Vector3 & vDelta = m_hPose.arrDeltas[iNodeIndex];
        vWeigthedDelta = ( (pNode->Position - m_hPose.vCenterOfMass) * m_hPose.arrWeights[iNodeIndex] );
        matRotScale.GetRow( vTmpRow, 0 );
        matRotScale.SetRow( 0, vTmpRow + (vDelta * vWeigthedDelta.X) );
        matRotScale.GetRow( vTmpRow, 1 );
        matRotScale.SetRow( 1, vTmpRow + (vDelta * vWeigthedDelta.Y) );
        matRotScale.GetRow( vTmpRow, 2 );
        matRotScale.SetRow( 2, vTmpRow + (vDelta * vWeigthedDelta.Z) );
        pNode = EnumNextNode();
    }

    Matrix3 matRot, matScale;
    matRotScale.PolarDecomposition( matRot, matScale );

    m_hPose.matRotation = matRot;
    m_hPose.matScaling = ( m_hPose.matBaseScaling * matScale );
    if ( m_fMaxVolumeRatio > 1.0f ) {
        Scalar fInvDet = Clamp<Scalar>( MathFn->Invert( m_hPose.matScaling.Determinant() ),
                                        1.0f, m_fMaxVolumeRatio );
        m_hPose.matScaling *= fInvDet;
    }
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:45,代码来源:SoftBody.cpp

示例4: Normalize

void
TrackMouseCallBack::draw_marker(ViewExp& vpt, Point3 p, Point3 norm)
{
return;   // sorry, this doesn't work yet - I'll post it later
	// set GW tm to orientation specified by norm and draw a circle
	Matrix3 tm;
	Point3 zdir, ydir, xdir;
	// compute the direction of the z axis to be.
	// the positive z axis points AWAY from the target.
	zdir = Normalize(norm);
	// compute direction of the X axis before roll.
	xdir = Normalize(CrossProd(zdir.x > 0 ? Point3(0, 0, 1) : Point3(0, 0, -1), zdir));
	// compute direction of the Y axis before roll.
	ydir = Normalize(CrossProd(zdir, xdir));
	tm.SetRow(0, xdir);
	tm.SetRow(1, ydir);
	tm.SetRow(2, zdir);

	vpt.getGW()->setTransform(tm);
	vpt.getGW()->setColor(LINE_COLOR, MARKER_COLOR);
	vpt.getGW()->marker(&p, CIRCLE_MRKR);
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:22,代码来源:moustrak.cpp

示例5: RemovePivotScale

void RemovePivotScale(INode* node)
{
	const TimeValue  t  = ccMaxWorld::MaxTime();
	Matrix3 nodeTM = node->GetNodeTM(t);

	Point3 pos = nodeTM.GetRow(3);
	Matrix3 objectTM = node->GetObjectTM(t);
	nodeTM = objectTM;
	nodeTM.SetRow(3, pos);
	Matrix3 pv = objectTM * Inverse(nodeTM);
	node->SetNodeTM(t, nodeTM);

	node->SetObjOffsetPos(pv.GetTrans()); 
	node->SetObjOffsetRot(IdentQuat()); 
	node->SetObjOffsetScale(ScaleValue(Point3(1,1,1))); 
}
开发者ID:ani19tha,项目名称:dynamica,代码行数:16,代码来源:MaxNode.cpp

示例6:

//---------------------------------------------------------------------------
Matrix3 U2MaxSceneExport::UniformMatrix(Matrix3 orig_cur_mat)
{
	AffineParts   parts;  
	Matrix3       mat;   

	// Remove scaling from orig_cur_mat
	// 1) Decompose original and get decomposition info
	decomp_affine(orig_cur_mat, &parts); 

	// 2) construct 3x3 rotation from quaternion parts.q
	parts.q.MakeMatrix(mat);

	// 3) construct position row from translation parts.t  
	mat.SetRow(3, parts.t);

	return mat;
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:18,代码来源:U2MaxSceneExport.cpp

示例7: ExportNodeTM

void XsiExp::ExportNodeTM( INode * node, int indentLevel)
{
	// dump the full matrix
	Matrix3 matrix = node->GetNodeTM(GetStaticFrame());
	TSTR indent = GetIndent(indentLevel);
	
	fprintf(pStream,"%s\t%s {\n\n", indent.data(), "FrameTransformMatrix");

	Object * obj = node->EvalWorldState(0).obj;
  BOOL isBone = obj && obj->ClassID() == Class_ID(BONE_CLASS_ID, 0) ? TRUE : FALSE;

  if (node->GetParentNode() && node->GetParentNode()->IsRootNode())
  {
    // bone chains get grafted into the hierarchy tree
    //
	  if (!isBone)
    {
      // root mesh
      oTopMatrix = matrix;
      AffineParts ap;
      decomp_affine( matrix, &ap);
      topMatrix.Set( Point3( ap.k.x,0.0f,0.0f), Point3( 0.0f,ap.k.z,0.0f), Point3(0.0f,0.0f,ap.k.y), Point3(0,0,0));

      // root transform is controlled by the engine
      matrix.IdentityMatrix();
    }
  }
  else
  {
    matrix = matrix * Inverse(node->GetParentTM(GetStaticFrame()));
    if (!isBone)
    {
      matrix.SetRow( 3, topMatrix * matrix.GetRow(3));
    }
  }

  // write the matrix values
  DumpMatrix3( &matrix, indentLevel+2);

  // transform close brace
	fprintf(pStream,"%s\t}\n", indent.data());
}
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:42,代码来源:export.cpp

示例8: PasteToBuffer


//.........这里部分代码省略.........

							}
						else 
							{
							targ->morphTargets[currentMorph]->d[j].vec = copyData->morphTargets[i]->d[sourceID].vec;
							targ->morphTargets[currentMorph]->d[j].vecParentSpace = copyData->morphTargets[i]->d[sourceID].vecParentSpace;
							}


//						Point3 pvec = copyData->morphTargets[i]->d[sourceID].vecParentSpace;

//						Matrix3 selfTM = ld->selfNodeTM;
//						Matrix3 parentTM = copyData->parentBoneNodeCurrentTM;
//						Matrix3 tm = parentTM * Inverse(selfTM) * mirrorTM * selfTM * Inverse(parentTM);

//						pvec = VectorTransform(tm,pvec);

						//do we need to flip the vecs?
						targ->morphTargets[currentMorph]->d[j].originalPt = copyData->morphTargets[i]->d[sourceID].originalPt * mirrorTM;

						}
					}
				}

	//resolve tms
			if (flipTM)
				{
				MorphByBoneLocalData *ld = mod->localDataList[0];
				Matrix3 mirror = Inverse(ld->selfNodeTM) * mirrorTM * ld->selfNodeTM;

		//mirror the initial copy node tm
				Matrix3 copyTM = copyData->currentBoneNodeTM;
				copyTM *= mirror;
				copyTM.SetRow(3,targ->currentBoneNodeTM.GetRow(3));

	//			targ->morphTargets[currentMorph]->boneTMInParentSpace = copyTM * ;


		//put our current targ node tm into the copyTM space
				Matrix3 targTM = targ->currentBoneNodeTM;
				targTM *= Inverse(copyTM);

		//put the morph tm in worldspace
				Matrix3 morphTM = copyData->morphTargets[i]->boneTMInParentSpace * copyData->parentBoneNodeCurrentTM;
		//mirror it
	//			morphTM *= mirror;
	//			morphTM.SetRow(3,targ->currentBoneNodeTM.GetRow(3));

		//now animate it back to world using the morph target tm
				targTM *= morphTM;
		//jam it back into our parent space
				targTM *= Inverse(targ->currentBoneNodeTM);

				targ->morphTargets[currentMorph]->boneTMInParentSpace = targTM;
				}
			else targ->morphTargets[currentMorph]->boneTMInParentSpace = copyData->morphTargets[i]->boneTMInParentSpace;


//puts it in world space
/*
			morphTM = copyData->morphTargets[i]->boneTMInParentSpace * copyData->parentBoneNodeCurrentTM;
			morphTM.SetRow(3,targ->currentBoneNodeTM.GetRow(3));
			morphTM = morphTM * mirror;
			morphTM = morphTM * Inverse(targ->parentBoneNodeCurrentTM);
			targ->morphTargets[currentMorph]->boneTMInParentSpace = morphTM;
*/
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:67,代码来源:MorphByBoneCopyPaste.cpp

示例9: _SetupPose

Void SoftBody::_SetupPose( Bool bIsVolume, Bool bIsFrame )
{
    const Node * pNode;
    UInt iNodeIndex;

    // Update links
    EnumLinks();
    Link * pLink = EnumNextLink();
    while( pLink != NULL ) {
        pLink->UpdateConstants();
        pLink = EnumNextLink();
    }

    // Compute total mass
    Scalar fTotalMass = _ComputeMass();
    Scalar fMassK = fTotalMass * 1000.0f * (Scalar)( GetNodeCount() );

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        if ( pNode->InvMass == 0.0f )
            fTotalMass += fMassK;
        pNode = EnumNextNode();
    }
    Scalar fInvTotalMass = MathFn->Invert( fTotalMass );

    // Flags
    m_hPose.bIsVolume = bIsVolume;
    m_hPose.bIsFrame = bIsFrame;

    // Weights
    m_hPose.arrWeights.Clear();

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        if ( pNode->InvMass > 0.0f )
            m_hPose.arrWeights.Push( pNode->Mass * fInvTotalMass );
        else
            m_hPose.arrWeights.Push( fMassK * fInvTotalMass );
        pNode = EnumNextNode();
    }

    // COM
    m_hPose.vCenterOfMass = _ComputeCenterOfMass();

    // Deltas
    m_hPose.arrDeltas.Clear();

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        m_hPose.arrDeltas.Push( pNode->Position - m_hPose.vCenterOfMass );
        pNode = EnumNextNode();
    }

    // Volume
    m_hPose.fVolume = ( (bIsVolume) ? _ComputeVolume() : 0.0f );

    // BaseScaling
    Matrix3 matBaseScaling;
    matBaseScaling.MakeNull();

    Vector3 vTmpRow;

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        iNodeIndex = pNode->GetIndex();
        const Vector3 & vDelta = m_hPose.arrDeltas[iNodeIndex];
        const Vector3 & vWeightedDelta = ( vDelta * m_hPose.arrWeights[iNodeIndex] );
        matBaseScaling.GetRow( vTmpRow, 0 );
        matBaseScaling.SetRow( 0, vTmpRow + (vDelta * vWeightedDelta.X) );
        matBaseScaling.GetRow( vTmpRow, 1 );
        matBaseScaling.SetRow( 1, vTmpRow + (vDelta * vWeightedDelta.Y) );
        matBaseScaling.GetRow( vTmpRow, 2 );
        matBaseScaling.SetRow( 2, vTmpRow + (vDelta * vWeightedDelta.Z) );
        pNode = EnumNextNode();
    }
    matBaseScaling.Invert( m_hPose.matBaseScaling );

    // Rotation & Scaling
    m_hPose.matRotation.MakeIdentity();
    m_hPose.matScaling.MakeIdentity();
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:85,代码来源:SoftBody.cpp

示例10: createShape


//.........这里部分代码省略.........
					{
						Point3 p0=tri->GetPoint(mesh.faces[i].v[0]);
						Point3 p1=tri->GetPoint(mesh.faces[i].v[1]);
						Point3 p2=tri->GetPoint(mesh.faces[i].v[2]);

						meshInterface->addTriangle( btVector3(p0.x,p0.y,p0.z),btVector3(p1.x,p1.y,p1.z),btVector3(p2.x,p2.y,p2.z));
					}

					
					if (actorDesc.mass>0)
					{
//						MaxMsgBox(NULL, _T("btGImpactMeshShape"), _T("Error"), MB_OK);

						btGImpactMeshShape* trimesh = new btGImpactMeshShape(meshInterface);
						shape = trimesh;

					} else
					{

//						MaxMsgBox(NULL, _T("btBvhTriangleMeshShape"), _T("Error"), MB_OK);
						btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true);
						shape = trimesh;
					}
					
					
				} else
				{
					MaxMsgBox(NULL, _T("Error: no faces"), _T("Error"), MB_OK);
				}
				if (needDel)
					delete tri;
				
			} else
			{
				MaxMsgBox(NULL, _T("Error: couldn't GetTriObjectFromNode"), _T("Error"), MB_OK);
			}

			break;
		}

	default:
		{
			MaxMsgBox(NULL, _T("unknown shape type"), _T("Error"), MB_OK);
		}
	};


#if 0
	NxShapeDesc* pd = NULL;
	NxShapeType type = node->ShapeType;
	PxSimpleMesh proxyMesh;
	Matrix3 nodePose = node->PhysicsNodePoseTM;
	if(m_proxyNode)
	{
		// for proxy, using mesh
		//type = NX_SHAPE_MESH;
		proxyMesh.clone(node->SimpleMesh);
		Point3 pos = nodePose.GetRow(3);
		pos = pos + ProxyDistance;
		nodePose.SetRow(3, pos);
	}
	if((type == NX_SHAPE_MESH) && (Interactivity != RB_STATIC))
	{
		type = NX_SHAPE_CONVEX;
	}
	//
	/*
	bool NeedCCDSkeleton = (Interactivity != RB_STATIC) && (MxUserPropUtils::GetUserPropBool(node->GetMaxNode(), "EnableCCD", false));
	if(NeedCCDSkeleton) 
	{
		NxPhysicsSDK* psdk = gPluginData->getPhysicsSDK();
		psdk->setParameter(NX_CONTINUOUS_CD, 1);
		psdk->setParameter(NX_CCD_EPSILON, 0.01f);
	}
	*/


	// create CCD skeleton for the shape
	//TODO("implement CCD skeleton creation");
	PX_CCD_SKELETON ccdType = (PX_CCD_SKELETON) MxUserPropUtils::GetUserPropInt(node->GetMaxNode(), "px_shape_ccdtype", 1);
	switch(type)
	{
	
	default:
		if (gCurrentstream) gCurrentstream->printf("Unable to create a shape of node \"%s\", unknown shape type: %d.\n", node->GetMaxNode()->GetName(), type);
		return false;
	}
	// load property settings and material things.
	//LoadShapeProperties(*pd, node->GetMaxNode());
	//CCD flag

	pd->name = node->GetMaxNode()->GetName();
	pd->userData = node;
	//
	bool isvalid = pd->isValid();
	actorDesc.shapes.push_back(pd);
#endif

	return shape;
}
开发者ID:ani19tha,项目名称:dynamica,代码行数:101,代码来源:MxActor.cpp

示例11: fnGizmoCenter

void UnwrapMod::fnGizmoCenter()
{
	//get our tm
	//set the tm scale



	TimeValue t = GetCOREInterface()->GetTime();



	
	//get our selection
	Box3 bounds;
	bounds.Init();
	//get the bounding box
	Point3 pnorm(0.0f,0.0f,0.0f);
	int ct = 0;
	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		Matrix3 tm = mMeshTopoData.GetNodeTM(t,ldID);

		for (int k = 0; k < ld->GetNumberFaces(); k++) 
		{
			if (ld->GetFaceSelected(k))
			{
				// Grap the three points, xformed
				int pcount = 3;
				//				if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
				pcount = ld->GetFaceDegree(k);//gfaces[k]->count;

				Point3 temp_point[4];
				for (int j=0; j<pcount; j++) 
				{
					int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
					bounds += ld->GetGeomVert(index) * tm; //gverts.d[index].p * tm;
					if (j < 4)
						temp_point[j] = ld->GetGeomVert(index) * tm; //gverts.d[index].p;
				}
				pnorm += Normalize(temp_point[1]-temp_point[0]^temp_point[2]-temp_point[1]);
				ct++;
			}
		}	
	}


	if (ct == 0) return;

	theHold.Begin();
	SuspendAnimate();
	AnimateOff();
	pnorm = pnorm / (float) ct;//gfaces.Count();
	

	//if just a primary axis set the tm;
	Point3 center = bounds.Center();
	// build the scale



	//get our tm
	Matrix3 tm(1);
	tm = *fnGetGizmoTM();
	Matrix3 initialTM = tm;

	Point3 vec2;
	vec2 = Normalize(tm.GetRow(0)); 
	tm.SetRow(0,vec2);

	vec2 = Normalize(tm.GetRow(1)) ;
	tm.SetRow(1,vec2);

	vec2 = Normalize(tm.GetRow(2)); 
	tm.SetRow(2,vec2);

	tm.SetRow(3,center);


 	Matrix3 itm = Inverse(tm);
	//find our x and y scale
	Box3 localBounds;
	localBounds.Init();
	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		Matrix3 tm = mMeshTopoData.GetNodeTM(t,ldID);

		for (int k = 0; k < ld->GetNumberFaces(); k++) 
		{
			if (ld->GetFaceSelected(k))
			{		// Grap the three points, xformed
				int pcount = 3;
				//				if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
				pcount = ld->GetFaceDegree(k);//gfaces[k]->count;

				Point3 temp_point[4];
				for (int j=0; j<pcount; j++) 
				{
					int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
//.........这里部分代码省略.........
开发者ID:artemeliy,项目名称:inf4715,代码行数:101,代码来源:ToolMapping.cpp

示例12: fnAlignAndFit

void UnwrapMod::fnAlignAndFit(int axis)
{



	//get our selection
	Box3 bounds;
	bounds.Init();
	//get the bounding box
	Point3 pnorm(0.0f,0.0f,0.0f);
	int ct = 0;
	TimeValue t = GetCOREInterface()->GetTime();
	for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
	{
		MeshTopoData *ld = mMeshTopoData[ldID];
		Matrix3 tm = mMeshTopoData.GetNodeTM(t,ldID);
		for (int k = 0; k < ld->GetNumberFaces(); k++) 
		{
			if (ld->GetFaceSelected(k))
			{
					// Grap the three points, xformed
				int pcount = 3;
					//				if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
				pcount = ld->GetFaceDegree(k);//gfaces[k]->count;

				Point3 temp_point[4];
				for (int j=0; j<pcount; j++) 
				{
					int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
					bounds += ld->GetGeomVert(index) *tm;//gverts.d[index].p;
					if (j < 4)
						temp_point[j] = ld->GetGeomVert(index);//gverts.d[index].p;
				}
				pnorm += VectorTransform(Normalize(temp_point[1]-temp_point[0]^temp_point[2]-temp_point[1]),tm);
				ct++;
			}
		}	
	}

	if (ct == 0) return;

	theHold.Begin();
	SuspendAnimate();
	AnimateOff();

	pnorm = pnorm / (float) ct;
	Matrix3 tm(1);
	
	//if just a primary axis set the tm;
	Point3 center = bounds.Center();
		// build the scale
	Point3 scale(bounds.Width().x ,bounds.Width().y , bounds.Width().z);
	if (scale.x == 0.0f) scale.x = 1.0f;
	if (scale.y == 0.0f) scale.y = 1.0f;
 	if (scale.z == 0.0f) scale.z = 1.0f;
	
 	if (axis == 0) // x axi
	{

  		tm.SetRow(0,Point3(0.0f,-scale.y,0.0f));
		tm.SetRow(1,Point3(0.0f,0.0f,scale.z));
		tm.SetRow(2,Point3(scale.x,0.0f,0.0f));
		if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)  || (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
			tm.SetRow(3,center);
		else if (fnGetMapMode() == CYLINDRICALMAP)
		{
			center.x = bounds.pmin.x;
			tm.SetRow(3,center);
		}		

		Matrix3 ptm(1), id(1);
		tm = tm ;
		SetXFormPacket tmpck(tm,ptm);
		tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);
	}
	else if (axis == 1) // y axi
	{
  		tm.SetRow(0,Point3(scale.x,0.0f,0.0f));
 		tm.SetRow(1,Point3(0.0f,0.0f,scale.z));
		tm.SetRow(2,Point3(0.0f,scale.y,0.0f));
		if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)|| (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
			tm.SetRow(3,center);
		else if (fnGetMapMode() == CYLINDRICALMAP)
		{
			center.y = bounds.pmin.y;
			tm.SetRow(3,center);
		}
		

		Matrix3 ptm(1), id(1);
		tm = tm;
		SetXFormPacket tmpck(tm,ptm);
		tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);
	}
	else if (axis == 2) //z axi
	{
		tm.SetRow(0,Point3(scale.x,0.0f,0.0f));
		tm.SetRow(1,Point3(0.0f,scale.y,0.0f));
		tm.SetRow(2,Point3(0.0f,0.0f,scale.z));
		if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)|| (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
//.........这里部分代码省略.........
开发者ID:artemeliy,项目名称:inf4715,代码行数:101,代码来源:ToolMapping.cpp

示例13: fnGizmoAlignToView

void UnwrapMod::fnGizmoAlignToView()
{

	if (ip == NULL) return;

	ViewExp& vpt = ip->GetActiveViewExp();
	if (!vpt.IsAlive()) return;
 
	//get our tm
	//set the tm scale
	theHold.Begin();
	SuspendAnimate();
	AnimateOff();
	TimeValue t = GetCOREInterface()->GetTime();
	


	// Viewport tm
	Matrix3 vtm;
	vpt.GetAffineTM(vtm);
	vtm = Inverse(vtm);

	// Node tm
	Matrix3 ntm(1);// = nodeList[0]->GetObjectTM(ip->GetTime());

	Matrix3 destTM = vtm * Inverse(ntm);
	//get our tm
	
	
	Matrix3 initialTM = *fnGetGizmoTM();


	

	Point3 center = Normalize(initialTM.GetRow(3)); 
	initialTM.SetRow(3,center);

	for (int i = 0; i < 3; i++)
	{
		Point3 vec = destTM.GetRow(i);
		float l  = Length(initialTM.GetRow(i));
		vec = Normalize(vec) * l;
		initialTM.SetRow(i,vec);
	}



	initialTM.SetRow(3,center);


	Matrix3 ptm(1), id(1);
	initialTM = initialTM ;
	SetXFormPacket tmpck(initialTM,ptm);
	tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);

	ResumeAnimate();

	fnGizmoFit();

	if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == CYLINDRICALMAP)  || (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
		ApplyGizmo();

	theHold.Accept(GetString(IDS_MAPPING_ALIGNTOVIEW));
	fnGetGizmoTM();
	if (ip) ip->RedrawViews(ip->GetTime());

}
开发者ID:artemeliy,项目名称:inf4715,代码行数:67,代码来源:ToolMapping.cpp

示例14: GetTracks

void SGP_MaxInterface::GetTracks( int nNodeCount, INode** nodes, Track** tracks )
{
	StartProgressInfo(_M("Get node track..."));

	TimeValue nStartTick = GetStartTick();
	TimeValue nEndTick = GetEndTick();
	int nTickPerFrame = GetTickPerFrame();
	int nFrameCount = 0;

	for( TimeValue t = nStartTick; t <= nEndTick; t += nTickPerFrame )
		nFrameCount++;

	for( int i = 0; i < nNodeCount; i++ )
	{
		tracks[i]->vectorVisible.resize( nFrameCount );
		tracks[i]->vectorTrans.resize( nFrameCount );
		tracks[i]->vectorRot.resize( nFrameCount );
		tracks[i]->vectorScale.resize( nFrameCount );

		Matrix3 matrix = nodes[i]->GetObjTMAfterWSM ( 0 );
		bool bMirror = DotProd ( CrossProd ( matrix.GetRow ( 0 ), matrix.GetRow ( 1 ) ), matrix.GetRow ( 2 ) ) < 0.0 ? true : false;
		tracks[i]->bMirror = bMirror;
	}
	TimeValue t = nStartTick;
	for( int nFrameId = 0; nFrameId < nFrameCount; nFrameId++, t += nTickPerFrame )
	{
		SetProgressInfo( 100.0f*nFrameId/nFrameCount );

		for( int nNodeId = 0; nNodeId < nNodeCount; nNodeId++ )
		{
			INode* pNode = nodes[nNodeId];
			Track* pTrack = tracks[nNodeId];

			Matrix3 tm = pNode->GetNodeTM(t);

			// The coordinate system of 3DMax9 is Right-X Up-Z Screenin-Y
			// But coordinate system of SGP Engine is like D3D Right-X Up-Y Screenin-Z
			// Node Transform Matrix should be swaped.
			/*
			If your matrix looks like this:
			{ rx, ry, rz, 0 }  
			{ ux, uy, uz, 0 }  
			{ lx, ly, lz, 0 }  
			{ px, py, pz, 1 }
			To change it from left to right or right to left, flip it like this:
			{ rx, rz, ry, 0 }  
			{ lx, lz, ly, 0 }  
			{ ux, uz, uy, 0 }  
			{ px, pz, py, 1 }
			*/
			Point3 Row0 = tm.GetRow(0);
			Point3 Row1 = tm.GetRow(1);
			Point3 Row2 = tm.GetRow(2);
			Point3 Row3 = tm.GetRow(3);
			sgp::swapVariables( Row0.y,  Row0.z );
			sgp::swapVariables( Row1.x,  Row2.x );
			sgp::swapVariables( Row1.y,  Row2.z );
			sgp::swapVariables( Row1.z,  Row2.y );
			sgp::swapVariables( Row3.y,  Row3.z );
			tm.SetRow(0, Row0);
			tm.SetRow(1, Row1);
			tm.SetRow(2, Row2);
			tm.SetRow(3, Row3);


			Point3 trans;
			Quat quat;
			Point3 scale;

			{
				// calculate the translation component
				Point3 p;
				p = tm.GetTrans();

				trans.x = p.x;
				trans.y = p.y;
				trans.z = p.z;

				scale.x = tm.GetRow(0).Length();
				scale.y = tm.GetRow(1).Length();
				scale.z = tm.GetRow(2).Length();

				tm.NoScale();

				// calculate the rotation component
				Quat q(tm);
				if( tracks[nNodeId]->bMirror )
				{
					float m[4][3];
					memcpy( m, &tm, sizeof(float)*4*3 );

					m[0][0] *= -1;
					m[1][0] *= -1;
					m[2][0] *= -1;
	
					Matrix3 mm(m);

					Quat q0(mm);
					q = q0;
				}
//.........这里部分代码省略.........
开发者ID:phoenixzz,项目名称:SGPEngine,代码行数:101,代码来源:SGP_MAX9Interface.cpp

示例15: ApplyModifiers

void Import::ApplyModifiers (dScene& scene, const MaxNodeChache& maxNodeCache)
{
    dScene::Iterator iter (scene);
    for (iter.Begin(); iter; iter ++) {
        dScene::dTreeNode* meshNode = iter.GetNode();
        dNodeInfo* info = scene.GetInfoFromNode(meshNode);
        if (info->IsType(dGeometryNodeInfo::GetRttiType())) {
            dScene::dTreeNode* skinModifierNode = NULL;
            for (void* ptr = scene.GetFirstChild(meshNode); ptr; ptr = scene.GetNextChild(meshNode, ptr)) {
                dScene::dTreeNode* node = scene.GetNodeFromLink(ptr);
                dNodeInfo* info = scene.GetInfoFromNode(node);
                if (info->GetTypeId() == dGeometryNodeSkinModifierInfo::GetRttiType()) {
                    skinModifierNode = node;
                    break;
                }
            }

            if (skinModifierNode) {
                //create a skin modifier and add it
                Modifier* skinMod = (Modifier*) CreateInstance(OSM_CLASS_ID, SKIN_CLASSID);
                ISkinImportData* iskinImport = (ISkinImportData*) skinMod->GetInterface(I_SKINIMPORTDATA);
                INode* maxNode = maxNodeCache.Find(meshNode)->GetInfo();
                _ASSERTE (maxNode);

                IDerivedObject *derob = NULL;
                Object* obj = maxNode->GetObjectRef();
                if(obj->SuperClassID() != GEN_DERIVOB_CLASS_ID)
                {
                    derob = CreateDerivedObject(obj);
                    maxNode->SetObjectRef(derob);
                } else {
                    derob = (IDerivedObject*) obj;
                }
                derob->AddModifier(skinMod);

                dGeometryNodeSkinModifierInfo* skinModifier = (dGeometryNodeSkinModifierInfo*) scene.GetInfoFromNode(skinModifierNode);

                dMatrix matrix (skinModifier->m_shapeBindMatrix);
                Matrix3 bindPoseMatrix;
                bindPoseMatrix.SetRow (0, *((Point3*) &matrix[0]));
                bindPoseMatrix.SetRow (1, *((Point3*) &matrix[1]));
                bindPoseMatrix.SetRow (2, *((Point3*) &matrix[2]));
                bindPoseMatrix.SetRow (3, *((Point3*) &matrix[3]));
                iskinImport->SetSkinTm(maxNode, bindPoseMatrix, bindPoseMatrix);

                int maxNodeCount = 0;
                INode* maxNodes[1024];

                for (void* ptr = scene.GetFirstChild(skinModifierNode); ptr; ptr = scene.GetNextChild(skinModifierNode, ptr)) {
                    dScene::dTreeNode* boneNode = scene.GetNodeFromLink(ptr);
                    INode* skelBone = maxNodeCache.Find(boneNode)->GetInfo();
                    maxNodes[maxNodeCount] = skelBone;
                    maxNodeCount ++;
                    skelBone->SetBoneNodeOnOff(TRUE, 0);
                    skelBone->BoneAsLine(TRUE);
                    skelBone->ShowBone(1);
                    if (iskinImport->AddBoneEx(skelBone, TRUE)) {
                        dSceneNodeInfo* sceneNode = (dSceneNodeInfo*) scene.GetInfoFromNode(boneNode);
                        dMatrix matrix (sceneNode->GetTransform());
                        Matrix3 bindPoseMatrix;
                        bindPoseMatrix.SetRow (0, *((Point3*) &matrix[0]));
                        bindPoseMatrix.SetRow (1, *((Point3*) &matrix[1]));
                        bindPoseMatrix.SetRow (2, *((Point3*) &matrix[2]));
                        bindPoseMatrix.SetRow (3, *((Point3*) &matrix[3]));
                        iskinImport->SetBoneTm(skelBone, bindPoseMatrix, bindPoseMatrix);
                    }
                }

                // must evaluate the node after adding bones
                maxNode->EvalWorldState(0);

                for (int i = 0; i < skinModifier->m_vertexCount; i ++) {
                    Tab<float> weightList;
                    Tab<INode*> boneNodeList;
                    for (int j = 0; j < 4; j ++) {
                        if (skinModifier->m_vertexWeights[i][j] > 1.0e-5f) {
                            int boneIndex = skinModifier->m_boneWeightIndex[i].m_index[j];
                            INode *skelBone = maxNodes[boneIndex];
                            _ASSERTE (skelBone);
                            boneNodeList.Append (1, &skelBone);
                            weightList.Append (1, &skinModifier->m_vertexWeights[i][j]);
                        }
                    }
                    iskinImport->AddWeights(maxNode, i, boneNodeList, weightList);
                }
            }
        }
    }
}
开发者ID:Naddiseo,项目名称:Newton-Dynamics-fork,代码行数:89,代码来源:Import.cpp


注:本文中的Matrix3::SetRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。