本文整理汇总了C++中Viewport::GetCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::GetCamera方法的具体用法?C++ Viewport::GetCamera怎么用?C++ Viewport::GetCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::GetCamera方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MousePressEvent
void StockShapeSelector::MousePressEvent(QMouseEvent* event) {
// Convert the mouse coordinates into a world-space ray.
Viewport* viewport = renderer_->GetViewport();
CameraNode* camera = viewport->GetCamera();
const QVector3D dir = camera->Unproject(event->x(), event->y()).normalized();
const QVector3D start = camera->Translation();
// Cast the ray into the scene to select an object. This query is performed
// using axis-aligned bounding boxes, which are fast and generally
// sufficient. The bounding boxes are automatically computed from the scene
// graph geometry, so we get the tests "for free".
//
// If we wanted more precise ray casting, then we could cull the results of
// the query with a more exact method (e.g., based on a custom collision
// volume).
const int64_t selection_mask = 0x1;
SelectionQuery query(renderer_->GetScene());
std::vector<QueryResult> qresult = query.CastRay(selection_mask, start, dir);
if (qresult.empty()) {
return;
}
// Found an object. Pass it on to StockShapeRenderer
QueryResult& first_result = qresult.front();
renderer_->NodeSelected(first_result.node);
}
示例2: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
Viewer viewer;
Viewport* viewport = viewer.GetViewport();
// Set initial camera position
const QVector3D eye(5, 5, -10);
const QVector3D look_at(0, 0, 0);
const QVector3D up(0, 1, 0);
viewport->GetCamera()->LookAt(eye, look_at, up);
// Add renderers
ModelRenderer* modeler = new ModelRenderer("model", viewport);
viewport->AddRenderer(modeler);
if (argc > 1) {
modeler->LoadModel(argv[1]);
}
// Add input handlers
viewport->AddInputHandler(new ViewHandlerHorizontal(viewport,
QVector3D(0, 1, 0), viewport));
viewer.show();
return app.exec();
}