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 

Really basic question light/material on surface


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


Joined: 17 Nov 2018
Posts: 24

PostPosted: Tue Apr 09, 2019 4:53 pm    Post subject:
Really basic question light/material on surface
Reply with quote

Hello,

I've playing aorund with some examples on the "OpenSceneGraph 3 Cookbook" by Wang and Quian. Specifically, with Chapter 10's "Playing with delaunay triangulator".

Here is the official repository code (with one small modification -commented-)

Code:
int main(int argc, char** argv)
{
   osg::ref_ptr<osg::Vec3Array> va = new osg::Vec3Array(9);
   (*va)[0].set(-5.0f, -5.0f, 0.4f);
   (*va)[1].set(1.0f, -5.6f, 0.0f);
   (*va)[2].set(5.0f, -4.0f, -0.5f);
   (*va)[3].set(-6.2f, 0.0f, 4.2f);
   (*va)[4].set(-1.0f, -0.5f, 4.8f);
   (*va)[5].set(4.3f, 1.0f, 3.0f);
   (*va)[6].set(-4.8f, 5.4f, 0.3f);
   (*va)[7].set(0.6f, 5.1f, -0.8f);
   (*va)[8].set(5.2f, 4.5f, 0.1f);

   osg::ref_ptr<osgUtil::DelaunayTriangulator> dt = new osgUtil::DelaunayTriangulator;
   dt->setInputPointArray(va.get());
   dt->setOutputNormalArray(new osg::Vec3Array);
   dt->triangulate();

   osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
   geometry->setVertexArray(dt->getInputPointArray());
   geometry->setNormalArray(dt->getOutputNormalArray());
   geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); // original code setted osg::Geometry::BIND_PER_PRIMITIVE.
   geometry->addPrimitiveSet(dt->getTriangles());

   osg::ref_ptr<osg::Geode> geode = new osg::Geode;
   geode->addDrawable(geometry.get());

   osgViewer::Viewer viewer;
   viewer.setSceneData(geode.get());

   return viewer.run();
}


So in the book, they show the following a snapshot of the result of the example (attached). The image shows that the "material/color" is responsive to "depth" (sorry if I'm using wrong terms).

But when I compile and run the example, the result is no responsive to "depth". Clearly it responds to light, as the bottom looks black and when I rotate it the surface color begins to show. For instance, I cannot differentiate between the faces as is shown on the books snapshot (see attachment).

So my question is really basic. What I'm doing wrong? or what I'm missing?
Bottomline is, how can I create a basic colored material that responds to the default light on a osg::Viewer as shown in the book?


Thank you!

Cheers,
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 Shininess without Material ehensens General 0 Wed Aug 07, 2019 6:47 pm View latest post
No new posts Shininess without Material ehensens General 1 Wed Aug 07, 2019 6:46 pm View latest post
No new posts Question about method of building osgQt trexmsuee Build system [build] 1 Thu Apr 11, 2019 2:22 pm View latest post
No new posts Question about linking OSG 3D content... Zachary1234 General 0 Mon Mar 25, 2019 6:14 am View latest post
No new posts Question about security of shader dev... Werner Modenbach General 5 Wed Jan 30, 2019 5:50 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