Imported .obj file not showing textures.

58 views
Skip to first unread message

JILJITH JOHN

unread,
Jan 14, 2020, 4:52:54 AM1/14/20
to OpenSceneGraph Users

Capture.PNG

Capture.PNG

Hi,

I am developing a tool for editing 3D models using openscenegraph. When I tried to load an .obj file, the texture is not applied. I am getting only black shade.
The model is imported using the below code. 


 osg
::ref_ptr<osg::Node> model1= osgDB::readNodeFile(path.toStdString());
 model1
->setDataVariance(osg::Object::DYNAMIC);


Tom Pollok

unread,
Jan 14, 2020, 5:24:05 AM1/14/20
to OpenSceneGraph Users
Which version of openscenegraph are you using?

Would you mind trying my obj model with mtl and jpg texture file.


Pw: osg

I use the following to load it, but it crashes on my system with openscenegraph_3.4.1. Im curious if it works on your system.

osgDB::Options* opt = new osgDB::Options;
opt->setOptionString("noRotation");

osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(pathToObjFile, opt);

L. Voerman

unread,
Jan 14, 2020, 8:09:07 AM1/14/20
to OpenSceneGraph Users
repost in google group; It seems like my reply to the mailing list does not show up in google groups.


Hi Jiljith,

The material has both an ambient and a diffuse texture (both refer to the same file)
while this can be made to work with a shader, using the fixed function pipeline means you'll have to choose one:

osgviewer -O DIFFUSE=0 12228_Dog_v1_L2.obj
Laurens.

Robert Osfield

unread,
Jan 14, 2020, 8:20:48 AM1/14/20
to OpenSceneGraph Users, OpenSceneGraph Users
On Tue, 14 Jan 2020 at 13:09, L. Voerman <l.vo...@rug.nl> wrote:
repost in google group; It seems like my reply to the mailing list does not show up in google groups.

I did think I had the two working together at the end of last year but current mailing lists are appearing, will look into it.
 

 

Voerman, L.

unread,
Jan 14, 2020, 8:45:48 AM1/14/20
to OpenSceneGraph Users
Hi Robert,
It did work, a mail from me to  osg-...@lists.openscenegraph.org on 11 november 2019 is on groups.google.com,
a post on 9 january is not.
Maybe this email will show up on google groups now that I've joined the group?
Laurens.

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Voerman, L.

unread,
Jan 14, 2020, 9:18:21 AM1/14/20
to OpenSceneGraph Users
To answer my own question, not that I've joint the google group my replies by e-mail to  osg-...@lists.openscenegraph.org show up in the google group as well
Laurens.

Robert Osfield

unread,
Jan 14, 2020, 9:34:30 AM1/14/20
to OpenSceneGraph Users


On Tuesday, 14 January 2020 14:18:21 UTC, Voerman, L. wrote:
To answer my own question, not that I've joint the google group my replies by e-mail to  osg-users@lists.openscenegraph.org show up in the google group as well

I wonder if googegroups is testing the from w.r.t accepting or rejecting posts and the posts from osg-users aren't signed in quite the right way to handle this.

Robert.

JILJITH JOHN

unread,
Jan 15, 2020, 2:10:29 AM1/15/20
to OpenSceneGraph Users
Hi Laurens,

The answer is so great. I am getting the texture applied. But it is in the osgviewer.exe only. 
Problematically I tried to add the option. Its not working.
osgDB::Options* opt = new osgDB::Options;

opt->setOptionString("DIFFUSE=0");

osg::ref_ptr<osg::Node> model1= osgDB::readNodeFile(path.toStdString(), opt);

JILJITH JOHN

unread,
Jan 15, 2020, 4:15:11 AM1/15/20
to OpenSceneGraph Users
Dear Tom,

Thank you for the reply. I tried to load your model. It is crashing in my PC also.
OSG version is 3.6.4

Voerman, L.

unread,
Jan 15, 2020, 4:15:25 AM1/15/20
to osg-...@googlegroups.com, OpenSceneGraph Users
Hi Jiljith,
I see no problem in your code, and it works when I add it to my osgviewer.
with OSG_NOTIFY_LEVEL=NOTICE it generates 2 messages:
Obj Found map in options, [DIFFUSE]=0
Scaling image 'D:\laurens\Download\objDog/Dog_diffuse.jpg' from (450,450) to (512,512)

I suggest you can convert your file with "osgconv -O DIFFUSE=0 12228_Dog_v1_L2.obj 12228_Dog_v1_L2.obj.osgt"
so you can read it in your program with "osgDB::readRefNodeFile(path.toStdString() + ".osgt", opt);"
maybe your scene has no light, or other reasons why the dog shows up black.
Laurens.


--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/424783f2-415d-4351-8bf7-83bc25d30936%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages