Hi Werner,

BIND_PER_PRIMITIVE_SET will mean that you'll have one of the
associated attribute (i.e. colour, normal) per osg::PrimitiveSet
attached the osg::Geometry, so if you have one osg::DrawElementsUShort
used for the triangles then you'll need just one of the associated
attribute for it.

BIND_PER_PRIMITIVE will apply the attribute per primitive in you case
per triangle.

Tex coords in the OSG are always bound per vertex, there isn't a
control to alter this.

If you have a vertex array and indices for your triangles the natural
thing to do would be to use a osg::DrawElementsUShort(GL_TRIANGLES)
then use push_back(tri.p1) for each index on each triangle.

I would suggest binding the normals per vertex, you'll have to do this
for the tex coords as well.  If a single vertex will have multiple tex
coords or multiple normals associated with it due to differences in
the triangles then you'll need to duplicate the vertices and remap the
indices on the triangles to fit this.

Robert.

On Thu, Aug 26, 2010 at 10:38 AM, Werner Modenbach
<[email protected]> wrote:
> Thank you Paul for your response.
>
> Yes, you are right, the solution isn't perfect at all. But I'm integrating
> some external code which is just giving me a vertex array and a per triangle
> callback with vertex indexes and normal and texture coords.
>
> And further more I need some screenshots very urgently for a customer
> presentation.
>
> The performance improvement has to wait :-(
>
> So I try to analyse why it's not working. And I detected something I don't
> understand.
> In my opinion it should give the same result having:
> 1) one normal per triangle an binding PER_PRIMITIVE
> 2) 3 times the same normal and binding PER_PRIMITIVE_SET
>
> But it doesn't. So I'm confused.
>
> Thanks for further hints.
>
> - Werner -
>
>
> Am Mittwoch, 25. August 2010 22:41:14 schrieb Paul Martz:
>> Werner Modenbach wrote:
>> > Maybe someone can give me some explanation on my stupid little problem.
>> >
>> > I have a geometry being composed of TRIANGLES.
>> > I have a vertex-array, a verted-index-array and a normal-array assigned
>> > to my geometry.
>>
>> Off-topic: Do you need to use the vertex-index-array? It is deprecated:
>>          /** deprecated - forces OpenGL slow path, just kept for backwards
>> compatibility.*/
>>          void setVertexIndices(IndexArray* array);
>>
>> > 3 indexes and 3 normals per Triangle.
>> > Normal binding is set to BIND_PER_PRIMITIVE_SET.
>> >
>> > Unfortunately the rendering shows the geometry flat in curious dark
>> > colors and some unexpected light behaviour.
>> > For analysis purpose I set the normal binding to BIND_PER_PRIMITIVE and
>> > pushed just 1 normal per TRIANGLE.
>> > Everything looks good except I see the triangles and the geometry isn't
>> > smooth.
>> > The next test is pushing the same normal vector 3 times and setting the
>> > binding back to BIND_PER_PRIMITIVE_SET.
>> > In my understanding this should give the same optical result as before.
>> > Unfortunately it doesn't and everything is dark again.
>> >
>> > I guess, I misunderstand something with the normal bindings.
>> >
>> > Any hint is highly appreciated. Thanks in advance
>>
>> I'm not sure why you don't use BIND_PER_VERTEX, as you stated above that
>> your normal array contains 3 normals per triangle, so you have one normal
>> per vertex, right?
>>
>> BIND_PER_PRIMITIVE would result in flat shading (only one normal used for
>> each triangle -- which, by the way, also forces OpenGL down the slow
>> path), and BIND_PER_PRIMITIVE_SET would be even more granular: one normal
>> used for each PrimitiveSet you add to the Geometry. This would make all
>> triangles in the PrimitiveSet either uniformly dark or uniformly lit,
>> depending on the direction of the one normal used for the whole group.
>>
>> For analysis purposes, I suggest using the normals pseudoloader:
>>    > osgviewer dumptruck.osg.normals
>>
>> Hope that helps,
>>     -Paul
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> --
> TEXION Software Solutions
>
> TEXION GmbH -  Rotter Bruch 26a  -  D 52068 Aachen - HRB 14999 Aachen
> Fon: +49 241 475757-0, Fax: +49 241 475757-29, web: http://www.texion.eu
>
> Geschäftsführer/Managing Director: Werner Modenbach
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to