12. Utilities Quadric Surfaces - Quadric

VglTools Programmer Manual

The utility module, Quadric is designed to complement the low level drawing functions by creating and tesselating higher level graphics objects. In particular, the Quadric module facilitates the drawing of spheres, cylinders, disks, etc. The graphics primitives generated by this modules are suitable to be rendered by the low level device interfaces.

The Quadric module is provided to draw simple quadric surfaces, in particular disks, cones, cylinders and spheres. The resolution of the tesselation, type of surface normal generation, texture coordinate generation, etc. may be specified.

Instance an Quadric object using vgl_QuadricBegin. Once a Quadric object is instanced, set the drawing function attribute object using vgl_QuadricSetObject. Set parameters which affect drawing style using vgl_QuadricSetParami, etc. The actual drawing is performed using vgl_QuadricCylinder and vgl_QuadricSphere.

12.1 Attribute Objects

A Quadric object requires a conventional DrawFun object to output its contents. Use vgl_QuadricSetObject to set a DrawFun object as an attribute.

12.2 Function Descriptions

The currently available Quadric functions are described in detail in this section.


Quadric

NAME

*vgl_QuadricBegin - create an instance of a Quadric object

C SPECIFICATION

    vgl_Quadric *vgl_QuadricBegin ()
    

ARGUMENTS

    None
    

FUNCTION RETURN VALUE

The function returns a pointer to the newly created Quadric object. If the object creation fails, NULL is returned.

ERRORS

VGL_ERROR_MEMORY is generated if the initial display list memory block allocation fails.

DESCRIPTION

Create an instance of a Quadric object. Memory is allocated for the object private data and the pointer to the data is returned. By default shading is flat, texture coordinate generation is off, the azimuth angle start and stop are 0., and 360. degrees, the number of slices is 17 and the number of stacks is 9. The drawing style is filled.

Destroy an instance of a Quadric object using

         void vgl_QuadricEnd (vgl_Quadric *quadric)
    

Return the current value of a Quadric object error flag using

         Vint vgl_QuadricError (vgl_Quadric *quadric)
    


Quadric

NAME

vgl_QuadricCylinder - draw variations of a cylinder

C SPECIFICATION

    void vgl_QuadricCylinder (vgl_Quadric *quadric,
                              Vfloat baserad,
                              Vfloat toprad,
                              Vfloat height)
    

INPUT ARGUMENTS

    quadric      Pointer to Quadric object.
    baserad      Radius of base of cylinder
    toprad       Radius of top of cylinder
    height       Height of cylinder
    

OUTPUT ARGUMENTS

    None
    

DESCRIPTION

Draw a cylinder oriented along the z axis. The base of the cylinder is at the origin, the top of the cylinder is at z = height. A cone may be drawn by specifying different radii at the base and top. A disk may be drawn by specifying different radii at the base and top with a height of zero. The circumferential angle is zero at the positive x axis and follows the right hand rule about the z axis. Texture coordinates vary from 0. to 1. in the circumferential direction and from 0. to 1. from the base to the top.


Quadric

NAME

vgl_QuadricSetObject - set pointers to attribute objects

C SPECIFICATION

    void vgl_QuadricSetObject (vgl_Quadric *quadric,
                              Vint objecttype,
                              Vobject *object)
    

INPUT ARGUMENTS

    quadric      Pointer to Quadric object.
    objecttype   The name of the object type to be set.
                 =VGL_DRAWFUN            DrawFun object
    object       Pointer to the object to be set.
    

OUTPUT ARGUMENTS

    None
    

ERRORS

VGL_ERROR_OBJECTTYPE is generated if an improper objecttype is specified.

DESCRIPTION

Set a pointer to an attribute object. The DrawFun attribute object is required.


Quadric

NAME

vgl_QuadricSetParam - set drawing style parameters

C SPECIFICATION

    void vgl_QuadricSetParamf (vgl_Quadric *quadric,
                               Vint ptype,
                               Vfloat fparam)
    
    void vgl_QuadricSetParami (vgl_Quadric *quadric,
                               Vint ptype,
                               Vint iparam)
    

INPUT ARGUMENTS

    quadric      Pointer to Quadric object.
    ptype        Type of drawing parameter to set
                 =QUADRIC_AZIMUTHSTART    Starting value of azimuthal angle
                 =QUADRIC_AZIMUTHSTOP     Stopping value of azimuthal angle
                 =QUADRIC_LINE            Feature line flag
                 =QUADRIC_FILL            Fill flag
                 =QUADRIC_SHADE           Type of normals to generate
                 =QUADRIC_SLICES          Resolution along azimuth.
                 =QUADRIC_STACKS          Resolution along elevation.
                 =QUADRIC_TEXTURECOORD    Texture coordinate generation flag
    fparam       Specifies the float value that ptype will be set to.
    iparam       Specifies the integer value that ptype will be set to.
    

OUTPUT ARGUMENTS

    None
    

ERRORS

VIS_ERROR_ENUM is generated if an improper node ptype is specified.

DESCRIPTION

Set drawing parameters. The QUADRIC_AZIMUTHSTART and QUADRIC_AZIMUTHSTOP parameters allow portions of the quadric surface to be drawn bound by the specified azimuthal angle. The values are specified in degrees. The default start and stop values are 0. and 360.

The QUADRIC_FILL parameter enables polygon generation By default QUADRIC_FILL is enabled. The QUADRIC_LINE parameter enables feature polyline generation By default QUADRIC_LINE is disabled.

The QUADRIC_SHADE parameter specifies the type of normals generated for light source shading. Possible values are VGL_NOSHADE, VGL_FLATSHADE and VGL_VERTEXSHADE. The default normal generation is VGL_FLATSHADE.

The QUADRIC_SLICES and QUADRIC_STACKS parameters specify the resolution of the surface tesselation. The default slices and stacks are 17 and 9. This resolution generates 128 quadrilateral polygons.

The QUADRIC_TEXTURECOORD parameter enables texture coordinate generation. The default is off.


Quadric

NAME

vgl_QuadricSetParamfv - set drawing parameters.

C SPECIFICATION

    void vgl_QuadricSetParamfv (vgl_Quadric *quadric,
                                Vint ptype,
                                Vfloat fparam[])
    

INPUT ARGUMENTS

    quadric      Pointer to Quadric object.
    ptype        Type of drawing parameter to set
                 =QUADRIC_ORIGIN          Origin of quadric
    fparam       Specifies the float values that ptype will be set to.
    

OUTPUT ARGUMENTS

    None
    

ERRORS

VIS_ERROR_ENUM is generated if an improper node ptype is specified.

DESCRIPTION

Set drawing parameters. The QUADRIC_ORIGIN parameter defines the world coordinate origin of the quadric.


Quadric

NAME

vgl_QuadricSphere - draw a sphere

C SPECIFICATION

    void vgl_QuadricSphere (vgl_Quadric *quadric,
                            Vfloat rad),
    

INPUT ARGUMENTS

    quadric      Pointer to Quadric object.
    rad          Radius of sphere
    

OUTPUT ARGUMENTS

    None
    

DESCRIPTION

Draw a sphere of radius rad oriented along the z axis. The center of the sphere is at the origin. The circumferential angle is zero at the positive x axis and follows the right hand rule about the z axis. The azimuthal angle is -90. degrees at the negative z axis and 90. degrees at the positive z axis. Texture coordinates vary from 0. to 1. in the circumferential direction and from 0. to 1. from the azimuthal direction.