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


C++ Mat4f::transpose方法代码示例

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


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

示例1: Primitive

Cube::Cube(const Vec3f &pos, const Vec3f &scale, const Mat4f &rot,
        const std::string &name, std::shared_ptr<Bsdf> bsdf)
: Primitive(name),
  _rot(rot),
  _invRot(rot.transpose()),
  _pos(pos),
  _scale(scale*0.5f),
  _bsdf(std::move(bsdf))
{
    _transform = Mat4f::translate(_pos)*rot*Mat4f::scale(Vec3f(scale));
}
开发者ID:1510649869,项目名称:tungsten,代码行数:11,代码来源:Cube.cpp

示例2: applyViewingTransform

void Camera::applyViewingTransform() {
	if( mDirtyTransform )
		calculateViewingTransformParameters();

	ModelerDrawState *mds = ModelerDrawState::Instance();

	if(mds->m_rayFile)
	{
		fprintf( mds->m_rayFile, "camera {\n\tposition = (%f, %f, %f);\n\tlook_at = (%f, %f, %f);\n\taspectratio = 1\n\tfov = 30; }\n\n",
			mPosition[0], mPosition[1], mPosition[2],
			mLookAt[0], mLookAt[1], mLookAt[2]);

		
	}

	// Place the camera at mPosition, aim the camera at
	// mLookAt, and twist the camera such that mUpVector is up
    /*gluLookAt(	mPosition[0], mPosition[1], mPosition[2],
				mLookAt[0],   mLookAt[1],   mLookAt[2],
				mUpVector[0], mUpVector[1], mUpVector[2]);*/

    // You Will Have to implement this (gluLookAt() ) yourself!
	// what fun that will be!
    Vec3f n = mPosition - mLookAt;
    Vec3f v = mUpVector - ((mUpVector * n) / (n * n)) * n;
    Vec3f u = v ^ n;
    u.normalize();
    v.normalize();
    n.normalize();

    Mat4f mat;
    mat[0][0] = u[0]; mat[0][1] = v[0]; mat[0][2] = n[0];
    mat[1][0] = u[1]; mat[1][1] = v[1]; mat[1][2] = n[1];
    mat[2][0] = u[2]; mat[2][1] = v[2]; mat[2][2] = n[2];
    mat = mat.transpose();
    mat = mat * mat.createTranslation(-mPosition[0], -mPosition[1], -mPosition[2]);
    
    // Transpose the final matrix so that n is in column-major order to match OpenGL.
    mat = mat.transpose();
    glMultMatrixf(mat.n);
}
开发者ID:aerieworks,项目名称:csep_557_modeler,代码行数:41,代码来源:camera.cpp

示例3: test_a


//.........这里部分代码省略.........
	Console::write_line("   Function: translate_self() (int)");
	{
		Mat4i answer(test_a);

		Mat4i result = test_a;
		result = result * Mat4i::translate(2, 3, 4);

		Mat4i result2 = test_a;
		result2.translate_self(2,3,4);

		if (result != result2) fail();
	}

	Console::write_line("   Function: translate_self() (float)");
	{
		Mat4f answer(test_a);

		Mat4f result(test_a);
		result = result * Mat4f::translate(2, 3, 4);

		Mat4f result2(test_a);
		result2.translate_self(2, 3, 4);

		if (!result.is_equal(result2, 0.00001f))
			fail();
	}

	Console::write_line("   Function: scale_self()");
	{
		Mat4i answer(test_a);

		Mat4i result = test_a;
		result = result * Mat4i::scale(2, 3, 4);

		Mat4i result2 = test_a;
		result2.scale_self(2,3,4);

		if (result != result2) fail();

		Mat4f test = test_c;
		test.scale_self(2.0f, 3.0f, 4.0f);

		if (!test.is_equal(test_c_scaled, 0.00001f))
			fail();
	}

	Console::write_line("   Function: rotate (using euler angles)");
	{
		Mat4f mv = Mat4f::identity();
		mv = mv * Mat4f::rotate(Angle(30.0f, angle_degrees), 0.0f, 0.0f, 1.0f, false);
		mv = mv * Mat4f::rotate(Angle(10.0f, angle_degrees), 1.0f, 0.0f, 0.0f, false);
		mv = mv * Mat4f::rotate(Angle(20.0f, angle_degrees), 0.0f, 1.0f, 0.0f, false);

		Mat4f test_matrix;
		test_matrix = Mat4f::rotate(Angle(10.0f, angle_degrees), Angle(20.0f, angle_degrees), Angle(30.0f, angle_degrees), order_YXZ);
		if (!test_matrix.is_equal(mv, 0.00001f))
			fail();

	}

	Console::write_line("   Function: rotate (using euler angles) and get_euler");
	{
		test_rotate_and_get_euler(order_XYZ);
		test_rotate_and_get_euler(order_XZY);
		test_rotate_and_get_euler(order_YZX);
		test_rotate_and_get_euler(order_YXZ);
		test_rotate_and_get_euler(order_ZXY);
		test_rotate_and_get_euler(order_ZYX);
	}

	Console::write_line("   Function: transpose() (float)");
	{
		Mat4f original(test_a);

		Mat4f transposed_matrix;
	
		transposed_matrix[0] = original[0];
		transposed_matrix[1] = original[4];
		transposed_matrix[2] = original[8];
		transposed_matrix[3] = original[12];
		transposed_matrix[4] = original[1];
		transposed_matrix[5] = original[5];
		transposed_matrix[6] = original[9];
		transposed_matrix[7] = original[13];
		transposed_matrix[8] = original[2];
		transposed_matrix[9] = original[6];
		transposed_matrix[10] = original[10];
		transposed_matrix[11] = original[14];
		transposed_matrix[12] = original[3];
		transposed_matrix[13] = original[7];
		transposed_matrix[14] = original[11];
		transposed_matrix[15] = original[15];

		Mat4f test = original;
		test.transpose();

		if (!test.is_equal(transposed_matrix, 0.00001f))
			fail();
	}
}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:101,代码来源:test_matrix.cpp


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