Пример #1
0
		public static void lib3ds_light_read(Lib3dsLight light, Lib3dsIo io)
		{
			Lib3dsChunk c=new Lib3dsChunk();
			Lib3dsChunks chunk;

			lib3ds_chunk_read_start(c, Lib3dsChunks.CHK_N_DIRECT_LIGHT, io);

			for(int i=0; i<3; i++) light.position[i]=lib3ds_io_read_float(io);
			lib3ds_chunk_read_tell(c, io);

			while((chunk=lib3ds_chunk_read_next(c, io))!=0)
			{
				switch(chunk)
				{
					case Lib3dsChunks.CHK_COLOR_F:
						for(int i=0; i<3; i++) light.color[i]=lib3ds_io_read_float(io);
						break;
					case Lib3dsChunks.CHK_DL_OFF: light.off=true; break;
					case Lib3dsChunks.CHK_DL_OUTER_RANGE: light.outer_range=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_INNER_RANGE: light.inner_range=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_MULTIPLIER: light.multiplier=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_EXCLUDE: lib3ds_chunk_unknown(chunk, io); break; // FIXME:
					case Lib3dsChunks.CHK_DL_ATTENUATE: light.attenuation=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_SPOTLIGHT: lib3ds_chunk_read_reset(c, io); spotlight_read(light, io); break;
					default: lib3ds_chunk_unknown(chunk, io); break;
				}
			}

			lib3ds_chunk_read_end(c, io);
		}
Пример #2
0
        public static Lib3dsSpotlightNode lib3ds_node_new_spotlight(Lib3dsLight light)
        {
            Debug.Assert(light != null);
            Lib3dsNode node = lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT);

            node.name = light.name;

            Lib3dsSpotlightNode n = (Lib3dsSpotlightNode)node;

            lib3ds_track_resize(n.pos_track, 1);
            lib3ds_vector_copy(n.pos_track.keys[0].value, light.position);

            lib3ds_track_resize(n.color_track, 1);
            lib3ds_vector_copy(n.color_track.keys[0].value, light.color);

            lib3ds_track_resize(n.hotspot_track, 1);
            n.hotspot_track.keys[0].value[0] = light.hotspot;

            lib3ds_track_resize(n.falloff_track, 1);
            n.falloff_track.keys[0].value[0] = light.falloff;

            lib3ds_track_resize(n.roll_track, 1);
            n.roll_track.keys[0].value[0] = light.roll;

            return(n);
        }
Пример #3
0
 public static void lib3ds_file_insert_light(Lib3dsFile file, Lib3dsLight light, int index)
 {
     Debug.Assert(file != null);
     if (index < 0)
     {
         file.lights.Add(light);
     }
     else
     {
         file.lights.Insert(index, light);
     }
 }
Пример #4
0
        static void spotlight_read(Lib3dsLight light, Lib3dsIo io)
        {
            Lib3dsChunk  c = new Lib3dsChunk();
            Lib3dsChunks chunk;

            lib3ds_chunk_read_start(c, Lib3dsChunks.CHK_DL_SPOTLIGHT, io);

            light.spot_light = true;
            for (int i = 0; i < 3; i++)
            {
                light.target[i] = lib3ds_io_read_float(io);
            }
            light.hotspot = lib3ds_io_read_float(io);
            light.falloff = lib3ds_io_read_float(io);
            lib3ds_chunk_read_tell(c, io);

            while ((chunk = lib3ds_chunk_read_next(c, io)) != 0)
            {
                switch (chunk)
                {
                case Lib3dsChunks.CHK_DL_SPOT_ROLL: light.roll = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_SHADOWED: light.shadowed = true; break;

                case Lib3dsChunks.CHK_DL_LOCAL_SHADOW2:
                    light.shadow_bias   = lib3ds_io_read_float(io);
                    light.shadow_filter = lib3ds_io_read_float(io);
                    light.shadow_size   = lib3ds_io_read_intw(io);
                    break;

                case Lib3dsChunks.CHK_DL_SEE_CONE: light.see_cone = true; break;

                case Lib3dsChunks.CHK_DL_SPOT_RECTANGULAR: light.rectangular_spot = true; break;

                case Lib3dsChunks.CHK_DL_SPOT_ASPECT: light.spot_aspect = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_SPOT_PROJECTOR:
                    light.use_projector = true;
                    light.projector     = lib3ds_io_read_string(io, 64);
                    break;

                case Lib3dsChunks.CHK_DL_SPOT_OVERSHOOT: light.spot_overshoot = true; break;

                case Lib3dsChunks.CHK_DL_RAY_BIAS: light.ray_bias = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_RAYSHAD: light.ray_shadows = true; break;

                default: lib3ds_chunk_unknown(chunk, io); break;
                }
            }

            lib3ds_chunk_read_end(c, io);
        }
Пример #5
0
        public static Lib3dsTargetNode lib3ds_node_new_spotligf_target(Lib3dsLight light)
        {
            Debug.Assert(light != null);
            Lib3dsNode node = lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT_TARGET);

            node.name = light.name;

            Lib3dsTargetNode n = (Lib3dsTargetNode)node;

            lib3ds_track_resize(n.pos_track, 1);
            lib3ds_vector_copy(n.pos_track.keys[0].value, light.target);

            return(n);
        }
Пример #6
0
		public static Lib3dsLight lib3ds_light_new(string name)
		{
			Debug.Assert(name!=null);
			Debug.Assert(name.Length<64);
			try
			{
				Lib3dsLight light=new Lib3dsLight();
				light.name=name;
				return light;
			}
			catch
			{
				return null;
			}
		}
Пример #7
0
 public static Lib3dsLight lib3ds_light_new(string name)
 {
     Debug.Assert(name != null);
     Debug.Assert(name.Length < 64);
     try
     {
         Lib3dsLight light = new Lib3dsLight();
         light.name = name;
         return(light);
     }
     catch
     {
         return(null);
     }
 }
Пример #8
0
        public static Lib3dsOmnilightNode lib3ds_node_new_omnilight(Lib3dsLight light)
        {
            Debug.Assert(light != null);
            Lib3dsNode node = lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_OMNILIGHT);

            node.name = light.name;

            Lib3dsOmnilightNode n = (Lib3dsOmnilightNode)node;

            lib3ds_track_resize(n.pos_track, 1);
            lib3ds_vector_copy(n.pos_track.keys[0].value, light.position);

            lib3ds_track_resize(n.color_track, 1);
            lib3ds_vector_copy(n.color_track.keys[0].value, light.color);

            return(n);
        }
Пример #9
0
        public static void lib3ds_light_read(Lib3dsLight light, Lib3dsIo io)
        {
            Lib3dsChunk  c = new Lib3dsChunk();
            Lib3dsChunks chunk;

            lib3ds_chunk_read_start(c, Lib3dsChunks.CHK_N_DIRECT_LIGHT, io);

            for (int i = 0; i < 3; i++)
            {
                light.position[i] = lib3ds_io_read_float(io);
            }
            lib3ds_chunk_read_tell(c, io);

            while ((chunk = lib3ds_chunk_read_next(c, io)) != 0)
            {
                switch (chunk)
                {
                case Lib3dsChunks.CHK_COLOR_F:
                    for (int i = 0; i < 3; i++)
                    {
                        light.color[i] = lib3ds_io_read_float(io);
                    }
                    break;

                case Lib3dsChunks.CHK_DL_OFF: light.off = true; break;

                case Lib3dsChunks.CHK_DL_OUTER_RANGE: light.outer_range = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_INNER_RANGE: light.inner_range = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_MULTIPLIER: light.multiplier = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_EXCLUDE: lib3ds_chunk_unknown(chunk, io); break;                         // FIXME:

                case Lib3dsChunks.CHK_DL_ATTENUATE: light.attenuation = lib3ds_io_read_float(io); break;

                case Lib3dsChunks.CHK_DL_SPOTLIGHT: lib3ds_chunk_read_reset(c, io); spotlight_read(light, io); break;

                default: lib3ds_chunk_unknown(chunk, io); break;
                }
            }

            lib3ds_chunk_read_end(c, io);
        }
Пример #10
0
		static void spotlight_read(Lib3dsLight light, Lib3dsIo io)
		{
			Lib3dsChunk c=new Lib3dsChunk();
			Lib3dsChunks chunk;

			lib3ds_chunk_read_start(c, Lib3dsChunks.CHK_DL_SPOTLIGHT, io);

			light.spot_light=true;
			for(int i=0; i<3; i++) light.target[i]=lib3ds_io_read_float(io);
			light.hotspot=lib3ds_io_read_float(io);
			light.falloff=lib3ds_io_read_float(io);
			lib3ds_chunk_read_tell(c, io);

			while((chunk=lib3ds_chunk_read_next(c, io))!=0)
			{
				switch(chunk)
				{
					case Lib3dsChunks.CHK_DL_SPOT_ROLL: light.roll=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_SHADOWED: light.shadowed=true; break;
					case Lib3dsChunks.CHK_DL_LOCAL_SHADOW2:
						light.shadow_bias=lib3ds_io_read_float(io);
						light.shadow_filter=lib3ds_io_read_float(io);
						light.shadow_size=lib3ds_io_read_intw(io);
						break;
					case Lib3dsChunks.CHK_DL_SEE_CONE: light.see_cone=true; break;
					case Lib3dsChunks.CHK_DL_SPOT_RECTANGULAR: light.rectangular_spot=true; break;
					case Lib3dsChunks.CHK_DL_SPOT_ASPECT: light.spot_aspect=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_SPOT_PROJECTOR:
						light.use_projector=true;
						light.projector=lib3ds_io_read_string(io, 64);
						break;
					case Lib3dsChunks.CHK_DL_SPOT_OVERSHOOT: light.spot_overshoot=true; break;
					case Lib3dsChunks.CHK_DL_RAY_BIAS: light.ray_bias=lib3ds_io_read_float(io); break;
					case Lib3dsChunks.CHK_DL_RAYSHAD: light.ray_shadows=true; break;
					default: lib3ds_chunk_unknown(chunk, io); break;
				}
			}

			lib3ds_chunk_read_end(c, io);
		}
Пример #11
0
		public static void lib3ds_light_free(Lib3dsLight light)
		{
		}
Пример #12
0
		public static void lib3ds_light_write(Lib3dsLight light, Lib3dsIo io)
		{
			Lib3dsChunk c_n_direct_light=new Lib3dsChunk();

			c_n_direct_light.chunk=Lib3dsChunks.CHK_N_DIRECT_LIGHT;
			lib3ds_chunk_write_start(c_n_direct_light, io);

			lib3ds_io_write_vector(io, light.position);
			{ // ---- LIB3DS_COLOR_F ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_COLOR_F;
				c.size=18;
				lib3ds_chunk_write(c, io);
				lib3ds_io_write_rgb(io, light.color);
			}
			if(light.off)
			{ // ---- LIB3DS_DL_OFF ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_DL_OFF;
				c.size=6;
				lib3ds_chunk_write(c, io);
			}
			{ // ---- LIB3DS_DL_OUTER_RANGE ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_DL_OUTER_RANGE;
				c.size=10;
				lib3ds_chunk_write(c, io);
				lib3ds_io_write_float(io, light.outer_range);
			}
			{ // ---- LIB3DS_DL_INNER_RANGE ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_DL_INNER_RANGE;
				c.size=10;
				lib3ds_chunk_write(c, io);
				lib3ds_io_write_float(io, light.inner_range);
			}
			{ // ---- LIB3DS_DL_MULTIPLIER ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_DL_MULTIPLIER;
				c.size=10;
				lib3ds_chunk_write(c, io);
				lib3ds_io_write_float(io, light.multiplier);
			}
			if(light.attenuation!=0)
			{ // ---- LIB3DS_DL_ATTENUATE ----
				Lib3dsChunk c=new Lib3dsChunk();
				c.chunk=Lib3dsChunks.CHK_DL_ATTENUATE;
				c.size=6;
				lib3ds_chunk_write(c, io);
			}

			if(light.spot_light)
			{
				Lib3dsChunk c_dl_spotlight=new Lib3dsChunk();

				c_dl_spotlight.chunk=Lib3dsChunks.CHK_DL_SPOTLIGHT;
				lib3ds_chunk_write_start(c_dl_spotlight, io);

				lib3ds_io_write_vector(io, light.target);
				lib3ds_io_write_float(io, light.hotspot);
				lib3ds_io_write_float(io, light.falloff);

				{ // ---- LIB3DS_DL_SPOT_ROLL ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SPOT_ROLL;
					c.size=10;
					lib3ds_chunk_write(c, io);
					lib3ds_io_write_float(io, light.roll);
				}
				if(light.shadowed)
				{ // ---- LIB3DS_DL_SHADOWED ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SHADOWED;
					c.size=6;
					lib3ds_chunk_write(c, io);
				}
				if((Math.Abs(light.shadow_bias)>EPSILON)||(Math.Abs(light.shadow_filter)>EPSILON)||(light.shadow_size!=0))
				{ // ---- LIB3DS_DL_LOCAL_SHADOW2 ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_LOCAL_SHADOW2;
					c.size=16;
					lib3ds_chunk_write(c, io);
					lib3ds_io_write_float(io, light.shadow_bias);
					lib3ds_io_write_float(io, light.shadow_filter);
					lib3ds_io_write_intw(io, (short)light.shadow_size);
				}
				if(light.see_cone)
				{ // ---- LIB3DS_DL_SEE_CONE ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SEE_CONE;
					c.size=6;
					lib3ds_chunk_write(c, io);
				}
				if(light.rectangular_spot)
				{ // ---- LIB3DS_DL_SPOT_RECTANGULAR ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SPOT_RECTANGULAR;
					c.size=6;
					lib3ds_chunk_write(c, io);
				}
				if(Math.Abs(light.spot_aspect)>EPSILON)
				{ // ---- LIB3DS_DL_SPOT_ASPECT ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SPOT_ASPECT;
					c.size=10;
					lib3ds_chunk_write(c, io);
					lib3ds_io_write_float(io, light.spot_aspect);
				}
				if(light.use_projector)
				{ // ---- LIB3DS_DL_SPOT_PROJECTOR ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SPOT_PROJECTOR;
					c.size=10;
					lib3ds_chunk_write(c, io);
					lib3ds_io_write_string(io, light.projector);
				}
				if(light.spot_overshoot)
				{ // ---- LIB3DS_DL_SPOT_OVERSHOOT ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_SPOT_OVERSHOOT;
					c.size=6;
					lib3ds_chunk_write(c, io);
				}
				if(Math.Abs(light.ray_bias)>EPSILON)
				{ // ---- LIB3DS_DL_RAY_BIAS ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_RAY_BIAS;
					c.size=10;
					lib3ds_chunk_write(c, io);
					lib3ds_io_write_float(io, light.ray_bias);
				}
				if(light.ray_shadows)
				{ // ---- LIB3DS_DL_RAYSHAD ----
					Lib3dsChunk c=new Lib3dsChunk();
					c.chunk=Lib3dsChunks.CHK_DL_RAYSHAD;
					c.size=6;
					lib3ds_chunk_write(c, io);
				}
				lib3ds_chunk_write_end(c_dl_spotlight, io);
			}

			lib3ds_chunk_write_end(c_n_direct_light, io);
		}
Пример #13
0
		public static Lib3dsTargetNode lib3ds_node_new_spotligf_target(Lib3dsLight light)
		{
			Debug.Assert(light!=null);
			Lib3dsNode node=lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT_TARGET);
			node.name=light.name;

			Lib3dsTargetNode n=(Lib3dsTargetNode)node;
			lib3ds_track_resize(n.pos_track, 1);
			lib3ds_vector_copy(n.pos_track.keys[0].value, light.target);

			return n;
		}
Пример #14
0
 public static void lib3ds_light_free(Lib3dsLight light)
 {
 }
Пример #15
0
        public static void lib3ds_light_write(Lib3dsLight light, Lib3dsIo io)
        {
            Lib3dsChunk c_n_direct_light = new Lib3dsChunk();

            c_n_direct_light.chunk = Lib3dsChunks.CHK_N_DIRECT_LIGHT;
            lib3ds_chunk_write_start(c_n_direct_light, io);

            lib3ds_io_write_vector(io, light.position);
            {             // ---- LIB3DS_COLOR_F ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_COLOR_F;
                c.size  = 18;
                lib3ds_chunk_write(c, io);
                lib3ds_io_write_rgb(io, light.color);
            }
            if (light.off)
            {             // ---- LIB3DS_DL_OFF ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_DL_OFF;
                c.size  = 6;
                lib3ds_chunk_write(c, io);
            }
            {             // ---- LIB3DS_DL_OUTER_RANGE ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_DL_OUTER_RANGE;
                c.size  = 10;
                lib3ds_chunk_write(c, io);
                lib3ds_io_write_float(io, light.outer_range);
            }
            {             // ---- LIB3DS_DL_INNER_RANGE ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_DL_INNER_RANGE;
                c.size  = 10;
                lib3ds_chunk_write(c, io);
                lib3ds_io_write_float(io, light.inner_range);
            }
            {             // ---- LIB3DS_DL_MULTIPLIER ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_DL_MULTIPLIER;
                c.size  = 10;
                lib3ds_chunk_write(c, io);
                lib3ds_io_write_float(io, light.multiplier);
            }
            if (light.attenuation != 0)
            {             // ---- LIB3DS_DL_ATTENUATE ----
                Lib3dsChunk c = new Lib3dsChunk();
                c.chunk = Lib3dsChunks.CHK_DL_ATTENUATE;
                c.size  = 6;
                lib3ds_chunk_write(c, io);
            }

            if (light.spot_light)
            {
                Lib3dsChunk c_dl_spotlight = new Lib3dsChunk();

                c_dl_spotlight.chunk = Lib3dsChunks.CHK_DL_SPOTLIGHT;
                lib3ds_chunk_write_start(c_dl_spotlight, io);

                lib3ds_io_write_vector(io, light.target);
                lib3ds_io_write_float(io, light.hotspot);
                lib3ds_io_write_float(io, light.falloff);

                {                 // ---- LIB3DS_DL_SPOT_ROLL ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SPOT_ROLL;
                    c.size  = 10;
                    lib3ds_chunk_write(c, io);
                    lib3ds_io_write_float(io, light.roll);
                }
                if (light.shadowed)
                {                 // ---- LIB3DS_DL_SHADOWED ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SHADOWED;
                    c.size  = 6;
                    lib3ds_chunk_write(c, io);
                }
                if ((Math.Abs(light.shadow_bias) > EPSILON) || (Math.Abs(light.shadow_filter) > EPSILON) || (light.shadow_size != 0))
                {                 // ---- LIB3DS_DL_LOCAL_SHADOW2 ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_LOCAL_SHADOW2;
                    c.size  = 16;
                    lib3ds_chunk_write(c, io);
                    lib3ds_io_write_float(io, light.shadow_bias);
                    lib3ds_io_write_float(io, light.shadow_filter);
                    lib3ds_io_write_intw(io, (short)light.shadow_size);
                }
                if (light.see_cone)
                {                 // ---- LIB3DS_DL_SEE_CONE ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SEE_CONE;
                    c.size  = 6;
                    lib3ds_chunk_write(c, io);
                }
                if (light.rectangular_spot)
                {                 // ---- LIB3DS_DL_SPOT_RECTANGULAR ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SPOT_RECTANGULAR;
                    c.size  = 6;
                    lib3ds_chunk_write(c, io);
                }
                if (Math.Abs(light.spot_aspect) > EPSILON)
                {                 // ---- LIB3DS_DL_SPOT_ASPECT ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SPOT_ASPECT;
                    c.size  = 10;
                    lib3ds_chunk_write(c, io);
                    lib3ds_io_write_float(io, light.spot_aspect);
                }
                if (light.use_projector)
                {                 // ---- LIB3DS_DL_SPOT_PROJECTOR ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SPOT_PROJECTOR;
                    c.size  = 10;
                    lib3ds_chunk_write(c, io);
                    lib3ds_io_write_string(io, light.projector);
                }
                if (light.spot_overshoot)
                {                 // ---- LIB3DS_DL_SPOT_OVERSHOOT ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_SPOT_OVERSHOOT;
                    c.size  = 6;
                    lib3ds_chunk_write(c, io);
                }
                if (Math.Abs(light.ray_bias) > EPSILON)
                {                 // ---- LIB3DS_DL_RAY_BIAS ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_RAY_BIAS;
                    c.size  = 10;
                    lib3ds_chunk_write(c, io);
                    lib3ds_io_write_float(io, light.ray_bias);
                }
                if (light.ray_shadows)
                {                 // ---- LIB3DS_DL_RAYSHAD ----
                    Lib3dsChunk c = new Lib3dsChunk();
                    c.chunk = Lib3dsChunks.CHK_DL_RAYSHAD;
                    c.size  = 6;
                    lib3ds_chunk_write(c, io);
                }
                lib3ds_chunk_write_end(c_dl_spotlight, io);
            }

            lib3ds_chunk_write_end(c_n_direct_light, io);
        }
Пример #16
0
		public static Lib3dsOmnilightNode lib3ds_node_new_omnilight(Lib3dsLight light)
		{
			Debug.Assert(light!=null);
			Lib3dsNode node=lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_OMNILIGHT);
			node.name=light.name;

			Lib3dsOmnilightNode n=(Lib3dsOmnilightNode)node;
			lib3ds_track_resize(n.pos_track, 1);
			lib3ds_vector_copy(n.pos_track.keys[0].value, light.position);

			lib3ds_track_resize(n.color_track, 1);
			lib3ds_vector_copy(n.color_track.keys[0].value, light.color);

			return n;
		}
Пример #17
0
		public static Lib3dsSpotlightNode lib3ds_node_new_spotlight(Lib3dsLight light)
		{
			Debug.Assert(light!=null);
			Lib3dsNode node=lib3ds_node_new(Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT);
			node.name=light.name;

			Lib3dsSpotlightNode n=(Lib3dsSpotlightNode)node;
			lib3ds_track_resize(n.pos_track, 1);
			lib3ds_vector_copy(n.pos_track.keys[0].value, light.position);

			lib3ds_track_resize(n.color_track, 1);
			lib3ds_vector_copy(n.color_track.keys[0].value, light.color);

			lib3ds_track_resize(n.hotspot_track, 1);
			n.hotspot_track.keys[0].value[0]=light.hotspot;

			lib3ds_track_resize(n.falloff_track, 1);
			n.falloff_track.keys[0].value[0]=light.falloff;

			lib3ds_track_resize(n.roll_track, 1);
			n.roll_track.keys[0].value[0]=light.roll;

			return n;
		}
Пример #18
0
		public static void lib3ds_file_insert_light(Lib3dsFile file, Lib3dsLight light, int index)
		{
			Debug.Assert(file!=null);
			if(index<0) file.lights.Add(light);
			else file.lights.Insert(index, light);
		}
Пример #19
0
		static void light_dump(Lib3dsLight light)
		{
			Debug.Assert(light!=null);

			Console.WriteLine("  name:             {0}", light.name);
			Console.WriteLine("  spot_light:       {0}", light.spot_light?"yes":"no");
			Console.WriteLine("  see_cone:         {0}", light.see_cone?"yes":"no");
			Console.WriteLine("  color:            ({0},{1},{2})", light.color[0], light.color[1], light.color[2]);
			Console.WriteLine("  position          ({0},{1},{2})", light.position[0], light.position[1], light.position[2]);
			Console.WriteLine("  target            ({0},{1},{2})", light.target[0], light.target[1], light.target[2]);
			Console.WriteLine("  roll:             {0}", light.roll);
			Console.WriteLine("  off:              {0}", light.off?"yes":"no");
			Console.WriteLine("  outer_range:      {0}", light.outer_range);
			Console.WriteLine("  inner_range:      {0}", light.inner_range);
			Console.WriteLine("  multiplier:       {0}", light.multiplier);
			Console.WriteLine("  attenuation:      {0}", light.attenuation);
			Console.WriteLine("  rectangular_spot: {0}", light.rectangular_spot?"yes":"no");
			Console.WriteLine("  shadowed:         {0}", light.shadowed?"yes":"no");
			Console.WriteLine("  shadow_bias:      {0}", light.shadow_bias);
			Console.WriteLine("  shadow_filter:    {0}", light.shadow_filter);
			Console.WriteLine("  shadow_size:      {0}", light.shadow_size);
			Console.WriteLine("  spot_aspect:      {0}", light.spot_aspect);
			Console.WriteLine("  use_projector:    {0}", light.use_projector?"yes":"no");
			Console.WriteLine("  projector:        {0}", light.projector);
			Console.WriteLine("  spot_overshoot:   {0}", light.spot_overshoot?"yes":"no");
			Console.WriteLine("  ray_shadows:      {0}", light.ray_shadows?"yes":"no");
			Console.WriteLine("  ray_bias:         {0}", light.ray_bias);
			Console.WriteLine("  hotspot:          {0}", light.hotspot);
			Console.WriteLine("  falloff:          {0}", light.falloff);
			Console.WriteLine();
		}
Пример #20
0
        static void named_object_read(Lib3dsFile file, Lib3dsIo io)
        {
            Lib3dsChunk  c = new Lib3dsChunk();
            string       name;
            Lib3dsChunks chunk;

            Lib3dsMesh        mesh         = null;
            Lib3dsCamera      camera       = null;
            Lib3dsLight       light        = null;
            Lib3dsObjectFlags object_flags = 0;

            lib3ds_chunk_read_start(c, Lib3dsChunks.CHK_NAMED_OBJECT, io);

            name = lib3ds_io_read_string(io, 64);
            lib3ds_io_log(io, Lib3dsLogLevel.LIB3DS_LOG_INFO, "NAME={0}", name);
            lib3ds_chunk_read_tell(c, io);

            while ((chunk = lib3ds_chunk_read_next(c, io)) != 0)
            {
                switch (chunk)
                {
                case Lib3dsChunks.CHK_N_TRI_OBJECT:
                    mesh = lib3ds_mesh_new(name);
                    lib3ds_file_insert_mesh(file, mesh, -1);
                    lib3ds_chunk_read_reset(c, io);
                    lib3ds_mesh_read(file, mesh, io);
                    break;

                case Lib3dsChunks.CHK_N_CAMERA:
                    camera = lib3ds_camera_new(name);
                    lib3ds_file_insert_camera(file, camera, -1);
                    lib3ds_chunk_read_reset(c, io);
                    lib3ds_camera_read(camera, io);
                    break;

                case Lib3dsChunks.CHK_N_DIRECT_LIGHT:
                    light = lib3ds_light_new(name);
                    lib3ds_file_insert_light(file, light, -1);
                    lib3ds_chunk_read_reset(c, io);
                    lib3ds_light_read(light, io);
                    break;

                case Lib3dsChunks.CHK_OBJ_HIDDEN: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_HIDDEN; break;

                case Lib3dsChunks.CHK_OBJ_DOESNT_CAST: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_DOESNT_CAST; break;

                case Lib3dsChunks.CHK_OBJ_VIS_LOFTER: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_VIS_LOFTER; break;

                case Lib3dsChunks.CHK_OBJ_MATTE: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_MATTE; break;

                case Lib3dsChunks.CHK_OBJ_DONT_RCVSHADOW: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_DONT_RCVSHADOW; break;

                case Lib3dsChunks.CHK_OBJ_FAST: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_FAST; break;

                case Lib3dsChunks.CHK_OBJ_FROZEN: object_flags |= Lib3dsObjectFlags.LIB3DS_OBJECT_FROZEN; break;

                default: lib3ds_chunk_unknown(chunk, io); break;
                }
            }

            if (mesh != null)
            {
                mesh.object_flags = object_flags;
            }
            if (camera != null)
            {
                camera.object_flags = object_flags;
            }
            if (light != null)
            {
                light.object_flags = object_flags;
            }

            lib3ds_chunk_read_end(c, io);
        }