示例#1
0
        public bool SetTexture(string name, string path)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Texture texture = null;

            try
            {
                texture = new warp_Texture(path);
            }
            catch (Exception)
            {
                return(false);
            }

            warp_Material material = (warp_Material)_scene.materialData[name];

            if (material == null)
            {
                return(false);
            }

            material.setTexture(texture);

            return(true);
        }
示例#2
0
        public bool SetBackgroundMaterial(string path)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = null;

            try
            {
                material = new warp_Material(path);
            }
            catch (Exception)
            {
                return(false);
            }

            warp_Texture texture = material.getTexture();

            if (texture == null)
            {
                return(false);
            }

            _scene.environment.setBackground(texture);

            return(true);
        }
示例#3
0
        public bool AddMaterial(string name, int color)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = new warp_Material(color);

            _scene.addMaterial(name, material);

            return(true);
        }
示例#4
0
        public void destroy()
        {
            name         = null;
            material     = null;
            matrix       = null;
            normalmatrix = null;
            parent       = null;

            fastvertex   = null;
            fasttriangle = null;
            vertexData.Clear();
            triangleData.Clear();
            vertexData   = null;
            triangleData = null;
        }
示例#5
0
        public void DisplayDefaultScene()
        {
            _scene = new warp_Scene(512, 512);

            warp_Material crystal = new warp_Material(warp_TextureFactory.MARBLE(128, 128, .15f));

            _scene.addMaterial("crystal", crystal);

            warp_Material c = (warp_Material)_scene.materialData["crystal"];

            c.setReflectivity(255);
            c.setTransparency(100);

            _scene.environment.setBackground(warp_TextureFactory.CHECKERBOARD(128, 128, 3, 0x000000, 0x999999));

            _scene.addLight("light1", new warp_Light(new warp_Vector(0.2f, 0.2f, 1f), 0xFFFFFF, 320, 80));
            _scene.addLight("light2", new warp_Light(new warp_Vector(-1f, -1f, 1f), 0xffffff, 100, 40));

            warp_Vector[] path = new warp_Vector[15];

            path[0]  = new warp_Vector(0.0f, 0.2f, 0);
            path[1]  = new warp_Vector(0.13f, 0.25f, 0);
            path[2]  = new warp_Vector(0.33f, 0.3f, 0);
            path[3]  = new warp_Vector(0.43f, 0.6f, 0);
            path[4]  = new warp_Vector(0.48f, 0.9f, 0);
            path[5]  = new warp_Vector(0.5f, 0.9f, 0);
            path[6]  = new warp_Vector(0.45f, 0.6f, 0);
            path[7]  = new warp_Vector(0.35f, 0.3f, 0);
            path[8]  = new warp_Vector(0.25f, 0.2f, 0);
            path[9]  = new warp_Vector(0.1f, 0.15f, 0);
            path[10] = new warp_Vector(0.1f, 0.0f, 0);
            path[11] = new warp_Vector(0.1f, -0.5f, 0);
            path[12] = new warp_Vector(0.35f, -0.55f, 0);
            path[13] = new warp_Vector(0.4f, -0.6f, 0);
            path[14] = new warp_Vector(0.0f, -0.6f, 0);

            _scene.addObject("wineglass", warp_ObjectFactory.ROTATIONOBJECT(path, 32));
            _scene.sceneobject("wineglass").setMaterial(_scene.material("crystal"));

            _scene.sceneobject("wineglass").scale(0.8f, 0.8f, 0.8f);
            _scene.sceneobject("wineglass").rotate(0.5f, 0f, 0f);

            _scene.render();

            //Refresh();
        }
示例#6
0
        public bool SetReflectivity(string name, int r)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = (warp_Material)_scene.materialData[name];

            if (material == null)
            {
                return(false);
            }

            material.setReflectivity(r);

            return(true);
        }
示例#7
0
        public bool SetWireframe(string name, bool w)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = ( warp_Material )_scene.materialData[name];

            if (material == null)
            {
                return(false);
            }

            material.setWireframe(w);

            return(true);
        }
示例#8
0
        public bool SetObjectMaterial(string name, string m)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = (warp_Material)_scene.materialData[m];

            if (material == null)
            {
                return(false);
            }

            _scene.sceneobject(name).setMaterial(material);

            return(true);
        }
示例#9
0
        public bool SetTransparency(string name, int t)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = (warp_Material)_scene.materialData[name];

            if (material == null)
            {
                return(false);
            }

            material.setTransparency(t);

            return(true);
        }
示例#10
0
        public bool AddMaterial(string name, string path)
        {
            if (_scene == null)
            {
                return(false);
            }

            warp_Material material = null;

            try
            {
                material = new warp_Material(path);
            }
            catch (Exception)
            {
                return(false);
            }

            _scene.addMaterial(name, material);

            return(true);
        }
示例#11
0
 public void setMaterial(warp_Material m)
 {
     material = m;
 }
示例#12
0
        // Material loader
        public void loadMaterial(warp_Object obj)
        {
            warp_Material material = obj.material;

            color        = material.color;
            reflectivity = material.reflectivity;
            texture      = material.texture;
            if (material.envmap != null)
            {
                envmap = material.envmap.pixel;
            }
            else
            {
                envmap = null;
            }

            if (texture != null)
            {
                if (obj.projectedmaxMips < 2)
                {
                    color   = warp_Color.multiply(color, texture.averageColor);
                    texture = null;
                }
                else
                {
                    int mip = obj.projectedmaxMips - 1;
                    if (mip > texture.maxmips)
                    {
                        mip = texture.maxmips;
                    }

                    if (texture.mips[mip] != null)
                    {
                        tpixels = texture.mips[mip];
                        tbitW   = texture.mipsBitWidth[mip];
                        tbitH   = texture.mipsBitHeight[mip];
                        tw      = texture.mipstw[mip] - 1;
                        th      = texture.mipsth[mip] - 1;
                    }
                    else
                    {
                        tpixels = texture.pixel;
                        tw      = texture.width - 1;
                        th      = texture.height - 1;
                        tbitW   = texture.bitWidth;
                        tbitH   = texture.bitHeight;
                    }
                }
            }

            mode = 0;
            if (!material.flat)
            {
                mode |= P;
            }
            if (envmap != null)
            {
                mode |= E;
            }
            if (texture != null)
            {
                mode |= T;
            }
            if (material.wireframe)
            {
                mode |= W;
            }

            shademode      = mode & SHADED;
            materialLoaded = true;
            ready          = lightmapLoaded;
        }
示例#13
0
 public void addMaterial(String key, warp_Material m)
 {
     materialData.Add(key, m);
 }