📄 regiscol.cpp
字号:
}
GLint readBeadList ()
{
if (BeadListPos == -1) return -1;
in.movefileptr (BeadListPos);
beadRoot = readBeadData ();
if (GlobalErrorFlag & 1) return -1;
return 0;
}
GLbeadTree *readBeadData ()
{
in.read ("%s", inString);
GLint type = GetStringType ((GLbyte *) inString);
if (type == 'Bead') {
GLbeadTree *bead = allocateBead ();
if (!bead) {
printf ("Can not allocate bead memory\n");
return 0;
}
GLint tempfilepos = in.getfileptr ();
in.read ("%s", inString);
GLint filepos = in.getfileptr ();
GLint pos = findString (inString);
if (pos == -1) {
GlobalErrorFlag |= 1;
return 0;
}
in.movefileptr (pos);
in.read ("%s", inString);
type = GetStringType ((GLbyte *) inString);
if (type == 'Bead') {
in.movefileptr (tempfilepos);
in.read ("%s", inString);
pos = findString (inString);
if (pos == -1) {
GlobalErrorFlag |= 1;
return 0;
}
in.movefileptr (pos);
}
else {
int parenttype = -1;
if (type == 'Name') {
in.read ("%s", beadName); // name
strupr (beadName);
in.read ("%s", inString); // "Type"
in.read ("%s", inString); // type
parenttype = GetStringType ((GLbyte *) inString);
switch (parenttype) {
// Ignore polygon information
case 'Info': // Polygon Information
{
GLint totalvert, j, k, l;
in.read ("%s", inString); // "VertexList"
in.read ("%d", &totalvert); // total vertices
for (j=0; j < totalvert; j++) {
in.read ("%d", &k);
}
while (1) {
in.read ("%s", inString);
type = GetStringType ((GLbyte *) inString);
if (type == 'ZZZZ') break;
switch (type) {
case 'Colo': // Color
in.read ("%d", &j);
in.read ("%d", &j);
in.read ("%d", &j);
in.read ("%d", &j);
break;
case 'Obje': // ObjectID
in.read ("%d", &j);
break;
case 'Text': // TextureNo
in.read ("%d", &j);
in.read ("%d", &l);
break;
case 'Tran': // Transparency
in.read ("%d", &j);
break;
case 'TwoS': // TwoSided
case 'Wire': // Wireframe
case 'Bill': // Billboard
case 'Tree': // Tree Billboard
case 'NoSh': // NoShading
break;
case 'Subf': // Subface
in.read ("%s", inString); // Subface address
GLint subfacepos = in.getfileptr ();
pos = findString (inString);
if (pos == -1) {
GlobalErrorFlag |= 1;
return 0;
}
in.movefileptr (pos);
readBeadData ();
in.movefileptr (subfacepos);
break;
}
}
}
break;
case 'Poly': // Polygon
{
GLint totalvert, j;
in.read ("%s", inString); // "VertexList"
in.read ("%d", &totalvert); // total vertices
GLint l;
GLfloat faceAlpha = 0.0f;
GLint faceColor = 0;
for (j=0; j < totalvert; j++)
in.read ("%d", &polyvertices[j]);
while (1) {
in.read ("%s", inString);
type = GetStringType ((GLbyte *) inString);
if (type == 'ZZZZ') break;
switch (type) {
case 'Colo': // Color
in.read ("%d", &j);
faceColor = j & 255;
in.read ("%d", &j);
faceColor |= ((j & 255) << 8);
in.read ("%d", &j);
faceColor |= ((j & 255) << 16);
in.read ("%d", &j);
faceColor |= ((j & 255) << 24);
break;
case 'Obje': // ObjectID
in.read ("%d", &j);
break;
case 'Text': // TextureNo
in.read ("%d", &j);
in.read ("%d", &l);
break;
case 'Tran': // Transparency
in.read ("%d", &j);
faceAlpha = (GLfloat) (j & 0xffff) / (GLfloat) 0xffff;
break;
case 'TwoS': // TwoSided
break;
case 'Wire': // Wireframe
break;
case 'Bill': // Billboard
break;
case 'Tree': // Tree Billboard
break;
case 'NoSh': // NoShading
break;
case 'Subf': // Subface
in.read ("%s", inString); // Subface address
GLint subfacepos = in.getfileptr ();
pos = findString (inString);
if (pos == -1) {
GlobalErrorFlag |= 1;
return 0;
}
in.movefileptr (pos);
readBeadData ();
in.movefileptr (subfacepos);
break;
}
}
if (faceAlpha) {
GLint a = (GLint) (faceAlpha * 255.0f);
faceColor = (a << 24) | (faceColor & 0xffffff);
}
InsertColor (faceColor);
}
break;
case 'Grou': // Group
break;
case 'Obje': // Object
break;
case 'BSP\0':
{
GLfloat f;
in.read ("%s", inString); // "Plane"
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
break;
case 'Degr': // DegreeOfFreedom
{
GLfloat f;
while (1) {
in.read ("%s", inString);
type = GetStringType ((GLbyte *) inString);
if (type == 'ZZZZ') break;
if (!strcmp (inString, "Origin")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "Yaw")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "Pitch")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "Roll")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "Scale")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "XTranslation")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "YTranslation")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "ZTranslation")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "PointXAxis")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "PointXYPlane")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "XAxis")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "YAxis")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "ZAxis")) {
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
else if (!strcmp (inString, "AxisRotation")) {
GLint yaw, pitch, roll;
in.read ("%d", &yaw);
in.read ("%d", &pitch);
in.read ("%d", &roll);
}
}
}
break;
case 'Swit': // Switch
{
in.read ("%s", inString); // "TotalMask"
in.read ("%s", inString);
in.read ("%s", inString); // "MaskValue"
in.read ("%s", inString);
}
break;
case 'Box\0': // Bounding Box
{
GLfloat f;
in.read ("%s", inString); // "Minimum"
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%s", inString); // "Maximum"
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
break;
case 'Sphe': // BoundingSphere
{
GLfloat f;
in.read ("%s", inString); // "Radius"
in.read ("%f", &f);
}
break;
case 'Matr':
{
GLfloat f;
in.read ("%s", inString); // "Plane"
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
in.read ("%f", &f);
}
break;
}
}
in.movefileptr (filepos);
in.read ("%s", inString);
type = GetStringType ((GLbyte *) inString);
if (type == 'Chil') {
in.read ("%s", inString);
if (*inString != '0') {
int filepos = in.getfileptr ();
pos = findString (inString);
if (parenttype != 'Obje' && parenttype != 'Grou') {
if (pos == -1) {
GlobalErrorFlag |= 1;
return 0;
}
}
if (pos != -1) {
in.movefileptr (pos);
bead -> child = readBeadData ();
in.movefileptr (filepos);
}
}
}
}
GLbeadTree *bead1 = bead;
while (bead1 -> next) bead1 = bead1 -> next;
bead1 -> next = readBeadData ();
return bead;
}
return 0;
}
// return -1 if can not find string, else return file position after string
GLint findString (char *string)
{
char str[256];
GLint i, j;
GLint filepos = in.getfileptr ();
j = 0;
while (1) {
do {
in.readline (str, 255);
if (in.eof()) {
if (j) {
printf ("Unexpected end of file! Can not find \'%s\'!\n", string);
in.movefileptr (filepos);
return -1;
}
in.movefileptr (); // find from the beginning
i = 0;
j = 1;
}
else i = *((int *) str);
} while (i != '====');
in.read ("%s", str);
if (!strcmp (str, string)) {
i = in.getfileptr ();
in.movefileptr (filepos);
return i;
}
}
}
GLbeadTree *allocateBead ()
{
GLbeadTree *bead = (GLbeadTree *) glAllocateMemory (sizeof(GLbeadTree));
if (!bead) {
printf ("Can not allocate bead memory\n");
return 0;
}
bead -> child = bead -> next = 0;
bead -> beadElement = 0;
bead -> type = BEAD_TYPE_UNDEFINED;
return bead;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -