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

C++ YsVec3类代码示例

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

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



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

示例1: YsMakeSmaller

void FsLazyWindowApplication::CacheBoundingBox(void)
{
	auto nVtx=vtx.size()/3;
	// Cache bounding box
	if(0<nVtx)
	{
		float minx,miny,minz,maxx,maxy,maxz;
		minx=vtx[0];
		miny=vtx[1];
		minz=vtx[2];
		maxx=vtx[0];
		maxy=vtx[1];
		maxz=vtx[2];
		for(decltype(nVtx) i=0; i<nVtx; ++i)
		{
			YsMakeSmaller(minx,vtx[i*3]);
			YsMakeSmaller(miny,vtx[i*3+1]);
			YsMakeSmaller(minz,vtx[i*3+2]);
			YsMakeGreater(maxx,vtx[i*3]);
			YsMakeGreater(maxy,vtx[i*3+1]);
			YsMakeGreater(maxz,vtx[i*3+2]);
		}
		min.Set(minx,miny,minz);
		max.Set(maxx,maxy,maxz);
	}
	else
	{
		min=YsVec3::Origin();
		max=YsVec3::Origin();
	}
}
开发者ID:HLH15,项目名称:24783,代码行数:31,代码来源:main.cpp


示例2: Motion

void YsClassSample::Motion(int x,int y)
{
	double dx,dy;
	YsVec3 vec;

	dx=double(x-lastX);
	dy=double(lastY-y);
	switch(mouseMode)
	{
	case 0:
		eyeAtt.NoseUp(dy/300.0);
		eyeAtt.YawLeft(-dx/300.0);
		break;
	case 1:
		vec.Set(-dx/30.0,-dy/30.0,0.0);
		vec=eyeAtt.GetMatrix()*vec;
		eyeLookAt=eyeLookAt+vec;
		break;
	case 2:
		RotatePolygon(p,dy/300.0,-dx/300.0);
		break;
	case 3:
		RotatePolygon(q,dy/300.0,-dx/300.0);
		break;
	case 4:
		RotatePolygon(r,dy/300.0,-dx/300.0);
		break;
	}
	lastX=x;
	lastY=y;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:31,代码来源:sample04.cpp


示例3: DrawNearestPointInsideOrOutside

void YsClassSample::DrawNearestPointInsideOrOutside(void)
{
	YsPlane pln;
	YsVec3 nearestPoint;
	YSSIDE sd;
	BIPOINT cursor;

	pln.MakeBestFitPlane(4,p);
	pln.GetNearestPoint(nearestPoint,pointOfInterest);

	sd=YsCheckInsidePolygon3(nearestPoint,4,p);
	BiSetPoint(&cursor,nearestPoint.x(),nearestPoint.y(),nearestPoint.z());
	switch(sd)
	{
	case YSINSIDE:
		BiInsMarker(&cursor,&BiGreen,BIMK_CROSS);
		break;
	case YSOUTSIDE:
		BiInsMarker(&cursor,&BiBlue,BIMK_CROSS);
		break;
	case YSBOUNDARY:
		BiInsMarker(&cursor,&BiYellow,BIMK_CROSS);
		break;
	case YSUNKNOWNSIDE:
		BiInsMarker(&cursor,&BiRed,BIMK_CROSS);
		break;
	}
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:28,代码来源:sample03.cpp


示例4: Display

void Display(void)
{
	double matBuf[4*4];
	YsVec3 eyePos;
	YsMatrix4x4 eyeTfm;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	eyePos.Set(0.0,0.0,eyeDistance);
	eyePos=eyeAtt.GetMatrix()*eyePos;

	eyeTfm.Initialize();
	eyeTfm.Translate(eyePos);
	eyeTfm.Rotate(eyeAtt);
	eyeTfm.Invert();
	eyeTfm.Translate(-eyeLookAt);

	eyeTfm.GetArray(matBuf);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glMultMatrixd(matBuf);
	DrawSeparatablePair(nVtx,vtx);

	glFlush();
	glutSwapBuffers();
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:27,代码来源:sample07.cpp


示例5: Display

void Display(void)
{
	double matBuf[4*4];
	YsVec3 eyePos;
	YsMatrix4x4 eyeTfm;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	eyePos.Set(0.0,0.0,eyeDistance);
	eyePos=eyeAtt.GetMatrix()*eyePos;

	eyeTfm.Initialize();
	eyeTfm.Translate(eyePos);
	eyeTfm.Rotate(eyeAtt);
	eyeTfm.Invert();
	eyeTfm.Translate(-eyeLookAt);

	eyeTfm.GetArray(matBuf);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glMultMatrixd(matBuf);
	DrawShell(sh1,blu,drawInPolygon);
	DrawShell(sh2,grn,drawInPolygon);
	DrawAxis(5.0);
	glFlush();
	glutSwapBuffers();
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:28,代码来源:sample05.cpp


示例6:

static YSRESULT YsClipInfiniteLine3_FindFirstIntersection
    (YsVec3 &itsc,const YsVec3 &org,const YsVec3 &vec,const YsVec3 range[2])
{
	int i,j,k;

	for(i=0; i<3; i++)
	{
		for(j=0; j<2; j++)
		{
			if(YsClip3DLine(itsc,org,vec,range[j].GetValue()[i],i)==YSOK)
			{
				for(k=0; k<3; k++)
				{
					if(i!=k &&
					   (itsc.GetValue()[k]<range[0].GetValue()[k]-YsTolerance ||
					    range[1].GetValue()[k]+YsTolerance<itsc.GetValue()[k]))
					{
						goto NEXTPLANE;
					}
				}
				return YSOK;
			}
		NEXTPLANE:
			;
		}
	}
	return YSERR;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:28,代码来源:ysclip.cpp


示例7: Motion

void Motion(int x,int y)
{
	if(button==GLUT_DOWN)
	{
		double dx,dy;
		YsVec3 vec;

		dx=double(x-lastX);
		dy=double(lastY-y);
		switch(mouseMode)
		{
		case 0:
			eyeAtt.NoseUp(dy/300.0);
			eyeAtt.YawLeft(-dx/300.0);
			break;
		case 1:
			vec.Set(-dx/30.0,-dy/30.0,0.0);
			vec=eyeAtt.GetMatrix()*vec;
			eyeLookAt=eyeLookAt+vec;
			break;
		}
		glutPostRedisplay();
	}
	lastX=x;
	lastY=y;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:26,代码来源:sample06.cpp


示例8: collide

void Cylinder::collide(Particle &particle)const
{
    YsVec3 r=particle.getPosition();
    YsVec3 v=particle.getVelocity();
    YsVec3 n;
    //particle penetrates neither bottom nor radius
    if (bottom_fun(r)<0 && side_fun(r)<0) {
        return;
    }
    if (bottom_fun(r)>0) {
        n=YsYVec();
        if (n*v<0) {
            v=v-2*(v*n)*n; //bounce velocity
            particle.setVelocity(v);
        }
    }
    if (side_fun(r)>0) {
        n=origin-r;
        n.SetY(0.0);
        n.Normalize();
        if (n*v<0) {
            v=v-2*(v*n)*n; //bounce velocity
            particle.setVelocity(v);
        }
    }
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:26,代码来源:Cylinder.cpp


示例9:

YSBOOL YsBoundingBoxMaker3::IsInsideXY(const YsVec3 &pos) const
{
	if(min.x()-YsTolerance<=pos.x() && pos.x()<=max.x()+YsTolerance &&
	   min.y()-YsTolerance<=pos.y() && pos.y()<=max.y()+YsTolerance)
	{
		return YSTRUE;
	}
	return YSFALSE;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:9,代码来源:yswizard.cpp


示例10: YsZClip

YSRESULT YsZClip(YsVec3 &clipPos,const YsVec3 &p1,const YsVec3 &p2,const double &clipz)
{
	const double denom=(p2.z()-p1.z());
	if(YsTolerance<=fabs(denom))
	{
		const YsVec3 v=p2-p1;
		const double t=(clipz-p1.z())/denom;
		clipPos.Set(p1[0]+t*v[0],p1[1]+t*v[1],clipz);
		return YSOK;
	}
	return YSERR;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:12,代码来源:ysclip.cpp


示例11: YsClipLineWithNearZ

YSRESULT YsClipLineWithNearZ(
	YsVec3 &newP1,YsVec3 &newP2,const YsVec3 &p1,const YsVec3 &p2,const double &nearz,YSBOOL positivez)
{
	class TestIsFrontSide
	{
	public:
		inline YSBOOL IsFrontSide(const double tstz,const double nearz,YSBOOL positivez)
		{
			if(YSTRUE==positivez && nearz<=tstz)
			{
				return YSTRUE;
			}
			else if(YSTRUE!=positivez && tstz<=nearz)
			{
				return YSTRUE;
			}
			return YSFALSE;
		}
	};

	TestIsFrontSide tester;

	if(YSTRUE==tester.IsFrontSide(p1.z(),nearz,positivez) &&
	   YSTRUE==tester.IsFrontSide(p2.z(),nearz,positivez))
	{
		newP1=p1;
		newP2=p2;
		return YSOK;
	}
	else if(YSTRUE==tester.IsFrontSide(p1.z(),nearz,positivez) ||
	        YSTRUE==tester.IsFrontSide(p2.z(),nearz,positivez))
	{
		YsVec3 clipPos;
		if(YSOK==YsZClip(clipPos,p1,p2,nearz))
		{
			if(YSTRUE==tester.IsFrontSide(p2.z(),nearz,positivez))
			{
				newP1=clipPos;
				newP2=p2;
				return YSOK;
			}
			else
			{
				newP1=p1;
				newP2=clipPos;
				return YSOK;
			}
		}
	}
	return YSERR;
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:51,代码来源:ysclip.cpp


示例12: YsTransform3DCoordToScreenCoord

void YsTransform3DCoordToScreenCoord(YsVec3 &scrn,const YsVec3 &from,const int viewport[4],const YsMatrix4x4 &projViewModelTfm)
{
	double pos4d[4]={from.x(),from.y(),from.z(),1.0};
	projViewModelTfm.Mul(pos4d,pos4d);

	pos4d[0]/=pos4d[3];
	pos4d[1]/=pos4d[3];
	pos4d[2]/=pos4d[3];

	pos4d[0]=(double)viewport[0]+(double)viewport[2]*(pos4d[0]+1.0)/2.0;
	pos4d[1]=(double)viewport[1]+(double)viewport[3]*(pos4d[1]+1.0)/2.0;

	scrn.Set(pos4d[0],pos4d[1],pos4d[2]);
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:14,代码来源:ysviewcontrol.cpp


示例13: Encache

YSRESULT YsShell::SaveMs3(int &nIgnored,const char fn[]) const
{
	FILE *fp;
	YsShellVertexHandle vtHd;
	YsShellPolygonHandle plHd;

	Encache();
	nIgnored=0;

	fp=fopen(fn,"w");
	if(fp!=NULL)
	{
		vtHd=NULL;
		while((vtHd=FindNextVertex(vtHd))!=NULL)
		{
			YsVec3 pos;
			GetVertexPosition(pos,vtHd);
			fprintf(fp,"V %lf %lf %lf\n",pos.x(),pos.y(),pos.z());
		}

		plHd=NULL;
		while((plHd=FindNextPolygon(plHd))!=NULL)
		{
			int n;
			const YsShellVertexHandle *plVtHd;
			n=GetNumVertexOfPolygon(plHd);
			plVtHd=GetVertexListOfPolygon(plHd);

			if(n==3)
			{
				fprintf(fp,"D %d %d %d\n",   // D of Delta
				    GetVertexIdFromHandle(plVtHd[0]),
				    GetVertexIdFromHandle(plVtHd[1]),
				    GetVertexIdFromHandle(plVtHd[2]));
			}
			else if(n==4)
			{
				fprintf(fp,"Q %d %d %d %d\n",
				    GetVertexIdFromHandle(plVtHd[0]),
				    GetVertexIdFromHandle(plVtHd[1]),
				    GetVertexIdFromHandle(plVtHd[2]),
				    GetVertexIdFromHandle(plVtHd[3]));
			}
		}

		fclose(fp);
		return YSOK;
	}
	return YSERR;
}
开发者ID:ninkamat,项目名称:CMU-24-681-CAD-MIProject,代码行数:50,代码来源:ysshellfileio.cpp


示例14: YsTransformScreenCoordTo3DCoord

void YsTransformScreenCoordTo3DCoord(YsVec3 &threeD,const YsVec3 &scrn,const int viewport[4],const YsMatrix4x4 &projViewModelTfm)
{
	double pos4d[4]=
	{
		(scrn.x()-(double)viewport[0])*2.0/(double)viewport[2]-1.0,
		(scrn.y()-(double)viewport[1])*2.0/(double)viewport[3]-1.0,
		scrn.z(),
		1.0
	};

	projViewModelTfm.MulInverse(pos4d,pos4d);

	pos4d[0]/=pos4d[3];
	pos4d[1]/=pos4d[3];
	pos4d[2]/=pos4d[3];
	threeD.Set(pos4d[0],pos4d[1],pos4d[2]);
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:17,代码来源:ysviewcontrol.cpp


示例15: if

const YsVec3 YsTraceLineSegment::GetCurrentTangent(void) const
{
	YsVec3 t;
	if(curPos.seg<lSeg.GetN()-1)
	{
		t=lSeg[curPos.seg+1]-lSeg[curPos.seg];
		t.Normalize();
		return t;
	}
	else if(2<=lSeg.GetN())
	{
		t=lSeg[lSeg.GetN()-1]-lSeg[lSeg.GetN()-2];
		t.Normalize();
		return t;
	}
	return YsOrigin();
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:17,代码来源:yswizard.cpp


示例16: MakeCloud

void ParticleGroup::MakeCloud(int nParticle,const YsVec3 &min,const YsVec3 &max)
{
	particle.resize(nParticle);
	for(auto &p : particle)
	{
		double s=(double)rand()/(double)RAND_MAX;
		double t=(double)rand()/(double)RAND_MAX;
		double u=(double)rand()/(double)RAND_MAX;

		double x=min.x()*(1.0-s)+max.x()*s;
		double y=min.y()*(1.0-t)+max.y()*t;
		double z=min.z()*(1.0-u)+max.z()*u;

		p.pos.Set(x,y,z);

		p.t=0.0;
		p.tRemain=1.0;

		// Assume 4x4 texture atlas
		s=0.25*(double)(rand()%4);
		t=0.75;
		p.texCoordRange[0]=(float)s;
		p.texCoordRange[1]=(float)t;
		p.texCoordRange[2]=(float)s+0.25;
		p.texCoordRange[3]=(float)t+0.25;
	}
}
开发者ID:HLH15,项目名称:24783,代码行数:27,代码来源:particle.cpp


示例17: Display

void Display(void)
{
	double matBuf[4*4];
	YsVec3 eyePos;
	YsMatrix4x4 eyeTfm;
	YsVec3 p;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	eyePos.Set(0.0,0.0,eyeDistance);
	eyePos=eyeAtt.GetMatrix()*eyePos;

	eyeTfm.Initialize();
	eyeTfm.Translate(eyePos);
	eyeTfm.Rotate(eyeAtt);
	eyeTfm.Invert();
	eyeTfm.Translate(-eyeLookAt);

	eyeTfm.GetArray(matBuf);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glMultMatrixd(matBuf);
	DrawAxis(5.0);

	glDisable(GL_LIGHTING);
	glColor3d(1.0,1.0,1.0);
	glBegin(GL_LINES);
	glVertex3d(0.0,0.0,0.0);
	glVertex3d(axisOfOrbit.x()*5.0,axisOfOrbit.y()*5.0,axisOfOrbit.z()*5.0);
	glEnd();

	rot.RotatePositive(p,orbiter);
	glPushMatrix();
	glTranslatef(p.x()*5.0,p.y()*5.0,p.z()*5.0);
	DrawCursor();
	glPopMatrix();

	glFlush();
	glutSwapBuffers();
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:41,代码来源:sample06.cpp


示例18: p1

void Ys3DDrawingEnvironment::TransformScreenCoordTo3DLine(YsVec3 &org,YsVec3 &vec,double sx,double sy) const
{
	if(YSTRUE==screenOriginIsTopLeft)
	{
		sy=(double)windowHeight-sy;
	}

	const YsMatrix4x4 &viewMat=GetViewMatrix();
	const YsMatrix4x4 &projMat=GetProjectionMatrix();
	const YsMatrix4x4 projViewMat=projMat*viewMat;

	const YsVec3 p1(sx,sy,-1.0),p2(sx,sy,1.0);
	YsTransformScreenCoordTo3DCoord(org,p1,viewport,projViewMat);
	YsTransformScreenCoordTo3DCoord(vec,p2,viewport,projViewMat);

	vec-=org;
	vec.Normalize();
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:18,代码来源:ysviewcontrol.cpp


示例19: YsSmaller

void YsBoundingBoxMaker3::Add(const YsVec3 &vec)
{
	if(first!=YSTRUE)
	{
		min.Set
		   (YsSmaller(min.x(),vec.x()),
		    YsSmaller(min.y(),vec.y()),
		    YsSmaller(min.z(),vec.z()));
		max.Set
		   (YsGreater(max.x(),vec.x()),
		    YsGreater(max.y(),vec.y()),
		    YsGreater(max.z(),vec.z()));
	}
	else
	{
		Begin(vec);
	}
}
开发者ID:Jenny19880324,项目名称:MCG03,代码行数:18,代码来源:yswizard.cpp


示例20: YsTransform3DCoordToScreenCoord

void FsGui3DInterface::DrawRectMarker(const YsVec3 &o,const double lng) const
{
	YsVec3 scrnO;
	YsTransform3DCoordToScreenCoord(scrnO,o,viewport,projViewModelTfm);

	YsVec3 quad[4]=
	{
		YsVec3(scrnO.x()-markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()+markerSize,scrnO.z()),
		YsVec3(scrnO.x()-markerSize,scrnO.y()+markerSize,scrnO.z())
	};
	YsTransformScreenCoordTo3DCoord(quad[0],quad[0],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[1],quad[1],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[2],quad[2],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[3],quad[3],viewport,projViewModelTfm);

	glBegin(GL_LINE_LOOP);
	glVertex3dv(quad[0]);
	glVertex3dv(quad[1]);
	glVertex3dv(quad[2]);
	glVertex3dv(quad[3]);
	glEnd();
}
开发者ID:ninkamat,项目名称:CMU-24-681-CAD-MIProject,代码行数:24,代码来源:fsgui3dgl1.x.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ZHTClient类代码示例发布时间:2022-05-31
下一篇:
C++ YsShellExt类代码示例发布时间: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