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 

How to texture map Box/Sphere/Cone/Capsule/Cylinder


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


Joined: 29 Jun 2011
Posts: 44
Location: Huntsville AL

PostPosted: Mon Aug 07, 2017 7:14 pm    Post subject:
How to texture map Box/Sphere/Cone/Capsule/Cylinder
Reply with quote

Trying to map a simple, uniform texture onto an osg::Shape instance and not finding a way to get a hold on the underlying osg::Geometry so I can call setTexCoordArray(...) on it ...

How would I do so?

example code :

osg::ref_ptr<osg::Sphere> rShape = new osg::Sphere( center, radius );
osg::ref_ptr<osg::ShapeDrawable> rDrawable = new osg::ShapeDrawable( rShape );
pGeom = rDrawable->asGeometry(); // returns NULL
rGeode->addDrawable( rDrawable );
rBaseNode->addChild( rGeode );

osg::ref_ptr<osg::Texture2D> rOSGTexture = CreateTexture( ... );

osg::Vec2 texCoords[] =
{
osg::Vec2(0,1),
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1)
};
int numTexCoords = sizeof(texCoords)/sizeof(osg::Vec2);
pGeom->setTexCoordArray(0,new osg::Vec2Array(numTexCoords,texCoords)); // NULL POINTER REFERENCED HERE

_________________
things are more like they are now than they have ever been before
Back to top
View user's profile Send private message Visit poster's website
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11190

PostPosted: Tue Aug 08, 2017 7:42 am    Post subject:
How to texture map Box/Sphere/Cone/Capsule/Cylinder
Reply with quote

Hi Paul,


Only in git master and recent 3.5.x dev series does ShapeDrawable subclass from osg::Geometry.  For older releases (3.4.0 and before) ShapeDrawable computes the coordinates on the fly so there isn't any coords you can get and modify.


As a general note, ShapeDrawable is a convenience class for visualizing shapes in a very basic way, it's not a general purpose tool.


Robert.





On 7 August 2017 at 20:14, Paul Leopard < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Trying to map a simple, uniform texture onto an osg::Shape instance and not finding a way to get a hold on the underlying osg::Geometry so I can call setTexCoordArray(...) on it ...

How would I do so?

example code :

osg::ref_ptr<osg::Sphere> rShape = new osg::Sphere( center, radius );
osg::ref_ptr<osg::ShapeDrawable> rDrawable = new osg::ShapeDrawable( rShape );
pGeom = rDrawable->asGeometry(); // returns NULL
rGeode->addDrawable( rDrawable );
rBaseNode->addChild( rGeode );

osg::ref_ptr<osg::Texture2D> rOSGTexture = CreateTexture( ... );

osg::Vec2 texCoords[] =
{
   osg::Vec2(0,1),
   osg::Vec2(0,0),
   osg::Vec2(1,0),
   osg::Vec2(1,1)
};
int numTexCoords = sizeof(texCoords)/sizeof(osg::Vec2);
pGeom->setTexCoordArray(0,new osg::Vec2Array(numTexCoords,texCoords)); // NULL POINTER PASSED HERE

------------------------
things are more like they are now than they have ever been before

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





_______________________________________________
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


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


Joined: 29 Jun 2011
Posts: 44
Location: Huntsville AL

PostPosted: Tue Aug 08, 2017 1:36 pm    Post subject:
Reply with quote

Ok thanks for the response

Regards,
P

_________________
things are more like they are now than they have ever been before
Back to top
View user's profile Send private message Visit poster's website
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 Problem With Osg Texture Colors! Bobykhani General [forum] 1 Tue Oct 10, 2017 8:20 am View latest post
No new posts obj plugin does not support diffuse a... Ralf Habacker General 5 Tue Sep 19, 2017 6:21 am View latest post
No new posts Render to texture with GL3. Raizel General 3 Tue May 23, 2017 10:33 am View latest post
No new posts How to replace the texture data in th... xdfanfan General 1 Wed Apr 05, 2017 12:44 pm View latest post
No new posts Multitexture: projection a texture on... Ekaterina General 2 Mon Feb 06, 2017 1:48 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