Ejemplo n.º 1
0
        internal protected override IGameResource PrecacheResource(Game owner, string resource_name, string r_path, string r_name)
        {
            IGameResource gr     = null;
            bool          result = false;

            switch (resource_name)
            {
            case Managers.BlamDefinition.ResourceScripts:
                gr     = new Scripting.XmlInterface();
                result = gr.Load(r_path, r_name);
                break;

            case Managers.BlamDefinition.ResourceStringIds:
                gr     = new Managers.StringIdStaticCollection();
                result = gr.Load(r_path, r_name);
                break;

            case Managers.BlamDefinition.ResourceVertexBuffers:
                gr     = new Render.VertexBufferInterface.VertexBuffersGen3();
                result = gr.Load(r_path, r_name);
                break;
            }

            if (!result && gr != null)
            {
                gr.Close();
                gr = null;
            }

            return(gr);
        }
Ejemplo n.º 2
0
		internal protected override IGameResource PrecacheResource(Game owner, string resource_name, string r_path, string r_name)
		{
			IGameResource gr = null;
			bool result = false;

			switch (resource_name)
			{
				case Managers.BlamDefinition.ResourceScripts:
					gr = new Scripting.XmlInterface();
					result = gr.Load(r_path, r_name);
					break;

				case Managers.BlamDefinition.ResourceStringIds:
					gr = new Managers.StringIdStaticCollection();
					result = gr.Load(r_path, r_name);
					break;

				case Managers.BlamDefinition.ResourceVertexBuffers:
					gr = new Render.VertexBufferInterface.VertexBuffersGen3();
					result = gr.Load(r_path, r_name);
					break;
			}

			if (!result && gr != null)
			{
				gr.Close();
				gr = null;
			}

			return gr;
		}
        void DebugVertices(StreamWriter s, Render.VertexBufferInterface.VertexBuffersGen3 gr, bool denormalize,
                           Render.VertexBufferInterface.VertexBuffersGen3.Definition def,
                           s_tag_d3d_vertex_buffer vb)
        {
            var stream_r = new Render.VertexBufferInterface.StreamReader(def);

            using (var er = new IO.EndianReader(vb.VertexBuffer.Value, IO.EndianState.Big, this))
            {
                for (int x = 0; x < vb.VertexCount.Value; x++)                 // foreach vertex...
                {
                    s.WriteLine("\tVertex\t{0}", x.ToString("X8"));
                    {
                        stream_r.Read(er);
                        if (denormalize)
                        {
                            foreach (string str in stream_r.GetDenormalizedStrings())
                            {
                                s.WriteLine("\t\t{0}", str);
                            }
                        }
                        else
                        {
                            foreach (string str in stream_r.GetNormalizedStrings())
                            {
                                s.WriteLine("\t\t{0}", str);
                            }
                        }
                    }
                    s.WriteLine();
                }
                s.WriteLine(); s.WriteLine();
            }
        }
        void DebugVertices(StreamWriter s, Render.VertexBufferInterface.VertexBuffersGen3 gr, bool denormalize)
        {
            int index = 0;

            foreach (s_tag_d3d_vertex_buffer_reference vbr in VertexBuffers)
            {
                var vb = vbr.Reference.Value;
                if (vb == null)
                {
                    s.WriteLine("VertexBuffer\t{0}\tNull", index.ToString("X8"));
                    s.WriteLine(); s.WriteLine();
                    index++;
                    continue;                     // wtf??
                }
                else
                {
                    s.WriteLine("VertexBuffer\t{0}", index.ToString("X8"));
                }

                var def = gr.DefinitionFind((short)vb.VertxType.Value) as Render.VertexBufferInterface.VertexBuffersGen3.Definition;
                s.WriteLine("\tSize\t{0}\tCount\t{1}\tType\t{2}",
                            vb.VertexSize.Value.ToString("X4"), vb.VertexCount.Value.ToString("X8"), vb.VertxType.Value.ToString("X2"));
                s.WriteLine("\tDefinition Size\t{0}", def.Size.ToString("X4"));
                s.WriteLine();

                //DebugVerticesOld(s, gr, denormalize, def, vb); // from before StreamReader was written!
                DebugVertices(s, gr, denormalize, def, vb);

                index++;
            }
        }
        void DebugVerticesOld(StreamWriter s, Render.VertexBufferInterface.VertexBuffersGen3 gr, bool denormalize,
                              Render.VertexBufferInterface.VertexBuffersGen3.Definition def,
                              s_tag_d3d_vertex_buffer vb)
        {
            LowLevel.Math.real_quaternion quat;

            var elements = new Render.DeclarationTypes.IDeclType[def.Elements.Length];

            for (int x = 0; x < elements.Length; x++)
            {
                elements[x] = def.Elements[x].DeclarationType.AllocateDeclType();
            }

            using (var er = new IO.EndianReader(vb.VertexBuffer.Value, IO.EndianState.Big, this))
            {
                for (int x = 0; x < vb.VertexCount.Value; x++)                 // foreach vertex...
                {
                    s.WriteLine("\tVertex\t{0}", x.ToString("X8"));
                    foreach (Render.DeclarationTypes.IDeclType dt in elements) // and foreach type in the vertex...
                    {
                        dt.Read(er);                                           // load the type data
                        if (denormalize)
                        {
                            dt.Denormalize(out quat);
                            s.WriteLine("\t\t{0}", dt.ToString(quat));
                        }
                        else
                        {
                            s.WriteLine("\t\t{0}", dt.ToString());
                        }
                        s.Flush();
                    }
                    s.WriteLine();
                }
                s.WriteLine(); s.WriteLine();
            }
        }