Exemplo n.º 1
0
MOboolean moPreEffectErase::Init()
{
    if (!PreInit()) return false;

    moDefineParamIndex( ERASE_ALPHA, moText("alpha") );
    moDefineParamIndex( ERASE_COLOR, moText("color") );

	return true;
}
Exemplo n.º 2
0
MOboolean moCalibrationGrid::Init() {

    if (!PreInit()) return false;

	moDefineParamIndex( CALIBRATIONGRID_ALPHA, moText("alpha") );
	moDefineParamIndex( CALIBRATIONGRID_COLOR, moText("color") );

    Tx = Ty = Tz = Rx = Ry = Rz = 0.0;
	Sx = Sy = Sz = 1.0;

	return true;
}
MOboolean
moPostEffectColorFilter::Init()
{
    if (!PreInit()) return false;

	moDefineParamIndex( COLORFILTER_COLOR, moText("color") );
	moDefineParamIndex( COLORFILTER_BLENDING, moText("blending") );
	moDefineParamIndex( COLORFILTER_SENSIBILITY, moText("sensibility") );
	moDefineParamIndex( COLORFILTER_SYNCRO, moText("syncro") );
	UpdateParameters();

	moTextArray filter_str;
	filter_str.Init(1, moText(""));
	filter_str.Set(0, moText("effects_texture shaders/ColorMatrix.cfg colorfilter_texture"));
	bool res = filters.Init(&filter_str, m_pResourceManager->GetGLMan(), m_pResourceManager->GetFBMan(), m_pResourceManager->GetShaderMan(), m_pResourceManager->GetTextureMan(), m_pResourceManager->GetRenderMan());

	int tex_moid = m_pResourceManager->GetTextureMan()->GetTextureMOId("colorfilter_texture", false);
	tex_glid = m_pResourceManager->GetTextureMan()->GetGLId(tex_moid);

	if (!res)
	{
		MODebug->Push("Error: cannot load shader in colorfilter");
		return false;
	}

	FilterParams = MOEmptyTexFilterParam;
	ColorMatrix.Init();
	HSIMatrix.Init(true, 0.0, 4.0, 0.0, 4.0);
	BCMatrix.Init(-1.0, 1.0, 0.0, 4.0);
	intensity0 = saturation0 = intensity = saturation = 0.25;
	hue0 = hue = 0.0;
	brightness0 = brightness = 0.5;
	contrast0 = contrast = 0.25;
	HSIMatrix.Update(intensity, saturation, hue);
	BCMatrix.Update(brightness, contrast);
	ColorMatrix.Copy(HSIMatrix);
	ColorMatrix.Multiply(BCMatrix);
	FilterParams.par_mat4 = ColorMatrix.GetMatrixPointer();

    sWidth = m_pResourceManager->GetRenderMan()->RenderWidth();
    sHeight = m_pResourceManager->GetRenderMan()->RenderHeight();

    if(m_Config.GetPreConfCount() > 0)
        m_Config.PreConfFirst();
		
	return true;
}
MOboolean
moPostEffectVideoWall::Init()
{
    if (!PreInit()) return false;

    moDefineParamIndex( VIDEOWALL_INLET, moText("inlets") );
    moDefineParamIndex( VIDEOWALL_OUTLET, moText("outlets") );
    moDefineParamIndex( VIDEOWALL_SCRIPT, moText("script") );
    moDefineParamIndex( VIDEOWALL_ALPHA, moText("alpha") );
    moDefineParamIndex( VIDEOWALL_SYNCRO, moText("syncro") );
    moDefineParamIndex( VIDEOWALL_PHASE, moText("phase") );
	moDefineParamIndex( VIDEOWALL_COLOR, moText("color") );
	moDefineParamIndex( VIDEOWALL_CONFIGURATION, moText("configuration") );
	moDefineParamIndex( VIDEOWALL_TRANSLATEZ, moText("translatez") );

	return true;
}
Exemplo n.º 5
0
MOboolean
moPostEffectDebug::Init()
{
    if (!PreInit()) return false;

	moDefineParamIndex( DEBUG_ALPHA, moText("alpha") );
	moDefineParamIndex( DEBUG_COLOR, moText("color") );
	moDefineParamIndex( DEBUG_SYNC, moText("syncro") );
	moDefineParamIndex( DEBUG_PHASE, moText("phase") );
	moDefineParamIndex( DEBUG_FONT, moText("font") );


	ticks = 0;
	fps_current = 0;
	fps_mean = 0;
	fps_count = 0;

	MODebug2->Message(moText("Debug initialized"));

	return true;
}
Exemplo n.º 6
0
MOboolean moDeformationGrid::Init() {

    if (!PreInit()) return false;

	moDefineParamIndex( DEFORMATIONGRID_ALPHA, moText("alpha") );
	moDefineParamIndex( DEFORMATIONGRID_COLOR, moText("color") );
	moDefineParamIndex( DEFORMATIONGRID_SYNC, moText("syncro") );
	moDefineParamIndex( DEFORMATIONGRID_PHASE, moText("phase") );
	moDefineParamIndex( DEFORMATIONGRID_TEXTURE, moText("texture") );

	moDefineParamIndex( DEFORMATIONGRID_WIDTH, moText("width") );
	moDefineParamIndex( DEFORMATIONGRID_HEIGHT, moText("height") );
	moDefineParamIndex( DEFORMATIONGRID_POINTS, moText("points") );
	moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_X1, moText("texcoord_x1") );
	moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_Y1, moText("texcoord_y1") );
	moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_X2, moText("texcoord_x2") );
	moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_Y2, moText("texcoord_y2") );

	moDefineParamIndex( DEFORMATIONGRID_TRANSLATEX, moText("translatex") );
	moDefineParamIndex( DEFORMATIONGRID_TRANSLATEY, moText("translatey") );
	moDefineParamIndex( DEFORMATIONGRID_TRANSLATEZ, moText("translatez") );
	moDefineParamIndex( DEFORMATIONGRID_ROTATEX, moText("rotatex") );
	moDefineParamIndex( DEFORMATIONGRID_ROTATEY, moText("rotatey") );
	moDefineParamIndex( DEFORMATIONGRID_ROTATEZ, moText("rotatez") );
	moDefineParamIndex( DEFORMATIONGRID_SCALEX, moText("scalex") );
	moDefineParamIndex( DEFORMATIONGRID_SCALEY, moText("scaley") );
	moDefineParamIndex( DEFORMATIONGRID_SCALEZ, moText("scalez") );

	moDefineParamIndex( DEFORMATIONGRID_SHOWGRID, moText("showgrid") );
	moDefineParamIndex( DEFORMATIONGRID_CLEAR, moText("clear") );
	moDefineParamIndex( DEFORMATIONGRID_PRECISION, moText("precision") );
	moDefineParamIndex( DEFORMATIONGRID_MODE, moText("mode") );

    m_Width = 0;
    m_Height = 0;
    pImage = NULL;
    m_Points = NULL;
    m_TPoints = NULL;

    UpdateParameters();

    m_Selector_I = 0;
    m_Selector_J = 0;
    m_Modo = (moDeformationGridMode)m_Config.Int( moR(DEFORMATIONGRID_MODE) );

	return true;
}
Exemplo n.º 7
0
MOboolean moSceneEffect::Init()
{
  if (!PreInit()) return false;

  moDefineParamIndex( SCENE_INLET, "inlet" );
  moDefineParamIndex( SCENE_OUTLET, "outlet" );
  moDefineParamIndex( SCENE_SCRIPT, "script" );
  moDefineParamIndex( SCENE_ALPHA, "alpha" );
  moDefineParamIndex( SCENE_COLOR, "color" );
  moDefineParamIndex( SCENE_SYNC, "syncro" );
  moDefineParamIndex( SCENE_PHASE, "phase" );
  moDefineParamIndex( SCENE_PREEFFECTS, "preeffect" );
  moDefineParamIndex( SCENE_EFFECTS, "effect" );
  moDefineParamIndex( SCENE_POSTEFFECTS, "posteffect" );
  moDefineParamIndex( SCENE_STATES, "scene_states" );
  moDefineParamIndex( SCENE_SEQUENCE_MODE, "sequence_mode" );
  moDefineParamIndex( SCENE_SEQUENCE_DURATION, "sequence_duration" );
  moDefineParamIndex( SCENE_SEQUENCE_LOOP, "sequence_loop" );
  moDefineParamIndex( SCENE_CREATE_LAYER, "create_layer" );

  m_i_scene_states = -1;
	m_EffectManager.Init();
	m_EffectManager.m_pEffectManager = &m_EffectManager;
	m_EffectManager.m_pResourceManager = GetResourceManager();

	moEffect* newEffect = NULL;
  bool res = false;
  int pre=-1,on=-1;
	/** CREATING NEW LAYER!! */
	//RenderMan->CreateNewLayer( this );

  m_Config.SetCurrentParam( "preeffect" );
	if (m_Config.FirstValue()) {
    do {
      moValue& mVal(m_Config.GetCurrentValue());
      moMobDefinition MoldeoObjectDef( mVal.GetSubValue( MO_CFG_EFFECT).Text(), mVal.GetSubValue( MO_CFG_EFFECT_CONFIG).Text(),
                                        MO_OBJECT_PREEFFECT, mVal.GetSubValue( MO_CFG_EFFECT_LABEL).Text() );

      newEffect = m_EffectManager.New( MoldeoObjectDef );
      if (newEffect) {
          res = newEffect->Init();
          pre = mVal.GetSubValue(MO_CFG_EFFECT_PRE).Int();
          on = mVal.GetSubValue(MO_CFG_EFFECT_ON).Int();
          if (pre>=0) newEffect->GetConfig()->SetCurrentPreConf(pre);
          if (on>0) newEffect->Activate();
          else newEffect->Deactivate();
      }
    } while (m_Config.NextValue());
	}


  m_Config.SetCurrentParam( "effect" );
	if (m_Config.FirstValue()) {
    do {
      moValue& mVal(m_Config.GetCurrentValue());
      moMobDefinition MoldeoObjectDef( mVal.GetSubValue( MO_CFG_EFFECT).Text(), mVal.GetSubValue( MO_CFG_EFFECT_CONFIG).Text(),
                                        MO_OBJECT_EFFECT, mVal.GetSubValue( MO_CFG_EFFECT_LABEL).Text() );
      newEffect = m_EffectManager.New( MoldeoObjectDef );
      if (newEffect) {
          res = newEffect->Init();
          pre = mVal.GetSubValue(MO_CFG_EFFECT_PRE).Int();
          on = mVal.GetSubValue(MO_CFG_EFFECT_ON).Int();
          if (pre>=0) newEffect->GetConfig()->SetCurrentPreConf(pre);
          if (on>0) newEffect->Activate();
          else newEffect->Deactivate();
      }

    } while (m_Config.NextValue());
	}

  m_Config.SetCurrentParam( "posteffect" );
	if (m_Config.FirstValue()) {
    do {
      moValue& mVal(m_Config.GetCurrentValue());
      moMobDefinition MoldeoObjectDef( mVal.GetSubValue( MO_CFG_EFFECT).Text(), mVal.GetSubValue( MO_CFG_EFFECT_CONFIG).Text(),
                                        MO_OBJECT_POSTEFFECT, mVal.GetSubValue( MO_CFG_EFFECT_LABEL).Text() );
      newEffect = m_EffectManager.New( MoldeoObjectDef );
      if (newEffect) {
          res = newEffect->Init();
          pre = mVal.GetSubValue(MO_CFG_EFFECT_PRE).Int();
          on = mVal.GetSubValue(MO_CFG_EFFECT_ON).Int();
          if (pre>=0) newEffect->GetConfig()->SetCurrentPreConf(pre);
          if (on>0) newEffect->Activate();
          else newEffect->Deactivate();
      }

    } while (m_Config.NextValue());
	}


	m_Config.SetCurrentParam( "scene_states" );
	m_n_scene_states = m_Config.GetCurrentParam().GetValuesCount();

	int i_scene_states = 0;
	if (m_Config.FirstValue()) {
    do {
        moValue& mVal(m_Config.GetCurrentValue());
        moSceneState SceneState;

        if (mVal.GetSubValueCount()>1) {
          SceneState.m_state_name = mVal.GetSubValue( 0 ).Text();
          SceneState.Set( mVal.GetSubValue( 1 ).Text());
        }

        m_SceneStates[i_scene_states] = SceneState;

        MODebug2->Message("scene_states: " + mVal.GetSubValue( 0 ).Text() );
        i_scene_states+= 1;
    } while (m_Config.NextValue());
	}
	m_Config[ moR(SCENE_STATES)].SetIndexValue(0);

  m_Config.SetCurrentPreConf( 0 );

	return true;
}
Exemplo n.º 8
0
MOboolean
moMidi::Init() {

	moText conf;
	MOint i;

	// Loading config file.
	//levantamos el config del keyboard
	conf = m_pResourceManager->GetDataMan()->GetDataPath()+moText("/");
    conf += GetConfigName();
    conf += moText(".cfg");
	if (m_Config.LoadConfig(conf) != MO_CONFIG_OK ) {
		moText text = "Couldn't load midi config";
		MODebug2->Error(text);
		return false;
	}

	moMoldeoObject::Init();

	moDefineParamIndex( MIDI_DEVICE, moText("mididevice") );


	mididevices = m_Config.GetParamIndex("mididevice");

	MOint nvalues = m_Config.GetValuesCount( mididevices );
	m_Config.SetCurrentParamIndex( mididevices );

	/*
        MO_MIDI_SYTEM_LABELNAME	0
        MO_MIDI_SYSTEM_ON 1
	*/
	for( int i = 0; i < nvalues; i++) {

		m_Config.SetCurrentValueIndex( mididevices, i );

		moMidiDevicePtr pDevice = NULL;
		pDevice = new moMidiDevice();

		if (pDevice!=NULL) {
			pDevice->MODebug = MODebug;
			moText MidiDeviceCode = m_Config.GetParam().GetValue().GetSubValue(MO_MIDI_SYTEM_LABELNAME).Text();
			if ( pDevice->Init( MidiDeviceCode ) ) {
				pDevice->SetActive( m_Config.GetParam().GetValue().GetSubValue(MO_MIDI_SYSTEM_ON).Int() );
			} else {
				MODebug2->Error( moText("Midi Device not found: ") + (moText)MidiDeviceCode );
			}
		}

		m_MidiDevices.Add( pDevice );

	}



	//levantamos los codes definidos
	MOint coparam = m_Config.GetParamIndex("code");
	m_Config.SetCurrentParamIndex(coparam);
	MOint ncodes = m_Config.GetValuesCount(coparam);

	m_Config.FirstValue();

	printf("\nMIDI: ncodes:%i\n",ncodes);

	for( i = 0; i < ncodes; i++) {
		moMidiDataCode mididatacode;
		mididatacode.strcode = m_Config.GetParam().GetValue().GetSubValue(0).Text();
		mididatacode.devcode = i;
		mididatacode.mididata.m_Type = (moEncoderType)m_Config.GetParam().GetValue().GetSubValue(1).Int();
		mididatacode.mididata.m_Channel = m_Config.GetParam().GetValue().GetSubValue(2).Int();
		mididatacode.mididata.m_CC = m_Config.GetParam().GetValue().GetSubValue(3).Int();
		mididatacode.mididata.m_Val = 0;
		mididatacode.state = MO_FALSE;
/*

		Codes[i].value = MO_FALSE;
		*/
		m_Codes.Add( mididatacode );
		m_Config.NextValue();
	}
	return true;
}
Exemplo n.º 9
0
MOboolean moNetOSCOut::Init()
{
    int dev;
    MOuint i, n, n_dev, n_hosts;
    moText conf, dev_name;

    // Loading config file.
    if (moMoldeoObject::Init()) {
      moMoldeoObject::CreateConnectors();
    } else return false;


    moDefineParamIndex( NETOSCOUT_HOSTS, moText("hosts") );
    moDefineParamIndex( NETOSCOUT_PORT, moText("port") );
    moDefineParamIndex( NETOSCOUT_DEVICES, moText("devices") );
    moDefineParamIndex( NETOSCOUT_LATENCY, moText("latency") );
    moDefineParamIndex( NETOSCOUT_MAXEVENTS, moText("max_events") );
    moDefineParamIndex( NETOSCOUT_SENDEVENTS, moText("send_events") );
    moDefineParamIndex( NETOSCOUT_DELETEEVENTS, moText("delete_events") );
    moDefineParamIndex( NETOSCOUT_SENDMOLDEOAPI, moText("send_moldeo_api") );
    moDefineParamIndex( NETOSCOUT_DEBUG, moText("debug") );


    // Reading list of devices which will be used as source of events to send over the network.
    /*
    for(dev = MO_IODEVICE_KEYBOARD; dev <= MO_IODEVICE_TABLET; dev++) recog_devices[dev] = false;
    n = m_Config.GetParamIndex("devices");
    n_dev = m_Config.GetValuesCount(n);
    for(i = 0; i < n_dev; i++)
    {
		dev_name = m_Config.GetParam(n).GetValue(i).GetSubValue(0).Text();

        dev = -1;
        if(!stricmp(dev_name, "keyboard")) dev = MO_IODEVICE_KEYBOARD;
        if(!stricmp(dev_name, "mouse")) dev = MO_IODEVICE_MOUSE;
        if(!stricmp(dev_name, "midi")) dev = MO_IODEVICE_MIDI;
        if(!stricmp(dev_name, "mixer")) dev = MO_IODEVICE_MIXER;
        if(!stricmp(dev_name, "joystick")) dev = MO_IODEVICE_JOYSTICK;
		if(!stricmp(dev_name, "tablet")) dev = MO_IODEVICE_TABLET;
		if(!stricmp(dev_name, "tracker")) dev = MO_IODEVICE_TRACKER;

        if(-1 < dev) recog_devices[dev] = true;
    }
    */

    // Reading hosts names and ports.
    n = m_Config.GetParamIndex("hosts");
	n_hosts = m_Config.GetValuesCount(n);

	host_name.Init(n_hosts, moText(""));

    host_port.Init(n_hosts, 0);

    transmitSockets.Init(n_hosts,NULL);

    for(i = 0; i < n_hosts; i++)
    {
		host_name.Set(i, m_Config.GetParam(n).GetValue(i).GetSubValue(0).Text());
		host_port.Set(i, m_Config.GetParam(n).GetValue(i).GetSubValue(1).Int());
	}

    i = 0;

    UpdateParameters();

	for(i = 0; i < n_hosts; i++)
	{
#ifdef OSCPACK
	    unsigned long ii = GetHostByName(host_name[i]);
        char buffer[100];
        snprintf(buffer, 100, "%lu", ii); // Memory-safe version of sprintf.
        moText str = buffer;
	    //MODebug2->Message( moText("moNetOscOut:: host: ") + moText(host_name[i]) + moText(" ip int:") + (moText)str );
	    IpEndpointName ipendpointname( ii, host_port[i] ) ;
		transmitSockets[i] = new UdpTransmitSocket( ipendpointname );
#else
    //transmitSockets[i] = new lo::Address( host_name[i], IntToStr(host_port[i]) );
    transmitSockets[i] = lo_address_new( host_name[i], IntToStr(host_port[i]) );
#endif

		if (transmitSockets[i]) {
        MODebug2->Message(moText("NetOSCOut UdptransmitSocket Created at")+host_name[i]+":"+ IntToStr(host_port[i]) );
    }


	    //eventPacket[i] = new moEventPacket(sendInterval, maxEventNum);
	}

    //OUTPUT_BUFFER_SIZE = 1024; // 10 = maximum length of a 32 bit int in decimal rep.
    OUTPUT_BUFFER_SIZE = 60000;
    packetBuffer = new char[OUTPUT_BUFFER_SIZE];
    #ifdef OSCPACK
    packetStream = new osc::OutboundPacketStream( packetBuffer, OUTPUT_BUFFER_SIZE );
    #endif
	return true;
}
Exemplo n.º 10
0
MOboolean moEffectSampleTest::Init() {

    if (!PreInit()) return false;

	moDefineParamIndex( SAMPLETEST_ALPHA, moText("alpha") );
	moDefineParamIndex( SAMPLETEST_COLOR, moText("color") );
	moDefineParamIndex( SAMPLETEST_SYNC, moText("syncro") );
	moDefineParamIndex( SAMPLETEST_PHASE, moText("phase") );
	moDefineParamIndex( SAMPLETEST_TEXTURE, moText("texture") );
	moDefineParamIndex( SAMPLETEST_BLENDING, moText("blending") );
	moDefineParamIndex( SAMPLETEST_WIDTH, moText("width") );
	moDefineParamIndex( SAMPLETEST_HEIGHT, moText("height") );
	moDefineParamIndex( SAMPLETEST_TRANSLATEX, moText("translatex") );
	moDefineParamIndex( SAMPLETEST_TRANSLATEY, moText("translatey") );
	moDefineParamIndex( SAMPLETEST_TRANSLATEZ, moText("translatez") );
	moDefineParamIndex( SAMPLETEST_ROTATEX, moText("rotatex") );
	moDefineParamIndex( SAMPLETEST_ROTATEY, moText("rotatey") );
	moDefineParamIndex( SAMPLETEST_ROTATEZ, moText("rotatez") );
	moDefineParamIndex( SAMPLETEST_SCALEX, moText("scalex") );
	moDefineParamIndex( SAMPLETEST_SCALEY, moText("scaley") );
	moDefineParamIndex( SAMPLETEST_SCALEZ, moText("scalez") );
	moDefineParamIndex( SAMPLETEST_INLET, moText("inlet") );
	moDefineParamIndex( SAMPLETEST_OUTLET, moText("outlet") );

    Tx = Ty = Tz = Rx = Ry = Rz = 0.0;
	Sx = Sy = Sz = 1.0;

	return true;
}
Exemplo n.º 11
0
MOboolean moEffectSound::Init() {

    if (!PreInit()) return false;

	moDefineParamIndex( SOUND_ALPHA, moText("alpha") );
	moDefineParamIndex( SOUND_COLOR, moText("color") );
	moDefineParamIndex( SOUND_SYNC, moText("syncro") );
	moDefineParamIndex( SOUND_PHASE, moText("phase") );

	moDefineParamIndex( SOUND_SOUND, moText("sound") );
	moDefineParamIndex( SOUND_MODE, moText("mode") );
	moDefineParamIndex( SOUND_LOOP, moText("loop") );
	moDefineParamIndex( SOUND_LAUNCH, moText("launch") );

	moDefineParamIndex( SOUND_POSITION, moText("position") );
	moDefineParamIndex( SOUND_PITCH, moText("pitch") );
	moDefineParamIndex( SOUND_VOLUME, moText("volume") );
  moDefineParamIndex( SOUND_BALANCE, moText("balance") );

  moDefineParamIndex( SOUND_ECHO_DELAY, moText("echo_delay") );
  moDefineParamIndex( SOUND_ECHO_INTENSITY, moText("echo_intensity") );
  moDefineParamIndex( SOUND_ECHO_FEEDBACK, moText("echo_feedback") );

  moDefineParamIndex( SOUND_POSITION_IN, moText("position_in") );
  moDefineParamIndex( SOUND_POSITION_OUT, moText("position_out") );
  moDefineParamIndex( SOUND_FADE_IN, moText("fade_in") );
  moDefineParamIndex( SOUND_FADE_OUT, moText("fade_out") );

	moDefineParamIndex( SOUND_INLET, moText("inlet") );
	moDefineParamIndex( SOUND_OUTLET, moText("outlet") );

  m_UserPosition = 0;
	return true;
}
Exemplo n.º 12
0
MOboolean moNetOSCIn::Init()
{
    int dev;
    MOuint i, n, n_dev, n_hosts;
    moText conf, dev_name;

    //==========================
    // CORRESPONDE A UN PREINIT
    //==========================

    // Loading config file.
	conf = m_pResourceManager->GetDataMan()->GetDataPath() + moSlash;
    conf += GetConfigName();
    conf += moText(".cfg");

	if (m_Config.LoadConfig(conf) != MO_CONFIG_OK ) {
		moText text = "Couldn't load netoscin config";
		MODebug->Push(text);
		return false;
	}

    //==========================
    // INIT
    //==========================

	moDefineParamIndex( NETOSCIN_INLET, moText("inlet") );
	moDefineParamIndex( NETOSCIN_OUTLET, moText("outlet") );
	moDefineParamIndex( NETOSCIN_HOSTS , moText("hosts") );
	moDefineParamIndex( NETOSCIN_PORT , moText("port") );
	moDefineParamIndex( NETOSCIN_RECEIVEEVENTS, moText("receive_events") );

    bool events_present;
    bool trackersystem_present;

    events_present = false;
    trackersystem_present = false;

    for( int i=0; i<m_Config.GetParam( moR(NETOSCIN_OUTLET) ).GetValuesCount(); i++) {
        moValue val( m_Config.GetParam( moR(NETOSCIN_OUTLET) ).GetValue(i));
        if ( val.GetSubValue().Text()==moText("EVENTS")) {
            events_present = true;
        }
        if ( val.GetSubValue().Text()==moText("TRACKERSYSTEM")) {
            trackersystem_present = true;
        }
    }
    if (!events_present) {
        m_Config.GetParam( moR(NETOSCIN_OUTLET) ).AddValue( moValue( "EVENTS", "TXT", "DATA", "TXT" ).Ref() );
    }
    if (!trackersystem_present) {
        m_Config.GetParam( moR(NETOSCIN_OUTLET) ).AddValue( moValue( "EVENTS", "TXT", "DATA", "TXT" ).Ref() );
    }

    moMoldeoObject::Init();


    for(int a=0; a <GetOutlets()->Count(); a++) {
        if ( m_Outlets[a]->GetConnectorLabelName() == moText("EVENTS") ) {
            m_pEvents = m_Outlets[a];
        }
    }

    // Reading hosts names and ports.
    n = m_Config.GetParamIndex("hosts");
	n_hosts = m_Config.GetValuesCount(n);
	host_name.Init(n_hosts, moText(""));
    host_port.Init(n_hosts, 0);
    for(i = 0; i < n_hosts; i++)
    {
		host_name.Set(i, m_Config.GetParam(n).GetValue(i).GetSubValue(0).Text());
		host_port.Set(i, m_Config.GetParam(n).GetValue(i).GetSubValue(1).Int());
	}

	for(i = 0; i < n_hosts; i++)
	{
		moOscPacketListener*    pListener = NULL;

		pListener = new moOscPacketListener();
        if (pListener) {
            /*
            if ( host_name[i] == moText("all") ) {
                if (host_port[i]>0)
                    pListener->Set( new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS,
                                                                host_port[i] ),
                                                               pListener ) );
                else
                    pListener->Set( new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS,
                                                                IpEndpointName::ANY_PORT ),
                                                               pListener ) );
            } else if ( host_name[i] != moText("") ) {
                moTextArray ipNumbers;
                unsigned long ipaddress = 0;
                unsigned long i1=0, i2=0, i3=0, i4=0;
                ipNumbers = host_name[i].Explode(".");
                if (ipNumbers.Count()==4) {
                    i1 = atoi(ipNumbers[0]);
                    i2 = atoi(ipNumbers[1]);
                    i3 = atoi(ipNumbers[2]);
                    i4 = atoi(ipNumbers[3]);
                    ipaddress = (i1 << 24) & (i2<<16) & (i3<<8) & i4;
                } else {
                    ipaddress = IpEndpointName::ANY_ADDRESS;
                }
                if (host_port[i]>0)
                    pListener->Set( new UdpListeningReceiveSocket( IpEndpointName( ipaddress,
                                                                host_port[i] ),
                                                               pListener ) );
                else
                    pListener->Set( new UdpListeningReceiveSocket( IpEndpointName( ipaddress,
                                                                IpEndpointName::ANY_PORT ),
                                                               pListener ) );
            } else {
                pListener->Set( new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS,
                                                                IpEndpointName::ANY_PORT ),
                                                               pListener ) );
            }
*/
            UdpListeningReceiveSocket   *socket = NULL;

            try {
                socket = new UdpListeningReceiveSocket(
                IpEndpointName( IpEndpointName::ANY_ADDRESS, host_port[i] ),
                pListener );
            } catch (std::exception &e) {
                MODebug2->Error(moText("could not bind to UDP port "));
                socket = NULL;
            }

            if (socket!=NULL) {
                if (!socket->IsBound()) {
                    delete socket;
                    socket = NULL;
                    MODebug2->Error( moText("NETOSCIN UDP socket not connected:") +
                                    + (moText)host_name[i]
                                    + moText(" PORT:")
                                    + IntToStr(host_port[i])
                                    );
                } else {
                   MODebug2->Message( moText("NetOSCIn listening to OSC messages on UDP port "));
                   pListener->Set(socket);
                }
            }
            if (socket) {
                m_OscPacketListeners.Add( pListener );
                if (pListener->CreateThread()) {
                    MODebug2->Message( moText(" NETOSCIN OK: HOST NAME:")
                                            + (moText)host_name[i]
                                            + moText(" PORT:")
                                            + IntToStr(host_port[i])

                                            );
                } else {
                    MODebug2->Error( moText("NETOSCIN:") +
                                    + (moText)host_name[i]
                                    + moText(" PORT:")
                                    + IntToStr(host_port[i])
                                    );
                }
            }
       }
	}


	return true;
}
Exemplo n.º 13
0
MOboolean
moEffectCubeMap::Init() {

    if (!PreInit()) return false;

	moDefineParamIndex( CUBEMAP_ALPHA, moText("alpha") );
	moDefineParamIndex( CUBEMAP_COLOR, moText("color") );
	moDefineParamIndex( CUBEMAP_SYNC, moText("syncro") );
	moDefineParamIndex( CUBEMAP_PHASE, moText("phase") );
	moDefineParamIndex( CUBEMAP_TEXTURELEFT, moText("textureleft") );
	moDefineParamIndex( CUBEMAP_TEXTUREFRONT, moText("texturefront") );
	moDefineParamIndex( CUBEMAP_TEXTURERIGHT, moText("textureright") );
	moDefineParamIndex( CUBEMAP_TEXTUREBACK, moText("textureback") );
	moDefineParamIndex( CUBEMAP_TEXTURETOP, moText("texturetop") );
	moDefineParamIndex( CUBEMAP_TEXTUREBOTTOM, moText("texturebottom") );
	moDefineParamIndex( CUBEMAP_TRANSLATEX, moText("translatex") );
	moDefineParamIndex( CUBEMAP_TRANSLATEY, moText("translatey") );
	moDefineParamIndex( CUBEMAP_TRANSLATEZ, moText("translatez") );
	moDefineParamIndex( CUBEMAP_ROTATEX, moText("rotatex") );
	moDefineParamIndex( CUBEMAP_ROTATEY, moText("rotatey") );
	moDefineParamIndex( CUBEMAP_ROTATEZ, moText("rotatez") );
	moDefineParamIndex( CUBEMAP_SCALEX, moText("scalex") );
	moDefineParamIndex( CUBEMAP_SCALEY, moText("scaley") );
	moDefineParamIndex( CUBEMAP_SCALEZ, moText("scalez") );
	moDefineParamIndex( CUBEMAP_INLET, moText("inlet") );
	moDefineParamIndex( CUBEMAP_OUTLET, moText("outlet") );

	return true;
}