本文整理汇总了C++中mat4::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::Inverse方法的具体用法?C++ mat4::Inverse怎么用?C++ mat4::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::Inverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DebugShowShadowMap
// Draw the shadow map in the world, so we can see it.
void WorldRenderer::DebugShowShadowMap(const corgi::CameraInterface& camera,
fplbase::Renderer& renderer) {
fplbase::RenderTarget::ScreenRenderTarget(renderer).SetAsRenderTarget();
static const mat4 kDebugTextureWorldTransform =
mat4::FromScaleVector(mathfu::vec3(10.0f, 10.0f, 10.0f));
const mat4 mvp = camera.GetTransformMatrix() * kDebugTextureWorldTransform;
const mat4 world_matrix_inverse = kDebugTextureWorldTransform.Inverse();
renderer.set_camera_pos(world_matrix_inverse * camera.position());
renderer.set_light_pos(world_matrix_inverse * light_camera_.position());
renderer.set_model_view_projection(mvp);
renderer.set_color(vec4(1.0f, 1.0f, 1.0f, 1.0f));
shadow_map_.BindAsTexture(0);
textured_shader_->Set(renderer);
// Render a large quad in the world, with the shadowmap texture on it:
fplbase::Mesh::RenderAAQuadAlongX(vec3(0.0f, 0.0f, 0.0f),
vec3(10.0f, 0.0f, 10.0f),
vec2(1.0f, 0.0f), vec2(0.0f, 1.0f));
}
示例2: RenderPass
// Render a single render-pass, by ID.
void RenderMeshComponent::RenderPass(int pass_id, const CameraInterface& camera,
fplbase::Renderer& renderer,
const fplbase::Shader* shader_override) {
mat4 camera_vp = camera.GetTransformMatrix();
for (size_t i = 0; i < pass_render_list_[pass_id].size(); i++) {
EntityRef& entity = pass_render_list_[pass_id][i].entity;
RenderMeshData* rendermesh_data = Data<RenderMeshData>(entity);
TransformData* transform_data = Data<TransformData>(entity);
AnimationData* anim_data = Data<AnimationData>(entity);
// TODO: anim_data will set uniforms for an array of matricies. Each
// matrix represents one bone position.
const bool has_anim = anim_data != nullptr && anim_data->motivator.Valid();
const int num_mesh_bones = rendermesh_data->mesh->num_bones();
const int num_anim_bones =
has_anim ? anim_data->motivator.DefiningAnim()->NumBones() : 0;
const bool has_one_bone_anim =
has_anim && (num_mesh_bones <= 1 || num_anim_bones == 1);
const mat4 world_transform =
has_one_bone_anim
? transform_data->world_transform *
mat4::FromAffineTransform(
anim_data->motivator.GlobalTransforms()[0])
: transform_data->world_transform;
const mat4 mvp = camera_vp * world_transform;
const mat4 world_matrix_inverse = world_transform.Inverse();
renderer.set_light_pos(world_matrix_inverse * light_position_);
renderer.set_color(rendermesh_data->tint);
renderer.set_model(world_transform);
// If the mesh has a skeleton, we need to update the bone positions.
// The positions are normally supplied by the animation, but if they are
// not, use the default pose in the RenderMesh.
if (num_mesh_bones > 1) {
const bool use_default_pose =
num_anim_bones != num_mesh_bones || rendermesh_data->default_pose;
const mathfu::AffineTransform* bone_transforms =
use_default_pose ? rendermesh_data->mesh->bone_global_transforms()
: anim_data->motivator.GlobalTransforms();
rendermesh_data->mesh->GatherShaderTransforms(
bone_transforms, rendermesh_data->shader_transforms);
renderer.SetBoneTransforms(rendermesh_data->shader_transforms,
rendermesh_data->num_shader_transforms);
}
if (!camera.IsStereo()) {
renderer.set_camera_pos(world_matrix_inverse * camera.position());
renderer.set_model_view_projection(mvp);
if (!shader_override && rendermesh_data->shader) {
rendermesh_data->shader->Set(renderer);
} else {
shader_override->Set(renderer);
}
rendermesh_data->mesh->Render(renderer);
} else {
const fplbase::Shader* shader = nullptr;
if (!shader_override && rendermesh_data->shader) {
shader = rendermesh_data->shader;
} else {
shader = shader_override;
}
mathfu::vec4i viewport[2] = {camera.viewport(0), camera.viewport(1)};
mat4 camera_vp_stereo = camera.GetTransformMatrix(1);
mat4 mvp_matrices[2] = {mvp, camera_vp_stereo * world_transform};
vec3 camera_positions[2] = {world_matrix_inverse * camera.position(0),
world_matrix_inverse * camera.position(1)};
rendermesh_data->mesh->RenderStereo(renderer, shader, viewport,
mvp_matrices, camera_positions);
}
}
}