如何在 QML 场景上绘制 3D 线条
How to draw 3D lines onto a QML scene?
我尝试将Bullet Physics的调试绘图接口集成到QML中,因此我必须实现一个drawLine()
方法。
void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color);
我尝试的是,我从QQuickItem3D和btIDebugDraw继承了一个在场景中使用的项目。在drawLine()
中,我将线添加到成员向量中。在Qt的drawItem()
中,我迭代这些行并使用OpenGL调用来渲染它们。但是,它们不会出现在屏幕上。
如何在 3D 空间和正确的摄像机视图中绘制线条?
void DebugDrawer::drawItem(QGLPainter *painter)
{
if (lines_.size() < 1)
return;
// Draw current lines
painter->modelViewMatrix().push();
glBegin(GL_LINES);
for (auto &line : lines_) {
glColor3f(line.color.getX(), line.color.getY(), line.color.getZ());
glVertex3f(line.from.getX(), line.from.getY(), line.from.getZ());
glVertex3f(line.to.getX(), line.to.getY(), line.to.getZ());
}
glEnd();
painter->modelViewMatrix().pop();
// Reset buffer
lines_.clear();
}
我最终使用了QtQuick的line类,并使用Bullet的flushLines()
方法中的setVertices()
设置了它的顶点。
相关文章:
- 如何在 3D OpenGL 场景上绘制 SDL 2D 矩形?
- 是否可以使用 DirectX 3D 11 绘制由三角形组成的圆?
- 如何在 DirectX 11 中使用曲面细分绘制虚线图案 3D 线
- 如何在C++中轻松地将 3D 阵列绘制为表面
- 通过在Android(和iOS)上使用QT绘制具有3D效果的2D线
- 想要在从搅拌机导入的实体3D对象上绘制线框网格
- OpenGL在3D游戏上绘制HUD
- 如何从3d点数组在Qt中绘制和保存3D模型
- 在3D世界中的显示器上固定位置绘制2D文本-OpenGL
- 如何在 QML 场景上绘制 3D 线条
- 如何绘制3d板?过剩
- 如何在 DirectX 中绘制 2D 几何体和 3D 对象?(D3D9)
- Opengl 在移动的 3D 场景中绘制 2D 矩形
- DirectX::SpriteFont/SpriteBatch 阻止绘制 3D 场景
- 如何在 3D 点上绘制文本
- 绘制大量三角形/高度图的更快方法(直接3D,C++)
- 使用glDrawElements绘制3D网格时的奇怪行为
- 尝试使用cocos2d-x 3.8.1绘制3d地形
- 我如何在c++中绘制3d散点图
- 使用Java和OpenGL绘制3D树的方法有哪些