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


C++ Matrix4x4类代码示例

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


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

示例1: NormalizePRSMatrix

void IceMaths::NormalizePRSMatrix(Matrix4x4& dest, Point& scale, const Matrix4x4& src)
{
	Point row;
	dest = src;
	for( int i=0;i<3;i++)
	{
		src.GetRow(i,row);

		// computes scales

		scale[i] = row.Magnitude();

		row /= scale[i];

		dest.SetRow(i,row);
	}
}
开发者ID:Arsakes,项目名称:ember,代码行数:17,代码来源:IceMatrix4x4.cpp

示例2: ProcessScaleHelper

/* Helper function to set up a scale matrix. */
static void
ProcessScaleHelper(Matrix4x4& aMatrix,
                   float aXScale, 
                   float aYScale, 
                   float aZScale)
{
  aMatrix.PreScale(aXScale, aYScale, aZScale);
}
开发者ID:MekliCZ,项目名称:positron,代码行数:9,代码来源:nsStyleTransformMatrix.cpp

示例3: BuildViewMatrix

Matrix4x4 RenderManager::BuildViewMatrix()
{
	Matrix4x4 view;
	if (viewMatrixMade == false) {
		Vector4 position = activeCamera->GetParent()->GetPosition();
		Vector4 upVector = activeCamera->GetParent()->GetLocalY();
		Vector4 lookAt = position + activeCamera->GetParent()->GetLocalZ();

		view.LookAt(position, lookAt, upVector);
		ConvertToOpenGLMatrix(view, viewMatrix);
		viewMat = view;
		viewMatrixMade = true;
	} else {
		view = viewMat;
	}
	return view;
}
开发者ID:Steelbadger,项目名称:OpenGLThreading,代码行数:17,代码来源:renderer.cpp

示例4: Perspective

Matrix4x4 Perspective( float fov, float aspectRatio, float fNear, float fFar )
{
	Matrix4x4 result;
	
	float yScale = ( 1 / tan( fov / 2 ) );		// cot( fov / 2 )
	float xScale = yScale / aspectRatio;
	
	result.Identity();
	result.m[0][0] = xScale;
	result.m[1][1] = yScale;
	result.m[2][2] = fFar / ( fFar - fNear );
	result.m[2][3] = ( -fNear * fFar) / ( fFar - fNear );
	result.m[3][2] = 1;
	result.m[3][3] = 0;

	return result;
}
开发者ID:FOBBEH,项目名称:Rendering-Demo,代码行数:17,代码来源:maths.cpp

示例5:

 Matrix4x4 Matrix4x4::Orthographic(float left, float right, float bottom, float top, float near, float far)
 {
     //http://www.songho.ca/opengl/gl_projectionmatrix.html
     Matrix4x4 matrix = Matrix4x4::identity;
     
     //Scale components
     matrix.RowCol(0, 0) = 2 / (right - left);
     matrix.RowCol(1, 1) = 2 / (top - bottom);
     matrix.RowCol(2, 2) = -2 / (far - near);
     
     //Translate components
     matrix.RowCol(0, 3) = -(right + left) / (right - left);
     matrix.RowCol(1, 3) = -(top + bottom) / (top - bottom);
     matrix.RowCol(2, 3) = -(far + near) / (far - near);
     
     return matrix;
 }
开发者ID:ncarnahan,项目名称:Canti,代码行数:17,代码来源:Matrix4x4.cpp

示例6: shadowMatrix

void MainWindow::setShaderConstants( SceneObject& obj,
                                     ShaderProgram& shader ) {
  uboMaterial.shadowMatrix = shadowMatrix();

  Matrix4x4 view = scene.camera().view();
  view.mul( obj.transform()  );

  Matrix4x4 mvp = scene.camera().projective();
  mvp.mul( view );

  uboMaterial.modelView  = view;
  uboMaterial.mvpMatrix  = mvp;
  uboMaterial.projMatrix = mvp;
  uboMaterial.diffuse    = obj.material().diffuse;
  uboMaterial.matColor   = obj.material().color;
  shader.setUniform(uboMaterial,umaterial,0);
  }
开发者ID:Try,项目名称:Tempest,代码行数:17,代码来源:mainwindow.cpp

示例7: ortho

Matrix4x4 matc::ortho(float left, float right, float bottom, float top, float nearVal, float farVal)
{
  float r_l = 1/(right-left);
  float t_b = 1/(top-bottom);
  float f_n = 1/(farVal-nearVal);

  Matrix4x4 res;
  res.set(0,0, 2*r_l);
  res.set(1,1, 2*t_b);
  res.set(2,2, (-2)*f_n);
  
  res.set(3,0, -(right+left)*r_l);
  res.set(3,1, -(top+bottom)*t_b);
  res.set(3,2, -(farVal+nearVal)*f_n);

  return res;
}
开发者ID:eulcey,项目名称:Wumpus-OGL,代码行数:17,代码来源:MathCore.cpp

示例8:

Vec4 Matrix4x4::transform_normal_ray(Matrix4x4 t,Vec4 p)
{
    Matrix4x4 scale,rot;

    scale.setMatrix4x4(t.scale_m);
    rot.setMatrix4x4(t.rotate_m);
    scale.matrix[0] = 1.0/scale.matrix[0];
    scale.matrix[5] = 1.0/scale.matrix[5];
    scale.matrix[10] = 1.0/scale.matrix[10];

    Matrix4x4 result;
    result = result.multMatrix(rot,scale);
    Vec4 out = scale.transpose().vector(p);
    out = rot.transpose().vector(out);
//    out = inv_scale.transpose().vector(out);
    return out;
}
开发者ID:danilob,项目名称:Raytracing,代码行数:17,代码来源:matrix4x4.cpp

示例9:

Matrix4x4::Matrix4x4( const Matrix4x4& m )
{
    this->ID = m.ID + " copy";
    this->Data = new float[ m.Dimensions * m.Dimensions ];
    for ( int x = 0; x < this->Dimensions; x++ )
        for ( int y = 0; y < this->Dimensions; y++ )
            this->SetValue( x, y, m.GetValue( x, y ) );
}
开发者ID:Wolf-Code,项目名称:CPP-Practice,代码行数:8,代码来源:Matrix4x4.cpp

示例10: acos

void Item::UpdateItemParticleEffects(float dt)
{
	if(m_erase)
	{
		return;
	}

	if(m_pVoxelItem != NULL)
	{
		for(int i = 0; i < m_pVoxelItem->GetNumParticleEffects(); i++)
		{
			unsigned int particleEffectId;
			vec3 ParticleEffectPos;
			string effectName;
			bool connectedToSegment;
			m_pVoxelItem->GetParticleEffectParams(i, &particleEffectId, &ParticleEffectPos, &effectName, &connectedToSegment);

			if(particleEffectId == -1)
			{
				m_pBlockParticleManager->ImportParticleEffect(effectName, ParticleEffectPos, &particleEffectId);
				m_pVoxelItem->SetParticleEffectId(i, particleEffectId);
			}

			if(connectedToSegment == false)
			{
				ParticleEffectPos *= m_renderScale;

				// Rotate due to characters forward vector
				float rotationAngle = acos(dot(vec3(0.0f, 0.0f, 1.0f), m_forward));
				if(m_forward.x < 0.0f)
				{
					rotationAngle = -rotationAngle;
				}
				Matrix4x4 rotationMatrix;
				rotationMatrix.SetRotation(0.0f, rotationAngle, 0.0f);
				ParticleEffectPos = rotationMatrix * ParticleEffectPos;

				// Translate to position
				ParticleEffectPos += m_position;
			}

			m_pBlockParticleManager->UpdateParticleEffectPosition(particleEffectId, ParticleEffectPos, ParticleEffectPos);
		}
	}
}
开发者ID:AlwaysGeeky,项目名称:Vox,代码行数:45,代码来源:Item.cpp

示例11: cos

void Matrix4x4::EulerRotation(const Vertex &rot)
{
	float radiansX = rot._x * (float(PI)/float(180));
	float radiansY = rot._y * (float(PI)/float(180));
	float radiansZ = rot._z * (float(PI)/float(180));

	Matrix4x4 matRotateX;
	matRotateX.SetMatrix(1.0f, 0.0f,         0.0f,
						0.0f, cos(radiansX), sin(radiansX),
						0.0f, -sin(radiansX),cos(radiansX));

	Matrix4x4 matRotateY; 
	matRotateY.SetMatrix(cos(radiansY), 0.0f, -sin(radiansY),
						0.0f,         1.0f, 0.0f,
						sin(radiansY), 0,    cos(radiansY));
	
	Matrix4x4 matRotateZ; 
	matRotateZ.SetMatrix(cos(radiansZ),  sin(radiansZ), 0.0f,
						-sin(radiansZ), cos(radiansZ), 0.0f,
						0.0f,          0.0f,         1.0f);

	matRotateZ.Transformation(matRotateX);
	matRotateZ.Transformation(matRotateY);

	Transformation(matRotateZ);
}
开发者ID:NickBMarine,项目名称:NicksPix,代码行数:26,代码来源:Matrix4x4.cpp

示例12: GetTransform

/**
*  @brief
*    Returns the 8 camera frustum vertices
*/
const Array<Vector3> &SNCamera::GetFrustumVertices(const Rectangle &cViewport)
{
	// Get the viewport width and height
	const uint32 nViewportWidth  = static_cast<uint32>(cViewport.GetWidth());
	const uint32 nViewportHeight = static_cast<uint32>(cViewport.GetHeight());

	// Calculate frustum vertices if required
	if ((m_nInternalCameraFlags & RecalculateFrustumVertices) ||
		m_nViewportWidth != nViewportWidth || m_nViewportHeight != nViewportHeight) {
		// Ensure that the other camera properties which depend on the viewport dimension are also updated correctly
		// -> This may lead to a "double" (in sense of "we could probably avoid one when doing more complex tests") calculation, but this in here is just an optimization and should never result in invalid settings
		m_nInternalCameraFlags |= RecalculateProjectionMatrix;
		m_nInternalCameraFlags |= RecalculateFrustum;

		// Backup the viewport dimension
		m_nViewportWidth  = nViewportWidth;
		m_nViewportHeight = nViewportHeight;

		// Set unit box
		m_cFrustumVertices.Resize(8);
		m_cFrustumVertices[0].SetXYZ(-1.0f, -1.0f, -1.0f);
		m_cFrustumVertices[1].SetXYZ(-1.0f,  1.0f, -1.0f);
		m_cFrustumVertices[2].SetXYZ( 1.0f,  1.0f, -1.0f);
		m_cFrustumVertices[3].SetXYZ( 1.0f, -1.0f, -1.0f);
		m_cFrustumVertices[4].SetXYZ(-1.0f, -1.0f,  1.0f);
		m_cFrustumVertices[5].SetXYZ(-1.0f,  1.0f,  1.0f);
		m_cFrustumVertices[6].SetXYZ( 1.0f,  1.0f,  1.0f);
		m_cFrustumVertices[7].SetXYZ( 1.0f, -1.0f,  1.0f);

		// Get world transform matrix with no scale
		Matrix4x4 mWorld;
		mWorld.FromQuatTrans(CalculateViewRotation(), GetTransform().GetPosition());
		mWorld *= GetProjectionMatrix(cViewport).GetInverted();

		// Project the vertices
		for (uint8 i=0; i<m_cFrustumVertices.GetNumOfElements(); i++)
			m_cFrustumVertices[i] *= mWorld;

		// Recalculation done
		m_nInternalCameraFlags &= ~RecalculateFrustumVertices;
	}

	// Return the frustum vertices
	return m_cFrustumVertices;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:49,代码来源:SNCamera.cpp

示例13: NativeRender

void NativeRender(GraphicsContext *graphicsContext) {
	g_GameManager.Update();

	float xres = dp_xres;
	float yres = dp_yres;

	// Apply the UIContext bounds as a 2D transformation matrix.
	Matrix4x4 ortho;
	if (GetGPUBackend() == GPUBackend::DIRECT3D9) {
		ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
		Matrix4x4 translation;
		translation.setTranslation(Vec3(-0.5f, -0.5f, 0.0f));
		ortho = translation * ortho;
	} else {
		ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
	}

	ui_draw2d.SetDrawMatrix(ortho);
	ui_draw2d_front.SetDrawMatrix(ortho);

	screenManager->render();
	if (screenManager->getUIContext()->Text()) {
		screenManager->getUIContext()->Text()->OncePerFrame();
	}

	DrawDownloadsOverlay(*screenManager->getUIContext());

	if (g_TakeScreenshot) {
		TakeScreenshot();
	}

	if (resized) {
		resized = false;

		graphicsContext->Resize();
		// TODO: Move this to new GraphicsContext objects for each backend.
#ifndef _WIN32
		if (GetGPUBackend() == GPUBackend::OPENGL) {
			PSP_CoreParameter().pixelWidth = pixel_xres;
			PSP_CoreParameter().pixelHeight = pixel_yres;
			NativeMessageReceived("gpu resized", "");
		}
#endif
	}
}
开发者ID:FreemanOpenTechnologiesLtd,项目名称:ppsspp,代码行数:45,代码来源:NativeApp.cpp

示例14: res

Matrix4x4 matc::translate(const Matrix4x4 &m, const Vector3 &v)
{
  matc::Matrix4x4 res(m);
  const float* p = m.asArray();
  res.set(MAT_DIM-1, 0, p[MAT_DIM * (MAT_DIM-1) + 0] + v.x);
  res.set(MAT_DIM-1, 1, p[MAT_DIM * (MAT_DIM-1) + 1] + v.y);
  res.set(MAT_DIM-1, 2, p[MAT_DIM * (MAT_DIM-1) + 2] + v.z);
  return res;
}
开发者ID:eulcey,项目名称:Wumpus-OGL,代码行数:9,代码来源:MathCore.cpp

示例15: Detransform

		void Ray::Detransform( const Matrix4x4 &p_Matrix )
		{
			Matrix4x4 Tmp;
			Tmp.Copy( p_Matrix );

			// Take the negated translation from the matrix
			m_Origin[ 0 ] -= p_Matrix( 0, 3 );
			m_Origin[ 1 ] -= p_Matrix( 1, 3 );
			m_Origin[ 2 ] -= p_Matrix( 2, 3 );

			// Get rid of the translation in the matrix
			Tmp( 0, 3 ) = Tmp( 1, 3 ) = Tmp( 2, 3 ) = 0.0f;

			// Invert the matrix
			Tmp.AffineInverse( );

/*UNCOMMENT!			m_Direction = m_Origin * Tmp;*/
		}
开发者ID:FashGek,项目名称:ZED,代码行数:18,代码来源:Ray.cpp


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