矩阵面板,拉丝问题,当模型视图矩阵 [英] Matrix Palette, Drawing Issue when ModelView Matrix

查看:104
本文介绍了矩阵面板,拉丝问题,当模型视图矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

利用OpenGL 1.1和矩阵面板扩展。我遇到的问题是,并非每一个模型被载入需要被动画化,所以我不认为我需要让这些客户端的状态,也不提供重量或体重指数数组。例如,我在我的绘画code时尝试这样的事情...

Using OpenGL 1.1 and the Matrix Palette extension. The issue I'm having, is that not every model being loaded needs to be animated, so I don't think that I need to enable those client states nor provide weights or weight index arrays. For example, I'm trying something like this during my drawing code...

glMatrixMode(GL_MATRIX_PALETTE_OES);

glBindBuffer(GL_ARRAY_BUFFER, dataBuffers[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dataBuffers[1]);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_WEIGHT_ARRAY_OES);
glEnableClientState(GL_MATRIX_INDEX_ARRAY_OES);

//Code to modify the palettes... works fine...
for(i = 0; i < mech.boneCount; ++i){
    glCurrentPaletteMatrixOES(i);
    glLoadPaletteFromModelViewMatrixOES();

    GenerateBoneMatrixPalette(bones, i);
}

glVertexPointer(3, GL_FLOAT, sizeof(VertexData), (char*)(NULL + 0));
glNormalPointer(GL_FLOAT, sizeof(VertexData), (char*)(NULL + 12));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexData), (char*)(NULL + 24));
glWeightPointerOES(1, GL_FLOAT, sizeof(VertexData), (char*)(NULL + 28));
glMatrixIndexPointerOES(1, GL_UNSIGNED_BYTE, sizeof(VertexData), (char*)(NULL + 32));
glDrawElements(GL_TRIANGLES, mech.indexsize, GL_UNSIGNED_SHORT, (char*)(NULL + 0));

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_WEIGHT_ARRAY_OES);
glDisableClientState(GL_MATRIX_INDEX_ARRAY_OES);

glBindBuffer(GL_ARRAY_BUFFER, dataBuffers[2]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dataBuffers[3]);

glMatrixMode(GL_MODELVIEW);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

//pardon the hard 28 value here, it's the correct offset for this test
glVertexPointer(3, GL_FLOAT, 28, (char*)(NULL + 0));
glNormalPointer(GL_FLOAT, 28, (char*)(NULL + 12));
glColorPointer(4, GL_UNSIGNED_BYTE, 28, (char*)(NULL + 24));
glDrawElements(GL_TRIANGLES, indexsize, GL_UNSIGNED_SHORT, (char*)(NULL + 0));

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

但它不工作。第一部分显示正确,但第二个不显示在所有。如果我增加一个,有什么感觉是,不必要的重量和体重指数元素,第二部分根据需要而不是设置矩阵模型视图修改步幅...那么它会显示我所期望的。

But it is not working. The first section displays correctly but the second does not display at all. If I add an, what feels to be, unnecessary weight and weight index element to the second section modifying the stride as needed and not setting the matrix to the modelview... then it displays what I expect.

这感觉奇怪的是,如果我不能够在所有的矩阵面板扩展,只画第二部分的测试,它工作得很好。然而,仅仅使矩阵面板扩展导致第二部分不工作,使它看起来,虽然模式设置为模型视图矩阵,我不能简单地画......虽然这似乎有点不寻常,因为该模型视图仍然是绝对的受转换。

The test that feels the strangest, is if I do not enable the Matrix Palette extension at all and only draw the second part, it works just fine. However, just enabling the Matrix Palette extension causes the second section to not work at all, making it seem that I can not draw simply while the mode is set to the ModelView Matrix... though this seems somewhat unusual as the ModelView still absolutely is affected by transformations.

所以...它可以切换和借鉴,而模型视图是当前矩阵,使用此扩展?或者,我必须利用/重复使用一个单一的调色板,使其工作。

So... is it possible to switch to and draw while the ModelView is the current matrix while using this extension? Or must I make use/reuse a single palette to make it work.

推荐答案

我还没有发现在扩展注册表中的OES矩阵面板延伸,而是一个ARB扩展,并假设它的工作原理类似。在此扩展,您必须启用 GL_MATRIX_PALETTE 和或 GL_VERTEX_BLEND (用过glEnable )使用矩阵面板蒙皮,并禁用它,不使用它。

I haven't found an OES matrix palette extension in the extension registry, but an ARB extension and suppose it works similar. In this extension, you have to enable GL_MATRIX_PALETTE and or GL_VERTEX_BLEND (with glEnable) to use matrix palette skinning and disable it to not use it.

但glMatrixMode简化版,有什么用启用或禁用它。它只是选择矩阵修改功能适用的基质(如 glLoadIdentity glTranslate ,...)。

But the glMatrixMode does't have anything to do with enabling or disabling it. It just selects the matrix to which matrix modification functions apply (like glLoadIdentity, glTranslate, ...).

编辑:谷歌搜索这个扩展(我没有ES经验),我发现,那你一定要启用 GL_MATRIX_PALETTE_OES 来使用它后(通过过glEnable ),然后禁用它再次作为你的第二个部分,以不使用它。正如我上面写的, glMatrixMode 不这样做,你想什么它。

After googling this extension (I have no ES experience) I found, that you definitely have to enable GL_MATRIX_PALETTE_OES to use it (via glEnable) and then disable it again for your second part to not use it. As I've written above, glMatrixMode doesn't do what you thought it to.

这篇关于矩阵面板,拉丝问题,当模型视图矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆