Iplane Module

This module contains functions for manipulating clipping planes. The planes can be in either arrays of a simple structure or in the more complicated structures that are maintained in model objects.

Header to include: iplane.h


Iplane *imodPlanesNew(int size)
void imodPlaneDelete(Iplane *plane)
void imodPlaneInit(Iplane *plane)
void imodPlaneSetPN(Iplane *plane, Ipoint *pnt, Ipoint *nor)
int imodPlaneClip(Iplane *plane, Ipoint *pnt)
int imodPlanesClip(Iplane *plane, int nplanes, Ipoint *pnt)
void imodClipsInitialize(IclipPlanes *clips)
void imodClipsCopy(IclipPlanes *fromClips, IclipPlanes *toClips)
int imodClipsRead(IclipPlanes *clips, FILE *fin)
void imodClipsFixCount(IclipPlanes *clips, b3dUInt32 flags)
void imodPlaneSetFromClips(IclipPlanes *objClips, IclipPlanes *glbClips, Iplane *plane, int maxPlanes, int *nPlanes)
void imodClipsTrans(IclipPlanes *clips, Imat *mat, Imat *mat2)


Iplane structure
IclipPlanes structure

Iplane *imodPlanesNew(int size)

Allocates an array of size Iplane structure, initializes them, and returns the pointer to the array, or NULL for error.

void imodPlaneDelete(Iplane *plane)

Frees an array of Iplane structure in plane.

void imodPlaneInit(Iplane *plane)

Initializes the Iplane structure in plane to the X/Y plane with a negative Z normal.

void imodPlaneSetPN(Iplane *plane, Ipoint *pnt, Ipoint *nor)

Set parameters of plane from a point pnt on a plane and a normal vector nor

int imodPlaneClip(Iplane *plane, Ipoint *pnt)

Tests whether point pnt is in the half space defined by the clipping plane plane, and returns 1 if it is or 0 if the point needs to be clipped.

int imodPlanesClip(Iplane *plane, int nplanes, Ipoint *pnt)

Tests whether point pnt is in the region defined by the nplanes clipping planes in plane, and returns 1 if it is or 0 if the point needs to be clipped.

void imodClipsInitialize(IclipPlanes *clips)

Initializes all clip planes and other parameters of the clip plane set in the IclipPlanes structure clips

void imodClipsCopy(IclipPlanes *fromClips, IclipPlanes *toClips)

Copies the clip planes and parameters of the clip plane set in fromClips to toClips.

int imodClipsRead(IclipPlanes *clips, FILE *fin)

Reads all the clip planes of a set into clips from the model file in fin; the number of vectors and normals read is based on the size of the data chunk

void imodClipsFixCount(IclipPlanes *clips, b3dUInt32 flags)

Fixes the count of clip planes in clips for old files or for a count set to zero when written in a new file.  flags should be the flags from the model structure.

void imodPlaneSetFromClips(IclipPlanes *objClips, IclipPlanes *glbClips, Iplane *plane, int maxPlanes, int *nPlanes)

Sets plane parameters in the plane array from the clipping plane sets in both objClips and glbClips, based upon which planes are on in each set.  Either objClips or glbClips can be NULL; i.e. one set of planes can be used.  maxPlanes should specify the size of the plane array or the maximum number of planes to set.  nPlanes is returned with the number of planes set up.  It should be set to zero before first the (first) call to this function.

void imodClipsTrans(IclipPlanes *clips, Imat *mat, Imat *mat2)

Transforms the clipping planes in clips, using mat to transform the points and mat2 to transform the normals.

Iplane structure

Holds the parameters for a clipping plane described by ax + by + cz = d
typedef struct Mod_Plane
{
  b3dFloat a, b, c, d;
} Iplane;

IclipPlanes structure

Holds a set of clipping planes, which may be part of an object, a view, or an object view
typedef struct Mod_Planes
{
  b3dUByte count;        /* number of clip planes.            */
  b3dUByte flags;        /* Which clip planes are on.         */
  b3dUByte trans;        /* Transparency for clipped area     */
  b3dUByte plane;        /* Current clip plane.               */
  Ipoint normal[IMOD_CLIPSIZE];   /* Normal vector to plane */
  Ipoint point[IMOD_CLIPSIZE];    /* Negative of point in clip plane */
} IclipPlanes;