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


C++ Plane::SetPlane方法代码示例

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


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

示例1: SetupVolumeSegment

void CGameVolume_Water::SetupVolumeSegment(const WaterProperties& waterProperties, const uint32 segmentIndex, const Vec3* pVertices, const uint32 vertexCount)
{
	SWaterSegment& segment = m_segments[segmentIndex];

	IWaterVolumeRenderNode*& pWaterRenderNode = segment.m_pWaterRenderNode;

	CreateWaterRenderNode(pWaterRenderNode);

	CRY_ASSERT ( pWaterRenderNode != NULL );

	const Matrix34& entityWorldTM = GetEntity()->GetWorldTM();

	pWaterRenderNode->SetMinSpec( waterProperties.minSpec );
	pWaterRenderNode->SetMaterialLayers( (uint8)waterProperties.materialLayerMask );
	pWaterRenderNode->SetViewDistRatio( waterProperties.viewDistanceRatio );

	Plane fogPlane;
	fogPlane.SetPlane( Vec3Constants<float>::fVec3_OneZ, pVertices[0] );

	pWaterRenderNode->SetFogDensity( waterProperties.fogDensity );
	pWaterRenderNode->SetFogColor( waterProperties.fogColor * max( waterProperties.fogColorMultiplier , 0.0f ) );
	pWaterRenderNode->SetFogColorAffectedBySun( waterProperties.fogColorAffectedBySun );
	pWaterRenderNode->SetFogShadowing( waterProperties.fogShadowing );
	pWaterRenderNode->SetCapFogAtVolumeDepth( waterProperties.capFogAtVolumeDepth );

	pWaterRenderNode->SetCaustics( waterProperties.caustics );
	pWaterRenderNode->SetCausticIntensity( waterProperties.causticIntensity );
	pWaterRenderNode->SetCausticTiling( waterProperties.causticTiling );
	pWaterRenderNode->SetCausticHeight( waterProperties.causticHeight );

	const Vec3* segmentVertices = pVertices;
	uint32 segmentVertexCount = vertexCount;

	Vec3 vertices[4];

	if(waterProperties.isRiver)
	{
		FillOutRiverSegment(segmentIndex, pVertices, vertexCount, &vertices[0]);

		segmentVertices = &vertices[0];
		segmentVertexCount = 4;
	}

	pWaterRenderNode->CreateArea( 0, &segmentVertices[0], segmentVertexCount, Vec2( waterProperties.uScale, waterProperties.vScale ), fogPlane, false );

	pWaterRenderNode->SetMaterial( GetEntity()->GetMaterial() );
	pWaterRenderNode->SetVolumeDepth( waterProperties.depth );
	pWaterRenderNode->SetStreamSpeed( waterProperties.streamSpeed );

	CreatePhysicsArea( segmentIndex, entityWorldTM, segmentVertices, segmentVertexCount, waterProperties.isRiver, waterProperties.streamSpeed );

	// NOTE:
	// Set the matrix after everything has been setup in local space
	UpdateRenderNode( pWaterRenderNode, entityWorldTM );
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:55,代码来源:GameVolume_Water.cpp

示例2: OnRayCastDataReceived

void CLaserBeam::OnRayCastDataReceived( const QueuedRayID& rayID, const RayCastResult& result )
{
	CRY_ASSERT(m_pLaserParams);
	CRY_ASSERT(rayID == m_queuedRayId);

	m_queuedRayId = 0;

	const float range = m_pLaserParams->laser_range[eIGS_ThirdPerson];
	float laserLength = range;

	Vec3 hitPos(0,0,0);
	bool hitSolid = false;

	if (result.hitCount > 0)
	{
		laserLength = result.hits[0].dist;
		hitPos = result.hits[0].pt;
		hitSolid = true;
	}
	else
	{
		hitPos = m_lastLaserUpdatePosition + (m_lastLaserUpdateDirection * range);
		laserLength = range + 0.1f;
	}

	const CCamera& camera = gEnv->pRenderer->GetCamera();

	// Hit near plane
	if (m_lastLaserUpdateDirection.Dot(camera.GetViewdir()) < 0.0f)
	{
		Plane nearPlane;
		nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
		nearPlane.d -= camera.GetNearPlane()+0.15f;
		Ray ray(m_lastLaserUpdatePosition, m_lastLaserUpdateDirection);
		Vec3 out;
		if (Intersect::Ray_Plane(ray, nearPlane, out))
		{
			float dist = Distance::Point_Point(m_lastLaserUpdatePosition, out);
			if (dist < laserLength)
			{
				laserLength = dist;
				hitPos = out;
				hitSolid = true;
			}
		}
	}

	m_hasHitData = true;
	m_lastHit = hitPos;
	m_hitSolid = hitSolid;


}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:53,代码来源:Laser.cpp

示例3: Update

void CExactPositioningTrigger::Update( float frameTime, Vec3 userPos, Quat userOrient, bool allowTriggering )
{
	if (m_state == eS_Invalid)
		return;

	CRY_ASSERT(m_pos.IsValid());
	CRY_ASSERT(m_userPos.IsValid());
	CRY_ASSERT(m_orient.IsValid());
	CRY_ASSERT(m_userOrient.IsValid());
	CRY_ASSERT(m_posSize.IsValid());
	CRY_ASSERT(NumberValid(m_cosOrientTolerance));

	CRY_ASSERT(NumberValid(frameTime));
	CRY_ASSERT(userPos.IsValid());
	CRY_ASSERT(userOrient.IsValid());

	m_userPos = userPos;
	m_userOrient = userOrient;

	if (m_state == eS_Initializing)
		m_state = eS_Before;

	Plane threshold;
	threshold.SetPlane( m_orient.GetColumn1(), m_pos );
	if (threshold.DistFromPlane(userPos) >= 0.0f)
	{
		if (m_sideTime < 0.0f)
			m_sideTime = 0.0f;
		else
			m_sideTime += frameTime;
	}
	else
	{
		if (m_sideTime > 0.0f)
			m_sideTime = 0.0f;
		else
			m_sideTime -= frameTime;
	}

	Vec3 curDir = userOrient.GetColumn1();
	Vec3 wantDir = m_orient.GetColumn1();

	if (m_state == eS_Before)
	{
		OBB triggerBox;
		triggerBox.SetOBB( Matrix33(m_orient), m_posSize+Vec3(0.5f,0.5f,0), ZERO );
		if (Overlap::Point_OBB(m_userPos, m_pos, triggerBox))
			m_state = eS_Optimizing;
	}

	if ((m_state == eS_Optimizing) && allowTriggering)
	{
#ifdef INCLUDE_EXACTPOS_DEBUGGING
		bool debug = (CAnimationGraphCVars::Get().m_debugExactPos != 0);
		CPersistantDebug* pPD = CCryAction::GetCryAction()->GetPersistantDebug();
#endif

		Vec3 bump(0.0f, 0.0f, 0.1f);

		Vec3 posDistanceError = m_userPos - m_pos;
		if ( posDistanceError.z > -1.0f && posDistanceError.z < 1.0f )
			posDistanceError.z = 0;

		Vec3 orientFwd = m_orient.GetColumn1(); orientFwd.z = 0.0f; orientFwd.Normalize();
		Vec3 rotAnimMovementWanted = orientFwd * m_animMovementLength;

		Vec3 userFwd = m_userOrient.GetColumn1(); userFwd.z = 0.0f; userFwd.Normalize();
		Vec3 rotAnimMovementUser = userFwd * m_animMovementLength;

		float cosRotError = orientFwd.Dot( userFwd );
		float rotError = CLAMP(m_cosOrientTolerance - cosRotError, 0.0f, 1.0f);
		//Vec3 rotDistanceError = rotAnimMovementUser - rotAnimMovementWanted;

		float fwdDistance = fabsf(orientFwd.Dot( posDistanceError ));
		float sideDistance = max( 0.0f, sqrtf( MAX(0,posDistanceError.GetLengthSquared2D() - sqr(fwdDistance)) ) - m_width );

		float deltaFwd = m_oldFwdDir < fwdDistance ? fwdDistance - m_oldFwdDir : 0.0f;
		m_oldFwdDir = fwdDistance;
		fwdDistance += deltaFwd * 0.5f;
		deltaFwd = max(0.1f, deltaFwd);

		f32 distanceError = sqrtf(sqr(fwdDistance) + sqr(sideDistance)); // posDistanceError.len() * m_distanceErrorFactor;
		f32 temp = 1.0f-sqr(1.0f-rotError*rotError);
		temp = max(temp,0.0f); //never do a sqrtf with a negative value 
		f32 orientError = sqrtf(temp) * m_animMovementLength; // rotDistanceError.len();
		f32 totalDistanceError = distanceError + orientError;
		if (((m_distanceError * 1.05f) < distanceError) && ((m_orientError * 1.05f) < orientError) && (totalDistanceError < deltaFwd) ||
			(totalDistanceError < deltaFwd*0.5f))
		{ // found local minimum in distance error, force triggering.
			m_state = eS_Triggered;
			m_oldFwdDir = 0.0f;

#ifdef INCLUDE_EXACTPOS_DEBUGGING
			if (debug)
			{
				pPD->Begin("AnimationTrigger LocalMinima Triggered", false);
				pPD->AddPlanarDisc(m_pos + bump, 0.0f, m_distanceError, ColorF(0,1,0,0.5), 10.0f);
			}
#endif
		}
//.........这里部分代码省略.........
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:101,代码来源:ExactPositioningTrigger.cpp

示例4: UpdateTPLaser


//.........这里部分代码省略.........
    if (m_allowUpdate)
    {
        m_allowUpdate = false;

        IPhysicalEntity* pSkipEntity = NULL;
        if(parent->GetOwner())
            pSkipEntity = parent->GetOwner()->GetPhysics();

        const float range = m_lamparams.laser_range[eIGS_ThirdPerson]*dsg1Scale;

        // Use the same flags as the AI system uses for visbility.
        const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living;
        const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);

        ray_hit hit;
        if (gEnv->pPhysicalWorld->RayWorldIntersection(lamPos, dir*range, objects, flags,
                &hit, 1, &pSkipEntity, pSkipEntity ? 1 : 0))
        {
            laserLength = hit.dist;
            m_lastLaserHitPt = hit.pt;
            m_lastLaserHitSolid = true;
        }
        else
        {
            m_lastLaserHitSolid = false;
            m_lastLaserHitPt = lamPos + dir * range;
            laserLength = range + 0.1f;
        }

        // Hit near plane
        if (dir.Dot(camera.GetViewdir()) < 0.0f)
        {
            Plane nearPlane;
            nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
            nearPlane.d -= camera.GetNearPlane()+0.15f;
            Ray ray(lamPos, dir);
            Vec3 out;
            m_lastLaserHitViewPlane = false;
            if (Intersect::Ray_Plane(ray, nearPlane, out))
            {
                float dist = Distance::Point_Point(lamPos, out);
                if (dist < laserLength)
                {
                    laserLength = dist;
                    m_lastLaserHitPt = out;
                    m_lastLaserHitSolid = true;
                    m_lastLaserHitViewPlane = true;
                }
            }
        }

        hitPos = m_lastLaserHitPt;
    }
    else
    {
        laserLength = Distance::Point_Point(m_lastLaserHitPt, lamPos);
        hitPos = lamPos + dir * laserLength;
    }

    if (m_smoothLaserLength < 0.0f)
        m_smoothLaserLength = laserLength;
    else
    {
        if (laserLength < m_smoothLaserLength)
            m_smoothLaserLength = laserLength;
        else
开发者ID:j30206868,项目名称:NetWars_cpp,代码行数:67,代码来源:Lam.cpp

示例5: UpdateTPLaser

//----------------------------------------------------
void CRocketLauncher::UpdateTPLaser(float frameTime)
{
	m_lastUpdate -= frameTime;

	bool allowUpdate = true;
	if(m_lastUpdate<=0.0f)
		m_lastUpdate = m_Timeout;
	else
		allowUpdate = false;

	const CCamera& camera = gEnv->pRenderer->GetCamera();

	//If character not visible, laser is not correctly updated
	if(CActor* pOwner = GetOwnerActor())
	{
		ICharacterInstance* pCharacter = pOwner->GetEntity()->GetCharacter(0);
		if(pCharacter && !pCharacter->IsCharacterVisible())
			return;
	}

	Vec3   offset(-0.06f,0.28f,0.115f); //To match scope position in TP LAW model
	Vec3   pos = GetEntity()->GetWorldTM().TransformPoint(offset);
	Vec3   dir = GetEntity()->GetWorldRotation().GetColumn1();

	Vec3 hitPos(0,0,0);
	float laserLength = 0.0f;

	if(allowUpdate)
	{
		IPhysicalEntity* pSkipEntity = NULL;
		if(GetOwner())
			pSkipEntity = GetOwner()->GetPhysics();

		const float range = m_LaserRangeTP;

		// Use the same flags as the AI system uses for visibility.
		const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living;
		const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);

		ray_hit hit;
		if (gEnv->pPhysicalWorld->RayWorldIntersection(pos, dir*range, objects, flags,
			&hit, 1, &pSkipEntity, pSkipEntity ? 1 : 0))
		{
			laserLength = hit.dist;
			m_lastLaserHitPt = hit.pt;
			m_lastLaserHitSolid = true;
		}
		else
		{
			m_lastLaserHitSolid = false;
			m_lastLaserHitPt = pos + dir * range;
			laserLength = range + 0.1f;
		}

		// Hit near plane
		if (dir.Dot(camera.GetViewdir()) < 0.0f)
		{
			Plane nearPlane;
			nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
			nearPlane.d -= camera.GetNearPlane()+0.15f;
			Ray ray(pos, dir);
			Vec3 out;
			m_lastLaserHitViewPlane = false;
			if (Intersect::Ray_Plane(ray, nearPlane, out))
			{
				float dist = Distance::Point_Point(pos, out);
				if (dist < laserLength)
				{
					laserLength = dist;
					m_lastLaserHitPt = out;
					m_lastLaserHitSolid = true;
					m_lastLaserHitViewPlane = true;
				}
			}
		}

		hitPos = m_lastLaserHitPt;
	}
	else
	{
		laserLength = Distance::Point_Point(m_lastLaserHitPt, pos);
		hitPos = pos + dir * laserLength;
	}

	if (m_smoothLaserLength < 0.0f)
		m_smoothLaserLength = laserLength;
	else
	{
		if (laserLength < m_smoothLaserLength)
			m_smoothLaserLength = laserLength;
		else
			m_smoothLaserLength += (laserLength - m_smoothLaserLength) * min(1.0f, 10.0f * frameTime);
	}

	const float assetLength = 2.0f;
	m_smoothLaserLength = CLAMP(m_smoothLaserLength,0.01f,m_LaserRangeTP);
	float scale = m_smoothLaserLength / assetLength; 

	// Scale the laser based on the distance.
//.........这里部分代码省略.........
开发者ID:nhnam,项目名称:Seasons,代码行数:101,代码来源:RocketLauncher.cpp


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