游戏开发论坛

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: yhchinabest

3ds max 导出插件的一些总结

[复制链接]

89

主题

4036

帖子

4132

积分

论坛元老

Rank: 8Rank: 8

积分
4132
发表于 2009-12-10 01:30:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

楼主的Normal是有错误的。支持小兰的观点,其实Normal是老大难,尤其是在Skin的时候,我取Normal方法抄的老宋的,不过他当时的骨骼动画的Normal却算错了。哈哈。
Normal最简单的就是根据SmoothGroup,自己来算。肯定不会有错。你自己算错那就撞豆腐去吧。哈哈。不过就不能支持EditNormal这样的可以揪Normal的Modifier了。
其次是用IGame. 这两天在准备把我自己的插件移植到IGame上去,奶奶的碰到两个恶心的问题,某个模型倒帧动画的时候,某个Mesh第二帧就让Max异常了。另外,IGame的IGameMesh不是RenderMesh。 就是说那些Modifier都不能塌陷到这个Mesh里。不知道哪位高人有办法。


附.老宋取Normal方法:
Normal难在没有NFace这样面来记录面使用的Normal索引。所以我们要自己生成一个。
Render Normal  保存在RVert里。RVert的索引跟Vertex索引一致。但是一个vertex里会保存多个normal。所以这样取:

89

主题

4036

帖子

4132

积分

论坛元老

Rank: 8Rank: 8

积分
4132
发表于 2009-12-10 01:30:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

Point3   CMaxMesh::__get_smgrp_normal(const MaxNormal& max_normal)
{
    int vertexId = max_normal.iVertex;
    int faceId   = max_normal.iFace;
    // get the "rendered" vertex
    RVertex *pRVertex;
    pRVertex = m_pMesh->getRVertPtr(vertexId);

    // get the face
    Face *pFace;
    pFace = &m_pMesh->faces[faceId];

    // get the smoothing group of the face
    DWORD smGroup;
    smGroup = pFace->smGroup;

    // get the number of normals
    int normalCount;
    normalCount = pRVertex->rFlags & NORCT_MASK;

    // check if the normal is specified ...
    if(pRVertex->rFlags & SPECIFIED_NORMAL)
    {
        return pRVertex->rn.getNormal();
    }
    // ... otherwise, check for a smoothing group
    else if((normalCount > 0) && (smGroup != 0))
    {
        // If there is only one vertex is found in the rn member.
        if(normalCount == 1)
        {
            return pRVertex->rn.getNormal();
        }
        else
        {
            int normalId;
            for(normalId = 0; normalId < normalCount; normalId++)
            {
                if(pRVertex->ern[normalId].getSmGroup() & smGroup)
                {
                    return pRVertex->ern[normalId].getNormal();
                }
            }
        }
    }

    // if all fails, return the face normal
    return m_pMesh->getFaceNormal(faceId);
}

89

主题

4036

帖子

4132

积分

论坛元老

Rank: 8Rank: 8

积分
4132
发表于 2009-12-10 01:32:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

bool operator == (const MaxNormal& lhv , const MaxNormal& rhv)
{
        //是同一个点.只要smgroup相同,且不为0,那么就是法向量相同
        if(lhv.iVertex == rhv.iVertex)
        {
                if(lhv.bSpecified == true)
                        return true;
                if(lhv.smgroup == rhv.smgroup && lhv.smgroup != 0)
                        return true;
                return false;
        }
          //顶点序号不一样。所以也不相同。
        return false;
}

对Normal检重的时候用到的判断

197

主题

1041

帖子

1104

积分

金牌会员

Rank: 6Rank: 6

积分
1104
QQ
发表于 2009-12-10 21:48:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

看规模你插件只是小范围使用

我也做了dle,太多了,太多了,懒,不写出来了,不浪费口水了

59

主题

1104

帖子

1199

积分

金牌会员

Rank: 6Rank: 6

积分
1199
发表于 2009-12-12 23:28:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

我始终觉得max的c++插件缺点很多,主要是
1,调试很不稳定,MAX很容易crash
2,文档太简单了

我目前的方法还是倾向于用maxscript输出所有需要的文本信息,然后再根据需求来打包,毕竟打包的过程是无法避免的,很多时候很多资源要打包,所以就干脆把ascii转binary也放到这一步

89

主题

4036

帖子

4132

积分

论坛元老

Rank: 8Rank: 8

积分
4132
发表于 2009-12-14 00:11:00 | 显示全部楼层

Re:3ds max 导出插件的一些总结

我现在基本导出的都是xml的数据. 除了顶点和矩阵太难表示的例外.
不过maxscript语法实在太恶心了.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-17 11:53

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表