Japanese
SGL User's ManualData exchange
Back | ■
Passing data

4.Data structure


This chapter explains the structure of model data, material name specifications, and texture data handled by Sega Saturn.

4-1. Model data specifications

The model data here refers to a set of three data: point data of three-dimensional coordinates (x, y, x), polygon data formed by four of the points, and attribute data representing the attributes of the polygon. Masu.
Below is the general format when the model name is assumed to be "label".

point data


POINT point_label[]={   
      POStoFIXED(x,y,z),
      POStoFIXED(x,y,z),
      POStoFIXED(x,y,z),
      POStoFIXED(x,y,z),
           .............
      };                
	
POINT:Point data  x,y,z:Float type coordinate values

This is the index of point data 0, 1, 2, 3 in order from the top.

polygon data


POLYGON polygon_label[]={
     NORMAL(x,y,z),      
     VERTICES(0,1,2,3),  
                         
     NORMAL(x,y,z),      
     VERTICES(0,1,2,3),  
          .............  
    };                   
	
NORMAL: Normal vector  x,y,z:Float type coordinate values  VERTICES: Point data of 4 points forming a polygon

For triangular polygons, repeat the last point to create 4 points of polygon data.

Example) For quadrilateral polygons
VERTICES(0,1,2,3)

Example) For triangular polygons
VERTICES(0,1,2,2)

attribute data


ATTR attribute_label=[]={                                           
        ATTRIBUTE(Plane,Sort,Texture,Color,Gouraud,Mode,Dir,Option),
         ....... .... ..... ... ... ..... ... .....          
                                                                    
        };                                                          
	
ATTR: Attribute  Plane: Attribute to determine whether back side is present or not Sort: Representative point of Z sort  Texture: Texture name (No.)  Color: Color data  Gouraud: Attribute of Gouraud shading Mode: Drawing mode  Dir: State of polygons and textures Option: Options and other functions 

Attributes have the following eight parameters. Here we will describe the symbols that should actually be output for each parameter and their contents.

[Plane]
Single_Plane: Back side judgment available
Dual_Plane: No back side detection

[Sort]
SORT_MIN: Nearest point
SORT_CEN: center point
SORT_MAX: farthest point
SORT_BFR: Display in front of the polygon registered just before

[Texture]
No_Texture: For polygons
Texture name: For texture (macro indicating texture data)

For details, see “ Section 4-3 : Texture data specifications”.

[Color]
No_Palet: For textures
C_RGB( r, g, b: Color data for polygons
r, g, b represent the three primary colors, and each has a decimal value from 0 to 31.

[Gouraud]
No_Gouraud: No Gouraud
Address: relative address of Gouraud shading table

[Mode]
group macro Contents
[1] No_Window Not subject to restrictions within the window (default)
Window_In Display inside Window
Window_Out Display outside the window
[2] MESHoff Normal display (default)
MESHon Display as mesh
[3] ECdis Disable EndCode
ECenb Enable EndCode (default)
[4] SPdis Also display transparent pixels (default)
SPenb Do not display transparent pixels
[5] CL16Bnk 16 colors Color bank mode (default)
CL16Look 16 colors lookup table mode
CL64Bnk 64 colors color bank mode
CL128Bnk 128 colors color bank mode
CL256Bnk 256 colors color bank mode
CL32KRGB 32768 colors RGB mode
[6] CL_Replace Overwrite (standard) mode (default)
CL_Shadow shadow mode
CL_Half half brightness mode
CL_Trans Translucent mode
CL_Gouraud gouraud shading mode

[Dir]
macro Contents
sprNoflip Display texture normally
sprHflip Flip the texture horizontally
sprVflip Flip the texture vertically
sprHVflip Flip the texture vertically and horizontally
sprPorygon display polygons
sprPolyLine display polyline
sprLine Displays a straight line using the first two points

[Option]
macro Contents
UseLight Perform light source calculations
UseClip Do not display if a vertex goes off the screen
Use Palette Indicates that polygon colors are in palette format

Among the above parameters, Plane , Sort , and Mode can be obtained by specifying them in the material name in the next section.

PDATA structure


PDATA pdata_label[]={   
       point_label,n1,  
       polygon_label,n2,
       attribute_label  
      };                
	
pdata_label: Indicates the PDATA type address to be passed to SGL. point_label: Indicates the address of the POINT type.  nl: Indicates the number of points.  polygon_label: Indicates the address of POLYGON type.  n2: Indicates the number of polygons.  attribute_label: Indicates the ATTR type address. 

OBJECT structure


OBJECT object_label[]={   
       pdata_label,       
       TRANSLATION(x,y,z),
       ROTATION(x,y,z),   
       SCALING(x,y,z),    
       object_child,      
       object_sibling,    

pdata_label: Indicates the PDATA type address.  TRANSLATION: Indicates the amount of movement.  ROTATION: Indicates the amount of rotation.  SCALING: Indicates the amount of expansion.  object_child: Indicates the address of the child's OBJECT type. object_sibling: Indicates the address of the sibling OBJECT type.

Please refer to the “design 3” sample source for information on how to use this structure.

4-2. Material name specifications

Each character in the material name has a meaning. The contents will be reflected in the attribute data as is. Its specifications are shown below.

Generally, it is as follows.
[Plane][Sort][Mesh] ([] contains one character, and the material name is represented by three characters, for example “SSN”.)

The attributes of each character are

[Plane]
S:Single_Plane
D:Dual_Plane

[Sort]
N:SORT_MIN
C:SORT_CEN
F:SORT_MAX
B:SORT_BFR

[Mesh]
O:MESHon
N:MESHoff

Example) If the material name is “SCN”, the attribute data is

ATTRIBUTE( Single_Plane, SORT_CEN, No_Texture, C_RGB( r, g, b ), No_Gouraud, MESHoff, sprNoflip, NoOption )

It becomes.

4-3. Texture data specifications

This data is only required for textures. The texture name in the attribute data “Texture” is based on this data.

If the DGT file used as a texture is “sample.dgt”,


TEXDAT sample[]={                      
        rgb,rgb,rgb,rgb,rgb,rgb,rgb,rgb
        rgb,rgb,rgb,rgb,rgb,rgb,rgb,rgb
        ......................................  
        };                             

TEXTB: Texture table  sample: Indicates a label with texture data (file name as is) hsize,vsize: Texture size (hsize is always a multiple of 8)  bgr: 1 pixel of texture data 

In addition, each of the three primary colors is expressed using 5 bits with a value between 0 and 31.
The data format is as follows.

B G R
1 4 3 2 1 0 4 3 2 1 0 4 3 2 1 0

Example) Let's assume that the graphic data file sample.dgt is an 8x2 white and black checker texture as shown below.

Figure 4-1 Checkered texture

Then the texture data for this texture will be as follows.


TEXDAT sample[]={                                               
        0xffff,0x8000,0xffff,0x8000,0xffff,0x8000,0xffff,0x8000,
        0x8000,0xffff,0x8000,0xffff,0x8000,0xffff,0x8000,0xffff 
        };                                                      
	

The attribute data of the polygon with the material name “SCN” to which this texture is attached is as follows:

ATTRIBUTE(Single_Plane, SORT_CEN, SAMPLE, No_Palet, No_Gouraud, MESHoff, SprNoflip, NoOption)

It becomes.

Note
For textures, the H size must be a multiple of 8. This is a limitation due to Saturn's hardware specifications.


Back | ■
SGL User's ManualData exchange
Copyright SEGA ENTERPRISES, LTD., 1997