Iview Module

This module contains functions for manipulating Iview structures, which control the model display in the model view window. These structures also contain object view structures, usually one per object, with nearly all of the display properties such as color, transparency, etc, associated with individual objects. The model contains an array of view structures. The first element of this array is called the default view, and it used in 3dmod as the primary source for display properties. This default view does not contain any object views; the objects themselves are the source of the properties used to display them. Also, the default view is not saved to the model file. The default view is always associated with one of the actual views in the array, the current view. Usually, the current view mirrors the default view and has object views that mirror the properties of the objects.

This module also has two functions for reading and writing the image transformation information associated with a model.

Header to include: iview.h
(includes imodel.h)


Iview *imodViewNew(int size)
void imodViewDelete(Iview *vw)
void imodViewDefault(Iview *vw)
void imodViewDefaultScale(Imod *imod, Iview *vw, Ipoint *imageMax, float binScale)
void imodViewModelDefault(Imod *imod, Iview *vw, Ipoint *imageMax)
int imodViewWrite(Iview *vw, FILE *fout, Ipoint *scale)
int imodViewModelRead(Imod *imod)
int imodViewClipRead(Imod *imod)
int imodViewModelNew(Imod *imod)
void imodObjviewToObject(Iobjview *objview, Iobj *obj)
void imodObjviewFromObject(Iobj *obj, Iobjview *objview)
void imodViewUse(Imod *imod)
int imodViewStore(Imod *imod, int cview)
int imodObjviewComplete(Imod *imod)
void imodObjviewDelete(Imod *imod, int index)
void imodObjviewsFree(Imod *imod)
int imodIMNXRead(Imod *imod)
int imodIMNXWrite(Imod *imod)
IrefImage *imodIMNXNew()


World flags
Iobjview structure
Iview structure
IrefImage structure

Iview *imodViewNew(int size)

Allocates a new array of Iview structure of the given size. Returns NULL for error.

void imodViewDelete(Iview *vw)

Frees the Iview structure or array of Iviews in vw, without freeing any object views.

void imodViewDefault(Iview *vw)

Sets default entries for the view vw with no model information, i.e. sets the rad to 1.0 and assumes no object views

void imodViewDefaultScale(Imod *imod, Iview *vw, Ipoint *imageMax, float binScale)

Sets the default scaling for a view vw based on current model dimensions in model imod.  If the model is empty and has no extent, it assumes the image dimensions given in imageMax.  The ratio of Z binning to X/Y binning given in binScale, as well as the model zscale, is used to scale the Z dimensions.

void imodViewModelDefault(Imod *imod, Iview *vw, Ipoint *imageMax)

Sets up a default view in vw given model information in imod and image dimensions in imageMax. No longer used in 3dmod but kept for consistency and for RIB conversion

int imodViewWrite(Iview *vw, FILE *fout, Ipoint *scale)

Writes an Iview structure vw, including object views and a model clip plane chunk, to the file fout.  Clip plane points are scaled by scale, and normals are scaled by the inverse.  Returns IMOD_ERROR_WRITE for error.

int imodViewModelRead(Imod *imod)

Reads one Iview structure into model imod from the model element file, and adds it to the model's view array.  Reads object views as well. Returns IMOD_ERROR_READ for error.

int imodViewClipRead(Imod *imod)

Reads the variable-sized model clip plane chunk.  Returns IMOD_ERROR_READ for error.

int imodViewModelNew(Imod *imod)

Adds a new view to view array in the model imod and assigns it default properties.  Returns IMOD_ERROR_MEMORY for memory error.

void imodObjviewToObject(Iobjview *objview, Iobj *obj)

Copies all of the characteristics from the Objview structure objview to the object obj

void imodObjviewFromObject(Iobj *obj, Iobjview *objview)

Copies all of the characteristics from the object obj to the object view objview.

void imodViewUse(Imod *imod)

Makes the view specified by the cview element of model imod be the current view by copying it to the default view (element 0 of the view array) and setting object properties from any object views.

int imodViewStore(Imod *imod, int cview)

Stores the default view and information about all objects in the cview element of the view array of model imod.  Returns IMOD_ERROR_MEMORY for memory error.

int imodObjviewComplete(Imod *imod)

Makes the actual model views in imod have a complete set of object views, copying from object properties into all views if any need to be created. Returns IMOD_ERROR_MEMORY for error.

void imodObjviewDelete(Imod *imod, int index)

Deletes the object views for object index from all of the views in model imod.

void imodObjviewsFree(Imod *imod)

Frees the object views from all views in model imod.

int imodIMNXRead(Imod *imod)

Allocates an IrefImage structure and reads the IMONX chunk for model imod.  Returns -1 for error.

int imodIMNXWrite(Imod *imod)

Writes the IrefImage structure refImage in model imod if any. Returns -1 if there is none.

IrefImage *imodIMNXNew()

Allocates and returns a new IrefImage structure with default values of 1 for cscale and oscale and 0 for crot, ctrans, orot, and otrans.

World flags

Definitions for bits of the Iview world flag
#define VIEW_WORLD_ON         1         /* Use mat matrix for transformation */
#define VIEW_WORLD_LIGHT      (1l << 1)  /* Use lighting */
#define VIEW_WORLD_DEPTH_CUE  (1l << 2)  /* Enable depth cueing */
#define VIEW_WORLD_WIREFRAME  (1l << 3)  /* Show wireframe not surface */

#define VIEW_WORLD_STEREO   (1l << 4)    /* Stereo flags (Unused 8/21/07) */
#define VIEW_WORLD_HARDWARE (1l << 5)
#define VIEW_WORLD_UPDOWN   (1l << 6)
#define VIEW_WORLD_LOWRES  (1l << 7)

/* Shift and actual bits reserved for point quality (8, 9, 10) */
#define WORLD_QUALITY_SHIFT  8
#define WORLD_QUALITY_BITS   (7l << WORLD_QUALITY_SHIFT)

#define WORLD_KICKOUT_CLIPS (1l << 11)  /* Push Z clipping planes far out */
#define WORLD_MOVE_ALL_CLIP (1l << 12)  /* Move all clipping planes together */
#define VIEW_WORLD_INVERT_Z (1l << 13)  /* Invert Z in model view */

Iobjview structure

Properties of an object that are stored in a view
typedef struct Mod_Object_View
{
  b3dUInt32              flags;               /* bit flags IMOD_OBJFLAG        */
  b3dFloat   red;                 /* Red (0 - 1.0)                 */
  b3dFloat   green;               /* Green (0 - 1.0)               */
  b3dFloat   blue;                /* Blue (0 - 1.0)                */
  b3dInt32     pdrawsize;           /* size to draw scattered objs   */

  b3dUByte     linewidth;           /* linewidth in 3-D              */
  b3dUByte     linesty;             /* line draw style               */
  b3dUByte     trans;               /* transperentcy                 */

  /* define clipping planes. max for each object is 7. */
  IclipPlanes clips;

  /* Added info IMAT */
  b3dUByte ambient;   /* Ambient multiplier to color */
  b3dUByte diffuse;   /* Diffuse multiplier to color */
  b3dUByte specular;  /* Specular property, added to color */
  b3dUByte shininess; /* shininess exponent */
  b3dUByte fillred;   /* Fill color red */
  b3dUByte fillgreen; /* Fill color green */
  b3dUByte fillblue;  /* Fill color blue */
  b3dUByte quality;   /* Sphere quality */
  b3dUInt32 mat2;     /* set to 0, use as flags.  Unused */
  b3dUByte valblack;  /* Black level for showing values */
  b3dUByte valwhite;  /* White level for showing values */
  b3dUByte matflags2; /* First two bits: skip low and high end in value draw */
  b3dUByte mat3b3;    /* Unused */
}Iobjview;

Iview structure

Properties of a model view
typedef struct
{
  /* Set up the camera */
  b3dFloat  fovy;   /* field of view of camera, perspective in degrees.  */
  b3dFloat  rad;    /* viewing radius of sphere encloseing bounding box. */
  b3dFloat  aspect; /* aspect ratio */
  b3dFloat  cnear;  /* clip near range 0.0 to 1.0, default 0.0. */
  b3dFloat  cfar;   /* clip far range 0.0 to 1.0, default 1.0. */
     
  /* Model transformation values for model view. */
  Ipoint rot;
  Ipoint trans;
  Ipoint scale;

  /* World OpenGL transformation matrix (unused 8/21/07). */
  b3dFloat mat[16];

  b3dUInt32 world;       /* flags */
  b3dByte  label[VIEW_STRSIZE];   /* Label for view */

  b3dFloat dcstart, dcend;  /* Depth cue start and end */
  b3dFloat lightx, lighty;  /* Light position X and Y */
  b3dFloat plax;            /* Parallax angle for stereo */
  IclipPlanes clips;        /* Global clipping planes */
  Iobjview *objview;        /* Array of properties of each object */
  b3dInt32 objvsize;        /* Number of objects properties exist for */
     
}Iview;

IrefImage structure

A structure for keeping track of current and previous image transformation information for a model loaded on an image file
typedef struct
{
  Ipoint oscale;
  Ipoint otrans;
  Ipoint orot;

  Ipoint cscale;
  Ipoint ctrans;
  Ipoint crot;

}IrefImage;