Jump to content

tracker api calls


photo

Recommended Posts

Hi Jonathan,

 

Currently tracker is not exported to C++ / C# API. We do have plan to implement tracker and expose it's API to C++ / C#.

I can suggest you to call script functions from C++ as a workaround.

In attachment you can find tracker_wrapper.h that you need to include to your world script (#include tracker_wrapper.h). In C++ you can do the following:

#include <UnigineInterpreter.h>
<...>

//inside init():

engine->runWorldFunction(Variable("TrackerWrapper::init"), Variable("clip.track")); // loading track

//inside update():
float min_time = (engine->runWorldFunction(Variable("TrackerWrapper::getMinTime"))).getFloat();
float max_time = (engine->runWorldFunction(Variable("TrackerWrapper::getMaxTime"))).getFloat();
float unit_time = (engine->runWorldFunction(Variable("TrackerWrapper::getUnitTime"))).getFloat();
 
time += ifps / unit_time;
if (time >= max_time) time = min_time;

engine->runWorldFunction(Variable("TrackerWrapper::set"), Variable(time));

<...>
//where engine and ifps are:
//Engine *engine = Engine::get();
//float ifps = Game::get()->getIFps();

Thanks!

tracker_wrapper.h

  • Like 2

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 1 year later...

Hi de-Roo.Lukas,

Simple put track and track_keys variables in some array in the tracker_wrapper.h file (and modify the methods accordingly).
Look at modified tracker_wrapper.h. It supports more than one tracks.

Best regards,
Alexander

tracker_wrapper.h

Link to comment
  • 11 months later...
On 1/29/2018 at 2:17 PM, alexander said:

Hi de-Roo.Lukas,

Simple put track and track_keys variables in some array in the tracker_wrapper.h file (and modify the methods accordingly).
Look at modified tracker_wrapper.h. It supports more than one tracks.

Best regards,
Alexander

tracker_wrapper.h

hi Alexander,

i followed your code, and loaded about 20 tracks at the same time, but it crashed in the script in the load_track function.

there is something wrong with the stack , the Machine::run() always use the code in the track script as its function address.

 

 

core/systems/tracker/tracker_parameter.h:861: Machine::run(): "PlayerSpectator 57583090 internal (139:0:0)" is not a user class
Stack dump:
0x0000: PlayerSpectator 57583090 internal (139:0:0)
0x0001: vec3: 0 1 0
0x0002: vec3: 0 0 1
0x0003: Unigine::Tracker::TrackerParameterVec3 0A53B010 (786434:0:0)
0x0004: string: "diffuse_color"
0x0005: Material 0B783F48 external (147:114:114)
0x0006: Unigine::Tracker::TrackerParameterColor::Track 6E3D1100 (262159:0:0)
0x0007: Unigine::Tracker::TrackerParameterColor 6E3CB050 (1048578:1:1)
0x0008: string: "material.parameterColor"
0x0009: Xml 6E3FD9C4 external (8:565:573)
0x000a: int: 5
0x000b: int: 2
0x000c: Xml 6E3FD650 internal (8:0:566)
0x000d: string: "my_track.track"
0x000e: Unigine::Tracker::TrackerTrack 6E409900 (2621442:9:9)
0x000f: Unigine::Tracker::TrackerTrack 6E3D0FC0 (2621442:2:2)
0x0010: string: "my_track.track"
0x0011: Unigine::Tracker::Tracker 0A53AFB0 (2883586:0:0)
0x0012: int: 1
0x0013: Unigine::Tracker::TrackerTrack 6E3D0EE0 (2621442:1:1)
0x0014: string: "my_track.track"

if(xml.getName() != "track" || xml.isArg("version") == 0 || strlen(xml.getArg("version")) == 0) {
core/systems/tracker/tracker_track.h:203: Machine::run(): "int: 0" is not an extern class
Stack dump:
0x0000: Unigine::Tracker::TrackerTrack 6E33AFC0 (2621442:2:2)
0x0001: Unigine::Tracker::Tracker 07F8FFB0 (2883586:0:0)
0x0002: TrackList 07F8FF90 (262144:0:0)
Call stack:
00: 0x00002f40 Unigine::Tracker::TrackerTrack::load()
01: 0x000035ea Unigine::Tracker::Tracker::loadTrack()

Link to comment
::class MyPlugin : public Unigine::Plugin
{
public:
    MyPlugin();
    virtual ~MyPlugin();

    virtual int init(){
		Unigine::Engine::get()->runWorldFunction(Variable("TrackerWrapper::init"));
		addPacketTrack(track_path_1);
		addPacketTrack(track_path_2);
		addPacketTrack(track_path_3);
		...
		addPacketTrack(track_path_20);
		return 0;
	}	
	void addPacketTrack(std::string path){
		Unigine::Engine::get()->runWorldFunction(Variable("TrackerWrapper::load"), Variable(path.c_str()));
	}
	...
}

i used 2.0 Unigine

Link to comment

Hi shichao,

There is something wrong with your "my_track.track" file. Tracker can't find a PlayerSpectator with id 57583090? Does it exist in the world? Have you loaded the world with that nodes before loading the tracks? I see you are using plugin for your code. Plugin::init() method called before loading any world. It's like a system logic class.

First of all, load the world. Then, you can load the tracks.

Best regards,
Alexander

Link to comment

hi Alexander,

world is loaded with the engine begins,

tracks are all well pleyed in the script 

Does c++ tracker API support now?

if supported , and which SDK version?

thanks 

Link to comment

Hi again,

"tracks are all well pleyed in the script"
What does it mean? If you write:
Tracker tracker = new Tracker();
Track t = new Track();
t.track = tracker.loadTrack("my_track.track");
in your world script will it run without any errors?

Does c++ tracker API support now?
Unfortunately, no. It still supports UnigineScript only.

Best regards,
Alexander

Link to comment
  • 1 year later...

zhu.jun

More information about C++ <> UnigineScript in samples: SDK Browser -> Samples -> C++ Samples -> Scripts. Also more information about callbacks you can find in the documentation:

To be able to call World script functions from C++ the .world itself should be loaded and the script assigned to this .world should not contain any compilation errors (in other words it needs to be loaded and working.

If you can provide us a small test scene with this behavior - we can probably found the root cause much faster.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...