ScummVM API documentation
rap_api.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_RAP_API_HH
28 #define ICB_RAP_API_HH
29 
30 #include "engines/icb/gfx/psx_pcdefines.h"
31 
32 #include "common/endian.h"
33 
34 namespace ICB {
35 
36 #define RAP_API_SCHEMA 10
37 
38 #define RAP_API_ID "RAP"
39 
40 // A bone-bone link
41 // tx, ty, tz : is translation
42 // parent : is the parent bone ID
43 // = nBones means no linkage
44 typedef struct BoneLink {
45  int16 tx, ty, tz;
46  uint16 parent;
47 } BoneLink;
48 
49 // A simple vertex description
50 typedef struct Vertex {
51  int16 vx, vy, vz;
52  uint16 vertId;
53 } Vertex;
54 
55 // A vertex-bone link
56 typedef struct VertexLink {
57  int16 vx, vy, vz; // the position in bone co-ordinate frame
58  int16 primId; // bone id - -ve number means no bone just "local" frame
59  uint32 vertId; // vertex id
60 } VertexLink;
61 
62 // A weighted vertex-bone link
63 typedef struct WeightedVertexLink {
64  VertexLink link;
65  uint32 weight; // % weight (fixed-point int scaled to weightScale)
67 
68 // Each polygon is 6 32-bit WORDS
69 // Bit 31 ----> Bit 0
70 //
71 // 8-bits | 8-bits | 16-bits
72 // --------------------------
73 // u0 | v0 | cba
74 // u1 | v1 | tsb
75 // u2 | v2 | pad
76 // --------------------------
77 // n0 | v0
78 // n1 | v1
79 // n2 | v2
80 //
81 // u0, v0 = u,v of vertex 0 : 0-255
82 // u1, v1 = u,v of vertex 1 : 0-255
83 // u2, v2 = u,v of vertex 2 : 0-255
84 // cba = weird PSX flag, giving the VRAM x,y of the CLUT to use
85 // tsb = weird PSX flag, giving the VRAM texture page to use
86 // pad = padding !
87 //
88 // n0, v0 = index into the normal and vertex pool for normal/vertex 0
89 // n1, v1 = index into the normal and vertex pool for normal/vertex 1
90 // n2, v2 = index into the normal and vertex pool for normal/vertex 2
91 //
92 // The .rap file format
93 //
94 // Notice, how poor ANSI C/C++ is at its representation
95 //
96 
97 typedef struct {
98  char id[4];
99  uint32 schema;
100  uint32 platform;
101  uint32 worldScaleShift;
102  uint32 weightScaleShift;
103  uint32 bothScaleShift;
104  uint32 nNone;
105  uint32 nSingle;
106  uint32 nMultiple;
107  uint32 nFUS3;
108  uint32 nGUS3;
109  uint32 nFTS3;
110  uint32 nGTS3;
111  uint32 nFUL3;
112  uint32 nGUL3;
113  uint32 nFTL3;
114  uint32 nGTL3;
115  uint16 nTRI3;
116  uint16 nFrames;
117  uint32 nAnimTypes;
118  uint32 animPolySize; // in bytes
119  uint16 nBones;
120  int8 jawBone; // -1 - means not there
121  int8 neckBone; // - 1 - means not there
122  uint32 singleLinkOffset; // in bytes
123  uint32 multiLinkOffset; // in bytes
124  uint32 FUS3offset; // in bytes
125  uint32 GUS3offset; // in bytes
126  uint32 FTS3offset; // in bytes
127  uint32 GTS3offset; // in bytes
128  uint32 FUL3offset; // in bytes
129  uint32 GUL3offset; // in bytes
130  uint32 FTL3offset; // in bytes
131  uint32 GTL3offset; // in bytes
132  uint16 TRI3offset; // in bytes
133  uint16 animPolyOffset; // in bytes
134  uint32 normalOffset; // in bytes
135  uint32 boneOffset; // in bytes
136  Vertex noneLinkData[1]; // Vertex noLinkData[nNone];
137 } RapAPI;
138 
140 public:
141  static Vertex *GetNoneLinkPtr(RapAPI *rap) { return rap->noneLinkData; }
142 
143  static VertexLink *GetSingleLinkPtr(RapAPI *rap) { return (VertexLink *)(rap->id + rap->singleLinkOffset); }
144 
145  static WeightedVertexLink *GetMultiLinkPtr(RapAPI *rap) { return (WeightedVertexLink *)(rap->id + rap->multiLinkOffset); }
146 
147  static uint32 *GetFUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUS3offset); }
148  static uint32 *GetGUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUS3offset); }
149  static uint32 *GetFTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTS3offset); }
150  static uint32 *GetGTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTS3offset); }
151  static uint32 *GetFUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUL3offset); }
152  static uint32 *GetGUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUL3offset); }
153  static uint32 *GetFTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTL3offset); }
154  static uint32 *GetGTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTL3offset); }
155  static uint32 *GetTRI3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->TRI3offset); }
156  static uint32 *GetNormalPtr(RapAPI *rap) { return (uint32 *)(rap->id + rap->normalOffset); }
157  static BoneLink *GetBonePtr(RapAPI *rap) { return (BoneLink *)(rap->id + rap->boneOffset); }
158  static uint32 *GetBoneHashPtr(RapAPI *rap) {
159  BoneLink *bPtr = GetBonePtr(rap);
160  return (uint32 *)(bPtr + rap->nBones);
161  }
162  static uint32 *GetAnimPolyPtr(RapAPI *rap) {
163  return (uint32 *)(rap->id + rap->animPolyOffset);
164 
165  }
166  static uint32 *GetAnimPolyFrame(RapAPI *rap, int32 frame) {
167  return (uint32 *)(rap->id + rap->animPolyOffset + rap->nAnimTypes * 2 * sizeof(uint32) + frame * rap->animPolySize);
168  }
169 };
170 
171 inline void ConvertRAP(RapAPI *rap) {
172  // Do we need to do any conversion ?
173  if (FROM_LE_32(rap->schema) == RAP_API_SCHEMA)
174  return;
175 
176  // You can't so a schema check will fail !
177  return;
178 }
179 
180 } // End of namespace ICB
181 
182 #endif // #ifndef RAP_API_HH
Definition: actor.h:32
Definition: rap_api.h:139
Definition: rap_api.h:97
Definition: rap_api.h:50