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


C++ ViewExp::GetAffineTM方法代码示例

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


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

示例1: Inverse

void U2MaxCameraExport::ExtractFromViewport(Interface* pIf)
{
	ViewExp* viewport = pIf->GetActiveViewport();
	if(viewport)
	{
		Matrix3 modelView, invModelView;

		viewport->GetAffineTM(modelView);

		invModelView = Inverse(modelView);

		Point3 up = invModelView.GetRow(0);	// up
		Point3 right = invModelView.GetRow(1); // right
		Point3 look = invModelView.GetRow(2);
		Point3 eye = invModelView.GetRow(3);

		float fFov = viewport->GetFOV();
		BOOL bIsPerp = viewport->IsPerspView();

		pIf->ReleaseViewport(viewport);

		if(bIsPerp)
		{
			;
		}
		else 
		{
			;
		}
	}
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:31,代码来源:U2MaxCameraExport.cpp

示例2: filename


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

	// Show quick preview
	if(_options->getQuickView()){

		float fNear = 1.0f;
		float fFar = 1000.0f;

		// Get the active viewport and the win32 window within it.
		// The position and size will be retreive from this.
		ViewExp* viewExp = _ip->GetActiveViewport();
		float fov = viewExp->GetFOV();
		HWND hWnd = viewExp->getGW()->getHWnd();
		RECT sRect;
		BOOL ok = GetWindowRect(hWnd, &sRect);
		int width = 100;
		int height = 100;
		int x =100;
		int y =100;
		if(ok){
			x = sRect.left;
			y = sRect.top;
			width = sRect.right - sRect.left;
			height = sRect.bottom - sRect.top;
		}

		// Create previewer window and set size.
		Previewer previewer;
		previewer.setWindowSize(x, y, width, height);


		// The affine TM transforms from world coords to view coords
		// so we need the inverse of this matrix
		Matrix3 aTM, camTM, coordSysTM;
		Point3 viewDir, viewPos, lookAtPos, upVector;
		INode* camera;
		float dist = 100;

		Point3 upperLeft = viewExp->MapScreenToView(IPoint2(0, 0), fFar);
		Point3 lowerRight = viewExp->MapScreenToView(IPoint2(width, height), fFar);
		
		viewExp->GetAffineTM(aTM);
		coordSysTM = Inverse(aTM);	

		viewDir = coordSysTM.VectorTransform(Point3(0.0f, 0.0f, -1.0f));
		viewPos = coordSysTM.GetRow(3);
		lookAtPos = viewPos + viewDir;
		upVector.Set(0.0f, 0.0f, 1.0f);

		switch(viewExp->GetViewType()){
			case VIEW_ISO_USER:
			case VIEW_PERSP_USER:
				previewer.setProjectionMatrixAsFrustum(lowerRight.x, upperLeft.x,  upperLeft.y, lowerRight.y, fFar, -fFar);
				break;
			case VIEW_CAMERA:
				previewer.setProjectionMatrixAsFrustum(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, fFar, -fFar);
				camera = viewExp->GetViewCamera();
				camTM = camera->GetObjTMBeforeWSM(_ip->GetTime());
				viewDir = camTM.VectorTransform(Point3(0.0f, 0.0f, -1.0f));
				viewPos = camTM.GetRow(3);
				lookAtPos = viewPos + viewDir;
				break;
			case VIEW_LEFT:
			case VIEW_RIGHT:
			case VIEW_TOP:
			case VIEW_BOTTOM:
			case VIEW_FRONT:
			case VIEW_BACK:
				previewer.setProjectionMatrixAsOrtho(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, -fFar, fFar);
				//cam->setOrtho(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, -fFar, fFar);
				// Go far away from the viewing point in the negative viewing direction.
				viewPos = coordSysTM.PointTransform(Point3(0.0f, 0.0f, fFar));
				lookAtPos = viewPos + viewDir;
				// In top view the up vector on the camera is the positive y-axis.
				if(viewExp->GetViewType() == VIEW_TOP)
					upVector.Set(0.0f, 1.0f, 0.0f);
				// In bottom view the up vector on the camera is the negative y-axis.
				if(viewExp->GetViewType() == VIEW_BOTTOM)
					upVector.Set(0.0f, -1.0f, 0.0f);
				break;
		}
		// When we are done with the viewport we should release it.
		_ip->ReleaseViewport(viewExp);

		// Set scene data.
		previewer.setSceneData(rootTransform.get());

		// set the view - OpenGL look at
		previewer.setViewMatrixAsLookAt(osg::Vec3( viewPos.x, viewPos.y, viewPos.z),
										 osg::Vec3(lookAtPos.x, lookAtPos.y, lookAtPos.z),
										 osg::Vec3(upVector.x, upVector.y, upVector.z) );
 		previewer.run();

		isExporting = FALSE;
		return TRUE;
	}
}
	isExporting = FALSE;
	return TRUE;
}
开发者ID:VRAC-WATCH,项目名称:deltajug,代码行数:101,代码来源:OSGExp.cpp

示例3: VertexPaintRestore

// *****************************************************************
void	VertexPaint::fillSelectionGradientColor()
{
	int		mci;

	// Put Data in Undo/Redo List.
	if(!theHold.Holding())
		theHold.Begin();
	
	ModContextList	modContexts;
	INodeTab		nodeTab;
	
	GetCOREInterface()->GetModContexts(modContexts, nodeTab);
	
	for (mci=0; mci<modContexts.Count(); mci++) 
	{
		ModContext *mc = modContexts[mci];
		if(mc && mc->localData)
			theHold.Put(new VertexPaintRestore((VertexPaintData*)mc->localData, this));
	}

	theHold.Accept(GetString(IDS_RESTORE_GRADIENT));


	// Which Component to change??
	VertexPaintData::TComponent	whichComponent;
	switch(getEditionType())
	{
	case 0: whichComponent= VertexPaintData::Red; break;
	case 1: whichComponent= VertexPaintData::Green; break;
	case 2: whichComponent= VertexPaintData::Blue; break;
	}
	COLORREF	grad0= iColorGradient[0]->GetColor();
	COLORREF	grad1= iColorGradient[1]->GetColor();


	// Get Matrix to viewport.
	Matrix3		viewMat;
	{
		ViewExp *ve = GetCOREInterface()->GetActiveViewport();
		// The affine TM transforms from world coords to view coords
		ve->GetAffineTM(viewMat);
		GetCOREInterface()->ReleaseViewport(ve);
	}


	// Modify all meshes.
	for (mci=0; mci<modContexts.Count(); mci++) 
	{
		ModContext *mc = modContexts[mci];
		if(mc && mc->localData)
		{
			VertexPaintData* d = (VertexPaintData*)mc->localData;
			Mesh*		mesh = 	d->GetMesh();
			if (mesh && mesh->vertCol) 
			{
				float	yMini= FLT_MAX;
				float	yMaxi= -FLT_MAX;

				// 1st, For all faces of the mesh, comute BBox of selection.
				int fi;
				for(fi=0; fi<mesh->getNumFaces(); fi++)
				{
					Face* f = &mesh->faces[fi];

					for (int i=0; i<3; i++) 
					{
						// Skip painting because not selected??
						if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] )
							continue;
						if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi])
							continue;
						// Also skip if face is hidden.
						if(f->Hidden())
							continue;

						// Transform to viewSpace.
						Point3	p= viewMat*mesh->getVert(f->v[i]);
						// extend bbox.
						yMini= p.y<yMini?p.y:yMini;
						yMaxi= p.y>yMaxi?p.y:yMaxi;
					}
				}

				// 2nd, For all faces of the mesh, fill with gradient
				for(fi=0; fi<mesh->getNumFaces(); fi++)
				{
					Face* f = &mesh->faces[fi];

					for (int i=0; i<3; i++) 
					{
						// Skip painting because not selected??
						if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] )
							continue;
						if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi])
							continue;
						// Also skip if face is hidden.
						if(f->Hidden())
							continue;

//.........这里部分代码省略.........
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:101,代码来源:vertex_tree_paint.cpp


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