There’s currently no plan. Simply because we haven’t really thought much more than putting the feature out there to see what requests we get. Your suggestion is a good one.
If you wouldn’t mind, please add a feature request in the repo!
Just opened my project with the new editor and immediately I saw the changing textures!
Any known performance advantage of using Mesh vs Model for simple 2D plane(quad) or circle ? (maybe for as a render buffer[render.draw] or shaders)
There’s not really much difference between them, other than that the Model has some more features (i.e. skinning).
I would second the index buffer request Would make life a touch simpler.
I’ve been trying to make a gameobject, that generates a vertex buffer on init. That works fine. The problem is, whenever I create another another instance of the go (either through factory or just plonking more in in the collection editor), the previous ones get the same vertices. I’m guessing it’s because all the meshes have the same .buffer file, and it’s that that is getting updated. Is it possible to create instances of a go with different vertex buffers at runtime somehow?
I guess this question got lost in the shuffle.
I believe the short answer is, “No”.
But the long answer is, you need to decide how many buffers you will need, max, and create a buffer file for each one in the editor, and load each one—either with a mesh component or a script property.
go.property("buf1", resource.buffer("/main/common/meshes/buffer1.buffer"))
go.property("buf2", resource.buffer("/main/common/meshes/buffer2.buffer"))
go.property("buf3", resource.buffer("/main/common/meshes/buffer3.buffer"))
go.property("buf4", resource.buffer("/main/common/meshes/buffer4.buffer"))
You can save these properties in a module for other scripts to use.
Thanks, figured something like this out as well. Shame there isn’t a nicer way, but eh, this works as well.
I’m trying to take advantage of meshes in the “world” vertex space as the direct replacement of built-in sprites (to make some stunning fx, actually).
Is this the right way to change a buffer in a mesh?
go.property("buf", resource.buffer("/assets/meshes/star.buffer"))
-- ...
go.set("#mesh", "vertices", self.buf)
I’m asking about this because the game reports about leaked resources on shutdown:
ERROR:RESOURCE: Leaked resources:
ERROR:RESOURCE: Resource: /assets/meshes/gun.bufferc ref count: 125
ERROR:RESOURCE: Resource: /assets/meshes/ball.bufferc ref count: 125
ERROR:RESOURCE: Resource: /assets/meshes/eye.bufferc ref count: 150
ERROR:RESOURCE: Resource: /assets/meshes/star.bufferc ref count: 125
Is this a bug, or am I doing something wrong?
I attached the demo project:
issue_mesh_buf_change.zip (51.1 KB)
So I found a bug today: If you spawn a mesh, then try to set the same buffer that is already set on it, it stops rendering. I’ll validate this tomorrow and open an issue about it.
go.set("#mesh", "vertices", go.get("#mesh", "vertices))
I think that use case looks good.
I think you’ve found a bug, and thanks for the repro case! (Added Issue #6054))
@dapetcu21 I’m unable to reproduce this problem. I’ve added a small example to the GitHub issue. Could you please take a look and see how it differs from your case?
Sure. I’ll check it out later today
Solved in 1.2.189!
Is mesh should update itself, when i manipulate buffer in runtime?
In my case i should update it by myself.
1)Buffer created in cpp.
2)Set go buffer to new buffer
resource.set_buffer(e.light_go.mesh.vertices, e.light_native:GetBuffer())
2)Modify vertices is cpp.
3)Call dmBuffer::UpdateContentVersion
4)Mesh draw prev data.
5)Check content version by myself and set buffer.
local buffer_version = e.light_native:BufferGetContentVersion()
if(buffer_version ~= e.light_go.mesh.buffer_version)then
e.light_go.mesh.buffer_version = buffer_version
resource.set_buffer(e.light_go.mesh.vertices, e.light_native:GetBuffer())
end
is this approach working for you? can you share some NE code?
I describe my solution. Is that what you need?
1)buffer have method for updating content version. In cpp
dmBuffer::UpdateContentVersion(this->buffer);
2)I make method to get content version from cpp to lua
static int BufferGetContentVersion(lua_State *L){
game_utils::check_arg_count(L, 1);
Light *light = Light_get_userdata_safe(L, 1);
uint32_t version = 0;
dmBuffer::Result result = dmBuffer::GetContentVersion(light->buffer, &version);
lua_pushnumber(L, version);
return 1;
};
3)In lua i set buffer if content version is changed.
local buffer_version = e.light_native:BufferGetContentVersion()
if(buffer_version ~= e.light_go.mesh.buffer_version)then
e.light_go.mesh.buffer_version = buffer_version
resource.set_buffer(e.light_go.mesh.vertices, e.light_native:GetBuffer())
end
Can we have detail explaination on how to export mesh buffer from blender, all the settings have to be made in blender to export shapes properly. I’m looking through sample blend file how all properties have done. Trying to do same while exporting mesh buffer but in defold not getting proper result. Textures are not showing.
The mesh export is mostly for runtime manipulation of the mesh, and the export script is an example of that.
Are you planning on changing the vertices in any way at runtime, or can you use the regular Model component with .gltf files? It might be a bit easier?