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


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

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


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

示例1: rotation_base

void rotation_base(float h) {
	setDiffuseColor( 0.85, 0.75, 0.25 );
	setAmbientColor( 0.95, 0.75, 0.25 );
	glPushMatrix();
		glPushMatrix();
			glScalef(4.0, h, 4.0);
			y_box(1.0f); // the rotation base
		glPopMatrix();
		setDiffuseColor( 0.15, 0.15, 0.65 );
		setAmbientColor( 0.15, 0.15, 0.65 );
		glPushMatrix();
			glTranslatef(-0.5, h, -0.6);
			glScalef(2.0, h, 1.6);
			y_box(1.0f); // the console
		glPopMatrix();
		setDiffuseColor( 0.65, 0.65, 0.65 );
		setAmbientColor( 0.65, 0.65, 0.65 );
		glPushMatrix();
			glTranslatef( 0.5, h, 0.6 );
			glRotatef( -90.0, 1.0, 0.0, 0.0 );
			Mat4f mvMatrix = glGetMatrix(GL_MODELVIEW_MATRIX);
			Mat4f matCamInverse = mvMatrix.inverse();
			Vec4f chimEmitPos = matCamInverse * mvMatrix * Vec4f(0.5, 2.5 * h, 0.6, 1.0);
			if (ps != NULL)
			{
				Vec3f chimPos = Vec3f(chimEmitPos[0], chimEmitPos[1], chimEmitPos[2]);
				ps->setEmitterPosition(chimPos, 0);
			}
			drawCylinder( h, 0.05, 0.05 ); // the pipe
		glPopMatrix();
	glPopMatrix();
}
开发者ID:kaivanwadia,项目名称:animator,代码行数:32,代码来源:robotarm.cpp

示例2: setProjectionMatrix

			void setProjectionMatrix(const Mat4f &projmat)
			{
				this->projmat = projmat;
				Mat4f projmatinv = projmat.inverse();
				// Corners of the frustum in world space
				corners[0] = projmatinv.transformPoint(Vec3f(-1, 1, -1));
				corners[1] = projmatinv.transformPoint(Vec3f(1, 1, -1));
				corners[2] = projmatinv.transformPoint(Vec3f(1, -1, -1));
				corners[3] = projmatinv.transformPoint(Vec3f(-1, -1, -1));
				corners[4] = projmatinv.transformPoint(Vec3f(-1, 1, 1));
				corners[5] = projmatinv.transformPoint(Vec3f(1, 1, 1));
				corners[6] = projmatinv.transformPoint(Vec3f(1, -1, 1));
				corners[7] = projmatinv.transformPoint(Vec3f(-1, -1, 1));
				// Near plane
				planes[0] = Plane(corners[0], corners[1], corners[2]);
				// Left plane
				planes[1] = Plane(corners[0], corners[3], corners[4]);
				// Top plane
				planes[2] = Plane(corners[0], corners[1], corners[4]);
				// Right plane
				planes[3] = Plane(corners[1], corners[2], corners[5]);
				// Bottom plane
				planes[4] = Plane(corners[2], corners[3], corners[6]);
				// Far plane
				planes[5] = Plane(corners[4], corners[5], corners[6]);
				// TODO: Fix normal vectors to point inside!
			}
开发者ID:mgottschlag,项目名称:GameMath,代码行数:27,代码来源:Frustum.hpp

示例3: SpawnParticles

void SpawnParticles(Mat4f CameraTransforms)
{

	Mat4f ModelTransforms = CameraTransforms.inverse() * getModelViewMatrix();
	Vec4<float> WorldPoint = ModelTransforms * Vec4f(0, 0, 0, 1);
	AddParticleStartingAt(WorldPoint);
	return;

}
开发者ID:billytotochan,项目名称:anime,代码行数:9,代码来源:robotarm.cpp

示例4: unproject

Vec3f GameTerrain::unproject(Vec3f win_pos, const Mat4f &modelview, const Mat4f &projection, const Rect &viewport)
{
	Mat4f matrix = projection;
	matrix = matrix * modelview;
	matrix.inverse();
	Vec4f v(
		2*(win_pos.x - (float)viewport.left)/(float)viewport.get_width() - 1,
		2*(win_pos.y - (float)(viewport.top))/(float)viewport.get_height() - 1,
		2*win_pos.z - 1,
		1.0f);
	Vec4f result = matrix * v;
	return Vec3f(result.x/result.w, result.y/result.w, result.z/result.w);
}
开发者ID:Zenol,项目名称:clanLib-3,代码行数:13,代码来源:game_terrain.cpp

示例5: dir

void m3dTest::orthonormalInverseTest()
{
	using namespace m3d;
	Vec3f dir(frand(), frand(), frand());
	Vec3f pos(frand(), frand(), frand());
	Mat4f matrix = Mat4f::gramSchmidt(dir, pos);

	Mat4f inverse = matrix.inverse();
	Mat4f orth_inverse = matrix.orthonormalInverse();

	for (int x = 0; x < 4; ++x) {
		for (int y = 0; y < 4; ++y) {
			// check if equal
			CPPUNIT_ASSERT(fabs(inverse[x][y] - orth_inverse[x][y]) < EPSILON);

			// check for NaN
			CPPUNIT_ASSERT(inverse[x][y] == inverse[x][y]);
			CPPUNIT_ASSERT(orth_inverse[x][y] == orth_inverse[x][y]);
		}
	}
}
开发者ID:Huebn0r,项目名称:dominator,代码行数:21,代码来源:m3dtest.cpp

示例6: draw

// We are going to override (is that the right word?) the draw()
// method of ModelerView to draw out RobotArm
void RobotArm::draw()
{
	/* pick up the slider values */

	float theta = VAL( BASE_ROTATION );
	float phi = VAL( LOWER_TILT );
	float psi = VAL( UPPER_TILT );
	float cr = VAL( CLAW_ROTATION );
	float h1 = VAL( BASE_LENGTH );
	float h2 = VAL( LOWER_LENGTH );
	float h3 = VAL( UPPER_LENGTH );
	float pc = VAL( PARTICLE_COUNT );

    // This call takes care of a lot of the nasty projection 
    // matrix stuff
    ModelerView::draw();

    // Save the camera transform that was applied by
    // ModelerView::draw() above.
    // While we're at it, save an inverted copy of this matrix.  We'll
    // need it later.
    Mat4f matCam = glGetMatrix( GL_MODELVIEW_MATRIX );
    matCamInverse = matCam.inverse();



	static GLfloat lmodel_ambient[] = {0.4,0.4,0.4,1.0};

	// define the model

	ground(-0.2);

	base(0.8);

    glTranslatef( 0.0, 0.8, 0.0 );			// move to the top of the base
    glRotatef( theta, 0.0, 1.0, 0.0 );		// turn the whole assembly around the y-axis. 
	rotation_base(h1);						// draw the rotation base

    glTranslatef( 0.0, h1, 0.0 );			// move to the top of the base
	glPushMatrix();
			glTranslatef( 0.5, h1, 0.6 );	
	glPopMatrix();
    glRotatef( phi, 0.0, 0.0, 1.0 );		// rotate around the z-axis for the lower arm
	glTranslatef( -0.1, 0.0, 0.4 );
	lower_arm(h2);							// draw the lower arm

    glTranslatef( 0.0, h2, 0.0 );			// move to the top of the lower arm
    glRotatef( psi, 0.0, 0.0, 1.0 );		// rotate  around z-axis for the upper arm
	upper_arm(h3);							// draw the upper arm

	glTranslatef( 0.0, h3, 0.0 );
	glRotatef( cr, 0.0, 0.0, 1.0 );

	Mat4f mvMatrix = glGetMatrix(GL_MODELVIEW_MATRIX);
	Vec4f clawEmitPos = matCamInverse * mvMatrix * Vec4f(0.0, 0.0, 0.0, 1.0);
	if (ps != NULL)
	{
		Vec3f clawPos = Vec3f(clawEmitPos[0], clawEmitPos[1], clawEmitPos[2]);
		ps->setEmitterPosition(clawPos, 1);
	}
	claw(1.0);




	//*** DON'T FORGET TO PUT THIS IN YOUR OWN CODE **/
	endDraw();
}
开发者ID:kaivanwadia,项目名称:animator,代码行数:70,代码来源:robotarm.cpp

示例7: SpawnParticles

void MyModel::SpawnParticles(Mat4f CameraTransforms)
{
	Mat4f WorldMatrix = CameraTransforms.inverse() * getModelViewMatrix();
	Vec3f WorldPoint = WorldMatrix * Vec4f(0, 0, 0, 1);
	particleSystem.addParticleAt(WorldPoint);
}
开发者ID:shayne1993,项目名称:ComputerGraphicProjects,代码行数:6,代码来源:model.cpp


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