Jump to content

[SOLVED] Tracker Track via Script, how to?


photo

Recommended Posts

Hi,

 

I try to create a Tracker with a Track-Parameter via Script, but don't know how..

 

 

tracker = new Unigine::Tracker::Tracker();


Unigine::Tracker::TrackerTrack track = new Unigine::Tracker::TrackerTrack(tracker);
track.load("MyGame/tracks/myTrack.track");
 
So, how do I put my track I loaded now into a TrackerParameterTrack?
 
A short example where the weight goes from 1.0 to 0.0 over time would be awesome!
 
 
Cheers
Link to comment

Hi Oliver!

 

It's supposed to create tracker parameters in the editor as well as tracks themselves. So in code you just load proper tracks and control their playback.

 

Please look at the valley demo, especially at valley/tracks folder. Open up day_cycle_mixed.track in the editor and see how tracker parameter track are supposed to work. Also, take a look into valley's world script, where the weather blending logic is located.

Link to comment

So this means I can only setup them via the UI, not on runtime via Script?

 

We have like 50 Tracks that we want to blend from one into another... if we can not do this on runtime via script, we would have to create about 2500 tracker by hand.. :(

Link to comment

Hi there!

 

No, just use TrackerTrack::blend function instead of TrackerTrack::set. For example, in washington demo we have a bunch of tracks for environment like sun/moon rotation, wind, clouds, time of the day and so on and so forth.

 

Like in this code:

/*
 */
void init() {
	tracker = new Tracker();
	
	// load clip track
	main_track = tracker.loadTrack("washington/tracks/clip2.track");
	
	// load environment tracks
	sun_rotation = tracker.loadTrack("washington/tracks/sun_rotation.track");
	moon_rotation = tracker.loadTrack("washington/tracks/moon_rotation.track");
	day_cycle_sunny = tracker.loadTrack("washington/tracks/day_cycle_sunny.track");
	day_cycle_cloudy = tracker.loadTrack("washington/tracks/day_cycle_cloudy.track");
	clouds_control = tracker.loadTrack("washington/tracks/clouds_control.track");
	rain_control = tracker.loadTrack("washington/tracks/rain_control.track");
	wet_control = tracker.loadTrack("washington/tracks/wet_control.track");
	wind_control = tracker.loadTrack("washington/tracks/wind_force_control.track");
}

If we want to just play some cool stuff that was pre-made by our artists team then we just loop main track. Also, we have a bunch of functions that blend this tracks for precise control of environment behaviour:

/*
 */
void setEnvironmentTime(float time,float clouds) {
	sun_rotation.set(time);
	moon_rotation.set(time);
	day_cycle_cloudy.blend(time,clouds);
	day_cycle_sunny.blend(time,1.0f - clouds);
	clouds_control.set(clouds);
}

void setEnvironmentRain(float rain) {
	rain_control.blend(rain,rain);
	wet_control.set(rain);
}

void setEnvironmentWind(float wind) {
	wind_control.set(wind);
}
Link to comment
×
×
  • Create New...