private bool _LoadMaterial(BlendTypeRepository repository, BlendValueCapsule bMaterial, out Dictionary <DrawSystem.TextureTypes, TextureInfo> outTextureInfos, out MaterialBase outMaterial)
        {
            string mtlName = bMaterial.GetMember("id").GetMember("name").GetAllValueAsString();

            Console.WriteLine("    found material : " + mtlName);

            var    texInfos         = new Dictionary <DrawSystem.TextureTypes, TextureInfo>();
            string materialTypeName = Path.GetExtension(mtlName);

            switch (materialTypeName)
            {
            case "":
            case ".std":
                _LoadTextures(repository, bMaterial, ref texInfos,
                              new DrawSystem.TextureTypes[] { DrawSystem.TextureTypes.Diffuse0, DrawSystem.TextureTypes.Bump0 });
                outMaterial     = new StandardMaterial();
                outTextureInfos = texInfos;
                return(true);

            case ".map":
                _LoadTextures(repository, bMaterial, ref texInfos,
                              new DrawSystem.TextureTypes[] { DrawSystem.TextureTypes.Diffuse0 });
                outMaterial = new MinimapMaterial();
                texInfos.Add(DrawSystem.TextureTypes.MinimapRoute, new TextureInfo {
                    Name = "route.png", UvScale = new Vector2(1, 1)
                });                                                                                                                                             // add a special texture
                outTextureInfos = texInfos;
                return(true);

            case ".mark":
            {
                var prop = _FindCustomProperty(bMaterial.GetMember("id"), "id");
                if (prop == null)
                {
                    Debug.Fail("marker material must have id property");
                    break;
                }

                outMaterial     = MarkerMaterial.Create(prop.Value);
                outTextureInfos = texInfos;
            }
                return(true);

            default:
                Debug.Fail("unknown material type : " + materialTypeName);
                break;
            }

            outMaterial     = null;
            outTextureInfos = texInfos;
            return(false);
        }
Exemplo n.º 2
0
        public void Draw(IDrawContext context)
        {
            var    drawSys = DrawSystem.GetInstance();
            Matrix layout  = m_initParam.Layout;

            foreach (char c in m_text)
            {
                var   tex    = DrawSystem.TextureData.Null();
                float offset = 0.0f;
                switch (c)
                {
                case '.':
                    tex    = m_initParam.Dot;
                    offset = -0.22f;
                    break;

                default:
                    if ('0' <= c && c <= '9')
                    {
                        int num = (int)c - (int)'0';
                        tex    = m_initParam.Numbers[num];
                        offset = -0.3f;
                    }
                    break;
                }

                Debug.Assert(tex.Resource != null, "invalid character");
                context.DrawModel(layout * m_worldTrans, Color4.White, m_plane.NodeList[0].Mesh, StandardMaterial.Create(tex), DrawSystem.RenderMode.Transparency, null);
                layout *= Matrix.Translation(offset, 0, 0);
            }
        }