如何将参数提供给期望所有常量值的方法
How togive parameters to a method which expects all const values?
http://www.chai3d.org/doc/classc_camera.html#6b5bbcc535b601c19e10be288dfc65f7
为
bool cCamera::set ( const cVector3d & a_localPosition,
const cVector3d & a_localLookAt,
const cVector3d & a_localUp
)
此调用返回 true 即为成功
camera->set( cVector3d (1, 0.0, 3), // camera position (eye)
cVector3d (0.0, 0.0, 0.0), // lookat position (target)
cVector3d (-1.0, 0.0, 0.0)); // direction of the "up" vector);
}
我没有收到任何错误,但是此调用返回false,这是无法设置相机新位置,为什么?
camera->set( cVector3d(toolPos.x,toolPos.y,toolPos.z),
cVector3d(toolPos.x,toolPos.y,toolPos.z),
cVector3d (1.0, 0.0, 0.0));
工具是一个 cVector3d 变量,当我使用断点检查时具有有效值....也cVector3d 的定义是
cVector3d (const double a_x, const double a_y, const double a_z)
构造函数通过传递双精度来初始化向量。
你的第一个向量(相机位置)和第二个向量(观察位置)具有相同的值。设置新位置的算法无法确定相机朝哪个方向,因为没有从eye
到lookAt
的方向。只需将lookat position
从eye
移动到您想要查看的方向即可。
相关文章:
- 为什么常量方法可以采用非常量引用?
- 常量方法中的非常量 lambda 捕获
- Gmock 常量方法不调用,而是调用原始方法
- 为什么我们需要常量方法?
- 模板常量/非常量方法
- 在常量方法中调用非常量方法
- 如何让编译器在C++中更喜欢常量方法重载?
- 常量方法中 decltype 的结果
- 如何从QDialog的常量方法显示QMessageBox?
- 常量方法指针的类型是什么
- C++类的常量方法中将字符数组分配给 T* 的方法
- 在公共常量方法中访问私有成员
- 常量方法中的奇怪行为,其中变量可以修改
- 当函数引用对象(并访问非常量方法)时,如何抛弃常量?
- 非常量指针成员上的C++常量方法
- 从 const 方法调用成员上的非常量方法
- "Reference qualifier correctness"还是应该将非常量方法应用于右值?
- 在Turtle中为常量方法创建Mock
- C++模板来覆盖常量和非常量方法
- 单元测试-在C++TDD中调用重载常量与非常量方法的好方法