Re: [osg-users] colours in Android OSG

2012-04-25 Thread Maurizio Lodo
Hi Jorge and thanks for your reply.
The file I am loading in the viewers is cell.osg (attached), which on 
Windows/Linux appears like screen_shot_0_0.jpg
In the OSG android viewer example it appears like osgAndroidLightOn.jpg and if 
I toggle the light with the corresponding button I get osgAndroidLightOff.jpg.
no message in LogCat about lights, the only message is about arial.ttf missing.
I know I am probably showing how daft I am, but I thought the viewers would 
have shown the same model in the same way.
Thanks
Maurizio

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




Attachments: 
http://forum.openscenegraph.org//files/osgandroidlightoff_208.jpg
http://forum.openscenegraph.org//files/osgandroidlighton_123.jpg
http://forum.openscenegraph.org//files/screen_shot_0_0_185.jpg
http://forum.openscenegraph.org//files/cell_100.osg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Jason Daly


Hi, Maurizio,

It probably comes from the fact that you're using ShapeDrawables for 
your geometry.  ShapeDrawable was never intended for serious work, and 
as such, probably wasn't high on the list for support when OSG was 
ported to work with OpenGL ES.  If you converted your geometry to use 
actual osg::Geometry drawables, you might have better luck.


--J



On 04/25/2012 10:47 AM, Maurizio Lodo wrote:

Hi Jorge and thanks for your reply.
The file I am loading in the viewers is cell.osg (attached), which on 
Windows/Linux appears like screen_shot_0_0.jpg
In the OSG android viewer example it appears like osgAndroidLightOn.jpg and if 
I toggle the light with the corresponding button I get osgAndroidLightOff.jpg.
no message in LogCat about lights, the only message is about arial.ttf missing.
I know I am probably showing how daft I am, but I thought the viewers would 
have shown the same model in the same way.
Thanks
Maurizio

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




Attachments:
http://forum.openscenegraph.org//files/osgandroidlightoff_208.jpg
http://forum.openscenegraph.org//files/osgandroidlighton_123.jpg
http://forum.openscenegraph.org//files/screen_shot_0_0_185.jpg
http://forum.openscenegraph.org//files/cell_100.osg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Maurizio Lodo
Thanks Jason,
true, I was using ShapeDrawables. However, I was already working on converting 
the geometries to use osg::Geometry. I have not done the cylinders yet; however 
I have converted the cubes, and, unfortunately the results are exactly the 
same. The code used to generate the cube geometry is pretty basic. Here it is:
Code:
osg::Geometry* CCubicPore::createCubeGeometry( const osg::Vec3 halfLengths, 
const osg::Vec4 color)
 {
const float xMin( -halfLengths[ 0 ] );
const float xMax( halfLengths[ 0 ] );
const float yMin( -halfLengths[ 1 ] );
const float yMax( halfLengths[ 1 ] );
const float zMin( -halfLengths[ 2 ] );
const float zMax( halfLengths[ 2 ] );

 osg::Geometry* cube = new osg::Geometry();
 osg::ref_ptr osg::Vec3Array  vertices = osg::ref_ptr osg::Vec3Array ( 
new osg::Vec3Array );
 osg::ref_ptr osg::Vec3Array  normals = osg::ref_ptr osg::Vec3Array ( 
new osg::Vec3Array );
 osg::ref_ptr osg::Vec4Array  colors = osg::ref_ptr osg::Vec4Array ( 
new osg::Vec4Array );

// front face
 vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
 vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
 vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
 vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
 normals-push_back( osg::Vec3( 0.0, 0.0, -1.0 ) );

 // back face
 vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
 vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
 normals-push_back( osg::Vec3( 0.0, 0.0, 1.0 ) );

 // left
 vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
 vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
normals-push_back( osg::Vec3( -1.0, 0.0, 0.0 ) );

// right
vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
 normals-push_back( osg::Vec3( 1.0, 0.0, 0.0 ) );

 // bottom
 vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
 vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
 vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
 vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
 normals-push_back( osg::Vec3( 0.0, -1.0, 0.0 ) );

 // top
 vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
 vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
 vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
 normals-push_back( osg::Vec3( 0.0, 1.0, 0.0 ) );
 
 cube-addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0, 
vertices-size() ) );
 cube-setVertexArray( vertices );

 cube-setTexCoordArray( 0, vertices );

 cube-setNormalArray( normals );
 cube-setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );

 colors-push_back( color );
 cube-setColorArray( colors );
 cube-setColorBinding( osg::Geometry::BIND_OVERALL );

 return cube;
 }



then I use osg::PositionAttitudeTransform to move the cubes to the correct 
position. 

Cheers,
Maurizio

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Jason Daly


If you're just using one overall color per drawable, try switching that 
for an osg::Material with the DIFFUSE color set to the same color.  You 
might have better luck that way.


--J


On 04/25/2012 01:08 PM, Maurizio Lodo wrote:

Thanks Jason,
true, I was using ShapeDrawables. However, I was already working on converting 
the geometries to use osg::Geometry. I have not done the cylinders yet; however 
I have converted the cubes, and, unfortunately the results are exactly the 
same. The code used to generate the cube geometry is pretty basic. Here it is:
Code:
osg::Geometry* CCubicPore::createCubeGeometry( const osg::Vec3  halfLengths, const 
osg::Vec4  color)
  {
 const float xMin( -halfLengths[ 0 ] );
 const float xMax( halfLengths[ 0 ] );
 const float yMin( -halfLengths[ 1 ] );
 const float yMax( halfLengths[ 1 ] );
 const float zMin( -halfLengths[ 2 ] );
 const float zMax( halfLengths[ 2 ] );

  osg::Geometry* cube = new osg::Geometry();
  osg::ref_ptr  osg::Vec3Array  vertices = osg::ref_ptr  
osg::Vec3Array( new osg::Vec3Array );
  osg::ref_ptr  osg::Vec3Array  normals = osg::ref_ptr  osg::Vec3Array( 
new osg::Vec3Array );
  osg::ref_ptr  osg::Vec4Array  colors = osg::ref_ptr  osg::Vec4Array( 
new osg::Vec4Array );

 // front face
  vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
  vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
  vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
  vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
  normals-push_back( osg::Vec3( 0.0, 0.0, -1.0 ) );

  // back face
  vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
  vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
  normals-push_back( osg::Vec3( 0.0, 0.0, 1.0 ) );

  // left
  vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
  vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
 normals-push_back( osg::Vec3( -1.0, 0.0, 0.0 ) );

 // right
 vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
 vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
 vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
 vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
  normals-push_back( osg::Vec3( 1.0, 0.0, 0.0 ) );

  // bottom
  vertices-push_back( osg::Vec3(xMax,yMin,zMax) );
  vertices-push_back( osg::Vec3(xMin,yMin,zMax) );
  vertices-push_back( osg::Vec3(xMin,yMin,zMin) );
  vertices-push_back( osg::Vec3(xMax,yMin,zMin) );
  normals-push_back( osg::Vec3( 0.0, -1.0, 0.0 ) );

  // top
  vertices-push_back( osg::Vec3(xMax,yMax,zMax) );
  vertices-push_back( osg::Vec3(xMax,yMax,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMax,zMin) );
  vertices-push_back( osg::Vec3(xMin,yMax,zMax) );
  normals-push_back( osg::Vec3( 0.0, 1.0, 0.0 ) );

  cube-addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0, 
vertices-size() ) );
  cube-setVertexArray( vertices );

  cube-setTexCoordArray( 0, vertices );

  cube-setNormalArray( normals );
  cube-setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );

  colors-push_back( color );
  cube-setColorArray( colors );
  cube-setColorBinding( osg::Geometry::BIND_OVERALL );

  return cube;
  }



then I use osg::PositionAttitudeTransform to move the cubes to the correct 
position.

Cheers,
Maurizio

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Maurizio Lodo
Unfortunately not. I am not getting this at all. The colour info is there, as 
you can see if I turn the light off, but as soon as the default headlight is 
turned on it all goes grey. Oh  well thanks for the help anyway. Obviously this 
is not my thing at all! :) 

Cheers,
Maurizio

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Rafa Gaitan
Hi Maurizio,

I think the problem could be that glColorMaterial is not supported in
OpenGLES 1.1. When you use ColorArray in a Geometry, I think it uses
glColorMaterial to enable lighting using the color of the geometry.

If you want to use Colors + Lighting in OpenGL ES 1.1, you need to
setup an osg::Material in the StateSet of the Geometry. There is an
osgmaterial example that you could use for reference.

Cheers,
Rafa.

El día 25 de abril de 2012 20:57, Maurizio Lodo maurimaur...@msn.com escribió:
 Unfortunately not. I am not getting this at all. The colour info is there, as 
 you can see if I turn the light off, but as soon as the default headlight is 
 turned on it all goes grey. Oh  well thanks for the help anyway. Obviously 
 this is not my thing at all! :)

 Cheers,
 Maurizio

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





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



-- 
Rafael Gaitán Linares
CTO at Mirage Technologies S.L - http://www.mirage-tech.com
gvSIG3D Developer - http://gvsig3d.blogspot.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Jason Daly

On 04/25/2012 03:21 PM, Rafa Gaitan wrote:

Hi Maurizio,

I think the problem could be that glColorMaterial is not supported in
OpenGLES 1.1. When you use ColorArray in a Geometry, I think it uses
glColorMaterial to enable lighting using the color of the geometry.

If you want to use Colors + Lighting in OpenGL ES 1.1, you need to
setup an osg::Material in the StateSet of the Geometry. There is an
osgmaterial example that you could use for reference.


Yeah, that's what I was trying to say.  Thanks for translating for me, 
Rafa  :-)


--J

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Maurizio Lodo
Thanks guys, you are helping loads. I will try that tomorrow. 
What about GLES2?
Cheers
Maurizio

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Jorge Izquierdo Ciges
Gles2 it goes all with shaders so if you don't rely on the default OSG
shaders, use your own, set uniforms as you like, etc it's pretty much
usable. There are still some glitches here and there that will be checked
when i can make a decent configuration to debug in Android.

2012/4/25 Maurizio Lodo maurimaur...@msn.com

 Thanks guys, you are helping loads. I will try that tomorrow.
 What about GLES2?
 Cheers
 Maurizio

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





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-25 Thread Maurizio Lodo
if I use osg::Material I get no colours and a warning in logcat

Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..)

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] colours in Android OSG

2012-04-24 Thread Maurizio Lodo
Hi,
 this is probably a daft question, but as I am a noob to the Android-OSG combo, 
I hope you will be gentle. I have built the android osgAndroidExampleGiLES1 and 
I tried to load,  one of my osg models (nothing fancy, just a bunch of cubes 
and cylinders). These models display perfectly in the Viewer in Linux or 
Windows, and the cubes and cylinders, have their right colours, with the right 
shades and all. However, in the Android viewer all is grey (even though the 
shades are fine). If I turn the light off in the Android viewer then the 
colours appear, but they are flat, no shades, no way to even recognise the 
edges of the cubes or anything at all. 
I am guessing it has something to do with lighting, but I cannot work out what 
the difference between the android viewer and the linux/windows one. Can anyone 
point me in the right direction? Much appreciated

Thank you!

Cheers,
Maurizio

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] colours in Android OSG

2012-04-24 Thread Jorge Izquierdo Ciges
Maybe it's some kind of error in the light commands executated by OSG for
GLES1. Still maybe you'll need to use the Notify to obtain errors through
LogCat and that way maybe we can find the source of trouble.

Good Luck

2012/4/24 Maurizio Lodo maurimaur...@msn.com

 These models display perfectly in the Viewer in Linux or Windows, and the
 cubes and cylinders, have their right colours, with the right shades and
 all. However, in the Android viewer all is grey (even though the shades are
 fine). If I turn the light off in the Android viewer then the colours
 appear, but they are flat, no shades, no way to even recognise the edges of
 the cubes or anything at all.
 I am guessing it has something to do with lighting, but I cannot work out
 what the difference between the android viewer and the linux/windows one.
 Can anyone point me in the right direction? Much appreciated

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org