Exemplo n.º 1
0
        private ArtToolInfo ImportArtToolInfo(COLLADA collada)
        {
            ZUp = false;
            var toolInfo = new ArtToolInfo();

            toolInfo.FromArtToolName      = "Unknown";
            toolInfo.ArtToolMajorRevision = 1;
            toolInfo.ArtToolMinorRevision = 0;
            toolInfo.ArtToolPointerSize   = Options.Is64Bit ? 64 : 32;
            toolInfo.Origin = new float[] { 0, 0, 0 };
            toolInfo.SetYUp();

            if (collada.asset != null)
            {
                if (collada.asset.unit != null)
                {
                    if (collada.asset.unit.name == "meter")
                    {
                        toolInfo.UnitsPerMeter = (float)collada.asset.unit.meter;
                    }
                    else if (collada.asset.unit.name == "centimeter")
                    {
                        toolInfo.UnitsPerMeter = (float)collada.asset.unit.meter * 100;
                    }
                    else
                    {
                        throw new NotImplementedException("Unsupported asset unit type: " + collada.asset.unit.name);
                    }
                }

                if (collada.asset.contributor != null && collada.asset.contributor.Length > 0)
                {
                    var contributor = collada.asset.contributor.First();
                    if (contributor.authoring_tool != null)
                    {
                        toolInfo.FromArtToolName = contributor.authoring_tool;
                    }
                }

                switch (collada.asset.up_axis)
                {
                case UpAxisType.X_UP:
                    throw new Exception("X-up not supported yet!");

                case UpAxisType.Y_UP:
                    toolInfo.SetYUp();
                    break;

                case UpAxisType.Z_UP:
                    ZUp = true;
                    toolInfo.SetZUp();
                    break;
                }
            }

            return(toolInfo);
        }