Пример #1
0
        public AssetWIRE(Section_AHDR AHDR, Game game, Endianness endianness, SharpRenderer renderer) : base(AHDR, game, endianness)
        {
            using (var reader = new EndianBinaryReader(AHDR.data, endianness))
            {
                reader.ReadInt32();
                int vertexAmount = reader.ReadInt32();
                int lineAmount   = reader.ReadInt32();
                hashID0 = reader.ReadUInt32();
                hashID1 = reader.ReadUInt32();

                Points = new WireVector[vertexAmount];
                for (int i = 0; i < Points.Length; i++)
                {
                    Points[i] = new WireVector(reader);
                }

                Lines = new Line[lineAmount];
                for (int i = 0; i < Lines.Length; i++)
                {
                    Lines[i] = new Line(reader);
                }

                Setup(renderer);
                ArchiveEditorFunctions.AddToRenderableAssets(this);
            }
        }
Пример #2
0
        public virtual bool ShouldDraw(SharpRenderer renderer)
        {
            if (isSelected)
            {
                return(true);
            }
            if (DontRender)
            {
                return(false);
            }
            if (isInvisible)
            {
                return(false);
            }
            if (movementPreview)
            {
                return(true);
            }

            if (AssetMODL.renderBasedOnLodt)
            {
                if (GetDistanceFrom(renderer.Camera.Position) <
                    (AssetLODT.MaxDistances.ContainsKey(_modelAssetID) ?
                     AssetLODT.MaxDistances[_modelAssetID] : SharpRenderer.DefaultLODTDistance))
                {
                    return(renderer.frustum.Intersects(ref boundingBox));
                }

                return(false);
            }

            return(renderer.frustum.Intersects(ref boundingBox));
        }
Пример #3
0
        public override float?GetIntersectionPosition(SharpRenderer renderer, Ray ray)
        {
            if (!ShouldDraw(renderer))
            {
                return(null);
            }

            if (Shape == TriggerShape.Box)
            {
                if (ray.Intersects(ref boundingBox))
                {
                    return(TriangleIntersection(ray, SharpRenderer.cubeTriangles, SharpRenderer.cubeVertices, world));
                }
            }
            else if (Shape == TriggerShape.Sphere)
            {
                if (ray.Intersects(ref boundingSphere))
                {
                    return(TriangleIntersection(ray, SharpRenderer.sphereTriangles, SharpRenderer.sphereVertices, world));
                }
            }
            else
            {
                if (ray.Intersects(ref boundingBox))
                {
                    return(TriangleIntersection(ray, SharpRenderer.cylinderTriangles, SharpRenderer.cylinderVertices, world));
                }
            }

            return(null);
        }
Пример #4
0
        public float?GetIntersectionPosition(SharpRenderer renderer, Ray ray)
        {
            if (!ShouldDraw(renderer))
            {
                return(null);
            }

            float?smallestDistance = null;

            foreach (Triangle t in model.triangleList)
            {
                Vector3 v1 = model.vertexListG[t.vertex1];
                Vector3 v2 = model.vertexListG[t.vertex2];
                Vector3 v3 = model.vertexListG[t.vertex3];

                if (ray.Intersects(ref v1, ref v2, ref v3, out float distance))
                {
                    if (smallestDistance == null || distance < smallestDistance)
                    {
                        smallestDistance = distance;
                    }
                }
            }

            return(smallestDistance);
        }
Пример #5
0
        public bool ShouldDraw(SharpRenderer renderer)
        {
            if (isSelected)
            {
                return(true);
            }
            if (dontRender)
            {
                return(false);
            }
            if (isInvisible)
            {
                return(false);
            }

            if (AssetMODL.renderBasedOnLodt)
            {
                if (GetDistanceFrom(renderer.Camera.Position) < SharpRenderer.DefaultLODTDistance)
                {
                    return(renderer.frustum.Intersects(ref boundingBox));
                }
                return(false);
            }

            return(renderer.frustum.Intersects(ref boundingBox));
        }
Пример #6
0
        public virtual void Setup(SharpRenderer renderer)
        {
            if (model != null)
            {
                model.Dispose();
            }

#if !DEBUG
            try
            {
#endif
            ReadFileMethods.treatStuffAsByteArray = false;
            var rwSecArray = ReadFileMethods.ReadRenderWareFile(Data);
            model = new RenderWareModelFile(renderer.device, rwSecArray);
            if (rwSecArray.Length > 0)
            {
                renderWareVersion = rwSecArray[0].renderWareVersion;
            }
            SetupAtomicFlagsForRender();
#if !DEBUG
        }

        catch (Exception ex)
        {
            if (model != null)
            {
                model.Dispose();
            }
            model = null;
            throw new Exception("Error: " + ToString() + " has an unsupported format and cannot be rendered. " + ex.Message);
        }
#endif
        }
Пример #7
0
        public void Render(SharpRenderer renderer, Matrix world, Vector4 color, Vector3 uvAnimOffset, bool[] atomicFlags)
        {
            renderData.worldViewProjection = world * renderer.viewProjection;
            renderData.Color        = color;
            renderData.UvAnimOffset = (Vector4)uvAnimOffset;

            renderer.device.SetBlendStateAlphaBlend();
            renderer.device.UpdateAllStates();

            renderer.device.UpdateData(renderer.tintedBuffer, renderData);
            renderer.device.DeviceContext.VertexShader.SetConstantBuffer(0, renderer.tintedBuffer);
            renderer.tintedShader.Apply();

            for (int i = 0; i < meshList.Count; i++)
            {
                if (meshList[i] == null || (dontDrawInvisible && atomicFlags[i]))
                {
                    continue;
                }

                meshList[i].Begin(renderer.device);
                for (int j = 0; j < meshList[i].SubSets.Count(); j++)
                {
                    meshList[i].Draw(renderer.device, j);
                }
            }
        }
        public static void RenderGizmos(SharpRenderer renderer)
        {
            switch (CurrentGizmoMode)
            {
            case GizmoMode.Position:
            {
                if (allCurrentlySelectedAssets.OfType <IClickableAsset>().Count() == 1 &&
                    allCurrentlySelectedAssets.OfType <IClickableAsset>().FirstOrDefault() is AssetTRIG TRIG &&
                    TRIG.Shape == TriggerShape.Box)
                {
                    TriggerGizmo = true;

                    SetCenterRotation(TRIG.Yaw, TRIG.Pitch, TRIG.Roll);

                    GizmoCenterPosition = TRIG.GetBoundingBox().Center;

                    float radius = Vector3.Distance(renderer.Camera.Position, GizmoCenterPosition) / 5f;

                    Vector3 TrigBound = new Vector3(TRIG.Position1X - TRIG.Position0X, TRIG.Position1Y - TRIG.Position0Y, TRIG.Position1Z - TRIG.Position0Z) / 2f;

                    foreach (BoxTrigPositionGizmo g in triggerPositionGizmos)
                    {
                        g.SetPosition(TRIG.GetBoundingBox().Center, TrigBound, radius, GizmoCenterRotation);
                        g.Draw(renderer);
                    }

                    radius = Vector3.Distance(renderer.Camera.Position, TRIG.Position) / 5f;

                    foreach (PositionGizmo g in positionGizmos)
                    {
                        g.SetPosition(TRIG.Position, radius);
                        g.Draw(renderer);
                    }
                }
Пример #9
0
        public void Render(SharpRenderer renderer, Matrix world, Vector4 color, Vector3 uvAnimOffset)
        {
            renderData.worldViewProjection = world * renderer.viewProjection;
            renderData.Color        = color;
            renderData.UvAnimOffset = (Vector4)uvAnimOffset;

            renderer.device.UpdateData(renderer.tintedBuffer, renderData);
            renderer.device.DeviceContext.VertexShader.SetConstantBuffer(0, renderer.tintedBuffer);
            renderer.tintedShader.Apply();

            foreach (SharpMesh mesh in meshList)
            {
                if (mesh == null)
                {
                    continue;
                }

                mesh.Begin(renderer.device);
                for (int i = 0; i < mesh.SubSets.Count(); i++)
                {
                    renderer.device.DeviceContext.PixelShader.SetShaderResource(0, mesh.SubSets[i].DiffuseMap);
                    mesh.Draw(renderer.device, i);
                }
            }
        }
Пример #10
0
        public override void Draw(SharpRenderer renderer)
        {
            if (movementPreview)
            {
                localFrameCounter++;
                if (localFrameCounter >= int.MaxValue)
                {
                    localFrameCounter = 0;
                }
            }

            if (DontRender || isInvisible)
            {
                return;
            }

            if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(_modelAssetID))
            {
                ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * _color : _color, UvAnimOffset);
            }
            else
            {
                renderer.DrawCube(LocalWorld(), isSelected);
            }
        }
Пример #11
0
 public float?GetIntersectionPosition(SharpRenderer renderer, Ray ray)
 {
     if (ShouldDraw(renderer) && ray.Intersects(ref boundingBox))
     {
         return(TriangleIntersection(ray, triangles, vertices, Matrix.Identity));
     }
     return(null);
 }
Пример #12
0
        public void Draw(SharpRenderer renderer)
        {
            if (dontRender || isInvisible)
            {
                return;
            }

            renderer.DrawPyramid(world, isSelected, 1f);
        }
Пример #13
0
        public void Draw(SharpRenderer renderer)
        {
            if (dontRender || isInvisible)
            {
                return;
            }

            renderer.DrawCube(world, isSelected);
        }
Пример #14
0
        public void Draw(SharpRenderer renderer)
        {
            if (dontRender || isInvisible)
            {
                return;
            }

            model.Render(renderer, Matrix.Identity, isSelected ? renderer.selectedObjectColor : Vector4.One, Vector3.Zero);
        }
Пример #15
0
        public void Draw(SharpRenderer renderer)
        {
            renderer.DrawSphere(world, isSelected, renderer.sfxColor);

            if (isSelected)
            {
                renderer.DrawSphere(world2, false, renderer.sfxColor);
            }
        }
Пример #16
0
        public override void Setup(SharpRenderer renderer)
        {
            base.Setup(renderer);
            AddToRenderingDictionary(assetID, this);

            if (game == Game.Incredibles)
            {
                AddToRenderingDictionary(Functions.BKDRHash(newName), this);
                AddToNameDictionary(Functions.BKDRHash(newName), newName);
            }
        }
Пример #17
0
 public override void Draw(SharpRenderer renderer, bool isSelected)
 {
     if (renderingDictionary.ContainsKey(DynaRingControl.RingModelAssetID))
     {
         renderingDictionary[DynaRingControl.RingModelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor : Vector4.One, Vector3.Zero);
     }
     else
     {
         renderer.DrawCube(world, isSelected);
     }
 }
Пример #18
0
 public void Draw(SharpRenderer renderer)
 {
     if (renderingDictionary.ContainsKey(_modelAssetID))
     {
         renderingDictionary[_modelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * _color : _color, new Vector3());
     }
     else
     {
         renderer.DrawCube(world, isSelected);
     }
 }
Пример #19
0
 public void Draw(SharpRenderer renderer)
 {
     if (IsZone == 1 || _arenaRadius == -1f)
     {
         renderer.DrawPyramid(world, isSelected, 1f);
     }
     else
     {
         renderer.DrawSphere(world, isSelected, renderer.mvptColor);
     }
 }
Пример #20
0
 public override void Draw(SharpRenderer renderer)
 {
     if (AHDR.assetType == HipHopFile.AssetType.UI && _textureAssetID == 0)
     {
         base.Draw(renderer);
     }
     else
     {
         renderer.DrawPlane(world, isSelected, _textureAssetID, UvAnimOffset);
     }
 }
Пример #21
0
 public void Draw(SharpRenderer renderer, Matrix world, Vector4 color, Vector3 uvAnimOffset)
 {
     if (renderingDictionary.ContainsKey(_modelAssetID))
     {
         renderingDictionary[_modelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * color : color, uvAnimOffset);
     }
     else
     {
         renderer.DrawCube(world, isSelected | isSelected);
     }
 }
Пример #22
0
 public virtual void Draw(SharpRenderer renderer)
 {
     if (renderingDictionary.ContainsKey(_modelAssetID))
     {
         renderingDictionary[_modelAssetID].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * _color : _color, UvAnimOffset);
     }
     else
     {
         renderer.DrawCube(LocalWorld(), isSelected);
     }
 }
Пример #23
0
        public override void Draw(SharpRenderer renderer)
        {
            if (AssetPICK.pickEntries.ContainsKey(_pickEntryID))
            {
                if (renderingDictionary.ContainsKey(AssetPICK.pickEntries[_pickEntryID]))
                {
                    renderingDictionary[AssetPICK.pickEntries[_pickEntryID]].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * _color : _color, UvAnimOffset);
                    return;
                }
            }

            renderer.DrawCube(LocalWorld(), isSelected);
        }
Пример #24
0
        public virtual float?GetIntersectionPosition(SharpRenderer renderer, Ray ray)
        {
            if (!ShouldDraw(renderer))
            {
                return(null);
            }

            if (ray.Intersects(ref boundingBox, out float distance))
            {
                return(TriangleIntersection(ray, distance));
            }
            return(null);
        }
Пример #25
0
        public override void Draw(SharpRenderer renderer, bool isSelected)
        {
            Vector4 Color = new Vector4(ColorRed, ColorGreen, ColorBlue, ColorAlpha);

            if (renderingDictionary.ContainsKey(Model_AssetID))
            {
                renderingDictionary[Model_AssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * Color : Color, Vector3.Zero);
            }
            else
            {
                renderer.DrawCube(world, isSelected);
            }
        }
Пример #26
0
        public float?GetIntersectionPosition(SharpRenderer renderer, Ray ray)
        {
            if (!ShouldDraw(renderer))
            {
                return(null);
            }

            if (ray.Intersects(ref boundingSphere))
            {
                return(TriangleIntersection(ray, SharpRenderer.sphereTriangles, SharpRenderer.sphereVertices, world));
            }
            return(null);
        }
Пример #27
0
        public void Draw(SharpRenderer renderer)
        {
            if (dontRender || isInvisible)
            {
                return;
            }

            renderer.DrawSphere(world, isSelected, renderer.sfxColor);

            if (isSelected)
            {
                renderer.DrawSphere(world2, false, renderer.sfxColor);
            }
        }
Пример #28
0
 public virtual void Setup(SharpRenderer renderer)
 {
     model = new RenderWareModelFile(AHDR.ADBG.assetName);
     try
     {
         model.SetForRendering(renderer.device, ReadFileMethods.ReadRenderWareFile(Data), Data);
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Error: " + ToString() + " (MODL) has an unsupported format and cannot be rendered. " + ex.Message);
         model.Dispose();
         model = null;
     }
 }
Пример #29
0
        public override void Draw(SharpRenderer renderer)
        {
            Vector4 Color = _color;

            Color.W = Color.W == 0f ? 1f : Color.W;

            if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(_modelAssetID))
            {
                ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * Color : Color, UvAnimOffset);
            }
            else
            {
                renderer.DrawCube(LocalWorld(), isSelected);
            }
        }
Пример #30
0
        public override bool ShouldDraw(SharpRenderer renderer)
        {
            if (AssetMODL.renderBasedOnLodt)
            {
                if (GetDistance(renderer.Camera.Position) <
                    (AssetLODT.MaxDistances.ContainsKey(Model_AssetID) ?
                     AssetLODT.MaxDistances[Model_AssetID] : SharpRenderer.DefaultLODTDistance))
                {
                    return(renderer.frustum.Intersects(ref boundingBox));
                }

                return(false);
            }

            return(renderer.frustum.Intersects(ref boundingBox));
        }