简体   繁体   English

使用opengl渲染围绕3d对象的框架

[英]Rendering a frame around a 3d object using opengl

I am rendering a 3d Object using Rajawali and Opengl on android. 我在android上使用Rajawali和Opengl渲染一个3d对象。 I want to render a cube around boundaries of the object in exactly the same as shown. 我想围绕对象的边界渲染一个立方体,与所示完全相同。

I understand the I may need to use a set of lines or the stack api in rajawali. 我理解我可能需要在rajawali中使用一组行或堆栈 api。 But I dont understand how can I use the Object3D api to figure out which points consists of the line. 但我不明白如何使用Object3D api来确定哪些点由线组成。 I tried using Object3D.getGeometry().getBoundingBox() api but its returning null. 我尝试使用Object3D.getGeometry()。getBoundingBox()api但返回null。

I need hints on how can I derive the min max Number3d points using Rajawali api and whether it would be the right solution to create a set of 12 lines based on those lines. 我需要提示如何使用Rajawali api得出min max Number3d点,以及是否能够根据这些线创建一组12行的正确解决方案。 Or should I somehow augment it into the Model after loading so that i can scale around with it? 或者我应该在加载后以某种方式将其扩展到模型中,以便我可以随身携带它?

This may be too obvious but please consider me a beginner. 这可能太明显但请考虑我是初学者。 Thanks. 谢谢。

带有框架的3D模型

Object3D.getGeometry().getBoundingBox() return undefined value until you call Object3D.getGeometry().computeBoundingBox() method which updates the bounding box information. Object3D.getGeometry().getBoundingBox()返回未定义的值,直到调用Object3D.getGeometry().computeBoundingBox()方法更新边界框信息。

The Answer below will give you more information if you are using complex 3d objects with scene hierarchy. 如果您使用具有场景层次结构的复杂3d对象,下面的答案将为您提供更多信息。 Any way to get a bounding box from a three.js Object3D? 有没有办法从three.js Object3D获取边界框?

Update: The best way is to create a separate object with lines using Min/Max values and use the original object's Transformation. 更新:最好的方法是使用最小/最大值创建一个单独的对象,并使用原始对象的转换。 Or make the BoundingBox geometry a child for the original object. 或者使BoundingBox几何体成为原始对象的子元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM