Accessing Defold objects directly from native extensions?

Is there a way to access Defold objects directly from native extensions, to change basic built in properties like position, material, scale, etc…?

If I want to move alot of objects using C++, Is the only way is to fill a buffer and then consume this buffer from lua (loop and update the objects).

Thanks

We are expanding our C API with new scene graph functionality as described here:

And part of the new API (in alpha):

2 Likes

That’s perfect Thank you very much! I will compile the engine and try it.

But sorry I have a question: What does this mean “Note: This scene graph traversal api is built for profiling in mind, and is also heavily reliant on reverse hashes. As such, this api isn’t suitable for release builds.” so this API is not have good performance characteristics? or is it just the scene traversal part of it?

Not necessary. There is an alpha here: http://d.defold.com/alpha/

Part of the new scene graph inspection additions are not available in release builds. Although I do believe the dmGameObject API is available in release builds. @JCash can confirm this.

While C++ API is heavily wanted, you can still do almost anything in C++. All you need is to call Lua functions via Lua C API.

// timer.delay()
static void timer_delay(lua_State *L, double delay, int callback) {
	lua_getglobal(L, "timer");
	lua_getfield(L, -1, "delay");
	lua_remove(L, -2); // Pop timer.

	lua_pushnumber(L, delay); // Duration.
	lua_pushboolean(L, false); // Repeat.
	lua_rawgeti(L, LUA_REGISTRYINDEX, callback); // Callback.
	luaL_unref(L, LUA_REGISTRYINDEX, callback);

	lua_call(L, 3, 0);
}
2 Likes

How we can get gameobject instance for use in GetPosition(dmGameObject::HInstance instance) function?

1 Like

It’s not available yet. It will be later next year, as part of other tasks.

Only parts of the dmGameObject api will be there for now.
We’ll open up more as we do other tasks this upcoming year.

1 Like

Well, sad.