本文整理汇总了C++中vector3::Cross方法的典型用法代码示例。如果您正苦于以下问题:C++ vector3::Cross方法的具体用法?C++ vector3::Cross怎么用?C++ vector3::Cross使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector3
的用法示例。
在下文中一共展示了vector3::Cross方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//-------------------------------------------------------------------------
// CREATE LOOK AT creates a look-at matrix for use as a view matrix
matrix4
create_look_at(vector3 &camera, vector3 &target, vector3 &up){
// Builds a look-at style view matrix.
// This is essentially the same matrix used by gluLookAt().
matrix4 out;
vector3 zAxis = camera - target;
zAxis.Normalize();
vector3 xAxis = up.Cross(zAxis);
xAxis.Normalize();
vector3 yAxis = zAxis.Cross(xAxis);
yAxis.Normalize();
out[0] = xAxis.x;
out[4] = xAxis.y;
out[8] = xAxis.z;
out[12] = -xAxis.Dot(camera);
out[1] = yAxis.x;
out[5] = yAxis.y;
out[9] = yAxis.z;
out[13] = -yAxis.Dot(camera);
out[2] = zAxis.x;
out[6] = zAxis.y;
out[10] = zAxis.z;
out[14] = -zAxis.Dot(camera);
out[3] = 0.0f;
out[7] = 0.0f;
out[11] = 0.0f;
out[15] = 1.0f;
return out;
}
示例2:
vector3 vector3::Cross(const vector3& v1, const vector3& v2)
{
return v1.Cross(v2);
}