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


C++ Matrix4x4f类代码示例

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


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

示例1:

	void Matrix4x4f::rotateDegrees(const float &angleDegrees, const Vector3f &axis)
	{
		float angleRadians = angleDegrees * DEG_TO_RAD;
		Matrix4x4f newMatrix;
		newMatrix.setAsRotationMatrix(angleRadians, axis);
		(*this) = newMatrix * (*this);
	}
开发者ID:Maligothez,项目名称:OpenGL-in-Virtual-Studio,代码行数:7,代码来源:Matrix4x4f.cpp

示例2: renderFrameItpWithVertexArrays

void
Md3Model::draw () const
{
  Matrix4x4f m;

  // Draw the model
  renderFrameItpWithVertexArrays (_currFrame, _nextFrame, _interp);

  // Draw models linked to this one
  for (int i = 0; i < _header.num_tags; ++i)
    {
      if (!_links[i])
	continue;

      const Quaternionf &qA = _qtags[_currFrame * _header.num_tags + i]->orient;
      const Quaternionf &qB = _qtags[_nextFrame * _header.num_tags + i]->orient;

      m.fromQuaternion (Slerp (qA, qB, _interp));

      const Vector3f &currPos = _qtags[_currFrame * _header.num_tags + i]->origin;
      const Vector3f &nextPos = _qtags[_nextFrame * _header.num_tags + i]->origin;

      m.setTranslation ((currPos + _interp * (nextPos - currPos)) * _scale);

      glPushMatrix ();
	glMultMatrixf (m);
	_links[i]->draw ();
      glPopMatrix ();
    }
}
开发者ID:shammellee,项目名称:moon9,代码行数:30,代码来源:Md3Model.cpp

示例3: GetDimensions

Matrix4x4f BoneBridgeCAL3D::CalculateBoneSpaceTransform() const
{
   Matrix4x4f boneSpaceTransform = Matrix4x4f::Identity();

   // set up bone space geometry transform
   {
      // transform forward by half the box length
      const Vec3f& dimensions = GetDimensions();
      boneSpaceTransform.SetTranslation(Vec3f(dimensions[Y] / 2.0f, 0.0f, 0.0f));

      // set rotational offset (the inversion of the core bone absolute rotation)
      {
         CalCoreBone* coreBone = mpCalBone->getCoreBone();

         CalQuaternion calRotAbsolute = coreBone->getRotationAbsolute();
         calRotAbsolute.invert();

         Quaternionf kernelRot = ConvertCAL3DtoKernel(calRotAbsolute);

         boneSpaceTransform.SetRotate(kernelRot);
      }
   }

   return boneSpaceTransform;
}
开发者ID:Danathus,项目名称:react3d,代码行数:25,代码来源:BoneBridgeCAL3D.cpp

示例4:

Matrix4x4f BoneBridgeCAL3D::GetModelSpaceTransform() const
{
   Matrix4x4f matrix = Matrix4x4f::Identity();

   // update model space position
   {
      Vec3f kernelPosVec;

      const CalVector& calPosVec = mpCalBone->getTranslationAbsolute();
      for (int i = 0; i < 3; ++i)
      {
         kernelPosVec[i] = calPosVec[i];
      }

      matrix.SetTranslation(kernelPosVec);
   }

   // update model space orientation
   {
      Quaternionf kernelRotQuat;

      const CalQuaternion& calRotQuat = mpCalBone->getRotationAbsolute();
      kernelRotQuat = ConvertCAL3DtoKernel(calRotQuat);

      matrix.SetRotate(kernelRotQuat);
   }

   return matrix;
}
开发者ID:Danathus,项目名称:react3d,代码行数:29,代码来源:BoneBridgeCAL3D.cpp

示例5: get

Matrix4x4f Matrix4x4f::transpose() const {
	Matrix4x4f transpose;

	for (int i = 0; i < 4; i++)
	for (int j = 0; j < 4; j++)
		transpose.set(j, i, get(i, j));

	return transpose;
}
开发者ID:asmith26,项目名称:PGE,代码行数:9,代码来源:Matrix4x4f.cpp

示例6: SetYaw

void Camera::SetYaw(float y)
{ 
	yaw = y;
	Matrix4x4f Rx = Matrix4x4f::RotationX(pitch);
	Matrix4x4f Ry = Matrix4x4f::RotationY(yaw);
	Matrix4x4f R = Ry * Rx;
	forward = R.TransformVector(Vector3f(0, 0, -1));
	right = R.TransformVector(Vector3f(1, 0, 0));
	up = R.TransformVector(Vector3f(0, 1, 0));
}
开发者ID:robert-porter,项目名称:3DAnimation,代码行数:10,代码来源:Camera.cpp

示例7:

Matrix4x4f Matrix4x4f::scaleMatrix(const Vec3f &scale) {
	Matrix4x4f scaleMatrix;

	scaleMatrix.setIdentity();

	scaleMatrix.set(0, 0, scale.x);
	scaleMatrix.set(1, 1, scale.y);
	scaleMatrix.set(2, 2, scale.z);

	return scaleMatrix;
}
开发者ID:asmith26,项目名称:PGE,代码行数:11,代码来源:Matrix4x4f.cpp

示例8: textureProjection

void textureProjection(Matrix4x4f &mv) {

	Matrix4x4f inverseMV = Matrix4x4f::invertMatrix(mv);
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glTranslatef(0.5f,0.5f,0.0f); //Bias
	glScalef(0.5f,0.5f,1.0f);		//Scale
	glFrustum(-0.035,0.035,-0.035,0.035,0.1,1.9); //MV for light map
	glTranslatef(0.0f,0.0f,-1.0f);
	glMultMatrixf(inverseMV.getMatrix());	//Inverse ModelView
	glMatrixMode(GL_MODELVIEW);
}
开发者ID:rodrigoalvarez,项目名称:camarasheterogeneas,代码行数:12,代码来源:COLOR_CUBE.cpp

示例9: randomInit

	void CastorUtilsMatrixTest::MatrixInversionComparison()
	{
		for ( int i = 0; i < 10; ++i )
		{
			Matrix4x4f mtx;
			glm::mat4 glm;
			randomInit( mtx.ptr(), &glm[0][0], 16 );
			CT_EQUAL( mtx, glm );
			Matrix4x4f mtxInv( mtx.getInverse() );
			glm::mat4 glmInv( glm::inverse( glm ) );
			CT_EQUAL( mtxInv, glmInv );
		}
	}
开发者ID:DragonJoker,项目名称:Castor3D,代码行数:13,代码来源:CastorUtilsMatrixTest.cpp

示例10: textureProjection

void textureProjection(Matrix4x4f &mv) {

    Matrix4x4f inverseMV = Matrix4x4f::invertMatrix(mv);
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(0.5f,0.5f,0.0f);
    float wImg = textureImage[textureIndex-1].Width;
    float hImg = textureImage[textureIndex-1].Height;
    if (wImg < hImg) {
        glScalef(1.0f,(1.f*wImg)/hImg,1.0f);
    } else {
        glScalef((1.f*hImg)/wImg,1.0f,1.0f);
    }
    glFrustum(-0.035,0.035,-0.035,0.035,0.02,2.0);
    glMultMatrixf(inverseMV.getMatrix());
    glMatrixMode(GL_MODELVIEW);
}
开发者ID:rodrigoalvarez,项目名称:camarasheterogeneas,代码行数:17,代码来源:mainImage.cpp

示例11: MVP

 MVP(const Matrix4x4f &modelMatrix, const Matrix4x4f &viewMatrix, const Matrix4x4f &projectionMatrix)
 {
     this->modelMatrix = modelMatrix;
     this->viewMatrix = viewMatrix;
     this->projectionMatrix = projectionMatrix;
     modelViewMatrix = viewMatrix * modelMatrix;
     modelViewMatrixForNormal = modelViewMatrix.inverse().transpose();
     modelViewProjMatrix = projectionMatrix * modelViewMatrix;
 }
开发者ID:cntoplolicon,项目名称:grape,代码行数:9,代码来源:shadow_volume.cpp

示例12: renderDirectionalLightPass

void renderDirectionalLightPass()
{
    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
    glCullFace(GL_FRONT);
    glUseProgram(directionalLightPass.program);

    Matrix4x4f identity = Matrix4x4f::identity();
    glUniformMatrix4fv(directionalLightPass.modelMatrix, 1, GL_FALSE, identity.const_value_ptr());
    glUniformMatrix4fv(directionalLightPass.viewMatrix, 1, GL_FALSE, identity.const_value_ptr());
    glUniformMatrix4fv(directionalLightPass.projectionMatrix, 1, GL_FALSE, identity.const_value_ptr());

    directionalLightPass.bindUniforms();
    directionalLightPass.directionalLight.setDirectionalLight(directionalLight);

    pQuadMesh->Render();

    glUseProgram(0);
}
开发者ID:cntoplolicon,项目名称:grape,代码行数:19,代码来源:deferred_shading.cpp

示例13: textureProjection

void textureProjection(Matrix4x4f &mv) {

	Matrix4x4f inverseMV = Matrix4x4f::invertMatrix(mv);
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glTranslatef(0.5f,0.5f,0.0f);//Bias

    float wImg = textureW[textureIndex-1];
    float hImg = textureH[textureIndex-1];
	if (wImg < hImg) {
        glScalef(1.0f,(1.f*wImg)/hImg,1.0f);//Scale
	} else {
        glScalef((1.f*hImg)/wImg,1.0f,1.0f);//Scale
	}

	glFrustum(-0.035,0.035,-0.035,0.035,0.02,2.0);//MV for light map
	//glTranslatef(0.0f,0.0f,-1.0f);
	glMultMatrixf(inverseMV.getMatrix());//Inverse ModelView
	glMatrixMode(GL_MODELVIEW);
}
开发者ID:rodrigoalvarez,项目名称:camarasheterogeneas,代码行数:20,代码来源:main.cpp

示例14: if

void Camera::LookUp(float angle)
{
	if(pitch - angle > PI/2.0f - 0.1)
	{
		pitch = PI/2.0f - 0.1;
	}
	else if(pitch - angle < -PI/2.0f)
	{
		pitch = -PI/2.0f + 0.1;
	}
	else
		pitch -= angle;

	Matrix4x4f Rx = Matrix4x4f::RotationX(pitch);
	Matrix4x4f Ry = Matrix4x4f::RotationY(yaw);
	Matrix4x4f R = Ry * Rx;
	forward = R.TransformVector(Vector3f(0, 0, -1));
	right = R.TransformVector(Vector3f(1, 0, 0));
	up = R.TransformVector(Vector3f(0, 1, 0));
}
开发者ID:robert-porter,项目名称:3DAnimation,代码行数:20,代码来源:Camera.cpp

示例15: renderLightVolume

void renderLightVolume(const MVPPipeline &program, const PointLight &light)
{
    Matrix4x4f modelMatrix = Matrix4x4f::identity();
    modelMatrix = modelMatrix.translate(light.position);
    float scale = calcPointLightScale(light);
    modelMatrix = modelMatrix.scale({scale, scale, scale});
    glUniformMatrix4fv(program.modelMatrix, 1, GL_FALSE, modelMatrix.const_value_ptr());

    Matrix4x4f viewMatrix = camera.getMatrix();
    glUniformMatrix4fv(program.viewMatrix, 1, GL_FALSE, viewMatrix.const_value_ptr());

    Matrix4x4f projectionMatrix = Matrix4x4f::perspective(60.0f, WINDOW_WIDTH * 1.0f / WINDOW_HEIGHT, 1.0f, 100.0f);
    glUniformMatrix4fv(program.projectionMatrix, 1, GL_FALSE, projectionMatrix.const_value_ptr());

    pSphereMesh->Render();
}
开发者ID:cntoplolicon,项目名称:grape,代码行数:16,代码来源:deferred_shading.cpp


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