本文整理汇总了C++中mat4::inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::inverse方法的具体用法?C++ mat4::inverse怎么用?C++ mat4::inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::inverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Ray_Tri_Intersect
float Trans_Mesh::Ray_Tri_Intersect(const vec3& rayorig, const vec3& raydir, mat4& world, uint16_t startindex, uint16_t numindices) const{
world.inverse();
vec3 org(rayorig*world), di(raydir);// transform these to the mesh's space so the checks are in object space, not world space
TransformNormal(di, world);
// do all checks in OBJECT SPACE!!!
di*=20000.0f;//make sure the ray is long enough
return RayTriangleIntersect(org, di, &Vertices[0], &Indices[startindex],numindices);
}
示例2: opengl_display
void opengl_display()
{
static double start = get_time();
float current_time = get_time()-start;
light_dir.x = sin(current_time * 0.6f);
light_dir.z = cos(current_time * 0.6f);
light_pos.x = -light_dir.x * 100.f;
light_pos.z = -light_dir.z * 100.f;
light_pos.y = 10.f * sin(current_time * 0.5f);
/* background and object ******************************************************************/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//-------------------------------------------------------------------
view_matrix.look_at(vec3(0,0,distance_z), vec3(0,0,0), vec3(0,1,0));
world_view_matrix = view_matrix * world_matrix;
world_view_proj_matrix = proj_matrix * world_view_matrix;
vec3 viewpos = world_view_matrix.inverse() * vec3(0,0,0);
view_pos = vec4(viewpos.x, viewpos.y, viewpos.z, 1.0);
glUseProgram(object_program.p_program->get_program());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_bump);
glUniform1i(object_program.texs_locs[0], 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture_obj);
glUniform1i(object_program.texs_locs[1], 1);
glUniformMatrix4fv(object_program.loc_world_view_proj, 1, GL_FALSE, &world_view_proj_matrix[0]);
glUniform4fv(object_program.loc_light_pos, 1, &light_pos.x);
glUniform4fv(object_program.loc_light_dir, 1, &light_dir.x);
glUniform4fv(object_program.loc_view_pos, 1, &view_pos.x);
draw(&object_program, &object_mesh);
}
示例3: mat
transform3d(const mat4& m) : mat(m), inv(m.inverse()) {}