OpenGL pModel 翻译

发布于 2024-12-23 05:56:28 字数 1042 浏览 0 评论 0原文

当我在 GMax 中加载 .obj 文件时,它位于空间的中心 (0,0,0)。 我怎样才能改变这个立场?有什么特殊功能吗?

我不想使用 glTranslatef。相反,我希望整个 pModel 移动(pModel 结构发生变化)。我找到了glmScale函数。有没有类似的平移或旋转功能?

当我加载 obj 时,我会这样做:

pModelScaun=glmReadOBJ(filename);   
glmUnitize(pModelScaun);
glmFacetNormals(pModelScaun);
glmVertexNormals(pModelScaun,90.0);

然后我使用三角形来确定灯光位置和阴影 frascum

for (unsigned int i = 0; i < pModelScaun->numtriangles; i++)
{
    //compute the light vector (between the center of the current 
    //triangle and the position of the light (converted to object space)
    for (unsigned int j = 0; j < 3; j++)
    {
        fvIncidentLightDir[j] = (pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[0]+j] +
                                pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[1]+j] +
                                pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[2]+j]) / 3.0 - lp[j];            
    }

你能给我指出一种在这种情况下使用变换矩阵的方法吗?

When I load an .obj file in GMax it is positioned in the center of the space (0,0,0).
How can I change this position? Is there any special function?

I don't want to use glTranslatef. Rather I would like the whole pModel to move (the pModel structure to change). I found the function glmScale. Is there anything similar for translating or rotating?

When I load the obj I do smth like this:

pModelScaun=glmReadOBJ(filename);   
glmUnitize(pModelScaun);
glmFacetNormals(pModelScaun);
glmVertexNormals(pModelScaun,90.0);

and then I use the triangle to determine the light position and the shadow frascum

for (unsigned int i = 0; i < pModelScaun->numtriangles; i++)
{
    //compute the light vector (between the center of the current 
    //triangle and the position of the light (converted to object space)
    for (unsigned int j = 0; j < 3; j++)
    {
        fvIncidentLightDir[j] = (pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[0]+j] +
                                pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[1]+j] +
                                pModelScaun->vertices[3*pModelScaun->triangles[i].vindices[2]+j]) / 3.0 - lp[j];            
    }

Can you point me a way in which I could use the transformation matrices in this situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疧_╮線 2024-12-30 05:56:29

由于您正在使用对象空间中的顶点,并将光线变换到对象空间中,因此您可以将 fvIncidentLightDir 乘以对象的变换矩阵,将其变换回世界空间。

Since you have are using the vertices in object-space, and have transformed the light into their object-space, you can multiply the fvIncidentLightDir by your object's transformation matrix to transform it back into world space.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文