本文整理汇总了C++中Basis::create_rotation_matrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Basis::create_rotation_matrix方法的具体用法?C++ Basis::create_rotation_matrix怎么用?C++ Basis::create_rotation_matrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basis
的用法示例。
在下文中一共展示了Basis::create_rotation_matrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_point
void draw_point(const Vertex &pt, scalar_t size) {
Vector3 p = pt.pos;
Vector3 cam_pos = Vector3(0,0,0).transformed(inv_view_matrix);
Basis basis;
basis.k = -(cam_pos - p).normalized();
basis.j = Vector3(0, 1, 0);
basis.i = cross_product(basis.j, basis.k);
basis.j = cross_product(basis.k, basis.i);
world_matrix.set_translation(p);
world_matrix = world_matrix * Matrix4x4(basis.create_rotation_matrix());
load_xform_matrices();
Vertex quad[] = {
Vertex(Vector3(-size, -size, 0), 0.0, 0.0, pt.color),
Vertex(Vector3(-size, size, 0), 0.0, 1.0, pt.color),
Vertex(Vector3(size, size, 0), 1.0, 1.0, pt.color),
Vertex(Vector3(size, -size, 0), 1.0, 0.0, pt.color)
};
set_lighting(false);
set_primitive_type(QUAD_LIST);
draw(VertexArray(quad, 4));
set_primitive_type(TRIANGLE_LIST);
set_lighting(true);
}
示例2: draw_line
/* draw_line(start_vertex, end_vertex, start_width, end_width)
* Draws a line as a cylindrically billboarded elongated quad.
*/
void draw_line(const Vertex &v1, const Vertex &v2, scalar_t w1, scalar_t w2) {
if(w2 < 0.0) w2 = w1;
Vector3 p1 = v1.pos;
Vector3 p2 = v2.pos;
Vector3 cam_pos = Vector3(0,0,0).transformed(inv_view_matrix);
Vector3 vec = p2 - p1;
scalar_t len = vec.length();
Basis basis;
basis.k = -(cam_pos - ((p2 + p1) / 2)).normalized();
basis.j = vec / len;
basis.i = cross_product(basis.j, basis.k).normalized();
basis.k = cross_product(basis.i, basis.j).normalized();
world_matrix.set_translation(p1);
world_matrix = world_matrix * Matrix4x4(basis.create_rotation_matrix());
load_xform_matrices();
Vertex quad[] = {
Vertex(Vector3(-w1, 0, 0), 0.0, v1.tex[0].u),
Vertex(Vector3(-w2, len, 0), 0.0, v2.tex[0].u),
Vertex(Vector3(w2, len, 0), 1.0, v2.tex[0].u),
Vertex(Vector3(w1, 0, 0), 1.0, v1.tex[0].u)
};
set_lighting(false);
set_primitive_type(QUAD_LIST);
draw(VertexArray(quad, 4));
set_primitive_type(TRIANGLE_LIST);
set_lighting(true);
}