#Access the triangles of the model
18 messages · Page 1 of 1 (latest)
After you asset is loaded you can access it via Res<Assets<Mesh>>.
eg
fn modify_mesh(mut meshes: ResMut<Assets<Mesh>>) {
let my_asset_handle: Handle<Mesh> = ...;
let mesh = meshes.get_mut(&my_asset_handle).unwrap();
}
I know. but how to access the triangles? idk the api to achieve this. thanks for replying
can this one be used to access the triangles?
also I dont know how to get the handle from another system
Since the loading of mesh is parallel, i dont know how to wait until the completion of loading the model
how are you loading the mesh in the first place?
if let Some(bevy::render::mesh::VertexAttributeValues::Float32x3(ref mut vertices)) =
mesh.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
// modify vertices
}
I load the model at Startup. I tried to store the handle somewhere, but idk how to check the completion of loading the model
asset_server.get_load_state
This process is a bit clunky in Bevy at the moment, hopefully it gets better in future versions
it's unfortunate there's not an example of how to do this in the repository
Thank you! I'll try that
combining the above is how I modify the vertices of this plane in my example here (takes a sec to load) https://trent.kiwi/noise-terrain
I meant like an example showing loading an asset from disk then modifying it at runtime like what you're trying to do
get_load_state is more useful because it will also tell you if the asset failed to load etc
ahh, anyway thank you!