Beispiel #1
0
        public static bool IsWmoHit(out WMOHitInformation info, out SlimDX.Vector3 hitPos)
        {
            info = null;
            bool hasHit   = false;
            uint uniqueId = 0;
            uint refId    = 0;

            hitPos = SlimDX.Vector3.Zero;
            SlimDX.Matrix modelMatrix = SlimDX.Matrix.Identity;
            WMOFile       hitFile     = null;
            WMORender     renderer    = null;
            uint          instanceID  = 0;

            lock (lockobj)
            {
                float curNear = 99999;

                foreach (var rndr in mRenders)
                {
                    float          curHit  = 0;
                    uint           curInst = 0;
                    uint           curRef  = 0;
                    SlimDX.Vector3 pos;
                    SlimDX.Matrix  tmpMatrix;
                    uint           tmpId = 0;
                    if (rndr.Value.IsInstanceHit(out curHit, out curInst, out curRef, out pos, out tmpMatrix, out tmpId))
                    {
                        hasHit = true;
                        if (curHit < curNear)
                        {
                            curNear     = curHit;
                            uniqueId    = curInst;
                            refId       = curRef;
                            hitPos      = pos;
                            modelMatrix = tmpMatrix;
                            hitFile     = rndr.Value.File;
                            renderer    = rndr.Value;
                            instanceID  = tmpId;
                        }
                    }
                }
            }

            if (hasHit)
            {
                info             = ADT.ADTManager.GetWmoInformation(uniqueId, refId);
                info.HitPoint    = hitPos;
                info.ModelMatrix = modelMatrix;
                info.Model       = hitFile;
                info.Renderer    = renderer;
                info.InstanceID  = instanceID;
            }

            return(hasHit);
        }
Beispiel #2
0
        public static WMOFile GetCacheEntry(string wmoFile)
        {
            lock (lockObj)
            {
                int hash = wmoFile.ToLower().GetHashCode();
                if (mCacheEntries.ContainsKey(hash))
                {
                    var ret = mCacheEntries[hash];
                    mCacheRefs[hash]++;
                    return ret;
                }

                WMOFile file = new WMOFile(wmoFile);
                mCacheEntries.Add(hash, file);
                mCacheRefs.Add(hash, 1);
                return file;
            }
        }
Beispiel #3
0
        public static WMOFile GetCacheEntry(string wmoFile)
        {
            lock (lockObj)
            {
                int hash = wmoFile.ToLower().GetHashCode();
                if (mCacheEntries.ContainsKey(hash))
                {
                    var ret = mCacheEntries[hash];
                    mCacheRefs[hash]++;
                    return(ret);
                }

                WMOFile file = new WMOFile(wmoFile);
                mCacheEntries.Add(hash, file);
                mCacheRefs.Add(hash, 1);
                return(file);
            }
        }
Beispiel #4
0
 public WMOEditDescriptor(WMOFile file, UI.Dialogs.WMOEditor editor)
 {
     mEditor = editor;
     mFile   = file;
 }
Beispiel #5
0
 public WMORender(string wmoName)
 {
     mFile = WMOCache.GetCacheEntry(wmoName);
     Game.GameManager.GraphicsThread.OnFrame += new Game.VideoThread.FrameRenderDelegate(RenderInstances);
 }
Beispiel #6
0
 public WMOGroup(string fileName, uint num, WMOFile parent)
 {
     mParent  = parent;
     FileName = Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_" + num.ToString("D3") + ".wmo";
 }