游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3429|回复: 1

关于父子节点位置计算问题,求助各位大侠

[复制链接]

3

主题

10

帖子

14

积分

新手上路

Rank: 1

积分
14
发表于 2011-5-21 21:29:00 | 显示全部楼层 |阅读模式
ogre中处理节点有这么一段代码:
    void Node::updateFromParentImpl(void) const
    {
        if (mParent)
        {
            // Update orientation
            const Quaternion& parentOrientation = mParent->_getDerivedOrientation();
            if (mInheritOrientation)
            {
                // Combine orientation with that of parent
                mDerivedOrientation = parentOrientation * mOrientation;
            }
                        else
            {
                // No inheritence
                mDerivedOrientation = mOrientation;
            }

            // Update scale
            const Vector3& parentScale = mParent->_getDerivedScale();
            if (mInheritScale)
            {
                // Scale own position by parent scale, NB just combine
                // as equivalent axes, no shearing
                mDerivedScale = parentScale * mScale;
            }
            else
            {
                // No inheritence
                mDerivedScale = mScale;
            }

            // Change position vector based on parent's orientation & scale
            mDerivedPosition = parentOrientation * (parentScale * mPosition);

            // Add altered position vector to parents
            mDerivedPosition += mParent->_getDerivedPosition();
        }
        else
        {
            // Root node, no parent
            mDerivedOrientation = mOrientation;
            mDerivedPosition = mPosition;
            mDerivedScale = mScale;
        }

                mCachedTransformOutOfDate = true;
                mNeedParentUpdate = false;

    }
这段处理父子节点关系的函数,有点想不明白的地方。在不考虑有transform的情况下,子节点的坐标不应该是RotateParent * ScaleParent * RotateChild * ScaleChild,应该是这样一层层下来吧。可是上面的代码的处理方法就变成了RotateParent * RotateChild * ScaleParent * ScaleChild了。旋转和缩放矩阵为什么可以拆分开来单独叠加再相乘,矩阵乘法不能换顺序吧,还是小弟有什么理解出错的地方,请大侠们指点啊

0

主题

1

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2012-6-11 20:08:00 | 显示全部楼层

Re:关于父子节点位置计算问题,求助各位大侠

缩放与旋转是无关的,只与平移有关系。把缩放安排在平移左边,表示平移的距离也被缩放了

兄弟,你是怎么看到源代码的?我下的SDK里没有源代码呀,请问是在哪个文件夹 [em23]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-29 12:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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