private static OpenGLVertex ConvertSingleVertex(ThreeD.Vertex v, UVTXFile?uvtx)
        {
            var texCoord = new Vector2();

            if (uvtx != null)
            {
                UVTXConverter.RDPState rdpState = UVTXConverter.ExecuteCommands(uvtx, out _);
                var tileDesc = rdpState.tileDescriptors[rdpState.tileToUseWhenTexturing];
                if (tileDesc.sLo == 0 && tileDesc.tLo == 0 && tileDesc.tHi == 0)
                {
                    //throw new Exception();
                }
                float origS   = ((short)v.unk1) / (float)0b100000;
                float origT   = ((short)v.unk2) / (float)0b100000;
                float openGLS = (origS - tileDesc.sLo) / (tileDesc.sHi - tileDesc.sLo);
                float openGLT = (origT - tileDesc.tLo) / (tileDesc.tHi - tileDesc.tLo);
                texCoord = new Vector2(openGLS, openGLT);
            }


            return(new OpenGLVertex
            {
                position = new Vector3(v.x, v.y, v.z),
                color = new Vector4(v.colorR, v.colorG, v.colorB, v.colorA) / 0xFF,
                texCoord = texCoord
            });
        }
        public void AddTexturedVertices(IList <ThreeD.Vertex> n64Verts, UVTXFile uvtx)
        {
            VertexDataSegment segment = new VertexDataSegment();

            segment.startIndex = verticesSoFar.Count;
            segment.length     = n64Verts.Count;
            segment.texture    = new Texture(UVTXConverter.GetBitmap(uvtx));

            UVTXConverter.GetBitmap(uvtx).Save("test.png");

            verticesSoFar.AddRange(UVMDVerticesToWindowVertices(n64Verts, uvtx));
            segments.Add(segment);
        }
Example #3
0
        static void Main(string[] args)
        {
            string action    = args[0];
            string romPath   = String.Join(" ", args.Skip(1)).Replace("\"", "");
            string outputDir = Path.GetFileNameWithoutExtension(romPath) + "/";

            switch (action)
            {
            case "dump-filesystem":
                FilesystemExtractor.ExtractToFolder(File.ReadAllBytes(romPath), outputDir);
                break;

            case "dump-converted-images":
                UVBTConverter.DumpBlits(File.ReadAllBytes(romPath), outputDir);
                UVTXConverter.DumpTextures(File.ReadAllBytes(romPath), outputDir);
                break;

            case "dump-converted-fonts":
                UVFTConverter.DumpFonts(File.ReadAllBytes(romPath), outputDir);
                break;

            case "show-models":
                UVMDDisplayer.DisplayModels(File.ReadAllBytes(romPath));
                break;

            case "show-tracks":
                UVTRParser.ParseUVTRs(File.ReadAllBytes(romPath));
                break;
            }

            // If we're the only process attached to the console, (e.g. if the user drags+drops a file onto the program)
            // then the console will close when the program exits. I'd rather not have this happen since most games will
            // extract far too quickly for the user to read any of the output.
            uint processCount = GetConsoleProcessList(new uint[64], 64);

            if (processCount == 1)
            {
                Console.ReadKey();
            }
        }