• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ViewExp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetDevice

static LPDIRECT3DDEVICE9 GetDevice()
{
	GraphicsWindow		*GW;
	ViewExp				*View;
	LPDIRECT3DDEVICE9	Device;

	View = GetCOREInterface()->GetActiveViewport();

	if(View)
	{
		GW = View->getGW();

		if(GW)
		{
			ID3D9GraphicsWindow *D3DGW = (ID3D9GraphicsWindow *)GW->GetInterface(D3D9_GRAPHICS_WINDOW_INTERFACE_ID);

			if(D3DGW)
			{
				Device = D3DGW->GetDevice();

				return(Device);
			}
		}
	}
	return NULL;
}
开发者ID:whztt07,项目名称:OgreGameProject,代码行数:26,代码来源:DxStdMtl2.cpp


示例2: 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


示例3: p

void CrossSectionMouseProc::DrawCrossing(HWND hWnd)
	{
	if (mShapeData == NULL) return;

	BezierShape *shape = mShapeData->TempData(es)->GetShape(ip->GetTime());
	if (shape == NULL) return;

	int polys = mSelectedSplines.Count();
	if (polys <= 0) return;

	Spline3D *spline = shape->GetSpline(mSelectedSplines[polys-1]);
	int knots = spline->KnotCount();
	Point3 p(0.0f, 0.0f, 0.0f);
	IPoint3 sp;

	ViewExp *vpt = ip->GetViewport(hWnd);
	GraphicsWindow *gw = vpt->getGW();
	ip->ReleaseViewport(vpt);
	gw->setTransform(mObjToWorldTM);

	HDC hdc = GetDC(hWnd);
	SetROP2(hdc, R2_XORPEN);
	SetBkMode(hdc, TRANSPARENT);
	SelectObject(hdc,CreatePen(PS_DOT, 0, ComputeViewportXORDrawColor()));
	for (int i = 0, j = 0; i < 2 && i <= j; i++, j += (knots-1)) {
		if (knots > i) p = spline->GetKnotPoint(j);
		gw->wTransPoint(&p, &sp);
		MoveToEx(hdc,sp.x,sp.y,NULL);
		LineTo(hdc,mMouse.x,mMouse.y);
		}
	DeleteObject(SelectObject(hdc,GetStockObject(BLACK_PEN)));
	ReleaseDC(hWnd, hdc);
	}
开发者ID:2asoft,项目名称:xray,代码行数:33,代码来源:editsops.cpp


示例4:

void U2MaxCameraExport::Export(Interface* pIf, INode *pMaxNode, Object *obj)
{

	CameraObject* camObj = (CameraObject*)obj;

	// get camera state
	Interval interval;
	CameraState camState;
	camObj->EvalCameraState(m_animStart, interval, &camState);

	bool bFixedCam = false;
	if(camObj->GetManualClip())
		bFixedCam = true;

	float fFov = camState.fov;
	BOOL bIsOrtho = camState.isOrtho;

	float fInvAspectRatio = 1.0f / pIf->GetRendImageAspect();

	if(bIsOrtho)
	{
		float fWidth = 640.0f / 4.0f;
		float fHeight = 480.0f / 4.0f;
		float fScalar = camObj->GetTDist(0) / 200.0f;
	}
	else 
	{
		// add
	}

	if(bFixedCam)
	{
		float fNearPlane = camState.hither;
		float farPlane = camState.yon;
	}
	else 
	{
		float nearPlane = 1.0f;
		float farPlane = 6000.0f;
	}

	ViewExp* viewport = pIf->GetActiveViewport();
	if(viewport)
	{
		INode* pMaxViewCam = viewport->GetViewCamera();

		if(pMaxNode == pMaxViewCam)
		{
			; 
		}

		pIf->ReleaseViewport(viewport);
	}
	else 
	{
		;
	}
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:58,代码来源:U2MaxCameraExport.cpp


示例5: GetMat

void ProtHelpObject::GetMat(TimeValue t, INode* inode, ViewExp& vpt, Matrix3& tm) 
{
   if ( ! vpt.IsAlive() )
	{
		tm.Zero();
		return;
	}
	 tm = inode->GetObjectTM(t);
   tm.NoScale();
   float scaleFactor = vpt.NonScalingObjectSize() * vpt.GetVPWorldWidth(tm.GetTrans()) / 360.0f;
   tm.Scale(Point3(scaleFactor,scaleFactor,scaleFactor));
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:12,代码来源:prothelp.cpp


示例6: proc

int SegRefineMouseProc::proc(
			HWND hwnd, 
			int msg, 
			int point, 
			int flags, 
			IPoint2 m )
	{
	ViewExp *vpt = ip->GetViewport(hwnd);	
	int res = TRUE;

	switch ( msg ) {
		case MOUSE_PROPCLICK:
			ip->SetStdCommandMode(CID_OBJMOVE);
			break;

		case MOUSE_POINT:
			if(HitTest(vpt,&m,HITTYPE_POINT,0) ) {
				HitLog &hits = vpt->GetSubObjHitList();
				HitRecord *rec = hits.First();
				HitRecord *bestRec = rec;
				DWORD best = rec->distance;
				while(rec) {
					rec = rec->Next();
					if(rec) {
						if(rec->distance < best) {
							best = rec->distance;
							bestRec = rec;
							}
						}
					}
				ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
				es->DoSegRefine(vpt, hit->shape, hit->poly, hit->index, m);
				}
			res = FALSE;
			break;
		
		case MOUSE_FREEMOVE:
			vpt->SnapPreview(m,m,NULL, SNAP_IN_3D);
			if ( HitTest(vpt,&m,HITTYPE_POINT,HIT_ABORTONHIT) ) {
				SetCursor(GetTransformCursor());
				}
			else {
				SetCursor(LoadCursor(NULL,IDC_ARROW));
				}
			break;
			
		}

	if ( vpt ) ip->ReleaseViewport(vpt);
	return res;
	}
开发者ID:2asoft,项目名称:xray,代码行数:51,代码来源:editsops.cpp


示例7: clipgrid

static BOOL clipgrid(Point3 wp, ViewExp& vpt)
{
	if ( ! vpt.IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	if(!vpt.IsPerspView())
		return TRUE;

	float minx, miny, maxx, maxy;
	vpt.GetGridDims(&minx, &maxx, &miny, &maxy);
	if(wp.x > minx && wp.x < maxx && wp.y > miny && wp.y < maxy)
		return TRUE;
	
	return FALSE;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:19,代码来源:gridsnap.cpp


示例8: 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


示例9: hitPoint

BOOL BoundsTree::HitQuadTree(IPoint2 m, int &nindex, DWORD &findex, Point3 &p, Point3 &norm, Point3 &bary, float &finalZ, Matrix3 &toWorldTm)
{
//int nindex = 0;
Leaf *l = head;
BOOL hit = FALSE;
Point3 hitPoint(0.0f,0.0f,0.0f);
DWORD smgroup;

hitPoint.x = (float) m.x;
hitPoint.y = (float) m.y;
float z = 0.0f;
Point3 bry;
if (l == NULL) 
	{
	z = 0.0f;
	return FALSE;
	}
int ct = 0;
while ( (l!=NULL) && (l->IsBottom() == FALSE))
	{
	int id = l->InWhichQuad(hitPoint);
	l = l->GetQuad(id);
	ct++;
	}
if (l)
	{
	if (l->faceIndex.Count() == 0) 
		return FALSE;
	else
		{
		for (int i = 0; i < l->faceIndex.Count(); i++)
			{
			int faceIndex = l->faceIndex[i].faceIndex;
			int nodeIndex = l->faceIndex[i].nodeIndex;

			LightMesh *lmesh = meshList[nodeIndex];

			Point3 *tempVerts = lmesh->vertsViewSpace.Addr(0);
			Face *tempFaces = lmesh->faces.Addr(faceIndex);

			Box2D b = lmesh->boundingBoxList[faceIndex];
			if ( (hitPoint.x >= b.min.x) && (hitPoint.x <= b.max.x) &&
				 (hitPoint.y >= b.min.y) && (hitPoint.y <= b.max.y) )
				{
//now check bary coords
				Point3 a,b,c;
				a = tempVerts[tempFaces->v[0]];
				b = tempVerts[tempFaces->v[1]];
				c = tempVerts[tempFaces->v[2]];
				Point3 az,bz,cz,hitPointZ;
				az = a;
				bz = b;
				cz = c;
				az.z = 0.0f;
				bz.z = 0.0f;
				cz.z = 0.0f;
				hitPointZ = hitPoint;
				hitPointZ.z = 0.0f;
	
				Point3 bry;
				bry = BaryCoords(az, bz, cz, hitPointZ);
//if inside bary find the the z point			
				if (!( (bry.x<0.0f || bry.x>1.0f || bry.y<0.0f || bry.y>1.0f || bry.z<0.0f || bry.z>1.0f) ||
					(fabs(bry.x + bry.y + bry.z - 1.0f) > EPSILON) ))
					{
					float tz = a.z * bry.x + b.z * bry.y + c.z * bry.z; 
					if ( (tz > z ) || (hit == FALSE) )  
						{
						z = tz;
						findex = faceIndex;
						nindex = nodeIndex;
						bary = bry;
						finalZ = z;
						smgroup = tempFaces->getSmGroup();
						}
					hit = TRUE;
					}
				}
			}
		}	
	}
if (hit)
	{
	Point3 a,b,c;
	int ia,ib,ic;
	LightMesh *lmesh = meshList[nindex];
	Point3 *tempVerts = lmesh->vertsWorldSpace.Addr(0);
	Face *tempFaces = lmesh->faces.Addr(findex);

	ia = tempFaces->v[0];
	ib = tempFaces->v[1];
	ic = tempFaces->v[2];
	a = tempVerts[ia];
	b = tempVerts[ib];
	c = tempVerts[ic];

	ViewExp *vpt = GetCOREInterface()->GetActiveViewport();

	Ray worldRay;
//	vpt->GetAffineTM(tm);
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:xray,代码行数:101,代码来源:BoundsTree.cpp


示例10: BMMSplitFilename


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

			if(res.error() && _options->getShowErrMsg()){
				static TCHAR szBuffer[256];
				wsprintf(szBuffer,TEXT("Error writing file %s:\n%s"), 
					     TEXT(filename.c_str()),res.message());
				MessageBox (GetActiveWindow(), szBuffer, TEXT("Warning"),
					        MB_OK | MB_ICONWARNING) ;
			}

			if(!_options->getIncludeImageDataInIveFile()){
                // Turn readerwriter options off again.
				osgDB::ReaderWriter::Options* opt = new osgDB::ReaderWriter::Options();
				osgDB::Registry::instance()->setOptions(opt);
            }
		}
		else{
			if(_options->getShowErrMsg()){
				std::string error("Can not find plugin to save file: ");
				error.append(name);
				MessageBox (GetActiveWindow(), error.c_str() , TEXT("Warning"), MB_OK | MB_ICONWARNING) ;
			}
		}
		_ip->ProgressEnd();
	}

	// 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);	
开发者ID:VRAC-WATCH,项目名称:deltajug,代码行数:67,代码来源:OSGExp.cpp


示例11: ComputeNewUVW

void TweakMouseProc::ComputeNewUVW(ViewExp& vpt, IPoint2 m)
{
	if ( ! vpt.IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return;
	}

	Ray r;
	vpt.MapScreenToWorldRay ((float) m.x, (float) m.y, r);
	TimeValue t = GetCOREInterface()->GetTime();
	Matrix3 tm = mod->GetMeshTopoDataNode(mHitLDIndex)->GetObjectTM(t);
	Matrix3 itm = Inverse(tm);

	r.p = r.p * itm;
	r.dir = VectorTransform(r.dir,itm);

	//intersect our ray with that face and get our new bary coords

	Point3 n = mHitLD->GetGeomFaceNormal(mHitFace);

	Point3 p1, p2, p3;

	p1 = mHitP[0];
	p2 = mHitP[1];
	p3 = mHitP[2];

	Point3  p, bry;
	float d, rn, a; 

	// See if the ray intersects the plane (backfaced)
	rn = DotProd(r.dir,n);
	if (rn > -0.0001) return;

	// Use a point on the plane to find d
	Point3 v1 = p1;
	d = DotProd(v1,n);

	// Find the point on the ray that intersects the plane
	a = (d - DotProd(r.p,n)) / rn;

	// Must be positive...
	if (a < 0.0f) return ;



	// The point on the ray and in the plane.
	p = r.p + a*r.dir;

	// Compute barycentric coords.
	bry = BaryCoords(p1,p2,p3,p);  // DbgAssert(bry.x + bry.y+ bry.z = 1.0) 

	Point3 uvw = mHitUVW[0] * bry.x + mHitUVW[1] * bry.y + mHitUVW[2] * bry.z;
	Point3 v = uvw - mSourceUVW;
	v *= -1.0f;
	mFinalUVW = mSourceUVW + v;
	mHitLD->SetTVVert(GetCOREInterface()->GetTime(),mHitTVVert,mFinalUVW,mod);

	mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE);
	mod->InvalidateView();
	if (mod->ip) 
		mod->ip->RedrawViews(mod->ip->GetTime());

}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:65,代码来源:ToolUVWTweak.cpp


示例12: if

BOOL
TrackMouseCallBack::point_on_obj(ViewExp& vpt, IPoint2 m, Point3& pt, Point3 &norm)
{
	if ( ! vpt.IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	// computes the normal ray at the point of intersection
	Ray ray, world_ray;
	float at, best_dist = 0.0f;
	TimeValue t = MAXScript_time();	
	Object *obj = NULL;
	Matrix3 obtm, iobtm;
	Point3 testNorm;

	BOOL found_hit = FALSE;
	
	vl->face_num_val = vl->face_bary = &undefined;
	hit_node = NULL;

	// Calculate a ray from the mouse point
	vpt.MapScreenToWorldRay(float(m.x), float(m.y), world_ray);

	for( int i=(nodeTab.Count()-1); i>=0; i-- ) {
		// Get the object from the node
		INode* node = nodeTab[i];
		ObjectState os = node->EvalWorldState(t);
		obj = os.obj;	

		// Back transform the ray into object space.
		obtm	= node->GetObjectTM(t);
		iobtm	= Inverse(obtm);
		ray.p   = iobtm * world_ray.p;
		ray.dir = VectorTransform(iobtm, world_ray.dir);
		
		// See if we hit the object
		if (obj->IsSubClassOf(triObjectClassID))
		{
			TriObject*  tobj = (TriObject*)obj;
			DWORD		fi;
			Point3		bary;
			if (tobj->mesh.IntersectRay(ray, at, testNorm, fi, bary)  &&
			   ((!found_hit) || (at<=best_dist)) )
			{
				// Calculate the hit point and transform everything back into world space.
				// record the face index and bary coord
				best_dist = at;
				pt = ray.p + ray.dir * at;
				pt = pt * obtm;
				norm = Normalize(VectorTransform(obtm, testNorm));
				vl->face_num_val = Integer::intern(fi + 1);
				vl->face_bary = new Point3Value(bary);
				hit_node = node;
				found_hit = TRUE;
			}
		}
		else if (obj->IntersectRay(t, ray, at, testNorm)  &&
				((!found_hit) || (at<=best_dist)) )
		{
			// Calculate the hit point and transform everything back into world space.
			best_dist = at;
			pt = ray.p + ray.dir * at;
			pt = pt * obtm;
			norm = Normalize(VectorTransform(obtm, testNorm));
			hit_node = node;
			found_hit = TRUE;
		}
	}
	if( found_hit ) return TRUE;

	// Failed to find a hit on any node, look at the Normal Align Vector for the first node
	if ((obj!=NULL) && obj->NormalAlignVector(t, pt, testNorm)) // See if a default NA vector is provided
	{
		pt   = pt * obtm;
		norm = Normalize(VectorTransform(obtm, testNorm));
		return TRUE;
	}
	else
		return FALSE;
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:83,代码来源:moustrak.cpp


示例13: GetCOREInterface

// *****************************************************************
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


示例14: proc

int CreateSWrapObjectProc::proc(HWND hwnd,int msg,int point,int flag,
				IPoint2 m )
{	int res=TRUE;	
	ViewExp *vpx = createInterface->GetViewport(hwnd); 
	assert( vpx );

#ifdef _3D_CREATE
	DWORD snapdim = SNAP_IN_3D;
#else
	DWORD snapdim = SNAP_IN_PLANE;
#endif
	switch ( msg ) {
		case MOUSE_POINT:
			switch ( point ) {
				case 0:
					assert( SWrapObj );					
					vpx->CommitImplicitGrid(m, flag );
					if ( createInterface->SetActiveViewport(hwnd) ) {
						return FALSE;
						}

					if (createInterface->IsCPEdgeOnInView()) { 
						res = FALSE;
						goto done;
						}

					if ( attachedToNode ) {
				   		// send this one on its way
#ifdef _OSNAP
                    SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
				   		SWrapObj->EndEditParams( (IObjParam*)createInterface, 0, NULL);
						if (SWrapNode) {
							theHold.Suspend();
							DeleteReference(0);
							theHold.Resume();
							}

						// new object
						CreateNewObject();   // creates SWrapObj
						}

				   	theHold.Begin();	 // begin hold for undo
					mat.IdentityMatrix();

					// link it up
					SWrapNode = createInterface->CreateObjectNode( SWrapObj);
					attachedToNode = TRUE;
					assert( SWrapNode );					
					createCB = NULL;
					createInterface->SelectNode( SWrapNode );
					
					// Reference the new node so we'll get notifications.
					theHold.Suspend();
					MakeRefByID( FOREVER, 0, SWrapNode);
					theHold.Resume();
					mat.IdentityMatrix();
				default:				
					res = createmethod(vpx,msg,point,flag,m,mat);
					createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
					if (res==CREATE_ABORT)
						goto abort;
					if (res==CREATE_STOP){
#ifdef _OSNAP
                        SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
						theHold.Accept(GetString(IDS_AP_CREATE));	
					}
					createInterface->RedrawViews(createInterface->GetTime()); 
					break;
				}			
			break;

		case MOUSE_MOVE:
			res = createmethod(vpx,msg,point,flag,m,mat);
			createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
			if (res==CREATE_ABORT)
				goto abort;
			if (res==CREATE_STOP){
#ifdef _OSNAP
               SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
			   theHold.Accept(GetString(IDS_AP_CREATE));	
			}
			createInterface->RedrawViews(createInterface->GetTime()); 
		break;

/*			res = createmethod(vpx,msg,point,flag,m,mat);
			createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
			if (res==CREATE_ABORT)
				goto abort;
			if (res==CREATE_STOP)
				theHold.Accept(GetString(IDS_AP_CREATE));	
			createInterface->RedrawViews(createInterface->GetTime()); 
		break;*/
	case MOUSE_PROPCLICK:
		createInterface->SetStdCommandMode(CID_OBJMOVE);
		break;
	case MOUSE_ABORT: 
	abort:
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:xray,代码行数:101,代码来源:surfwrap.cpp


示例15: Snap

void gridSnap::Snap(Object* pobj, IPoint2 *p, TimeValue t)
{	

	ViewExp *vpt = theman->GetVpt();

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return;
	}

	DbgAssert(vpt != NULL);

	//local copy of the cursor position
	Point2 fp = Point2((float)p->x, (float)p->y);

	BOOL got_one= FALSE;
	//Get point on the consttruction plane 
	Point3 local_cp = vpt->GetPointOnCP(*p);
	Point3 world_snapped;

	Matrix3 tmconst;
	vpt->GetConstructionTM( tmconst );

	// aszabo|nov.01.05|#596889, #613720, #703875 
	// In order to allow snapping to the grid sub-divisions computed based on viewport 
	// the zoom facto, the grid spacing is taken from the viewport.  
	// When the grid is invisible and the zoom factor changes, the viewport returns 
	// the grid spacing computed last time the grid was displayed.
	// When max starts up with hidden grids (via maxstart.max), the viewport's grid 
	// spacing will be zero and in that case we take the grid spacing value specified 
	// in the Grid setting UI.
	float gridSpacing = vpt->GetGridSize();
	if (!(gridSpacing > 0.0f || gridSpacing < 0.0f)) {
		gridSpacing = GetCOREInterface()->GetGridSpacing();
	}


	//Compute all the hit point candidates
	if(	GetActive(INT_SUB))
	{
		float gridZ = 0.f;
#ifdef GAME_VER
		float gridSpacing = GetCOREInterface()->GetGridSpacing();

		SnapInfo si;
		GetCOREInterface()->InitSnapInfo(&si);
		if(si.snapType == SNAP_25D)
			gridZ = GridCoord(local_cp.z,gridSpacing);

		Point3 intsnapped = Point3(GridCoord(local_cp.x,gridSpacing),GridCoord(local_cp.y,gridSpacing),gridZ);
		world_snapped = tmconst * intsnapped;//now in world space
		got_one = TRUE;

		hitmesh = new HitMesh(5);
		hitmesh->setVert(0,tmconst * Point3(intsnapped.x,intsnapped.y - gridSpacing,gridZ));
		hitmesh->setVert(1,tmconst * Point3(intsnapped.x,intsnapped.y + gridSpacing,gridZ));
		hitmesh->setVert(2,tmconst * Point3(intsnapped.x-gridSpacing,intsnapped.y,gridZ));
		hitmesh->setVert(3,tmconst * Point3(intsnapped.x + gridSpacing,intsnapped.y,gridZ));

		//now register a hit with the osnap manager
		//possibly screen for proximity to the foreground
		theman->RecordHit(new OsnapHit(world_snapped, this, INT_SUB, hitmesh));

#else //!GAME_VER
		// aszabo|sep.15.04|#596889|The gridSpacing spacing shouldn't be zero, but if it is, it can lead to infinite loops
		DbgAssert(gridSpacing > 0.0f || gridSpacing < 0.0f);
		if (gridSpacing > 0.0f || gridSpacing < 0.0f)
		{
			// Record all hits that fall in the snap preview area.
			// Grids are infinite, so we can't loop  through their "vertexes".
			// Instead go through only those that are potential snap points, by starting
			// at the closest grid point to the mouse and extending in all directions
			// using "grid size" steps.
			Point3 intsnapped = Point3(GridCoord(local_cp.x,gridSpacing),GridCoord(local_cp.y,gridSpacing),gridZ);
			Point3 curIntsnapped(intsnapped);
			world_snapped = tmconst * intsnapped;

			// set the window transform to identity to guarantee a world-screen transformation.
			if (theman->GetVpt() && theman->GetVpt()->getGW()) {
				theman->GetVpt()->getGW()->setTransform(Matrix3(TRUE));
			}
			// Find all snap points on the right side (positive x) of the intsnapped, including the intsnapped
			while (CheckPotentialHit(&world_snapped,0, fp)) 
			{
				got_one = TRUE;
				RecordNewIntSubHit(world_snapped, tmconst, curIntsnapped, gridSpacing);

				//ktong|Jan.27.2006|#748560|Limit the number of snap points to search only visibly distinct points.
				// If the grid point is too far away to tell it from the next gridpoint, stop searching.
				// No point in enumerating snap points a user can't visibly tell apart.
				// Check after the first snap point (the closest) is registered to at least have one.
				if (TooDistant(theman, world_snapped, gridSpacing)) {
					break;
				}

				// Go down the vertical grid line
				curIntsnapped.y -= gridSpacing;
				FindVerticalIntSubHit(tmconst, curIntsnapped, fp, (-gridSpacing));
//.........这里部分代码省略.........
开发者ID:artemeliy,项目名称:inf4715,代码行数:101,代码来源:gridsnap.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ViewGroup类代码示例发布时间:2022-05-31
下一篇:
C++ ViewEdge类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap