[osg-users] Can I use Material, Color, LightSource, etc. in Android?
Daniel Ponsoda
dponsoda at gmail.com
Thu Jul 19 03:02:17 PDT 2018
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
More information about the osg-users
mailing list