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?
Yes, I’m changing vertices at runtime. I just need to look structure of buffer of the shape I’m creating. To help create buffer at runtime referenceing structure of mesh buffer from blender shape.
For reference dealing with some shape like this when dragging the edge changing mesh at runtime.
How vertex positions fill in screen the start point and end point when creating shapes. If I want to create polygon shapes with even more dense shapes then above images. How to create vertex positions map that make that shape. Or any other tips.
Regarding debugging your setup, do you have texture coordinates in your blender scene?
What does your output .buffer file look like?
Yes, finally understand how to properly export mesh buffer to defold. Also get it how to set texture coordinates.
I’m not good with blender also. Didn’t know that I have to tap assign button assign texture.
I wondered if you or anyone had an update to this? My problem is I am making an editor inside my game that builds shapes on the fly at runtime.
But editing one shape edits them all, which is really not wanted. Is there a way to make each mesh modification unique without hundreds of source files?
My game will need a few hundred to a thousand shapes (runtime authored meshes).
Thanks for insights
I think you should be able to create a buffer for each mesh at runtime now using buffer.create() and the use go.set() to set it on a mesh component instance.
These are spawned using a factory, is that possibly why it is not working?
local newBuff = buffer.create(numVerts,
{
{
name = hash("position"),
type = buffer.VALUE_TYPE_FLOAT32,
count = 3
}
})
local positions = buffer.get_stream(newBuff, “position”)
–fill some positions in
–etc
local url = msg.url(nil, shape.id, mesh)
local res = go.get(url, vertices)|
resource.set_buffer(res, newBuff)
It acts as if all the separate shapes are using the same underlying data, so if I move a vert on one, they all have a moved vert. I am creating new vertex data for each one so I am confused here.
It is important to note that you update the resource in your example.
If all meshes use that same resource, then it won’t work as you intended.
Instead, you can create a new buffer resource dynamically, and assign it:
local newBuff = buffer.create(...) -- as you do now
local resource_name = "/my_cloned_buffer.bufferc" -- make this unique for each resource!
local buffer_resource = reource.create_buffer(resource_name, { buffer = newBuff })
go.set(url, "vertices", buffer_resource) -- replace it's current resource hash, with the new one
Note, read the documentation! E.g. the name of the resource must be unique!
I.e. they can’t all be named /my_cloned_buffer.bufferc
Thanks, that was it!
Have a great weekend, Mathias and britzl