简体   繁体   English

WebGL显示不带矩阵的加载模型

[英]WebGL display loaded model without matrix

I'm learning webgl. 我正在学习webgl。 I've managed to draw stuff and hopefully understood the pipeline. 我设法画东西,希望能理解管道。 Now, every tutorial I see explains matrices before even loading a mesh. 现在,我看到的每个教程甚至在加载网格之前都会解释矩阵。 While it can be good for most, I think I need to concentrate on the process of loading external geometry, maybe through a json file. 虽然这对大多数人都可能有好处,但我认为我需要专注于加载外部几何体的过程,可能需要通过json文件。 I've read that openGL by default displays things orthogonally, so I ask: is it possible to display a 3d mesh without any kind of transformation? 我已经阅读过openGL默认情况下会正交显示内容,所以我问:是否可以显示3d网格而无需任何形式的转换?

Now, every tutorial I see explains matrices before even loading a mesh. 现在,我看到的每个教程甚至在加载网格之前都会解释矩阵。

Yes. 是。 Because understanding transformations is essential and you will need to work with them. 因为了解转换是至关重要的,所以您需要与之合作。 They're not hard to understand and the sooner you wrap your head around them, the better. 它们并不难理解,而且您越早将头缠在它们上越好。 Actually in the case of OpenGL for the model-view transformation part it's actually rather simple: 实际上,对于模型视图转换部分的OpenGL,实际上非常简单:

The transformation matrix is just a bunch of vectors (in columns) placed within a "parent" coordinate system. 转换矩阵只是放置在“父”坐标系中的一堆矢量(以列为单位)。 The first the columns define how the X, Y and Z axes of the "embedded" coordinate system are aligned within the "parent", the W column moves it around. 第一列定义了“嵌入式”坐标系的X,Y和Z轴在“父代”中的对齐方式,W列将其四处移动。 By varying the lengths of the base vectors you can stretc, ie scale things. 通过改变基本向量的长度,您可以进行拉伸,即缩放事物。

That's it, there's nothing more to it (in the modelview) than that. 就是这样,(在模型视图中)仅此而已。 Learn the rules of matrix-matrix multiplication. 了解矩阵矩阵乘法的规则。 Matrix-vector multiplication is just a special case of matrix-matrix multiplication. 矩阵向量乘法只是矩阵矩阵乘法的一种特殊情况。

The projection matrix is a little bit trickier, but I suggest you don't bother too much with it, just use GLM, Eigen::3D or linmath.h to build the matrix. 投影矩阵有点棘手,但我建议您不要太在意它,只需使用GLM,Eigen :: 3D或linmath.h来构建矩阵。 The best analogy for the projection matrix is being the "lens" of OpenGL, ie this is where you apply zoom (aka field of view), tilt and shift. 投影矩阵的最佳类比是OpenGL的“镜头”,即在此处可以应用缩放(又称为视场),倾斜和平移。 But the place of the "camera" is defined through the modelview. 但是“相机”的位置是通过模型视图定义的。

is it possible to display a 3d mesh without any kind of transformation? 是否可以显示3d网格而无需任何形式的转换?

No. Because the mesh coordinates have to be transformed into screen coordinates. 否。因为必须将网格坐标转换为屏幕坐标。 However a identity transform is perfectly possible, which, yes, looks like a dead on orthographic projection where the coordinate range [-1, 1] in either dimension is mapped to fill the viewport. 但是,完全可以进行身份​​转换,是的,看起来像正交投影上的死角,其中任一维度上的坐标范围[-1,1]被映射为填充视口。

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

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