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


C++ BoundingBox::SetMin方法代码示例

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


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

示例1: SetCameraFocus

void ModelBrowserTool::SetCameraFocus()
{
	BoundingBox boundingBox = mModel->GetBoundingBox();
    Vector3f boxCenter = boundingBox.GetCenter();
	
	// Cubify the bounding box.
	BoundingBox boundingCube = boundingBox;
	Float maxValue = Maths::Max(boundingCube.Max().x, Maths::Max(boundingCube.Max().y, boundingCube.Max().z));
	Float minValue = Maths::Min(boundingCube.Min().x, Maths::Min(boundingCube.Min().y, boundingCube.Min().z));
	boundingCube.SetMax( Vector3f(maxValue, maxValue, maxValue) );
    boundingCube.SetMin( Vector3f(minValue, minValue, minValue) );
	
	// Recenter
	Vector3f cubeCenter = boundingCube.GetCenter();
	Vector3f offset = cubeCenter - boxCenter;
	cubeCenter -= offset;
	boundingCube(0) -= offset;
	boundingCube(1) -= offset;

	Float fovAngle = Maths::ToRadians(mCamera.GetFovAngle());
	Float halfFov = fovAngle / 2.0f;
	Float sin = Maths::Sin(halfFov);
	Float cos = Maths::Cos(halfFov);

	// Compute the camera position and viewing position.
	Float halfPos = cubeCenter.y - boundingCube.Min().y;
	Float zPos = boundingBox.Max().z + (cos * halfPos / sin);

	mCamera.SetPosition(Vector3f(boxCenter.x, boxCenter.y, zPos));
	mObjectCenter = Vector3f(boxCenter.x, boxCenter.y, boxCenter.z);
}
开发者ID:SebastienLussier,项目名称:Gamedesk,代码行数:31,代码来源:ModelBrowserTool.cpp

示例2: Render


//.........这里部分代码省略.........
    Vector3f vBottomRight = light.mPosition + ( vRight - vUp).Normalize() * 2;
    Vector3f vTopRight    = light.mPosition + ( vRight + vUp).Normalize() * 2;
    Vector3f vTopLeft     = light.mPosition + (-vRight + vUp).Normalize() * 2;

    /*renderer->SetRenderState( Renderer::DepthMask, false );
    renderer->SetRenderState( Renderer::Lighting, false );
    renderer->SetRenderState( Renderer::Blend, true );
    renderer->SetBlendFunc( Renderer::BlendSrcAlpha, Renderer::BlendOne );*/
    renderer->SetRenderState( Renderer::Lighting, false );
    renderer->DrawQuad( vBottomLeft, vBottomRight, vTopRight, vTopLeft, false );
    renderer->SetRenderState( Renderer::Lighting, true );
#endif


    renderer->SetAmbiantColor( Color4f(1.0f, 1.0f, 1.0f, 1.0f) );

      /*Light lightPoint;
    lightPoint.mPosition = currentCamera->GetPosition();
    lightPoint.mAmbient  = Color4f(0.00f,0.00f, 0.00f,1.0f);
    lightPoint.mDiffuse  = Color4f(1.0f,1.0f, 1.0f,1.0f);
    lightPoint.mSpecular = Color4f(1.0f,1.0f, 1.0f,1.0f);
    lightPoint.mType = Renderer::LightPoint;
    lightPoint.mAttenuationConstant  = 0;
    lightPoint.mAttenuationLinear    = 0;
    lightPoint.mAttenuationQuadratic = 0.01f;
    renderer->SetRenderState( Renderer::Light_i, true, 0 );
    renderer->SetLight( 0, lightPoint );*/

	// Get the frustum.
	Matrix4f modelViewMatrix;
    Matrix4f projectionMatrix;
    Frustum  frustum;

	renderer->GetModelViewMatrix(modelViewMatrix);
	renderer->GetProjectionMatrix(projectionMatrix);
	frustum.CalculateFrustum(projectionMatrix, modelViewMatrix);

	mNbRenderedEntities = 0;

    // Render the objects in the world.
    /*
    List<Entity*> visibleEntities;
	mSpacePartition->Query(frustum, visibleEntities);
    */
    List<Entity*>::const_iterator itEntity;
    for( itEntity = mEntities.begin(); itEntity != mEntities.end(); ++itEntity )
    {
        if( *itEntity != currentCamera )
        {
			// Do frustum culling.
			if((*itEntity)->GetClass() != Terrain::StaticClass() &&
               (*itEntity)->GetClass() != SkyDome::StaticClass())
			{
				BoundingBox boundingBox = (*itEntity)->GetBoundingBox();

                if( (*itEntity)->GetClass() != ParticleEmitter::StaticClass() )
                {
                    Matrix4f translation = Matrix4f::Translation((*itEntity)->GetPosition());
				    Matrix4f rotation;
				    (*itEntity)->GetOrientation().ToMatrix(rotation);

				    Matrix4f trsMatrix = rotation * translation;
				    boundingBox.SetMin( boundingBox.Min() * trsMatrix );
				    boundingBox.SetMax( boundingBox.Max() * trsMatrix );
                }

				if( frustum.BoxInFrustum(boundingBox) )
				{
					mNbRenderedEntities++;
				}
				else
				{
					continue;
				}
			}

            renderer->PushMatrix();

            if( String((*itEntity)->GetClass()->GetName()) == "SkyDome" )
                renderer->Translate(currentCamera->GetPosition()-Vector3f(0,100,0) );
            else
                renderer->Translate((*itEntity)->GetPosition());

            renderer->Rotate((*itEntity)->GetOrientation());

            if( (*itEntity)->IsSelected() )
                (*itEntity)->RenderSelected();

            (*itEntity)->Render();

            renderer->PopMatrix();
        }
    }

    renderer->SetMatrixMode(Renderer::ModelViewMatrix);
    renderer->LoadIdentity();
    currentCamera->ApplyViewMatrix();

    //renderer->EndScene();
}
开发者ID:SebastienLussier,项目名称:Gamedesk,代码行数:101,代码来源:World.cpp


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