コード例 #1
0
        private byte[] GetBody()
        {
            ByteArray bytes = new ByteArray();

            // Write Packets Data
            for (int i = 0; i < _objects.Count; i++)
            {
                SEAObject asset = _objects[i];

                ByteArray data = new ByteArray();

                byte[] buffer = asset.Write().ToArray();

                data.WriteByte(asset.Flag);
                data.WriteTypeCode(asset.Type);

                if (asset.Named)
                {
                    data.WriteUTF8(asset.Name);
                }

                if (asset.Compressed)
                {
                    buffer = Compression.Compress(buffer, compressAlgorithm);
                }

                data.WriteBytes(buffer);

                bytes.WriteBytesObject(data.ToArray());
            }

            return(bytes.ToArray());
        }
コード例 #2
0
 private int GetIndex(SEAObject obj)
 {
     return(Writer.Objects.IndexOf(obj));
 }
コード例 #3
0
 public int AddObject(SEAObject obj)
 {
     _objects.Add(obj);
     return(_objects.Count - 1);
 }
コード例 #4
0
        private SEAMaterial AppendMaterial(Scene scene, Material material)
        {
            int sIndex = GetIndexByTag(material);

            if (sIndex != -1)
            {
                return((SEAMaterial)Writer.Objects[sIndex]);
            }

            SEAMaterial mat = new SEAMaterial(GetValidString(materials, material.Name));

            mat.doubleSided = material.IsTwoSided;

            mat.receiveLights  = true;
            mat.receiveShadows = true;
            mat.receiveFog     = true;

            mat.repeat = true;

            mat.alpha = material.Opacity;

            //
            //  DEFAULT
            //

            PhongTech defaultTech = new PhongTech();

            defaultTech.diffuseColor  = ToInteger(material.ColorDiffuse);
            defaultTech.specularColor = ToInteger(material.ColorSpecular);

            defaultTech.specular = material.ShininessStrength;
            defaultTech.gloss    = material.Shininess;

            mat.techniques.Add(defaultTech);

            //
            //  DIFFUSE_MAP
            //

            if (material.HasTextureDiffuse)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.TextureDiffuse);

                if (tex != null)
                {
                    DiffuseMapTech tech = new DiffuseMapTech();
                    tech.texture = GetIndex(tex);
                    mat.techniques.Add(tech);
                }
            }

            //
            //  SPECULAR_MAP
            //

            if (material.HasTextureSpecular)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.TextureSpecular);

                if (tex != null)
                {
                    SpecularMapTech tech = new SpecularMapTech();
                    tech.texture = GetIndex(tex);
                    mat.techniques.Add(tech);
                }
            }

            //
            //  EMISSIVE_MAP
            //

            if (material.HasTextureAmbient || material.HasTextureEmissive)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.HasTextureAmbient ? material.TextureAmbient : material.TextureEmissive);

                if (tex != null)
                {
                    EmissiveMapTech tech = new EmissiveMapTech();
                    tech.texture = GetIndex(tex);
                    mat.techniques.Add(tech);
                }
            }

            //
            //  NORMAL_MAP
            //

            if (material.HasTextureNormal)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.TextureNormal);

                if (tex != null)
                {
                    NormalMapTech tech = new NormalMapTech();
                    tech.texture = GetIndex(tex);
                    mat.techniques.Add(tech);
                }
            }

            //
            //  OPACITY_MAP
            //

            if (material.HasTextureOpacity)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.TextureOpacity);

                if (tex != null)
                {
                    OpacityMapTech tech = new OpacityMapTech();
                    tech.texture = GetIndex(tex);
                    mat.techniques.Add(tech);
                }
            }

            //
            //  REFLECTION_MAP
            //

            if (material.HasTextureReflection)
            {
                SEAObject tex = AppendTextureFromSlot(scene, material.TextureReflection);

                if (tex != null)
                {
                    ReflectionTech tech = new ReflectionTech();
                    tech.texture = GetIndex(tex);
                    tech.alpha   = material.Reflectivity;
                    mat.techniques.Add(tech);
                }
            }

            //  --

            mat.tag = material;

            materials.Add(mat);
            Writer.AddObject(mat);

            return(mat);
        }