// ---------------------------------------------------------------------------- // ScenePixelAnimator* VenueReader::read( TiXmlElement* self, ScenePixelAnimator* animation ) { animation = new ScenePixelAnimator(); animation->m_uid = (UID)read_dword_attribute( self, "uid" ); animation->m_name = read_text_element( self, "name" ); animation->m_description = read_text_element( self, "description" ); animation->m_effect = (PixelEffect)read_unsigned_attribute( self, "pixel_effect", 1 ); animation->m_generations = read_unsigned_attribute( self, "generations", 1 ); animation->m_num_pixels = read_unsigned_attribute( self, "pixels", 1 ); animation->m_increment = read_unsigned_attribute( self, "increment", 1 ); animation->m_color_fade = read_bool_attribute( self, "fade", 1 ); animation->m_combine_fixtures = read_bool_attribute( self, "combine", 1 ); animation->m_empty_color = read_rgbw_attribute( self, "pixel_off_color" ); TiXmlElement* signal_element = self->FirstChildElement( "signal" ); if ( signal_element ) { AnimationSignal* signal = read( signal_element, (AnimationSignal*)NULL ); animation->m_signal = *signal; delete signal; } read_uids( self, "pfuids", animation->m_actors ); read_colors( self, "custom_colors", animation->m_custom_colors ); return animation; }
// ---------------------------------------------------------------------------- // SceneActor* VenueReader::read( TiXmlElement* self, SceneActor* actor ) { actor = new SceneActor(); actor->m_uid = (UID)read_dword_attribute( self, "fixure_uid" ); actor->m_group = read_bool_attribute( self, "group", false ); TiXmlElement * container = self->FirstChildElement( "channels" ); channel_t max_channel = 0; if ( container ) { TiXmlElement* element = container->FirstChildElement( "channel" ); while ( element ) { channel_t channel = read_int_attribute( element, "number" ); BYTE value = (BYTE)read_int_attribute( element, "value" ); actor->m_channel_values[ channel ] = value; if ( channel+1 > max_channel ) max_channel = channel+1; element = element->NextSiblingElement(); } } actor->m_channels = (size_t)max_channel; return actor; }
// ---------------------------------------------------------------------------- // Chase* VenueReader::read( TiXmlElement* self, Chase* chase ) { chase = new Chase; readDObject( self, chase, "chase_number" ); chase->m_delay_ms = (ULONG)read_dword_attribute( self, "delay_ms" ); chase->m_fade_ms = (ULONG)read_dword_attribute( self, "fade_ms" ); chase->m_repeat = read_bool_attribute( self, "repeat", true ); TiXmlElement* acts = self->FirstChildElement( "acts" ); if ( acts ) { TiXmlElement* element = acts->FirstChildElement( "act" ); while ( element ) { chase->m_acts.insert( read_unsigned_attribute( element, "number" ) ) ; element = element->NextSiblingElement(); } } // Add chase steps std::vector<ChaseStep *> steps = read_xml_list<ChaseStep>( self->FirstChildElement( "chase_steps" ), "chase_step" ); for ( std::vector<ChaseStep *>::iterator it=steps.begin(); it != steps.end(); ++it ) { chase->m_chase_steps.push_back( *(*it) ); delete (*it); } return chase; }
// ---------------------------------------------------------------------------- // MovementAnimation* VenueReader::read( TiXmlElement* self, MovementAnimation* movement ) { movement = new MovementAnimation(); movement->m_movement_type = (MovementAnimationType)read_unsigned_attribute( self, "type" ); movement->m_tilt_start = read_unsigned_attribute( self, "tilt_start_angle" ); movement->m_tilt_end = read_unsigned_attribute( self, "tilt_end_angle" ); movement->m_pan_start = read_unsigned_attribute( self, "pan_start_angle" ); movement->m_pan_end = read_unsigned_attribute( self, "pan_end_angle" ); movement->m_pan_increment = read_unsigned_attribute( self, "pan_increment" ); movement->m_speed = (BYTE)read_unsigned_attribute( self, "speed" ); movement->m_home_wait_periods = read_unsigned_attribute( self, "home_wait_periods" ); movement->m_dest_wait_periods = read_unsigned_attribute( self, "dest_wait_periods" ); movement->m_group_size = read_unsigned_attribute( self, "group_size" ); movement->m_positions = read_unsigned_attribute( self, "positions" ); movement->m_alternate_groups = read_bool_attribute( self, "alternate_groups" ); movement->m_backout_home_return = read_bool_attribute( self, "blackout_return" ); movement->m_run_once = read_bool_attribute( self, "run_once" ); movement->m_home_x = read_float_attribute( self, "home_x" ); movement->m_home_y = read_float_attribute( self, "home_y" ); movement->m_height = read_float_attribute( self, "height" ); movement->m_fixture_spacing = read_float_attribute( self, "fixture_spacing" ); movement->m_radius = read_float_attribute( self, "radius" ); movement->m_head_number = read_unsigned_attribute( self, "head_number" ); TiXmlElement* coordinates_element = self->FirstChildElement( "coordinate_list" ); if ( coordinates_element ) { TiXmlElement* element = coordinates_element->FirstChildElement( "coordinate" ); while ( element ) { UINT pan = read_unsigned_attribute( element, "pan" ); UINT tilt = read_unsigned_attribute( element, "tilt" ); movement->m_coordinates.push_back( FixtureCoordinate( pan, tilt ) ); element = element->NextSiblingElement(); } } return movement; }
// ---------------------------------------------------------------------------- // Venue * VenueReader::read( TiXmlElement* self, Venue* venue ) { venue = new Venue(); venue->m_scenes.clear(); // Kill the auto generated default scene venue->m_uid_pool = read_dword_attribute( self, "next_uid" ); venue->m_current_scene = (UID)read_dword_attribute( self, "current_scene" ); venue->m_name = read_text_element( self, "name" ); venue->m_description = read_text_element( self, "description" ); // Add all universes (up to the max, must be in correct order) std::vector<Universe *> universes = read_xml_list<Universe>( self->FirstChildElement( "dmx_universes" ), "universe" ); for ( std::vector<Universe *>::iterator it=universes.begin(); it != universes.end(); ++it ) { venue->addUniverse( (*it) ); } TiXmlElement *dimmer = self->FirstChildElement( "dimmer" ); if ( dimmer ) { venue->m_master_dimmer = (BYTE)read_int_attribute( dimmer, "master_dimmer" ); venue->m_auto_backout_ms = read_dword_attribute( dimmer, "auto_blackout" ); venue->m_whiteout_strobe_ms = read_unsigned_attribute( dimmer, "whiteout_strobe", venue->getWhiteoutStrobeMS() ); venue->m_whiteout_color = read_rgbw_attribute( dimmer, "whiteout_color", RGBWA::WHITE ); } TiXmlElement *audio = self->FirstChildElement( "audio" ); if ( audio ) { venue->m_audio_capture_device = read_text_element( audio, "capture_device" ); venue->m_audio_boost = (float)read_double_attribute( audio, "scale" ); venue->m_audio_boost_floor = (float)read_double_attribute( audio, "floor" ); venue->m_audio_sample_size = (UINT)read_unsigned_attribute( audio, "sample_size", 1024 ); } venue->m_venue_layout = read_text_element( self, "venue_layout" ); // Add all fixtures std::vector<Fixture *> fixtures = read_xml_list<Fixture>( self->FirstChildElement( "fixtures" ), "fixture" ); for ( std::vector<Fixture *>::iterator it=fixtures.begin(); it != fixtures.end(); ++it ) { venue->addFixture( *(*it) ); delete (*it); } // Add scenes std::vector<Scene *> scenes = read_xml_list<Scene>( self->FirstChildElement( "scenes" ), "scene" ); for ( std::vector<Scene *>::iterator it=scenes.begin(); it != scenes.end(); ++it ) { venue->addScene( *(*it), (*it)->getNumber() == DEFAULT_SCENE_NUMBER); delete (*it); } // Add fixture groups std::vector<FixtureGroup *> fixture_groups = read_xml_list<FixtureGroup>( self->FirstChildElement( "fixture_groups" ), "fixture_group" ); for ( std::vector<FixtureGroup *>::iterator it=fixture_groups.begin(); it != fixture_groups.end(); ++it ) { venue->addFixtureGroup( *(*it) ); delete (*it); } // Add chases std::vector<Chase *> chases = read_xml_list<Chase>( self->FirstChildElement( "chases" ), "chase" ); for ( std::vector<Chase *>::iterator it=chases.begin(); it != chases.end(); ++it ) { venue->addChase( *(*it) ); delete (*it); } // Add music mappings TiXmlElement *music_scenes_element = self->FirstChildElement( "music_scenes" ); if ( music_scenes_element ) { venue->m_music_scene_select_enabled = read_bool_attribute( music_scenes_element, "enabled" ); std::vector<MusicSceneSelector *> music_scenes = read_xml_list<MusicSceneSelector>( self->FirstChildElement( "music_scenes" ), "music_mapping" ); for ( std::vector<MusicSceneSelector *>::iterator it=music_scenes.begin(); it != music_scenes.end(); ++it ) { venue->addMusicMapping( *(*it) ); delete (*it); } } return venue; }
// ---------------------------------------------------------------------------- // Channel* DefinitionReader::read( TiXmlElement* self, Channel* channel ) { channel = new Channel(); try { channel->m_channel_offset = (channel_t)read_dword_attribute( self, "index" ); channel->m_type = Channel::convertTextToChannelType( read_text_attribute( self, "type" ) ); channel->m_name = read_text_element( self, "name" ); channel->m_is_color = read_bool_attribute( self, "color" ); channel->m_can_blackout = read_bool_attribute( self, "blackout" ); channel->m_can_whiteout = read_bool_attribute( self, "whiteout", true ); channel->m_default_value = (BYTE)read_int_attribute( self, "value" ); channel->m_home_value = (BYTE)read_int_attribute( self, "home_value" ); channel->m_pixel_index = (BYTE)read_int_attribute( self, "pixel" ); channel->m_head_number = (BYTE)read_int_attribute( self, "head" ); // If head number is not set on tilt or pan, default to 1 if ( channel->m_head_number == 0 && (channel->m_type == CHNLT_TILT || channel->m_type == CHNLT_PAN || channel->m_type == CHNLT_PAN_FINE || channel->m_type == CHNLT_TILT_FINE) ) channel->m_head_number = 1; STUDIO_ASSERT( channel->m_channel_offset > 0, "Channel '%s' index < 1", channel->m_name ); channel->m_channel_offset--; // Adjust offset for internal zero based TiXmlElement *dimmer = self->FirstChildElement( "dimmer" ); if ( dimmer ) { channel->m_is_dimmer = true; channel->m_lowest_intensity = (BYTE)read_int_attribute( dimmer, "lowest_intensity", 0 ); channel->m_highest_intensity = (BYTE)read_int_attribute( dimmer, "highest_intensity", 255 ); } else { channel->m_is_dimmer = ( channel->m_type == CHNLT_DIMMER ); // Implies this is the default 0-255 dimmer channel type channel->m_lowest_intensity = 0; channel->m_highest_intensity = 255; } // Add channel ranges std::vector<ChannelValueRange *> ranges = read_xml_list<ChannelValueRange>( self->FirstChildElement( "ranges" ), "range" ); for ( std::vector<ChannelValueRange *>::iterator it=ranges.begin(); it != ranges.end(); ++it ) { STUDIO_ASSERT( (*it)->getEnd() >= (*it)->getStart(), "Channel '%s' range %s invalid", channel->m_name, (*it)->getName() ); STUDIO_ASSERT( channel->getRange( (*it)->getEnd() ) == NULL, "Channel '%s' range %s overlaps", channel->m_name, (*it)->getName() ); STUDIO_ASSERT( channel->getRange( (*it)->getStart() ) == NULL, "Channel '%s' range %s overlaps", channel->m_name, (*it)->getName() ); channel->m_ranges.push_back( *(*it) ); delete (*it); } // Add angles std::vector<ChannelAngle *> angles = read_xml_list<ChannelAngle>( self->FirstChildElement( "angles" ), "angle" ); for ( std::vector<ChannelAngle *>::iterator it=angles.begin(); it != angles.end(); ++it ) { channel->m_angles[ (*it)->getAngle() ] = *(*it); delete (*it); } channel->generateAngleTable(); } catch( ... ) { delete channel; throw; } return channel; }