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 

Can Material, Color, LightSource, etc. be used when developing for Android?


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


Joined: 11 Jul 2018
Posts: 2

PostPosted: Thu Jul 19, 2018 10:02 am    Post subject:
Can Material, Color, LightSource, etc. be used when developing for Android?
Reply with quote

Hi,

I'm playing with the OSG sample code for Android (GLES2) and as I see, it attaches user defined GLSL shaders to the drawable objects in order to display them with the proper shading effects.

Is it not possible to use the OSG API Objects such as Material, Color, LightSource etc. when programming for Android?

I tried them but all I get is plain color shapes for my 3d objects with no shading effects at all as we can see in the PC version of the sample code.

I tried this code (scene draws shaded on Windows, but with plain colors on Android):

Code:

// Create a light source
osg::LightSource ls = new LightSource;
ls->getLight()->setPosition(Vec4(10, 10, 20, 0));
ls->getLight()->setAmbient(Vec4(0.2, 0.2, 0.2, 1.0));
ls->getLight()->setDiffuse(Vec4(0.7, 0.4, 0.6, 1.0));
ls->getLight()->setSpecular(Vec4(1.0, 1.0, 1.0, 1.0));
root->addChild(ls.get());

// Create a sphere
ShapeDrawable* sphere = new ShapeDrawable(new Sphere(Vec3f(0, 0, 0), 2));
Material *material = new Material();
material->setDiffuse(Material::FRONT, Vec4(0, 1, 0, 1));
sphere->getOrCreateStateSet()->setAttribute(material);


Is there a portable way to do this on Android?

Thank you!

Cheers,
Daniel
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Thu Jul 19, 2018 11:40 am    Post subject:
Can I use Material, Color, LightSource, etc. in Android?
Reply with quote

Hi,

http://forum.openscenegraph.org/viewtopic.php?t=11390



Chris is explaining well here. Hope it helps


Cheers,
Nick


On Thu, Jul 19, 2018 at 12:09 PM Daniel Ponsoda < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

I'm playing with the OSG sample code for Android (GLES2) and as I see, it attaches user defined GLSL shaders to the drawable objects in order to display them with the proper shading effects.

Is it not possible to use the OSG API Objects such as Material, Color, LightSource etc. when programming for Android?

I tried them but all I get is plain color shapes for my 3d objects with no shading effects at all as we can see in the PC version of the sample code.

I tried this code (scene draws shaded on Windows, but with plain colors on Android):


Code:

// Create a light source
osg::LightSource ls = new LightSource;
ls->getLight()->setPosition(Vec4(10, 10, 20, 0));
ls->getLight()->setAmbient(Vec4(0.2, 0.2, 0.2, 1.0));
ls->getLight()->setDiffuse(Vec4(0.7, 0.4, 0.6, 1.0));
ls->getLight()->setSpecular(Vec4(1.0, 1.0, 1.0, 1.0));
root->addChild(ls.get());

// Create a sphere
ShapeDrawable* sphere = new ShapeDrawable(new Sphere(Vec3f(0, 0, 0), 2));
Material *material = new Material();
material->setDiffuse(Material::FRONT, Vec4(0, 1, 0, 1));
sphere->getOrCreateStateSet()->setAttribute(material);




Is there a portable way to do this in Android?

Thank you!

Cheers,
Daniel[/code]

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





_______________________________________________
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



--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
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 Attaching color buffer with GL_R32F i... deroliver General 0 Tue Apr 09, 2019 6:19 pm View latest post
No new posts Really basic question light/material ... dhhabyc General 0 Tue Apr 09, 2019 4:53 pm View latest post
No new posts Camera clear color cdp97531 General 1 Sat Dec 01, 2018 8:15 am View latest post
No new posts Update node color on demand dhhabyc General 12 Sat Nov 24, 2018 3:05 pm View latest post
No new posts Change color of node read from dxf file dhhabyc General 10 Sat Nov 17, 2018 12:58 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