本文整理汇总了C++中Intersection::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Intersection::init方法的具体用法?C++ Intersection::init怎么用?C++ Intersection::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intersection
的用法示例。
在下文中一共展示了Intersection::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
Intersection Model::intersect(Ray r) {
Intersection xsect;
xsect.init();
Vector3 e = invMat.transform_point(r.e);
Vector3 d = normalize(invMat.transform_vector(r.d));
Mesh::MeshTriangleList m;
m = kdtree->Test(e, d);
real_t min_dis = 9999999.9;
// Convert each triangle into a "Triangle" Class object, and pass
// it to that class's intersection test. Yay DRY.
for (size_t i = 0; i < m.size(); i++) {
MeshTriangle tri = m[i];
Triangle t;
for (size_t j = 0; j < 3; j++) {
Triangle::Vertex& tv = t.vertices[j];
const MeshVertex& mv = mesh->vertices[tri.vertices[j]];
tv.position = mv.position;
tv.normal = mv.normal;
tv.tex_coord = mv.tex_coord;
tv.material = material;
}
t.position = position;
t.orientation = orientation;
t.scale = scale;
t.invMat = invMat;
t.normMat = normMat;
Intersection ti = t.intersect(r);
if (ti.exists && ti.squared_dist < min_dis) {
min_dis = ti.squared_dist;
xsect = ti;
}
}
return xsect;
}