Robert,
Thanks for the reply. I switched my code to not use indices per your
suggestion and as shown in the osggeometry example. I ended up not using
any DrawElements*() calls, so I am not 100% sure what you are meaning in
the last line of your second paragraph. Anyway, everything works fine
now and my code is much cleaner.
Thanks again,
Jason
Robert Osfield wrote:
> Hi Jason,
>
> Your final geometry has the DrawElementsUInt refernces vertex with
> index 6, yet you only have 4 color indices. The OSG doesn't check at
> runtime to see if you've put in valid data, it simply passes to
> OpenGL, this is done so that well conditioned scene graphs don't pay
> the penalty required to catch badly conditioned scene graphs, much in
> the same way that OpenGL doesn't try to nanny you.
>
> As a general note I'd strongly recommend against using vertex indices
> other that through DrawElement*() primitive sets as it force the OSG
> to use OpenGL slow paths for dispatching geometry and primitive calls
> as OpenGL. For performance Its better to duplicate vertex data and
> use DrawElements*() than use vertex indices.
>
> I would like to move indice support out of osg::Geometry into a
> separate class that isn't part of the core OSG to prevent to help
> guide users into use fast paths over "tempting" but inefficient slow
> paths.
>
> Robert.
>
> On 12/19/06, Jason K. Howlett <[EMAIL PROTECTED]> wrote:
>> I have a very simple model (see below for .osg file) with a box with
>> four sides and a top. The color of the top of the box is specified as a
>> PER_VERTEX color index array, but it turns out that all four vertices
>> have the same color. If I load this model and view it with
>> osgProducer::Viewer and *without* using osgUtil::Optimizer to optimize
>> the model, the program seg faults. If I optimize the model with
>> osgUtil::Optimizer, the PER_VERTEX binding for the roof polygon is
>> changed to PER_PRIMITIVE (see the note in the file data below for
>> location) and the model displays fine (this change makes sense, of
>> course, for this statically colored model). Shouldn't the model display
>> even with the PER_VERTEX setting?
>>
>> I tracked this through the code (version 1.2) and found in Geometry.cpp,
>> line 1762
>> if (_colorData.binding==BIND_PER_VERTEX)
>> drawColor(vindex);
>> In this case, vindex has a value of 6. Following the call into
>> DrawColor::operator()(int), defined at line 189 as an inline function,
>> the input parameter pos, which should be 6, is instead some large random
>> number. This initiates the seg fault as pos is used as an index into the
>> _colors array.
>>
>> Please let me know if there is any additional information I can provide
>> that might be helpful.
>> Jason
>>
>>
>> test.osg
>> Group {
>> DataVariance DYNAMIC
>> nodeMask 0xffffffff
>> cullingActive TRUE
>> num_children 1
>> Geode {
>> DataVariance DYNAMIC
>> nodeMask 0xffffffff
>> cullingActive TRUE
>> num_drawables 2
>> Geometry {
>> DataVariance DYNAMIC
>> useDisplayList TRUE
>> useVertexBufferObjects FALSE
>> PrimitiveSets 1
>> {
>> DrawElementsUInt TRIANGLE_STRIP 10
>> {
>> 0 1 2 3 4 5 6 7 0 1
>> }
>> }
>> VertexArray UniqueID Vec3Array_0 Vec3Array 8
>> {
>> 180 30 20
>> 180 30 0
>> 180 60 20
>> 180 60 0
>> 210 60 20
>> 210 60 0
>> 210 30 20
>> 210 30 0
>> }
>> ColorBinding PER_VERTEX
>> ColorArray UniqueID Vec4Array_1 Vec4Array 3
>> {
>> 0 0.5 0 1
>> 1 1 0 1
>> 0.6 0.6 0.6 1
>> }
>> ColorIndices UIntArray 8 {
>> 1 0 1 0 1 0 1 0
>> }
>> }
>> Geometry {
>> DataVariance DYNAMIC
>> useDisplayList TRUE
>> useVertexBufferObjects FALSE
>> PrimitiveSets 1
>> {
>> DrawElementsUInt POLYGON 4
>> {
>> 0 2 4 6
>> }
>> }
>> VertexArray Use Vec3Array_0
>> ColorBinding PER_VERTEX ********** This is the line that
>> changes **********
>> ColorArray Use Vec4Array_1
>> ColorIndices UIntArray 4 {
>> 2 2 2 2
>> }
>> }
>> }
>> }
>>
>> --
>> Jason K. Howlett
>> U.S. Army Aeroflightdynamics Directorate
>>
>> Phone: 650-604-5374
>> Fax: 650-604-2414
>> mailto: [EMAIL PROTECTED]
>> Mail Stop T12B-2
>> Moffett Field, CA 94035-1000
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://openscenegraph.net/mailman/listinfo/osg-users
>> http://www.openscenegraph.org/
>>
>
>
> --===============1952405976==
> Content-Type: message/rfc822
> MIME-Version: 1.0
>
--
Jason K. Howlett
U.S. Army Aeroflightdynamics Directorate
Phone: 650-604-5374
Fax: 650-604-2414
mailto: [EMAIL PROTECTED]
Mail Stop T12B-2
Moffett Field, CA 94035-1000
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/