本文整理汇总了C++中Transformd::point_to_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformd::point_to_parent方法的具体用法?C++ Transformd::point_to_parent怎么用?C++ Transformd::point_to_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformd
的用法示例。
在下文中一共展示了Transformd::point_to_parent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_autofocus_focal_distance
double get_autofocus_focal_distance(const Intersector& intersector) const
{
// The autofocus considers the scene at the middle of the shutter interval.
const double time = get_shutter_middle_time();
const Transformd transform = m_transform_sequence.evaluate(time);
// Compute the camera space coordinates of the focus point.
const Vector3d film_point = ndc_to_camera(m_autofocus_target);
// Create a ray in world space.
ShadingRay ray;
ray.m_org = transform.point_to_parent(Vector3d(0.0));
ray.m_dir = transform.point_to_parent(film_point) - ray.m_org;
ray.m_tmin = 0.0;
ray.m_tmax = numeric_limits<double>::max();
ray.m_time = time;
ray.m_type = ShadingRay::ProbeRay;
ray.m_depth = 0;
// Trace the ray.
ShadingPoint shading_point;
intersector.trace(ray, shading_point);
if (shading_point.hit())
{
// Hit: compute the focal distance.
const Vector3d v = shading_point.get_point() - ray.m_org;
const double af_focal_distance = -transform.vector_to_local(v).z;
RENDERER_LOG_INFO(
"camera \"%s\": autofocus sets focal distance to %f (using camera position at time=%.1f).",
get_name(),
af_focal_distance,
ray.m_time);
return af_focal_distance;
}
else
{
// Miss: focus at infinity.
RENDERER_LOG_INFO(
"camera \"%s\": autofocus sets focal distance to infinity (using camera position at time=%.1f).",
get_name(),
ray.m_time);
return 1.0e38;
}
}
示例2: compute_ray_direction
Vector3d compute_ray_direction(
const Vector2d& film_point, // NDC
const Vector3d& lens_point, // world space
const Transformd& transform) const
{
// Compute film point in camera space.
const Vector3d film_point_cs = ndc_to_camera(film_point);
// Compute focal point in world space.
const Vector3d focal_point = transform.point_to_parent(-m_focal_ratio * film_point_cs);
// Return ray direction in world space.
return normalize(focal_point - lens_point);
}
示例3: add_cube
void add_cube(
Assembly& assembly,
const size_t ix,
const size_t iy,
const double fx,
const double fz,
const Color3b& color,
const Transformd& transform) override
{
// Push vertices.
const size_t base_vertex_index = m_mesh->get_vertex_count();
for (size_t i = 0; i < m_cube->get_vertex_count(); ++i)
{
m_mesh->push_vertex(
transform.point_to_parent(m_cube->get_vertex(i)));
}
// Push normals.
const size_t base_vertex_normal_index = m_mesh->get_vertex_normal_count();
for (size_t i = 0; i < m_cube->get_vertex_normal_count(); ++i)
{
m_mesh->push_vertex_normal(
normalize(
transform.normal_to_parent(m_cube->get_vertex_normal(i))));
}
// Push texture coordinates.
const size_t tex_coords_index =
m_mesh->push_tex_coords(
GVector2(static_cast<float>(fx), static_cast<float>(1.0 - fz)));
// Push triangles.
for (size_t i = 0; i < m_cube->get_triangle_count(); ++i)
{
Triangle triangle = m_cube->get_triangle(i);
triangle.m_v0 += static_cast<uint32>(base_vertex_index);
triangle.m_v1 += static_cast<uint32>(base_vertex_index);
triangle.m_v2 += static_cast<uint32>(base_vertex_index);
triangle.m_n0 += static_cast<uint32>(base_vertex_normal_index);
triangle.m_n1 += static_cast<uint32>(base_vertex_normal_index);
triangle.m_n2 += static_cast<uint32>(base_vertex_normal_index);
triangle.m_a0 = triangle.m_a1 = triangle.m_a2 = static_cast<uint32>(tex_coords_index);
m_mesh->push_triangle(triangle);
}
}
示例4: collect_emitting_triangles
void LightSampler::collect_emitting_triangles(
const Assembly& assembly,
const AssemblyInstance& assembly_instance)
{
// Loop over the object instances of the assembly.
const size_t object_instance_count = assembly.object_instances().size();
for (size_t object_instance_index = 0; object_instance_index < object_instance_count; ++object_instance_index)
{
// Retrieve the object instance.
const ObjectInstance* object_instance = assembly.object_instances().get_by_index(object_instance_index);
// Retrieve the materials of the object instance.
const MaterialArray& front_materials = object_instance->get_front_materials();
const MaterialArray& back_materials = object_instance->get_back_materials();
// Skip object instances without light-emitting materials.
if (!has_emitting_materials(front_materials) && !has_emitting_materials(back_materials))
continue;
// Compute the object space to world space transformation.
// todo: add support for moving light-emitters.
const Transformd& object_instance_transform = object_instance->get_transform();
const Transformd assembly_instance_transform =
assembly_instance.transform_sequence().empty()
? Transformd::identity()
: assembly_instance.transform_sequence().earliest_transform();
const Transformd global_transform = assembly_instance_transform * object_instance_transform;
// Retrieve the object.
Object& object = object_instance->get_object();
// Retrieve the region kit of the object.
Access<RegionKit> region_kit(&object.get_region_kit());
// Loop over the regions of the object.
const size_t region_count = region_kit->size();
for (size_t region_index = 0; region_index < region_count; ++region_index)
{
// Retrieve the region.
const IRegion* region = (*region_kit)[region_index];
// Retrieve the tessellation of the region.
Access<StaticTriangleTess> tess(®ion->get_static_triangle_tess());
// Loop over the triangles of the region.
const size_t triangle_count = tess->m_primitives.size();
for (size_t triangle_index = 0; triangle_index < triangle_count; ++triangle_index)
{
// Fetch the triangle.
const Triangle& triangle = tess->m_primitives[triangle_index];
// Skip triangles without a material.
if (triangle.m_pa == Triangle::None)
continue;
// Fetch the materials assigned to this triangle.
const size_t pa_index = static_cast<size_t>(triangle.m_pa);
const Material* front_material =
pa_index < front_materials.size() ? front_materials[pa_index] : 0;
const Material* back_material =
pa_index < back_materials.size() ? back_materials[pa_index] : 0;
// Skip triangles that don't emit light.
if ((front_material == 0 || front_material->get_uncached_edf() == 0) &&
(back_material == 0 || back_material->get_uncached_edf() == 0))
continue;
// Retrieve object instance space vertices of the triangle.
const GVector3& v0_os = tess->m_vertices[triangle.m_v0];
const GVector3& v1_os = tess->m_vertices[triangle.m_v1];
const GVector3& v2_os = tess->m_vertices[triangle.m_v2];
// Transform triangle vertices to assembly space.
const GVector3 v0_as = object_instance_transform.point_to_parent(v0_os);
const GVector3 v1_as = object_instance_transform.point_to_parent(v1_os);
const GVector3 v2_as = object_instance_transform.point_to_parent(v2_os);
// Compute the support plane of the hit triangle in assembly space.
const GTriangleType triangle_geometry(v0_as, v1_as, v2_as);
TriangleSupportPlaneType triangle_support_plane;
triangle_support_plane.initialize(TriangleType(triangle_geometry));
// Transform triangle vertices to world space.
const Vector3d v0(assembly_instance_transform.point_to_parent(v0_as));
const Vector3d v1(assembly_instance_transform.point_to_parent(v1_as));
const Vector3d v2(assembly_instance_transform.point_to_parent(v2_as));
// Compute the geometric normal to the triangle and the area of the triangle.
Vector3d geometric_normal = cross(v1 - v0, v2 - v0);
const double geometric_normal_norm = norm(geometric_normal);
if (geometric_normal_norm == 0.0)
continue;
const double rcp_geometric_normal_norm = 1.0 / geometric_normal_norm;
const double rcp_area = 2.0 * rcp_geometric_normal_norm;
const double area = 0.5 * geometric_normal_norm;
geometric_normal *= rcp_geometric_normal_norm;
assert(is_normalized(geometric_normal));
// Retrieve object instance space vertex normals.
const GVector3& n0_os = tess->m_vertex_normals[triangle.m_n0];
//.........这里部分代码省略.........
示例5: build
void AOVoxelTree::build(
const Scene& scene,
BuilderType& builder)
{
// The voxel tree is built using the scene geometry at the middle of the shutter interval.
const double time = scene.get_camera()->get_shutter_middle_time();
// Loop over the assembly instances of the scene.
for (const_each<AssemblyInstanceContainer> i = scene.assembly_instances(); i; ++i)
{
// Retrieve the assembly instance.
const AssemblyInstance& assembly_instance = *i;
// Retrieve the assembly.
const Assembly& assembly = assembly_instance.get_assembly();
// Loop over the object instances of the assembly.
for (const_each<ObjectInstanceContainer> j = assembly.object_instances(); j; ++j)
{
// Retrieve the object instance.
const ObjectInstance& object_instance = *j;
// Compute the object space to world space transformation.
const Transformd transform =
assembly_instance.transform_sequence().evaluate(time)
* object_instance.get_transform();
// Retrieve the object.
Object& object = object_instance.get_object();
// Retrieve the region kit of the object.
Access<RegionKit> region_kit(&object.get_region_kit());
// Loop over the regions of the object.
const size_t region_count = region_kit->size();
for (size_t region_index = 0; region_index < region_count; ++region_index)
{
// Retrieve the region.
const IRegion* region = (*region_kit)[region_index];
// Retrieve the tessellation of the region.
Access<StaticTriangleTess> tess(®ion->get_static_triangle_tess());
// Push all triangles of the region into the tree.
const size_t triangle_count = tess->m_primitives.size();
for (size_t triangle_index = 0; triangle_index < triangle_count; ++triangle_index)
{
// Fetch the triangle.
const Triangle& triangle = tess->m_primitives[triangle_index];
// Retrieve object instance space vertices of the triangle.
const GVector3& v0_os = tess->m_vertices[triangle.m_v0];
const GVector3& v1_os = tess->m_vertices[triangle.m_v1];
const GVector3& v2_os = tess->m_vertices[triangle.m_v2];
// Transform triangle vertices to world space.
const GVector3 v0(transform.point_to_parent(v0_os));
const GVector3 v1(transform.point_to_parent(v1_os));
const GVector3 v2(transform.point_to_parent(v2_os));
// Push the triangle into the tree.
TriangleIntersector intersector(v0, v1, v2);
builder.push(intersector);
}
}
}
}
}