Example #1
0
        void RenderGraphObject(GraphObject graphObject, RenderFlags renderFlags)
        {
            // visibility check
            if (!graphObject.Visible)
            {
                return;
            }

            // render-flag check
            if (!renderFlags.HasFlag(RenderFlags.Ceilings) && graphObject.HasRenderFlag(GraphObjectRenderFlags.Ceiling))
            {
                return;
            }
            if (!renderFlags.HasFlag(RenderFlags.FourthWalls) && graphObject.HasRenderFlag(GraphObjectRenderFlags.FourthWall))
            {
                return;
            }

            // matrix transformations
            GL.PushMatrix();
            TransformMatrix(graphObject.Position, graphObject.Rotation, graphObject.Scale);

            // bounding box
            if (renderFlags.HasFlag(RenderFlags.BoundingBox))
            {
                GL.Disable(EnableCap.Lighting);
                GL.Disable(EnableCap.Texture2D);
                GL.Color3(Color.Yellow);
                GLUtility.WireCube(graphObject.BoundingBox * GlobalScaleReciprocal);
                GL.Color3(Color.White);
                GL.Enable(EnableCap.Texture2D);
                GL.Enable(EnableCap.Lighting);
            }

            if (graphObject.HasRenderFlag(GraphObjectRenderFlags.FullBright))
            {
                GL.Disable(EnableCap.Lighting);
            }

            // Render parts.
            foreach (var part in graphObject)
            {
                if (shaders[part.ShaderIndex].Tint.A > 0 && ((shaders[part.ShaderIndex].Tint.A == Color.Opaque && renderFlags.HasFlag(RenderFlags.Opaque)) || (shaders[part.ShaderIndex].Tint.A < Color.Opaque && renderFlags.HasFlag(RenderFlags.Translucent))))
                {
                    RenderPart(part, renderFlags);
                }
            }

            GL.Enable(EnableCap.Lighting);

            // Render children.
            for (int childIndex = graphObject.ChildIndex; childIndex >= 0; childIndex = graphObjects[childIndex].NextIndex)
            {
                RenderGraphObject(graphObjects[childIndex], renderFlags);
            }

            GL.PopMatrix();
        }
Example #2
0
        GraphObject GetGraphObject(int index)
        {
            const int itemSize = 0x8C;

            binaryReader.Goto(GraphOffset + itemSize * index);
            binaryReader.PositionAnchor = GraphOffset;
            GraphObject graphObject = new GraphObject(binaryReader);

            binaryReader.ResetAnchor();
            binaryReader.Back();

            return(graphObject);
        }
Example #3
0
        GraphObject[] GetGraphObjects(int index)
        {
            List <GraphObject> graphObjects = new List <GraphObject>(10);
            GraphObject        graphObject  = GetGraphObject(index);

            graphObjects.Add(graphObject);

            if (graphObject.ChildIndex >= 0)
            {
                graphObjects.AddRange(GetGraphObjects(graphObject.ChildIndex));
            }

            if (graphObject.NextIndex >= 0)
            {
                graphObjects.AddRange(GetGraphObjects(graphObject.NextIndex));
            }

            return(graphObjects.ToArray());
        }