本文整理汇总了C++中CoordinateFrame::lookAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CoordinateFrame::lookAt方法的具体用法?C++ CoordinateFrame::lookAt怎么用?C++ CoordinateFrame::lookAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoordinateFrame
的用法示例。
在下文中一共展示了CoordinateFrame::lookAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frame
CoordinateFrame GLight::frame() const {
CoordinateFrame f;
if (rightDirection == Vector3::zero()) {
// No specified right direction; choose one automatically
if (position.w == 0) {
// Directional light
f.lookAt(-position.xyz());
} else {
// Spot light
f.lookAt(spotDirection);
}
} else {
const Vector3& Z = -spotDirection.direction();
Vector3 X = rightDirection.direction();
// Ensure the vectors are not too close together
while (abs(X.dot(Z)) > 0.9f) {
X = Vector3::random();
}
// Ensure perpendicular
X -= Z * Z.dot(X);
const Vector3& Y = Z.cross(X);
f.rotation.setColumn(Vector3::X_AXIS, X);
f.rotation.setColumn(Vector3::Y_AXIS, Y);
f.rotation.setColumn(Vector3::Z_AXIS, Z);
}
f.translation = position.xyz();
return f;
}
示例2: testCoordinateFrame
void testCoordinateFrame() {
printf("CoordinateFrame ");
{
// Easy case
CoordinateFrame c;
c.lookAt(Vector3(-1, 0, -1));
float h = c.getHeading();
debugAssert(fuzzyEq(h, G3D::pi() / 4));
}
// Test getHeading at a variety of angles
for (int i = -175; i <= 175; i += 5) {
CoordinateFrame c;
float h = c.getHeading();
debugAssert(h == 0);
c.rotation = Matrix3::fromAxisAngle(Vector3::unitY(), toRadians(i));
h = c.getHeading();
debugAssert(fuzzyEq(h, toRadians(i)));
}
printf("passed\n");
}
示例3: insertRamps
/**
Two slanted green ramps.
*/
void Demo::insertRamps() {
{
Box b(Vector3(-1, 0, -5), Vector3(1, .25f, 5.5f));
CoordinateFrame c;
c.lookAt(Vector3(0, 1, 2));
c.translation = Vector3(-2.5f, 2.25f, 5.5f);
scene.insertStatic(new BoxObject(c.toWorldSpace(b), (Color3::green() + Color3::white()) / 2));
}
// Corner ramp
{
Box b(Vector3(-1, 0, -5), Vector3(1, .25f, 5.5f));
CoordinateFrame c;
c.lookAt(Vector3(-2, 2, -2));
c.translation = Vector3(-11.2f, 2.85f, -7.2f);
scene.insertStatic(new BoxObject(c.toWorldSpace(b), (Color3::green() + Color3::white()) / 2));
}
}
示例4: insertSpiralSlide
void Demo::insertSpiralSlide() {
int i;
for (i = 0; i < 41; ++i) {
double angle = pi() * i / 10.0;
double angle2 = pi() * (i - 0.6) / 10.0;
// Outer spiral
CoordinateFrame c;
Box b(Vector3(-1, -1, -.1f), Vector3(1, 1, .1f));
c.translation = Vector3(cos(angle) * 2.9f, i / 3.5f + 1.5f, sin(angle) * 2.9f);
c.lookAt(Vector3(cos(angle2) * 1.5f, i / 3.5 + 2.2f, sin(angle2) * 1.5f));
scene.insertStatic(new BoxObject(c.toWorldSpace(b), (Color3::yellow() + Color3::white()) / 2));
// Inner inner spiral
{
Box b(Vector3(-.3f, -.3f, -.1f), Vector3(.25f, .25f, .1f));
c.translation = Vector3(cos(angle) * 1.2f, i / 3.5f + 1, sin(angle) * 1.2f);
c.lookAt(Vector3(cos(angle2) * 3, i / 3.5f + 2, sin(angle2) * 3));
scene.insertStatic(new BoxObject(c.toWorldSpace(b), (Color3::yellow() + Color3::white()) / 2));
}
}
scene.insertDynamic(new SimSphere(Sphere(Vector3(1.9f, 13, -1), .75f), Vector3(-2,-.5f,-2), Color3::blue()));
}