Japanese
PROGRAMMER'S GUIDEVDP1 library
BackForward
VDP1 library

6.VDP1 3D Reference


6.1 Data specifications


 Title

data specifications

 Data

cluster definition

 Data Name

SprCluster

 No

 typedef struct SprCluster {
     Uint16 no; /* Cluster number */
     Uint16 angleSeq; /* Rotation order */
     MthXyz angle; /* Rotation in the parent cluster's coordinate system */
     MthXyz point; /* Coordinates of the origin in the parent cluster's coordinate system */
     SprObject3D *object /* 3D object */
     SprCluster *next; /* Next cluster */
     SprCluster *child; /* Child cluster */
     SprInbetInf *inbetInf; /* Connection polygon information between objects */
     void (*transStart)(SprCluster*);
                                   /* User callback routine before starting coordinate transformation */
     void (transEnd)(SprCluster*, SprObject3D*, MthMatrix*, MthXyz*);
                                   /* User callback routine after coordinate transformation */
     void *context; /* User context area */
} SprCluster;

no is used by the user callback routine to identify the cluster table, and is optional.

 angleSeq = ROT_SEQ_ZYX: Rotate the object in the order of Z→Y→X = ROT_SEQ_ZXY: ” Z→X→Y ”
           = ROT_SEQ_YZX : ”Y→Z→X”
           = ROT_SEQ_YXZ : ”Y→X→Z”
           = ROT_SEQ_XYZ : ”X→Y→Z”
           = ROT_SEQ_XZY : ”X→Z→Y”

 If the 3D object, next cluster, and child cluster are not connected, set object, next, and child to 0, respectively.

If there is no connection polygon information between objects, set inbetInf to 0.

transStart specifies a user callback routine that is called before starting the coordinate transformation for this cluster. The routine moves clusters, changes object data, etc. Set to 0 if there is no callback routine.

[TransStart routine calling sequence] void transStart(SprCluster *cluster);
cluster: Local cluster table

 transEnd specifies a user callback routine that is called after the coordinate transformation for this cluster is complete. This callback routine uses 3D data connected to the cluster.
Called for each object. Set to 0 if there is no callback routine.

[TransStart routine calling sequence] void transEnd(SprCluster *cluster, SprObject3D *object,
MthMatrix *worldMatrix, MthXyz *worldVertPoint);
cluster: Own cluster table object: 3D object table worldMatrix: Transformation matrix to world coordinate system (3 rows and 4 columns) worldVertPoint: Vertex coordinate value table in the world coordinate system (Returned when #define SPR_3NEED_WORLD_VERT is defined in the 3D sprite work area definition macro.)

context specifies the context area used by the user callback routine for each cluster. If not, set it to 0.


 Title

data specifications

 Data

object definition

 Data Name

SprObject3D

 No

 typedef struct SprObject3D {
     Uint16 no; /* Object number */
     Uint16 dispFlag /* Display flag */
     Uint16 vertCount; /* Number of vertices */
     Uint16 surfaceCount; /* Number of surfaces */
     MthXyz *vertPoint; /* Vertex coordinate table */
     MthXyz *vertNormal; /* Vertex normal vector table */
     SprSurface *surface; /* Surface definition table */
     MthXyz *surfaceNormal; /* Surface normal vector table */
     MthXyz *surfaceVert; /* Surface representative point coordinate table */
     Uint16 **shdIdxTbl; /* Shading index table */
     Fixed32 surfNormK; /* Calculation correction value of surface normal vector */
     SprObject3D *next; /* Next 3D object */
} SprObject3D;

no is used by the user callback routine to identify the object table, and is optional.

 dispFlag b15,b14 = 00: Polygon display = 10: Polyline display

b12 = 1: double-sided polygon

b9,b8 = 00: No shading 01: Flat shading 10: Gouraud shading

b4 = 1: Connection polygon object between objects

 vertNormal: Set when performing Gouraud shading.
surface: Pointer to the table that defines the vertices that make up the surface and color information for each surface surfaceNormal: Pointer to the table that defines the normal for each surface surfaceVert: Representative point of the surface that is referenced when calculating the brightness of the surface (Center point) Sets the coordinate table pointer. If set to 0, the first vertex of the surface definition will be used as the representative point.
shdIdxTbl: When performing flat shading using a shading table, set the index table of the shading table. When Gouraud shading is specified,
              If this parameter is specified, shdIdxTbl[0] will be the Gouraud shading Gray code table. If flat shading is used and the surface definition drawing mode is texture specification, if this parameter is specified, shdIdxTbl[0] will be used as the flat shading Gray code table.
surfNormK: Specify this when calculating the surface normal vector for this object using the SPR_3SetNormVect() routine, or when this object is an inter-object connection polygon object. For details, see the MTH_ComputeNormVect() routine in the mathematical calculation library.
              See fNormK parameter.
              For object-to-object connection polygon objects, specify a negative value.

If the vertex normal vector table, shading index table, and next object are not connected, set vertNormal, shdIdxTbl, and next to 0, respectively.

The shading table is specified in the following format using 32 levels of RGB code.

Uint16 shadingTbl[32]; 0←Dark Light→31

If double-sided polygon specification is set to 1, single-sided polygon data will be displayed on both sides.


 Title

data specifications

 Data

surface definition

 Data Name

SprSurface

 No

 typedef struct SprSurface {
     Uint16 vertNo[4]; /* Vertex number composing the surface */
     Uint16 drawMode; /* draw mode */
     Uint16 color; /* Color data */
} SprSurface;

drawMode b15,b14 = 00: color is the color code 01: color is the texture character number 10: color is the shading table index number 11: color is the original RGB code for automatic shading

b13,b12 = 00: Set the minimum value among the 4 vertices after coordinate transformation as the target point for Z sorting. 01: The maximum value among the 4 vertices after coordinate transformation is the target point for Z sorting. 10: Set the center value of the 4 vertices after coordinate transformation as the target point for Z sorting.

b11-b0: Same as sprite drawing mode word. If you specify a texture in drawMode, the color bits will be as follows: color b15,b14 specifies the texture inversion mode. b15,b14 =00: No reversal =01: Horizontal reversal =10: Vertical reversal =11: Vertical, horizontal reversal

b13-b0: Texture character number


 Title

data specifications

 Data

Connection polygon information between objects

 Data Name

SprInbetInf

 No

 typedef struct SprInbetInf {
     Sint32 vertCount; /* Number of vertices to extract */
     SprObject3D *fromObj; /* Connection vertex data extraction object */
     Uint16 *fromVertNo; /* Extract vertex number array */
     SprObject3D *toObj; /* Connection vertex data setting object */
     Uint16 *toVertNo; /* Setting vertex number array */
     SprInbetInf *next; /* Connection polygon information between next objects */
} SprTexture;

If there is no connection polygon information between the next objects, set next to 0.


 Title

data specifications

 Data

texture table

 Data Name

SprTexture

 No

 typedef struct SprTexture {
     Uint16 charNo; /* Character number */
     Uint16 colorMode; /* Color mode */
     Uint16 color; /* Color data */
     Uint16 width; /* Character width */
     Uint16 height; /* Character height */
     Uint8 *charData; /* Character data pointer */
     SprLookupTbl *lookupTbl; /* Lookup table pointer */
} SprTexture;

SprTexture texture[n]; The charNo of the final entry should be 0xffff (stopper).

colorMode : b5 - b3 is the same as the sprite drawing mode word. color: Color data Lookup table number when color mode = 1 Color bank code when color mode = 0, 2, 3, 4 Ignored when color mode = 5


 Title

data specifications

 Data

3D environment data table

 Data Name

Spr3dStatus

 No

 typedef struct Spr3dStatus {
     MthXyz lightAngle; /* Light source angle */
     MthXyz viewCoordPoint; /* View position in the view coordinate system */
     MthXyz viewPoint; /* Viewpoint coordinates */
     MthXyz viewAngle; /* View angle */
     Sint32 viewAngleSeq; /* View angle rotation operation */
     Sint32 zSortMode; /* Z sort Z coordinate value adoption mode */
     Fixed32 zSortZMin; /* Z sort current point coordinate system Z minimum value */
     Fixed32 zSortZMax; /* Z sort current coordinate system Z maximum value */
     Fixed32 clipZMin; /* Viewpoint coordinate system clip Z minimum value */
     Fixed32 clipZMax; /* View coordinate system clip Z maximum value */
     Sint32 clipLevel; /* Clipping level */
     MthXy unitPixel; /* Number of screen pixels for x,y1.0*/
} Spr3dStatus;


BackForward
PROGRAMMER'S GUIDEVDP1 library
Copyright SEGA ENTERPRISES, LTD., 1997