On 22/10/09 9:40 PM, tien dat wrote:
> I have a model in obj format and want to load the model into
> OpenSceneGraph. When there is no texture, OpenSceneGraph can load the
> model fine. But when I use the model with texture, OpenSceneGraph
> allocates a huge amount of memory and crashes. I think it's a runtime
> bug and would like to know how to fix it. Please find some pictures
Not really a bug, I'd say you're running out of memory.
- try to reduce the image sizes.
- a lot of materials reference the same image. I don't think the obj loader caches this
which means you're loading that image over and over again. Use osgDB::Options to specify
caching of images.
Hope this helps,
Cheers,
/ulrich
Oh, and you seem to have pretty much one material per drawable. This will absolutely kill
your performance. Have a look at the .mtl file, you'll notice that there are heaps of
materials that have identical properties.
On 23/10/09 5:26 PM, tien dat wrote:
> Dear Ulrich,
> Could you tell me more about how to specify that option? Can I specify
> it while using osgviewer.exe or I have to rebuild osgviewer.exe with
> the option?
Unfortunately you can't (at the moment) set this option externally or internally, because
the .obj loader doesn't pass the options object along.
Even if you could it would only avoid loading the same image over and over again. It will
not solve the massively duplicated state/material that the model has.
Either the modelling is done very inefficiently in the 3D application or whatever exporter
is used messes things up.
If you absolutely have to use osgviewer (rather than your own app) I'd actually write a
script to optimise the .obj and .mtl files by removing duplicate materials.
What you might also want to do is to remove the 'map_Ka' (ambient texture map) statements
since they are not used with the standard OpenGL paths (but are still loaded).
Cheers,
/ulrich
> On Fri, Oct 23, 2009 at 5:02 AM, Ulrich Hertlein<u.her...@sandbox.de> wrote:
>> On 23/10/09 10:58 AM, Ulrich Hertlein wrote:
>>>
>>> On 22/10/09 9:40 PM, tien dat wrote:
>>>>
>>>> I have a model in obj format and want to load the model into
>>>> OpenSceneGraph. When there is no texture, OpenSceneGraph can load the
>>>> model fine. But when I use the model with texture, OpenSceneGraph
>>>> allocates a huge amount of memory and crashes. I think it's a runtime
>>>> bug and would like to know how to fix it. Please find some pictures
>>>
>>> Not really a bug, I'd say you're running out of memory.
>>>
>>> - try to reduce the image sizes.
>>> - a lot of materials reference the same image. I don't think the obj
>>> loader caches this which means you're loading that image over and over
>>> again. Use osgDB::Options to specify caching of images.
>>
>> Oh, and you seem to have pretty much one material per drawable. This will
>> absolutely kill your performance. Have a look at the .mtl file, you'll
>> notice that there are heaps of materials that have identical properties.
--
Dat Tien Nguyen
PhD student, Computer Science Department
The University of Iowa, IA 52242
http://cs.uiowa.edu/~tinguyen
On 27/10/09 2:05 AM, Nguyen Tien Dat wrote:
> So I have read about .mtl and .obj files and understood what you
> meant. I created a program to optimize the model
> (http://cs.uiowa.edu/~tinguyen/OptimizeMtlFiles.rar)
> But the new one that I created doesn't look the same as the old one
> when I don't use texture. Please click this link to download both
> versions, and use osgviewer.exe to view them.
> http://cs.uiowa.edu/~tinguyen/supermarket_3ds.rar
> The old one has some color (again, without texture), but the new one
> doesn't. So I'm wondering what's wrong.
Quite simple: if you look at the beginning of the 'supermarket_new.obj' file you'll see
the reference to the material file: 'mtllib supermarket_new.mlt'
Note the file extension, it's 'mlt' but it should be 'mtl'.
The obj reader should complain rather loudly that it can't find this file but apparently
it isn't.
Cheers,
/ulrich
Maybe I am not seeing something obvious here, but why don't you use
the OpenSceneGraph VRML loader instead of taking a detour via 3DS Max
and convert to .obj format?
Erik den Dekker
--
Dat Tien Nguyen
PhD student, Computer Science Department
The University of Iowa, IA 52242
http://cs.uiowa.edu/~tinguyen
On 27/10/09 11:53 AM, Ulrich Hertlein wrote:
> On 27/10/09 2:05 AM, Nguyen Tien Dat wrote:
>> So I have read about .mtl and .obj files and understood what you
>> meant. I created a program to optimize the model
>> (http://cs.uiowa.edu/~tinguyen/OptimizeMtlFiles.rar)
Oh and one more thing: you have a lot of identical materials without texture. Does your
optimizer only check for identical textures?
--
Dat Tien Nguyen
PhD student, Computer Science Department
The University of Iowa, IA 52242
http://cs.uiowa.edu/~tinguyen
Everything except the name ;-D