• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            說明:本文章純屬學習之用,如有商業之用,與本人無關。

            網絡游戲《天龍八部》采用的是Ogre3d作為其客戶端渲染引擎,他們對之做了許多自定義的修改,在這里作為學習只用,特別說明一下其自定義的Skeleton的格式,以及如何加載的辦法。

            天龍八部加入了這樣一個區段:
            SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME  0x4120 (16672)
            在加入了這個區段的內容之后,其格式大概就是這樣一個樣子:
             enum SkeletonChunkID {
                    SKELETON_HEADER            
            = 0x1000,
                        
            // char* version           : Version number check
                    SKELETON_BONE              = 0x2000,
                    
            // Repeating section defining each bone in the system. 
                    
            // Bones are assigned indexes automatically based on their order of declaration
                    
            // starting with 0.

                        
            // char* name                       : name of the bone
                        
            // unsigned short handle            : handle of the bone, should be contiguous & start at 0
                        
            // Vector3 position                 : position of this bone relative to parent 
                        
            // Quaternion orientation           : orientation of this bone relative to parent 
                        
            // Vector3 scale                    : scale of this bone relative to parent 

                    SKELETON_BONE_PARENT       
            = 0x3000,
                    
            // Record of the parent of a single bone, used to build the node tree
                    
            // Repeating section, listed in Bone Index order, one per Bone

                        
            // unsigned short handle             : child bone
                        
            // unsigned short parentHandle   : parent bone

                    SKELETON_ANIMATION         
            = 0x4000,
                    
            // A single animation for this skeleton

                        
            // char* name                       : Name of the animation
                        
            // float length                      : Length of the animation in seconds

                        SKELETON_ANIMATION_TRACK 
            = 0x4100,
                        
            // A single animation track (relates to a single bone)
                        
            // Repeating section (within SKELETON_ANIMATION)
                            
                            
            // unsigned short boneIndex     : Index of bone to apply to

                            SKELETON_ANIMATION_TRACK_KEYFRAME 
            = 0x4110,
                            
            // A single keyframe within the track
                            
            // Repeating section

                                
            // float time                    : The time position (seconds)
                                
            // Quaternion rotate            : Rotation to apply at this keyframe
                                
            // Vector3 translate            : Translation to apply at this keyframe
                                
            // Vector3 scale                : Scale to apply at this keyframe

                            SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME 
            = 0x4120,
                            
            // A multiple keyframe within the track
                            
            // Repeating section

                                
            // float length                 : Length of the animation in seconds
                                
            // float flags                  : Length of the animation in seconds
                                    
            // float time                   : The time position (seconds)
                                    
            // Quaternion rotate            : Rotation to apply at this keyframe
                                    
            // Vector3 translate            : Translation to apply at this keyframe
                            
                    SKELETON_ANIMATION_LINK         
            = 0x5000
                    
            // Link to another skeleton, to re-use its animations

                        
            // char* skeletonName                    : name of skeleton to get animations from
                        
            // float scale                            : scale to apply to trans/scale keys

                };


            然后我們打開OgreSkeletonSerializer.cpp找到SkeletonSerializer::readAnimationTrack的實現,然后替換為下面的代碼:
            void SkeletonSerializer::readAnimationTrack(DataStreamPtr& stream, Animation* anim, 
                    Skeleton
            * pSkel)
                {
                    
            // unsigned short boneIndex     : Index of bone to apply to
                    unsigned short boneHandle;
                    readShorts(stream, 
            &boneHandle, 1);

                    
            // Find bone
                    Bone *targetBone = pSkel->getBone(boneHandle);

                    
            // Create track
                    NodeAnimationTrack* pTrack = anim->createNodeTrack(boneHandle, targetBone);

                    
            // Keep looking for nested keyframes
                    if (!stream->eof())
                    {
                        unsigned 
            short streamID = readChunk(stream);
                        
            while( (streamID == SKELETON_ANIMATION_TRACK_KEYFRAME || streamID == SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME)
                            
            && !stream->eof())
                        {
                            
            if (streamID == SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME)
                            {
                                
            // TLBB 新增了此部分
                                unsigned short len;
                                unsigned 
            short flags;
                                readShorts(stream, 
            &len, 1);
                                readShorts(stream, 
            &flags, 1);

                                
            int count = (mCurrentstreamLen - 4 - 4/ 4;
                                
            if (len != count / 8)
                                {
                                    len 
            = len;
                                }
                                
            float time;
                                
            for (int i = 0; i < len; i += 1)
                                {
                                    readFloats(stream, 
            &time, 1);
                                    TransformKeyFrame 
            *kf = pTrack->createNodeKeyFrame(time);

                                    Quaternion rot 
            = Quaternion::IDENTITY;
                                    
            if (flags & 1)
                                    {
                                        readObject(stream, rot);
                                    }
                                    kf
            ->setRotation(rot);

                                    Vector3 trans 
            = Vector3::ZERO;
                                    
            if (flags & 2)
                                    {
                                        readObject(stream, trans);
                                    }
                                    kf
            ->setTranslate(trans);
                                }
                            }
                            
            else
                            {
                                readKeyFrame(stream, pTrack, pSkel);
                            }

                            
            if (!stream->eof())
                            {
                                
            // Get next stream
                                streamID = readChunk(stream);
                            }
                        }
                       
                        
            if (!stream->eof())
                        {
                            
            // Backpedal back to start of this stream if we've found a non-keyframe
                            stream->skip(-STREAM_OVERHEAD_SIZE);
                        }
                    }
                }
            保存然后重新編譯Ogre就OK了,理論上就是可以加載其骨骼動畫了。
            另外,其骨骼文件名,模型文件名都是用的中文,而VS2005對中文路徑名的支持是有一個bug的,解決此問題參見下面這篇文章:
            http://www.shnenglu.com/tx7do/archive/2008/12/09/68897.html
            posted on 2009-01-25 10:36 Felicia 閱讀(963) 評論(0)  編輯 收藏 引用 所屬分類: 雜題
             
            久久青青色综合| 久久精品国产99久久丝袜| 无码人妻久久一区二区三区免费丨| 亚洲精品午夜国产VA久久成人| 色妞色综合久久夜夜 | 免费精品久久久久久中文字幕| 久久精品国产男包| 久久国产精品99精品国产| 久久精品国产69国产精品亚洲| 四虎影视久久久免费| 久久99国产综合精品女同| 久久久久无码中| 亚洲午夜精品久久久久久人妖| 久久中文字幕无码专区| 99国产欧美精品久久久蜜芽| 亚洲国产成人精品91久久久| 国产高潮国产高潮久久久91 | 久久91精品国产91| 88久久精品无码一区二区毛片| 无码AV波多野结衣久久| 久久久久亚洲AV成人网人人网站| 欧美午夜精品久久久久免费视| 亚洲精品国产综合久久一线| 久久99精品免费一区二区| 国产精品久久成人影院| 日韩人妻无码一区二区三区久久 | 噜噜噜色噜噜噜久久| 久久成人精品| 久久高潮一级毛片免费| 精品国产VA久久久久久久冰 | 久久人搡人人玩人妻精品首页| 精品久久久久久亚洲| 久久久久亚洲Av无码专| 久久久久久久久久久久中文字幕| 久久天天躁夜夜躁狠狠| 国产成人精品三上悠亚久久| 久久久国产视频| 性欧美大战久久久久久久久| 性色欲网站人妻丰满中文久久不卡| 日产精品99久久久久久| AV无码久久久久不卡网站下载|