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


C++ CVector3D函数代码示例

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


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

示例1: if

void CGraphicsCamera::RotateXY( double xInc, double yInc, CWindowFilter& filter )
{
	m_rot.x += xInc;
	if( m_rot.x > M_PI*2 )
		m_rot.x = 0.0;
	else if( m_rot.x < -M_PI*2 )
		m_rot.x = 0.0;
	m_rot.y += yInc;
	if( m_rot.y > M_PI*2 )
		m_rot.y = 0.0;
	else if( m_rot.y < -M_PI*2 )
		m_rot.y = 0.0;
	filter.SetRotations( m_rot );

	//get the quaternion representation of this rotation
	CVector3D right = m_up.cross( CVector3D( m_pos, m_focalPt ).normalize() );
	CQuaternion xquat( xInc, CVector3D( right ).normalize() );
	CQuaternion yquat( yInc, m_up.normalize() );
	CQuaternion total_quat = xquat + yquat;
	total_quat.normalize();

	double m[4][4] = {0.};
	total_quat.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	//multiply our view vector by the rotation matrix
	v1 = v1*m;
	//update our position
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	//update our camera's up vector
	m_up = m_up*m;

}
开发者ID:JeffLutzenberger,项目名称:fea-graphics-engine-example,代码行数:32,代码来源:GraphicsCamera.cpp

示例2: CVector3D

// internal. Based on Equation 15
CVector3D RNSpline::GetEndVelocity(int index)
{
	if (index >= NodeCount || index < 1)
		return CVector3D(0.0f, 0.0f, 0.0f);
	CVector3D temp = CVector3D(Node[index].Position - Node[index-1].Position) * 3.0f * (1.0f / Node[index-1].Distance.ToFloat());
	return (temp - Node[index-1].Velocity) * 0.5f;
}
开发者ID:2asoft,项目名称:0ad,代码行数:8,代码来源:NUSpline.cpp

示例3: tracer

CVector3D CCamera::GetFocus() const
{
	// Basically the same as GetWorldCoordinates

	CHFTracer tracer(g_Game->GetWorld()->GetTerrain());
	int x, z;

	CVector3D origin, dir, delta, terrainPoint, waterPoint;

	origin = m_Orientation.GetTranslation();
	dir = m_Orientation.GetIn();

	bool gotTerrain = tracer.RayIntersect(origin, dir, x, z, terrainPoint);

	CPlane plane;
	plane.Set(CVector3D(0.f, 1.f, 0.f),										// upwards normal
		CVector3D(0.f, g_Renderer.GetWaterManager()->m_WaterHeight, 0.f));	// passes through water plane

	bool gotWater = plane.FindRayIntersection( origin, dir, &waterPoint );

	// Clamp the water intersection to within the map's bounds, so that
	// we'll always return a valid position on the map
	ssize_t mapSize = g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide();
	if (gotWater)
	{
		waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*TERRAIN_TILE_SIZE));
		waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*TERRAIN_TILE_SIZE));
	}

	if (gotTerrain)
	{
		if (gotWater)
		{
			// Intersecting both heightmap and water plane; choose the closest of those
			if ((origin - terrainPoint).LengthSquared() < (origin - waterPoint).LengthSquared())
				return terrainPoint;
			else
				return waterPoint;
		}
		else
		{
			// Intersecting heightmap but parallel to water plane
			return terrainPoint;
		}
	}
	else
	{
		if (gotWater)
		{
			// Only intersecting water plane
			return waterPoint;
		}
		else
		{
			// Not intersecting terrain or water; just return 0,0,0.
			return CVector3D(0.f, 0.f, 0.f);
		}
	}
}
开发者ID:Gallaecio,项目名称:0ad,代码行数:59,代码来源:Camera.cpp

示例4: PolygonOrientation

//! polygon orientation - clockwise or anti-clockwise
CPolygonOrientation
CMathGeom3D::
PolygonOrientation(const CPoint3D &point1, const CPoint3D &point2,
                   const CPoint3D &point3, const CPoint3D &eye)
{
  CVector3D off(point1, eye);

  CVector3D d1d2 =
    CVector3D(point1, point2).crossProduct(CVector3D(point2, point3));

  double dotprod = d1d2.dotProduct(off);

  return (CPolygonOrientation) CMathGen::sign(dotprod);
}
开发者ID:colinw7,项目名称:CMath,代码行数:15,代码来源:CMathGeom3D.cpp

示例5: ADDBOUND

///////////////////////////////////////////////////////////////////
// Scissor rectangle of water patches
CBoundingBoxAligned TerrainRenderer::ScissorWater(const CMatrix3D &viewproj)
{
	CBoundingBoxAligned scissor;
	for (size_t i = 0; i < m->visiblePatches.size(); ++i)
	{
		CPatchRData* data = m->visiblePatches[i];
		const CBoundingBoxAligned& waterBounds = data->GetWaterBounds();
		if (waterBounds.IsEmpty())
			continue;

		CVector4D v1 = viewproj.Transform(CVector4D(waterBounds[0].X, waterBounds[1].Y, waterBounds[0].Z, 1.0f));
		CVector4D v2 = viewproj.Transform(CVector4D(waterBounds[1].X, waterBounds[1].Y, waterBounds[0].Z, 1.0f));
		CVector4D v3 = viewproj.Transform(CVector4D(waterBounds[0].X, waterBounds[1].Y, waterBounds[1].Z, 1.0f));
		CVector4D v4 = viewproj.Transform(CVector4D(waterBounds[1].X, waterBounds[1].Y, waterBounds[1].Z, 1.0f));
		CBoundingBoxAligned screenBounds;
		#define ADDBOUND(v1, v2, v3, v4) \
			if (v1[2] >= -v1[3]) \
				screenBounds += CVector3D(v1[0], v1[1], v1[2]) * (1.0f / v1[3]); \
			else \
			{ \
				float t = v1[2] + v1[3]; \
				if (v2[2] > -v2[3]) \
				{ \
					CVector4D c2 = v1 + (v2 - v1) * (t / (t - (v2[2] + v2[3]))); \
					screenBounds += CVector3D(c2[0], c2[1], c2[2]) * (1.0f / c2[3]); \
				} \
				if (v3[2] > -v3[3]) \
				{ \
					CVector4D c3 = v1 + (v3 - v1) * (t / (t - (v3[2] + v3[3]))); \
					screenBounds += CVector3D(c3[0], c3[1], c3[2]) * (1.0f / c3[3]); \
				} \
				if (v4[2] > -v4[3]) \
				{ \
					CVector4D c4 = v1 + (v4 - v1) * (t / (t - (v4[2] + v4[3]))); \
					screenBounds += CVector3D(c4[0], c4[1], c4[2]) * (1.0f / c4[3]); \
				} \
			}
		ADDBOUND(v1, v2, v3, v4);
		ADDBOUND(v2, v1, v3, v4);
		ADDBOUND(v3, v1, v2, v4);
		ADDBOUND(v4, v1, v2, v3);
		#undef ADDBOUND
		if (screenBounds[0].X >= 1.0f || screenBounds[1].X <= -1.0f || screenBounds[0].Y >= 1.0f || screenBounds[1].Y <= -1.0f)
			continue;
		scissor += screenBounds;
	}
	return CBoundingBoxAligned(CVector3D(clamp(scissor[0].X, -1.0f, 1.0f), clamp(scissor[0].Y, -1.0f, 1.0f), -1.0f),
				  CVector3D(clamp(scissor[1].X, -1.0f, 1.0f), clamp(scissor[1].Y, -1.0f, 1.0f), 1.0f));
}
开发者ID:Gallaecio,项目名称:0ad,代码行数:51,代码来源:TerrainRenderer.cpp

示例6: CVector3D

CVector3D CVector3D::GetVerticalVector(int m) const
{

	if(!IS_ZERO(dx))
		return CVector3D(-(m*dy+dz)/dx,m,1);
	else
		if(!IS_ZERO(dy))
			return CVector3D(1,-(dx+m*dz)/dy,m);
		else
			if(!IS_ZERO(dz))
				return CVector3D(m,1,-(m*dx+dy)/dz);
			else
				return CVector3D(0,0,0);

}
开发者ID:vujn,项目名称:chenan,代码行数:15,代码来源:GeomCalc.cpp

示例7: CVector3D

CVector3D CCamera::GetWorldCoordinates(int px, int py, float h) const
{
	CPlane plane;
	plane.Set(CVector3D(0.f, 1.f, 0.f), CVector3D(0.f, h, 0.f)); // upwards normal, passes through h

	CVector3D origin, dir, delta, currentTarget;

	BuildCameraRay(px, py, origin, dir);

	if (plane.FindRayIntersection(origin, dir, &currentTarget))
		return currentTarget;

	// No intersection with the infinite plane - nothing sensible can be returned,
	// so just choose an arbitrary point on the plane
	return CVector3D(0.f, h, 0.f);
}
开发者ID:Gallaecio,项目名称:0ad,代码行数:16,代码来源:Camera.cpp

示例8: GetPosition

void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation)
{
	CCamera *camera = g_Game->GetView()->GetCamera();
	t = (this->*DistModePtr)(t);

	CVector3D pos = GetPosition(t);

	if (m_LookAtTarget)
	{
		if (m_TimeElapsed <= m_TargetSpline.MaxDistance.ToFloat())
			camera->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance.ToFloat()), CVector3D(0, 1, 0));
		else
			camera->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
	}
	else
	{
		CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
		CQuaternion start, end;
		start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
		end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
		start.Slerp(start, end, nodet);

		camera->m_Orientation.SetIdentity();
		camera->m_Orientation.Rotate(start);
		camera->m_Orientation.Translate(pos);
	}
	camera->UpdateFrustum();
}
开发者ID:AnthonyAaronHughWong,项目名称:0ad,代码行数:28,代码来源:CinemaPath.cpp

示例9: RemoveAll

void CTestParticleSet::setupTestParticles( ) 
{
	RemoveAll( );

	// Check for invalid ranges.
	if( m_xRange.m_y < m_xRange.m_x ||
		m_yRange.m_y < m_yRange.m_x ||
		m_zRange.m_y < m_zRange.m_x ||
		IS_LESS_THAN_OR_EQUAL( m_xRange.m_z, 0 ) ||
		IS_LESS_THAN_OR_EQUAL( m_yRange.m_z, 0 ) ||
		IS_LESS_THAN_OR_EQUAL( m_zRange.m_z, 0 ) )
		return;

	for( double i=m_xRange.m_x; i<=m_xRange.m_y; i+=m_xRange.m_z )
	{
		for( double j=m_yRange.m_x; j<=m_yRange.m_y; j+=m_yRange.m_z )
		{
			for( double k=m_zRange.m_x; k<=m_zRange.m_y; k+=m_zRange.m_z )
			{
				// A planet.
				CPlanet newPlanet;
				newPlanet.setPositionOptimized( CVector3D( i, j, k ) );
				newPlanet.setRadius( 0.1 );
				newPlanet.setDrawAsPoint( true );

				Add( newPlanet );
			}
		}
	}
}
开发者ID:roice3,项目名称:Gravitation3D,代码行数:30,代码来源:testParticleSet.cpp

示例10: CVector4D

void Utility::ScreenToWorld(CVector3D *out,CVector3D spos,CMatrix mProj,CMatrix mView,int w,int h){
	CMatrix	mVP;
	mVP.Viewport(0.0f,0.0f, static_cast<float>(w), static_cast<float>(h));
	CVector4D o = (mView.getInverse() * mProj.getInverse() * mVP.getInverse()) * CVector4D(spos.x,spos.y,spos.z,1);
	*out = CVector3D(o.x/o.w,o.y/o.w,o.z/o.w);
	
}
开发者ID:KemogeJam,项目名称:Kemoge,代码行数:7,代码来源:Utility.cpp

示例11: CVector3D

CVector3D CConeVecProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
{
	const SConeProjection& p = m_pProjectionAngles[_iProjectionIndex];
	int u = _iDetectorIndex % m_iDetectorColCount;
	int v = _iDetectorIndex / m_iDetectorColCount;

	return CVector3D(p.fDetSX + (u+0.5)*p.fDetUX + (v+0.5)*p.fDetVX - p.fSrcX, p.fDetSY + (u+0.5)*p.fDetUY + (v+0.5)*p.fDetVY - p.fSrcY, p.fDetSZ + (u+0.5)*p.fDetUZ + (v+0.5)*p.fDetVZ - p.fSrcZ);
}
开发者ID:viktorrulev,项目名称:gem_optical_tomography,代码行数:8,代码来源:ConeVecProjectionGeometry3D.cpp

示例12: GetProjectileLaunchPoint

	virtual CVector3D GetProjectileLaunchPoint()
	{
		if (!m_Unit)
			return CVector3D();

		if (m_Unit->GetModel().ToCModel())
		{
			// Ensure the prop transforms are correct
			m_Unit->GetModel().ValidatePosition();

			CModelAbstract* ammo = m_Unit->GetModel().ToCModel()->FindFirstAmmoProp();
			if (ammo)
				return ammo->GetTransform().GetTranslation();
		}

		return CVector3D();
	}
开发者ID:stonefruit,项目名称:0ad,代码行数:17,代码来源:CCmpVisualActor.cpp

示例13: CVector3D

CVector3D CBoundingBox::GetPosition()
{
	return CVector3D(
		(m_vMin[0] + m_vMax[0]) / 2.0,
		(m_vMin[1] + m_vMax[1]) / 2.0,
		(m_vMin[2] + m_vMax[2]) / 2.0
	);
}
开发者ID:lclsdut,项目名称:UrbanReconstruction,代码行数:8,代码来源:BoundingBox.cpp

示例14: q

//void CGraphicsCamera::Rotate
void CGraphicsCamera::Rotate( const CPoint3D& euler_angles )
{
	CQuaternion q( euler_angles.x, euler_angles.y, euler_angles.z );
	double m[4][4] = {0. };
	q.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	double dist = v1.length();
	v1 = CVector3D( 0., 0., 1. );
	v1*dist;
	
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	m_up = CVector3D( 0., 1., 0. );
	Rotate( CVector3D::X_AXIS, euler_angles.x );
	Rotate( CVector3D::Y_AXIS, euler_angles.y );
	Rotate( CVector3D::Z_AXIS, euler_angles.z );
	//m_up = m_up*m;
}
开发者ID:JeffLutzenberger,项目名称:fea-graphics-engine-example,代码行数:18,代码来源:GraphicsCamera.cpp

示例15: m_etDir

CGraphicsRigidDiaphragmLoad::CGraphicsRigidDiaphragmLoad( const CRigidDiaphragmLoad* pRDL ):
m_etDir( DY ),
m_loc( CPoint3D() ),
m_textPoint ( CPoint() ),
m_axis( CVector3D() ),
m_rot( 0.f ),
m_pRDL( pRDL )
{
}
开发者ID:JeffLutzenberger,项目名称:fea-graphics-engine-example,代码行数:9,代码来源:GraphicsNodeLoad.cpp


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