Hi,
I know that this should be in dev-forums but I’d like to try my luck here first.
The problem is that I need some generic way of handling level of detail in Blender. I don’t mean automatic poly count reducer like Decimator-modifier but ability set by hand several meshes for same object with view distance information.
I need that for exporting external real-time engine (OpenSceneGraph). Now I have to that by editing OSG-files and that is not that fun… or fast
Does any one know way to do this? Any hints are wellcome!
If this was implemented internally in Blender, I think that would also benefit echo-plugin and current game-engine.
Thanks, but I can not use decimator because I’ll make different version by hand. Decimators fails with architecture since they are often designed for organic models.
But thas is very interesting, maybe he could make a lod modifier also
One solution would be to bind LOD models to empties. So each empty would represent a collection of building LODs. Empty would be a parent and a container of the collection of building LOD levels. Then develop a naming scheme so that you know which LOD level is which (empty (parent): hotel, lowest LOD: hotel_0, middle LOD: hotel_1, high_LOD: hotel_2 or something like this would work).
There’s a ton of stuff in BP, so I’ve snipped and cleaned the relevant function for you…
import math
def setLoDforselected():
selected=Blender.Object.GetSelected()
if (selected is not None):
#find if a camera object is included in the list
camOb=None
for object in selected:
if (object.getType()=='Camera'):
camOb=object
if (camOb):
camMat=camOb.getMatrix()
camLoc=camMat.translationPart()
for object in selected:
if (object<>camOb):
obMat=object.getMatrix()
obLoc=obMat.translationPart()
distance=math.sqrt(((obLoc[0]-camLoc[0])**2)+((obLoc[1]-camLoc[1])**2)+((obLoc[2]-camLoc[2])**2))
# Your code for selecting the proper dupligroup based on distance goes here
# place name of new group in the variable nameofnewgroup
# nameofnewgroup=groupnames[index] or something like that
obGroup=object.DupGroup
newGroup=Blender.Group.Get(nameofnewgroup)
if (newGroup):
object.DupGroup=newGroup
else:
return "No Camera object in selection."
To use this, you select a camera object and your Empty placeholders that have a dupligroup assigned. You also need to have your other meshes each in their own group so you can re-assign your empty to point to them. If you know anything about python scripting in Blender, this code should be pretty straightforward.
If not, I unfortunately don’t have time to fix it up/make it turn-key, etc. Also, this is just a function definition, so you’d need to add some kind of call, or remove the function def portion.
Thank you! Although I don’t need camera info because I only need a solution how to export information about lod-levels and models related to them. But thanks anyway!
@Fligh: Thanks, but as I said earlier scripts are not suitable for my purposes. See my previous post.
The point of my script snippet is how you do the kind of thing you’re talking about. You create an Empty as your base object. You then create your different models of varying Level of Detail. Make each model (or collection of model and armature, etc.) into a Group. Then, you enable Dupligroups on the Empty, pointing it toward each of the different LoD Group stand-ins you created.
That’s how you do it in Blender.
You could also try re-assigning the Mesh datablock of an object to point to varying library meshes, but you lose a number of mesh effects that are held at the object level by doing that.
Empty+Dupligroups is the way to go. My script snippet was nothing more than an automatic way to manage those different groups.