[osg-users] Can I use Material, Color, LightSource, etc. in Android?

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Thu Jul 19 04:39:36 PDT 2018


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 <dponsoda at gmail.com> wrote:

> 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
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180719/732d191b/attachment.html>


More information about the osg-users mailing list