本文整理汇总了C++中Mat4::Translate方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4::Translate方法的具体用法?C++ Mat4::Translate怎么用?C++ Mat4::Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4
的用法示例。
在下文中一共展示了Mat4::Translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Mat4& BcCamera::GetTransform()
{
Mat4* Ret = new Mat4();
Ret->Translate(m_Position);
Ret->Rotate(m_Rotation);
return *Ret;
}
示例2: RenderSprite
void RenderSprite(float size, Vec3 *eyePos, Mat4 matModelView)
{
if(size == 0)
return;
size /= 2;
glPushMatrix();
matModelView.Translate(*eyePos);
matModelView = matModelView.Inverse();
glMultMatrixf(matModelView.m);
glDisable(GL_CULL_FACE);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( -size, size, 0);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( size, size, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex3f( -size, -size, 0);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( size, -size, 0);
glEnd();
glEnable(GL_CULL_FACE);
glPopMatrix();
}
示例3: up
void GraphicsGL2::SetupScene(
float fov, float new_view_distance,
const Vec3 cam_position,
const Quat & cam_rotation,
const Vec3 & dynamic_reflection_sample_pos)
{
// setup the default camera from the passed-in parameters
{
GraphicsCamera & cam = cameras["default"];
cam.fov = fov;
cam.pos = cam_position;
cam.orient = cam_rotation;
cam.view_distance = new_view_distance;
cam.w = w;
cam.h = h;
}
// create a camera for the skybox with a long view distance
{
GraphicsCamera & cam = cameras["skybox"];
cam = cameras["default"];
cam.view_distance = 10000;
cam.pos = Vec3(0);
}
// create a camera for the dynamic reflections
{
GraphicsCamera & cam = cameras["dynamic_reflection"];
cam.pos = dynamic_reflection_sample_pos;
cam.fov = 90; // this gets automatically overridden with the correct fov (which is 90 anyway)
cam.orient.LoadIdentity(); // this gets automatically rotated for each cube side
cam.view_distance = 100;
cam.w = 1; // this gets automatically overridden with the cubemap dimensions
cam.h = 1; // this gets automatically overridden with the cubemap dimensions
}
// create a camera for the dynamic reflection skybox
{
GraphicsCamera & cam = cameras["dynamic_reflection_skybox"];
cam = cameras["dynamic_reflection"];
cam.view_distance = 10000;
cam.pos = Vec3(0);
}
// create an ortho camera for 2d drawing
{
GraphicsCamera & cam = cameras["2d"];
// this is the glOrtho call we want: glOrtho( 0, 1, 1, 0, -1, 1 );
cam.orthomode = true;
cam.orthomin = Vec3(0, 1, -1);
cam.orthomax = Vec3(1, 0, 1);
}
// put the default camera transform into texture3, needed by shaders only
Mat4 viewMatrix;
cam_rotation.GetMatrix4(viewMatrix);
float translate[4] = {-cam_position[0], -cam_position[1], -cam_position[2], 0};
viewMatrix.MultiplyVector4(translate);
viewMatrix.Translate(translate[0], translate[1], translate[2]);
glMatrixMode(GL_TEXTURE);
glActiveTexture(GL_TEXTURE3);
glLoadMatrixf(viewMatrix.GetArray());
// create cameras for shadow passes
if (shadows)
{
Mat4 viewMatrixInv = viewMatrix.Inverse();
// derive light rotation quaternion from light direction vector
Quat light_rotation;
Vec3 up(0, 0, 1);
float cosa = up.dot(light_direction);
if (cosa * cosa < 1.0f)
{
float a = -acosf(cosa);
Vec3 x = up.cross(light_direction).Normalize();
light_rotation.SetAxisAngle(a, x[0], x[1], x[2]);
}
std::vector <std::string> shadow_names;
shadow_names.push_back("near");
shadow_names.push_back("medium");
shadow_names.push_back("far");
for (int i = 0; i < 3; i++)
{
float shadow_radius = (1<<i)*closeshadow+(i)*20.0; //5,30,60
Vec3 shadowbox(1,1,1);
shadowbox = shadowbox * (shadow_radius*sqrt(2.0));
Vec3 shadowoffset(0,0,-1);
shadowoffset = shadowoffset * shadow_radius;
(-cam_rotation).RotateVector(shadowoffset);
shadowbox[2] += 60.0;
GraphicsCamera & cam = cameras["shadows_"+shadow_names[i]];
cam = cameras["default"];
//.........这里部分代码省略.........