Jump to content

callbackbase


photo

Recommended Posts

how can i use callbackbase ??

 

It seems similar to the c# delegate, but I think the usage is different.

VR sample code does not seem to connect any function to callbackbase variable, but it calls the run function (+ argument)

image.png.ab04959f741c24d923d3e94e2240e24c.png

What function does called when use_callback run?

 

Link to comment

A Сallbackbase is class for working with pointers to functions or methods. (simple analog for std::function)

use_callback->run() will run the callback, that you put in VRPlayer::setUseCallback(Unigine::CallbackBase* callback)

for creating callback use MakeCallback

Link to comment

Yes, in this particular case it is designed to let you set your own callback function for "use" action.

For example, you can specify a custom callback for the Vive player like this:

// callback function to be called for "use" action
void VRPlayerVive::my_custom_callback(NodePtr node)
{
	// your code goes here
}

/* ... */

void VRPlayerVive::init()
{
    /* ... */
  
  	// setting my_custom_callback for "use" action
	setUseCallback(MakeCallback(this, &VRPlayerVive::my_custom_callback));
    }
}

In this case use_callback->run(someNode)   will actually call my_custom_callback(someNode) .

Thank you!

  • Like 1
Link to comment
×
×
  • Create New...