OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Load an obj file and mapping a given vertex to its Texture coordinates


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
aaa3d
Newbie


Joined: 06 Aug 2018
Posts: 1

PostPosted: Mon Aug 06, 2018 2:27 pm    Post subject:
Load an obj file and mapping a given vertex to its Texture coordinates
Reply with quote

Hi everyone, I'm new here.

I load an obj file with osgDB::readNodeFile("my.obj") and add it to my scene.
now, given a vertex Id, I'd like to be able to get its UV/Texture coordinate.

I can see that osg::Geometry has a getTexCoordArray() method, but dynamically casting my node to org::Geometry crashes the program.
moreover, according to the docs, getTexCoordArray() simply returns a pointer to osg::Array, and it's unclear what type the elements of that array is (osg::Vec2?)
...

Thank you!

Cheers,
mike
Back to top
View user's profile Send private message
wernerM
Appreciator


Joined: 06 Feb 2013
Posts: 105

PostPosted: Wed Aug 08, 2018 12:44 pm    Post subject:
Load an obj file and mapping a given vertex to its Texture coordinates
Reply with quote

Hi Mike,

the loaded node isn't just a single node but a treelike structure where
your actual geode(s) is/are located somewhere in the structure.
What you mean by vertex Id? Each geode contains 1 or more drawables and
each drawable contains a vertex array and eventually texCoordArray(s).

So you have to identify the geode your vertex is in. Then you can try to
dynamic_cast. Anyway you need to check if your cast returned 0.

The next problem is the osg::Array. I didn't find a solution for that so
far. If you kno

Am 06.08.2018 um 16:27 schrieb Mike Blakefiled:
Quote:
Hi everyone, I'm new here.

I load an obj file with osgDB::readNodeFile("my.obj") and add it to my scene.
now, given a vertex Id, I'd like to be able to get its UV/Texture coordinate.

I can see that osg::Geometry has a getTexCoordArray() method, but dynamically casting my node to org::Geometry crashes the program.
moreover, according to the docs, getTexCoordArray() simply returns a pointer to osg::Array, and it's unclear what type the elements of that array is (osg::Vec2?)
...

Thank you!

Cheers,
mike

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74473#74473











------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 300

PostPosted: Thu Aug 09, 2018 10:40 am    Post subject:
Load an obj file and mapping a given vertex to its Texture coordinates
Reply with quote

Here's how I change texture coordinates:
https://github.com/OGStudio/ogs-mahjong-components/blob/0308cd2ed97b001cf5aecea1b5aada839707c5cf/02.Theme/desktop/src/render.h#L184
Note that the function gets osg::Geode that has already been extracted
from osg::Node.

Here's a sample class to print whole osg::Node structure (replace
log::logprintf with printf):
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/f692fd8b0886dbdba1d4e99087998e87827056db/features/scene/PrintGraphVisitor.cpp
You need to create this class instance and call
'yourNode.accept(instance);' to have the structure printed.
On Wed, 8 Aug 2018 at 15:43, Werner Modenbach
<> wrote:
Quote:

Hi Mike,

the loaded node isn't just a single node but a treelike structure where
your actual geode(s) is/are located somewhere in the structure.
What you mean by vertex Id? Each geode contains 1 or more drawables and
each drawable contains a vertex array and eventually texCoordArray(s).

So you have to identify the geode your vertex is in. Then you can try to
dynamic_cast. Anyway you need to check if your cast returned 0.

The next problem is the osg::Array. I didn't find a solution for that so
far. If you kno

Am 06.08.2018 um 16:27 schrieb Mike Blakefiled:
Quote:
Hi everyone, I'm new here.

I load an obj file with osgDB::readNodeFile("my.obj") and add it to my scene.
now, given a vertex Id, I'd like to be able to get its UV/Texture coordinate.

I can see that osg::Geometry has a getTexCoordArray() method, but dynamically casting my node to org::Geometry crashes the program.
moreover, according to the docs, getTexCoordArray() simply returns a pointer to osg::Array, and it's unclear what type the elements of that array is (osg::Vec2?)
...

Thank you!

Cheers,
mike

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74473#74473












------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
wernerM
Appreciator


Joined: 06 Feb 2013
Posts: 105

PostPosted: Thu Aug 09, 2018 3:07 pm    Post subject:
Load an obj file and mapping a given vertex to its Texture coordinates
Reply with quote

Hi Mike,

I suggest checking the results of "geom" and "coords" before using them.
If they are nullptr it will crash your program.

- Werner -

Am 09.08.2018 um 12:39 schrieb michael kapelko:

Quote:
Quote:
Here's how I change texture coordinates:
https://github.com/OGStudio/ogs-mahjong-components/blob/0308cd2ed97b001cf5aecea1b5aada839707c5cf/02.Theme/desktop/src/render.h#L184
Note that the function gets osg::Geode that has already been extracted
from osg::Node.

Here's a sample class to print whole osg::Node structure (replace
log::logprintf with printf):
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/f692fd8b0886dbdba1d4e99087998e87827056db/features/scene/PrintGraphVisitor.cpp
You need to create this class instance and call
'yourNode.accept(instance);' to have the structure printed.
On Wed, 8 Aug 2018 at 15:43, Werner Modenbach
<> (
Only registered users can see emails on this board!
Get registred or enter the forums!
) wrote:
Quote:

Hi Mike,

the loaded node isn't just a single node but a treelike structure where
your actual geode(s) is/are located somewhere in the structure.
What you mean by vertex Id? Each geode contains 1 or more drawables and
each drawable contains a vertex array and eventually texCoordArray(s).

So you have to identify the geode your vertex is in. Then you can try to
dynamic_cast. Anyway you need to check if your cast returned 0.

The next problem is the osg::Array. I didn't find a solution for that so
far. If you kno

Am 06.08.2018 um 16:27 schrieb Mike Blakefiled:
Quote:
Hi everyone, I'm new here.

I load an obj file with osgDB::readNodeFile("my.obj") and add it to my scene.
now, given a vertex Id, I'd like to be able to get its UV/Texture coordinate.

I can see that osg::Geometry has a getTexCoordArray() method, but dynamically casting my node to org::Geometry crashes the program.
moreover, according to the docs, getTexCoordArray() simply returns a pointer to osg::Array, and it's unclear what type the elements of that array is (osg::Vec2?)
...

Thank you!

Cheers,
mike

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74473#74473





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: (
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Force OSG for GLES 2.0 to reenable ve... plamen_t General 4 Tue Jun 11, 2019 11:57 am View latest post
No new posts 回复: Is it possible to load text... GarfieldPig General 118 Fri May 10, 2019 4:32 pm View latest post
No new posts Is it possible to load texture withou... robertosfield General 9 Thu May 09, 2019 8:29 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:30 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:29 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP