桌面增强现实应用程序的 3D 模型操作
我正在开发一个增强现实项目,该项目使用多个标记来获取我计划覆盖的 3D 模型的位置。 (我使用 OpenCV 从头开始执行此操作,并且没有使用 ARToolkit 或任何其他现成的标记检测库)。
环境:Visual C++ 2008、Windows 7、Core2Duo 1GB ram、OpenCV 2.3
我希望用户可以操作 3D 模型,这样它将成为一种模拟。
为此我计划使用 OpenGL。您有什么建议、推荐?模拟部分可以通过使用 OpenGL 本身来完成吗?还是我需要使用 OpenSceneGraph/ODE/Unity 3D/Ogre 3D 之类的东西?
这是一个学术项目,如果我可以生成更多的自编码系统,那就更好了比使用现成的产品。
I'm working on an Augmented Reality project that uses multiple markers to get positions for 3D models that I'm planning to overlay. (I'm doing this from scratch using OpenCV and I'm not using ARToolkit or any other off the shelf marker detection libraries).
Environment: Visual C++ 2008, Windows 7, Core2Duo 1GB ram, OpenCV 2.3
I want the 3D models to be manipulated by user so it will turn out to a sort of simulation.
For this I'm planning to use OpenGL. What are your suggestions, recommendations? Can the simulation part be done by using OpenGL itself or will i need to use something like OpenSceneGraph/ODE/Unity 3D/Ogre 3D?
This is for an academic project so better if I can produce more self-coded system rather than using off-the-shelf products.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OpenGL 似乎足以满足您的需求(绘制具有特定颜色和尺寸的模型)。
如果您是 OpenGL 新手,并且不打算在未来的项目中使用它,那么使用旧的固定功能管道可能会更容易,该管道已经准备好照明和颜色系统,并且不需要您学习如何编写着色器。
对于您的项目,您将需要一个纹理,您可以使用 glTexSubImage2D() 从相机复制图像,然后将其绘制到背景(或者您可以使用 glDrawPixels() 如果您不需要任何缩放)。之后,您需要拥有包含照明法线的模型。模型可以是例如。从 Blender 或 3DS Max 导出为 ascii 格式,这非常容易解析。然后就可以画模型了。在绘制模型之前可以使用 glColor3f() 更改颜色(确保在绘制模型时没有指定不同的颜色)。模型的定位是使用矩阵完成的。旧的 OpenGL 有一些方便且易于使用的函数来旋转和平移对象。还有用于缩放对象(更改大小)的函数,因此非常容易涵盖。您所需要的只是找出相机相对于标记的位置(我相信这是在 OpenCV 中实现的)。
如果要使用向前兼容的 OpenGL,则需要设置顶点缓冲区对象来包含模型数据,并编写顶点和片段着色器来着色和显示模型。这是更多的工作,但你可以获得更大的灵活性。但是,如果您决定需要它们(例如,用于某些特殊效果),您也可以在旧版 OpenGL 中使用着色器。
学习如何使用场景图或引擎(食人魔)可能需要一些时间,我不会推荐它来完成您的任务。
it would seem that OpenGL is pretty enough for your needs (drawing a model with a specific colour and size).
If you're new to OpenGL, and you are not going to be using it for your future projects, it might be easier to use the old fixed-function pipeline, which already has the lighting and color system ready and doesn't require you to learn how to write shaders.
For your project, you will need a texture where you would copy the image from camera using glTexSubImage2D() which you would in turn draw to background (or you can use glDrawPixels() in case you don't require any scaling). After that, you need to have your model, complete with normals for lighting. Models can be eg. exported from Blender or 3DS Max to ascii format, which is pretty easy to parse. Then you can draw the model. Colors can be changed using glColor3f() before drawing the model (make sure you don't specify different color while drawing the model). Positioning of the models is done using matrices. The old OpenGL have some handy and easy-to-use functions for rotating and translating objects. There are also functions for scaling the objects (changing size), so that is covered pretty easy. All you need is to figure out camera position, relative to the marker (which i believe is implemented in OpenCV).
If you were to use the forward-compatible OpenGL, you would need to set up vertex buffer objects to contain model data and write vertex and fragment shaders to shade and display your model. That's kinda more work for which you get extended flexibility. But you can use shaders in the old OpenGL as well, if you decide you need them (eg. for some special effects).
Learning how to use a scenegraph or an engine (ogre) can take some time, i would not recommend it for your task.