Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Hiding Mesh

Author
Message
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 30th Apr 2018 20:13
I'm using an FBX model which contains multiple meshes for LOD. Is there any way to hide meshes so only the appropriate one is rendered?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Apr 2018 20:37 Edited at: 30th Apr 2018 20:42
You could use a custom shader that disregards all the data passed to it and assign it to any meshes that your not currently showing but that would be a poor solution I think.

In a similar way you could set the Mesh UV offset so the mesh only shows an area of texture that is completely transparent and hence is invisible, but thats also a rather horrid fix too that i wouldnt recommend.


Its probably best to:
Split the multimesh object into multiple single mesh objects using CreateObjectFromObjectMesh() (store these in an array - delete the original object)
Use FixObjectToObject() on all the objects you just created so you can control it using just 1 object position and rotation. Link them all to the Object with the highest LOD
Turn off any collision on the objects that are not the highest LOD and dont make them part of physics at all...only the highest LOD needs to be
Use SetObjectVisible on these so that only 1 of them is ever visible...which one depends on the range from the camera.


Unfortunately you will still get moments when the LOD changes though so the object appears to physically change as you walk towards it or away. Continiously variable level of detail isnt really doable in AppGameKit at the moment, unless you actually do it as an object animation so that it is infinately variable between two LOD's and that takes a lot of setup in the animation to make it work seamlessly.
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 30th Apr 2018 23:33 Edited at: 1st May 2018 20:21
Thanks Bengismo. I think CreateObjectFromObjectMesh() will do the trick.
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 1st May 2018 20:21
Sadly, copying the mesh doesn't copy the animation so that method is out
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 1st May 2018 20:42 Edited at: 1st May 2018 20:44
Ahh... i did it with static meshes not animated ones.

So... probably best to open up the fbx in modelling program and save the separate LOD's to separate files and load the files as separate objects (one for each LOD) and display just the one you want - depending on distance.

Alternatively, the shader idea would work...Ie use a shader on the meshes that doesnt actually draw anything for the ones you dont want to draw. Id rather not do that as it seems a poor solution and probably wasteful.

it would be good if agk had some form of built in LOD capability... but there are quite a few ways of doing it.... so it still might be best to implement it ourselves with multiple objects and a simple distance from the camera algorithm. it does work ok.
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 1st May 2018 23:51
Yeah, I think just the ability to toggle visibility of meshes or make them inactive would be a pretty simple feature to implement.

I'll probably just use the shader hide method, or use SetObjectTransparency() and set the texture to transparent on the meshes I want to hide.

Login to post a reply

Server time is: 2024-04-25 07:49:09
Your offset time is: 2024-04-25 07:49:09