[llvm-commits] CVS: llvm/test/Programs/MultiSource/McCat-08-main/Includes.h Makefile convert.c header.h main.c object.c trig.c types.h
Chris Lattner
lattner at cs.uiuc.edu
Mon May 12 13:33:36 PDT 2003
Changes in directory llvm/test/Programs/MultiSource/McCat-08-main:
Includes.h added (r1.1)
Makefile added (r1.1)
convert.c added (r1.1)
header.h added (r1.1)
main.c added (r1.1)
object.c added (r1.1)
trig.c added (r1.1)
types.h added (r1.1)
---
Log message:
Initial checkin
---
Diffs of the changes:
Index: llvm/test/Programs/MultiSource/McCat-08-main/Includes.h
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/Includes.h:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/Includes.h Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,6 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <math.h>
+
+ #include "types.h"
Index: llvm/test/Programs/MultiSource/McCat-08-main/Makefile
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/Makefile:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/Makefile Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,6 ----
+ LEVEL = ../../../..
+ PROG = main
+ LDFLAGS = -lm
+
+ include ../Makefile.multisrc
+
Index: llvm/test/Programs/MultiSource/McCat-08-main/convert.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/convert.c:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/convert.c Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,59 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ /*****************************************************************************/
+ /* Author: Peter Riishoej Brinkler (riishigh at daimi.aau.dk) */
+ /*****************************************************************************/
+
+ #include "header.h"
+ /****************************************************************************/
+ HPoint
+ PointToHPoint(ObjPoint P)
+ {
+ HPoint res;
+ res.x = P.x;
+ res.y = P.y;
+ res.z = P.z;
+ res.w = 1;
+ return res;
+ }
+ HPoint
+ TPointToHPoint(ObjPoint TP)
+ {
+ HPoint res;
+ res.x = TP.tx;
+ res.y = TP.ty;
+ res.z = TP.tz;
+ res.w = 1;
+ return res;
+ }
+ ObjPoint
+ HPointToPoint(HPoint P)
+ {
+ ObjPoint res;
+ res.x = P.x;
+ res.y = P.y;
+ res.z = P.z;
+ return res;
+ }
+ ObjPoint
+ HPointToTPoint(HPoint P)
+ {
+ ObjPoint res;
+ res.tx = P.x;
+ res.ty = P.y;
+ res.tz = P.z;
+ return res;
+ }
Index: llvm/test/Programs/MultiSource/McCat-08-main/header.h
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/header.h:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/header.h Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,61 ----
+ #include "Includes.h"
+ /********************************************************************************
+ * Golbal defs for Mesa dependent features and objects, *
+ * X dependent defs are in Interface.h *
+ ********************************************************************************/
+ #define PI 3.14159265359
+ #define DTOR(v) (PI/180*v)
+ #define RTOD(v) (180/PI*v)
+
+ /********************************************************************************
+ * Prototypes for the object system *
+ ********************************************************************************/
+ ObjPtr Oalloc(char name[57]);
+
+ void PrintObject(ObjPtr o);
+ void PrintPoints(ObjPtr o);
+ void PrintPoly3s(ObjPtr o);
+ void PrintPoly4s(ObjPtr o);
+ ObjPointPtr InsertPoint(ObjPtr o, double x, double y, double z);
+ void InsertPoly3(ObjPtr o,Point p[3],TexturePtr txture,MaterialPtr mtrial);
+ void InsertPoly4(ObjPtr o,Point p[3],TexturePtr txture,MaterialPtr mtrial);
+ void InsertChild(ObjPtr par, ObjPtr chld);
+ ObjPtr ArrayToPoly3(ObjPtr o,double array[][3],int size);
+ ObjPtr ArrayToPoly4(ObjPtr o,double array[][3],int size);
+ void SetObjectColor(ObjPtr o, float R, float G, float B);
+ void CalcObjectChildren(ObjPtr o,double sx, double sy, double sz,
+ double ax, double ay, double az,
+ double dx, double dy, double dz);
+ void CalcObject(ObjPtr o);
+ void TranslateAll(ObjPtr o, double dx, double dy, double dz);
+ void TranslateObjectOverwrite(ObjPtr o, double dx, double dy, double dz);
+ void TranslateObjectAdd(ObjPtr o, double dx, double dy, double dz);
+ void RotateAll(ObjPtr o, double ax, double ay, double az);
+ void RotateObjectAdd(ObjPtr o, double ax, double ay, double az);
+ void RotateObjectOverwrite(ObjPtr o, double ax, double ay, double az);
+ void ScaleAll(ObjPtr o, double sx, double sy, double sz);
+ void ScaleObjectAdd(ObjPtr o, double ax, double ay, double az);
+ void ScaleObjectOverwrite(ObjPtr o, double ax, double ay, double az);
+ void Draw_Children(ObjPtr o);
+ void Draw_Object(ObjPtr o);
+ void Draw_All_Nexts(ObjPtr o);
+ void Draw_All_Prevs(ObjPtr o);
+ void Draw_All(ObjPtr o);
+ /************************** Trig.c Headers **************************/
+ void MultMatrixMatrix(Matrix *A, Matrix *B, Matrix *C);
+ HPoint MultMatrixHPoint(Matrix *mat,HPoint P);
+ ObjPoint RotatePoint( ObjPoint a, double rx, double ry, double rz);
+ void PrintMatrix( Matrix Mat);
+ Matrix * CopyMatrix(Matrix *Mat);
+ void trigmain(void);
+ Matrix *ScaleMatrix( double sx, double sy, double sz );
+ Matrix *RotateMatrix( double rx, double ry, double rz);
+ Matrix *TranslateMatrix( double dx, double dy, double dz);
+ Matrix *IdentMatrix( void );
+
+ /************************* Convert.c Headers ************************/
+ HPoint PointToHPoint(ObjPoint P);
+ HPoint TPointToHPoint(ObjPoint TP);
+ ObjPoint HPointToPoint(HPoint P);
+ ObjPoint HPointToTPoint(HPoint P);
+
Index: llvm/test/Programs/MultiSource/McCat-08-main/main.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/main.c:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/main.c Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,133 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ /*****************************************************************************/
+ /* Author: Peter Riishoej Brinkler (riishigh at daimi.aau.dk) */
+ /*****************************************************************************/
+
+ #include "header.h"
+ double pyramid[][3] =
+ {
+ { 1.00,-0.67, 0.67}, /* BundFladen */
+ {-1.00,-0.67, 0.67},
+ { 0.00,-0.67,-1.00},
+
+ /* Flade 1 Right Side*/
+ { 0.00, 1.00, 0.00},
+ { 1.00,-0.67, 0.67},
+ { 0.00,-0.67,-1.00},
+ /* Flade 2 */
+ { 0.00, 1.00, 0.00},
+ { 0.00,-0.67,-1.00},
+ {-1.00,-0.67, 0.67},
+ /* Flade 3 Front */
+ { 0.00, 1.00, 0.00},
+ { 1.00,-0.67, 0.67},
+ {-1.00,-0.67, 0.67},
+
+ };
+ double SPyramid[][3] =
+ {
+ /* BundFladen */
+ { 1.00,-1.00, 1.00},
+ {-1.00,-1.00, 1.00},
+ {-1.00,-1.00,-1.00},
+ { 1.00,-1.00,-1.00},
+ /* TopFladen */
+ { 1.00, 1.00, 1.00},
+ { 1.00, 1.00,-1.00},
+ {-1.00, 1.00,-1.00},
+ {-1.00, 1.00, 1.00},
+ /* FrontFladen */
+ { 1.00,-1.00, 1.00},
+ { 1.00, 1.00, 1.00},
+ {-1.00, 1.00, 1.00},
+ {-1.00,-1.00, 1.00},
+ /* BagFladen */
+ { 1.00,-1.00,-1.00},
+ {-1.00,-1.00,-1.00},
+ {-1.00, 1.00,-1.00},
+ { 1.00, 1.00,-1.00},
+ /* HSideFlade */
+ { 1.00,-1.00,-1.00},
+ { 1.00, 1.00,-1.00},
+ { 1.00, 1.00, 1.00},
+ { 1.00,-1.00, 1.00},
+ /* VSideFlade */
+ {-1.00,-1.00,-1.00},
+ {-1.00,-1.00, 1.00},
+ {-1.00, 1.00, 1.00},
+ {-1.00, 1.00,-1.00}
+ };
+ ObjPtr
+ MakeSphere( ObjPtr o,int sli, int pol, double r)
+ {
+ Point p[4];
+ double fi,theta;
+ double dfi, dtheta;
+ /*printf("MakeSphere");*/
+ dfi = 2*PI/sli; /* The step in the slices */
+ dtheta = 2*PI/pol; /* The step in the amount of polys in a slice */
+ for(fi=-PI;fi<PI;fi=fi+dfi){ /* The slices */
+ for(theta=-PI;theta<PI;theta=theta+dtheta){ /* The polys in the slices */
+ /*printf(".");
+ fflush(stdout);*/
+ p[0].x = cos(theta)*cos(fi)*r;
+ p[0].y = sin(theta)*cos(fi)*r;
+ p[0].z = sin(fi)*r;
+
+ p[1].x = cos(theta)*cos(fi+dfi)*r;
+ p[1].y = sin(theta)*cos(fi+dfi)*r;
+ p[1].z = sin(fi+dfi)*r;
+
+ p[2].x = cos(theta+dtheta)*cos(fi+dfi)*r;
+ p[2].y = sin(theta+dtheta)*cos(fi+dfi)*r;
+ p[2].z = sin(fi+dfi)*r;
+
+ p[3].x = cos(theta+dtheta)*cos(fi)*r;
+ p[3].y = sin(theta+dtheta)*cos(fi)*r;
+ p[3].z = sin(fi)*r;
+
+ InsertPoly4(o,p,NULL,NULL);
+ }
+ }
+ /* printf("\n");*/
+ return o;
+ }
+ int
+ main(int argc, char **argv)
+ {
+ int i = 0;
+ ObjPtr o = NULL, tmp = NULL, ttmp = NULL;
+ o = Oalloc("TestObject");
+ tmp = Oalloc("SphereObject");
+ tmp = MakeSphere(tmp,25,25,10);
+ tmp->Origin.x = 87;
+ tmp->Origin.y = 87;
+ InsertChild(o,tmp);
+
+ for(i=0;i<360;i++){
+ o->Rotation.y = i;
+ CalcObject(o);
+ }
+
+ PrintObject(tmp);
+
+ o=ttmp;
+
+ Draw_All(o);
+
+ return 1;
+ }
Index: llvm/test/Programs/MultiSource/McCat-08-main/object.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/object.c:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/object.c Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,588 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ /*****************************************************************************/
+ /* Author: Peter Riishoej Brinkler (riishigh at daimi.aau.dk) */
+ /*****************************************************************************/
+
+ #include "header.h"
+
+ ObjPtr
+ Oalloc(char name[57])
+ {
+ ObjPtr o=NULL;
+ o = (ObjPtr) malloc(sizeof(object));
+ printf(o->Name);
+ strcpy(o->Name,name);
+ o->Color.R = 1;
+ o->Color.G = 1;
+ o->Color.B = 1;
+ o->ReNo = 0;
+ o->styletag = FULL;
+ o->Number_of_Children = 0;
+ o->Number_of_Points = 0;
+ o->Number_of_Poly3s = 0;
+ o->Number_of_Poly4s = 0;
+ o->Number_of_Textures = 0;
+ o->Number_of_Materials = 0;
+ o->Number_of_BitMaps = 0;
+ o->Children = NULL;
+ o->Parent = NULL;
+ o->Rotation.x = 0;
+ o->Rotation.y = 0;
+ o->Rotation.z = 0;
+ o->Scale.x = 1;
+ o->Scale.y = 1;
+ o->Scale.z = 1;
+ o->Origin.x = 0;
+ o->Origin.y = 0;
+ o->Origin.z = 0;
+ return (ObjPtr)o;
+ }
+ ObjPointPtr
+ InsertPoint(ObjPtr o, double x, double y, double z)
+ {
+ /***** Remember to remove p's when debugged *********/
+ PointListPtr tmp,prv=NULL;
+ ObjPointPtr p=NULL;
+ #ifdef DEBUG_OSYS
+ printf("****Entered InsertPoint(%2.2f, %2.2f, %2.2f)****\n",x,y,z);
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*/
+ if(o->Number_of_Points == 0) /* The simple case */{
+ #ifdef DEBUG_OSYS
+ printf("Starting new structure\n");
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*/
+ o->Points = malloc(sizeof(PointList));
+ o->Points->P = malloc(sizeof(ObjPoint));
+ o->Points->P->x = x;
+ o->Points->P->y = y;
+ o->Points->P->z = z;
+ o->Points->P->tx = x;
+ o->Points->P->ty = y;
+ o->Points->P->tz = z;
+
+ o->Points->NextPoint = NULL;
+ o->Points->PrevPoint = NULL;
+ p = o->Points->P;
+ o->Number_of_Points++;
+ } else {
+ tmp = o->Points;
+ /*Iterative search through the pointlist, as long as p==NULL point not found*/
+ while( ((tmp) != NULL) && (p == NULL) ){
+ if( (tmp->P->x == x) && (tmp->P->y == y) && (tmp->P->z == z) )
+ { /* We found the point in the list */
+ #ifdef DEBUG_OSYS
+ printf("Found (%2.2f,%2.2f,%2.2f,)\n",x,y,z);
+ printf("x,y,z (%2.2f,%2.2f,%2.2f,)\n",x,y,z);
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*/
+ p = tmp->P;
+ }
+ else
+ { /*We are still looking */
+ prv = tmp;
+ tmp = tmp->NextPoint;
+ }
+ }
+ if( tmp==NULL && p == NULL )
+ { /*Then we haven't found the point in the list so we insert new */
+ #ifdef DEBUG_OSYS
+ printf("New (%2.2f,%2.2f,%2.2f,)\n",x,y,z);
+ printf("x,y,z (%2.2f,%2.2f,%2.2f,)\n",x,y,z);
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*/
+ tmp = malloc(sizeof(PointList));
+ prv->NextPoint = tmp;
+ tmp->P = (ObjPointPtr) malloc(sizeof(ObjPoint));
+ tmp->P->x = x;
+ tmp->P->y = y;
+ tmp->P->z = z;
+ tmp->P->tx = x;
+ tmp->P->ty = y;
+ tmp->P->tz = z;
+ tmp->PrevPoint = prv;
+ tmp->NextPoint = NULL;
+ p = tmp->P;
+ o->Number_of_Points++;
+ }
+ }
+
+ return p;
+ }
+ void /* The Poly p are inserted in o, with the texture txture and .... */
+ InsertPoly3(ObjPtr o,Point p[3],TexturePtr txture,MaterialPtr mtrial)
+ {
+ Poly3Ptr tmp=NULL;
+ int i;
+ #ifdef DEBUG_OSYS
+ printf("####Entered InsertPoly3####\n");
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*//* first poly ever */
+ tmp = malloc(sizeof(Poly3));
+ tmp->Next = NULL;
+ tmp->Prev = NULL;
+ tmp->Mat = NULL;
+ tmp->Txt = NULL;
+ for(i=0;i<3;i++)
+ tmp->P[i] = InsertPoint(o,p[i].x,p[i].y,p[i].z);
+
+ if(o->Poly3s == NULL)
+ {
+ o->Poly3s = tmp;
+ }
+ else
+ {
+ o->Poly3s->Prev = tmp;
+ tmp->Next = o->Poly3s;
+ o->Poly3s = tmp;
+ }
+ o->Number_of_Poly3s++;
+ return;
+ }
+
+ void /* The Poly p are inserted in o, with the texture txture and .... */
+ InsertPoly4(ObjPtr o,Point p[4],TexturePtr txture,MaterialPtr mtrial)
+ {
+ Poly4Ptr tmp=NULL;
+ int i;
+ #ifdef DEBUG_OSYS
+ printf("####Entered InsertPoly4####\n");
+ fflush(stdout);
+ #endif /*DEBUG_OSYS*//* first poly ever */
+ tmp = malloc(sizeof(Poly4));
+ tmp->Next = NULL;
+ tmp->Prev = NULL;
+ tmp->Mat = NULL;
+ tmp->Txt = NULL;
+ for(i=0;i<4;i++)
+ tmp->P[i] = InsertPoint(o,p[i].x,p[i].y,p[i].z);
+
+ if(o->Poly4s == NULL)
+ {
+ o->Poly4s = tmp;
+ }
+ else
+ {
+ o->Poly4s->Prev = tmp;
+ tmp->Next = o->Poly4s;
+ o->Poly4s = tmp;
+ }
+ o->Number_of_Poly4s++;
+ return;
+ }
+
+ ObjPtr /* ( double array[][] ) giver 1 array med alle tal */
+ ArrayToPoly3(ObjPtr o,double array[][3],int size)
+ { Point p[3];
+ int i=0;
+ #ifdef DEBUG_OSYS
+ printf("ArrayToPoly3\n");
+ #endif
+ for(i=0;i<size;i=i+3)
+ {
+ p[0].x = array[i][0];
+ p[0].y = array[i][1];
+ p[0].z = array[i][2];
+
+ p[1].x = array[i+1][0];
+ p[1].y = array[i+1][1];
+ p[1].z = array[i+1][2];
+
+ p[2].x = array[i+2][0];
+ p[2].y = array[i+2][1];
+ p[2].z = array[i+2][2];
+
+ InsertPoly3(o,p,NULL,NULL);
+ }
+ return o;
+ }
+ ObjPtr /* ( double array[][] ) giver 1 array med alle tal */
+ ArrayToPoly4(ObjPtr o,double array[][3],int size)
+ { Point p[4];
+ int i=0;
+ #ifdef DEBUG_SYS
+ printf("ArrayToPoly\n");
+ #endif
+ for(i=0;i<size;i=i+4)
+ {
+ p[0].x = array[i][0];
+ p[0].y = array[i][1];
+ p[0].z = array[i][2];
+
+ p[1].x = array[i+1][0];
+ p[1].y = array[i+1][1];
+ p[1].z = array[i+1][2];
+
+ p[2].x = array[i+2][0];
+ p[2].y = array[i+2][1];
+ p[2].z = array[i+2][2];
+
+ p[3].x = array[i+3][0];
+ p[3].y = array[i+3][1];
+ p[3].z = array[i+3][2];
+
+ InsertPoly4(o,p,NULL,NULL);
+ }
+ return o;
+ }
+
+ void
+ PrintPoints(ObjPtr o)
+ {
+
+ int i=0;
+ PointListPtr tmp=NULL;
+ if(o->Points != NULL)
+ tmp = o->Points;
+ while(tmp != NULL) {
+ printf("Point[%i] = (%.2f, %.2f, %.2f)",i,tmp->P->x,tmp->P->y,tmp->P->z);
+ printf(" -> (%.2f, %.2f, %.2f)\n",tmp->P->tx,tmp->P->ty,tmp->P->tz);
+ ++i;
+ tmp = tmp->NextPoint;
+ }return;
+ }
+ void
+ PrintPoly3s(ObjPtr o)
+ {
+ Poly3Ptr tmp = NULL;
+ int i,j=0;
+ if(o->Poly3s != NULL) {
+ tmp = o->Poly3s;
+ while(tmp != NULL) {
+ for(i=0;i<3;i++){
+ printf("PrintPoly3s[%i] = (%.2f, %.2f, %.2f)",i
+ ,tmp->P[i]->x,tmp->P[i]->y,tmp->P[i]->z);
+ printf("-> (%.2f, %.2f, %.2f)\n",tmp->P[i]->tx,tmp->P[i]->ty,tmp->P[i]->tz);
+ }tmp = tmp->Next;
+ j++;
+ }
+ }
+ }
+ void
+ PrintPoly4s(ObjPtr o)
+ {
+ Poly4Ptr tmp = NULL;
+ int i,j=0;
+ if(o->Poly4s != NULL) {
+ tmp = o->Poly4s;
+ while(tmp != NULL) {
+ for(i=0;i<4;i++){
+ printf("PrintPoly4s[%i] = %.2f, %.2f, %.2f",i
+ ,tmp->P[i]->x,tmp->P[i]->y,tmp->P[i]->z);
+ printf("-> (%.2f, %.2f, %.2f)\n",tmp->P[i]->tx,tmp->P[i]->ty,tmp->P[i]->tz);
+ }tmp = tmp->Next;
+ j++;
+ }
+ }
+ }
+
+ void
+ PrintObject(ObjPtr o)
+ {
+ printf("Name: %s\n",o->Name);
+ PrintPoints(o);
+ PrintPoly3s(o);
+ PrintPoly4s(o);
+ /*
+ Print names of textures and materials
+ */
+ printf("Scale : (%.2f,%.2f,%.2f)\n",o->Scale.x,o->Scale.y,o->Scale.z);
+ printf("Origin : (%.2f,%.2f,%.2f)\n",o->Origin.x,o->Origin.y,o->Origin.z);
+ printf("Rotation : (%.2f,%.2f,%.2f)\n",o->Rotation.x,o->Rotation.y,o->Rotation.z);
+ printf("Color : (%.2f,%.2f,%.2f)\n",o->Color.R,o->Color.G,o->Color.B);
+ if(o->styletag==FULL)
+ printf("Style : FULL\n");
+ if(o->styletag==HALF)
+ printf("Style : HALF\n");
+ if(o->styletag==NONE)
+ printf("Style : NONE\n");
+ /* Print Names of Children & Parents */
+ }
+ void
+ InsertChild(ObjPtr par, ObjPtr chld)
+ {
+ if (par!=NULL)
+ {
+ if (par->Children==NULL)
+ par->Children=chld;
+ else {
+ par->Children->next = chld;
+ chld->prev = par->Children;
+ chld->next = NULL;
+ par->Children = chld;
+ }
+ }
+ }
+ /****************************** Trig Routines ***********************************/
+
+ void
+ CalcObjectChildren(ObjPtr o,
+ double sx, double sy, double sz,
+ double ax, double ay, double az,
+ double dx, double dy, double dz)
+ {
+ ObjPtr tmp = NULL;
+ if(o != NULL) {
+ /*printf("CalcObjChildren(%s,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f)\n",
+ o->Name,
+ sx,sy,sz,
+ ax,ay,az,
+ dx,dy,dz);*/
+ tmp = o->Children;
+ while(tmp!=NULL){
+ ScaleObjectAdd(tmp,sx,sy,sz);
+ RotateObjectAdd(tmp,ax,ay,az);
+ TranslateObjectAdd(tmp,dx,dy,dz);
+ CalcObjectChildren(tmp,sx,sy,sz,ax,ay,az,dx,dy,dz);
+ tmp=tmp->next;
+ }
+ }
+ }
+ void
+ CalcObject(ObjPtr o)
+ {
+ ObjPtr tmp = NULL;
+ if(o != NULL) {
+ /*printf("CalcObj(%s)\n",o->Name);*/
+ tmp = o->Children;
+ while(tmp!=NULL){
+ CalcObject(tmp);
+ tmp=tmp->next;
+ }
+ CalcObjectChildren(o,
+ o->Scale.x,o->Scale.y,o->Scale.z,
+ o->Rotation.x,o->Rotation.y,o->Rotation.z,
+ o->Origin.x,o->Origin.y,o->Origin.z);
+ ScaleObjectOverwrite(o,o->Scale.x,o->Scale.y,o->Scale.z);
+ RotateObjectAdd(o,o->Rotation.x,o->Rotation.y,o->Rotation.z);
+ TranslateObjectAdd(o,o->Origin.x,o->Origin.y,o->Origin.z);
+ }
+ }
+ void
+ TranslateObjectAdd(ObjPtr o, double dx, double dy, double dz)
+ {
+ Matrix *Rot = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ if (o!=NULL){
+ /*printf("TranslateObjectAdd(%s, %.2f, %.2f, %.2f)\n",o->Name,dx,dy,dz);*/
+ Rot = TranslateMatrix(dx,dy,dz);
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = TPointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Rot,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Translate NULL-object\n");
+ }
+ }
+ void
+ TranslateObjectOverwrite(ObjPtr o, double dx, double dy, double dz)
+ {
+ Matrix *Rot = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ if (o!=NULL){
+ /*printf("TranslateObjectOverwrite(%s, %.2f, %.2f, %.2f)\n",o->Name,dx,dy,dz);*/
+ Rot = TranslateMatrix(dx,dy,dz);
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = PointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Rot,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Translate NULL-object\n");
+ }
+ }
+ void
+ RotateObjectAdd(ObjPtr o, double ax, double ay, double az)
+ {
+ Matrix *Rot = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ if (o!=NULL){
+ /*printf("RotateObjectAdd(%s, %.2f, %.2f, %.2f)\n",o->Name,ax,ay,az);*/
+ Rot = RotateMatrix(ax,ay,az);
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = TPointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Rot,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Rotate NULL-object\n");
+ }
+ }
+ void
+ RotateObjectOverwrite(ObjPtr o, double ax, double ay, double az)
+ {
+ Matrix *Rot = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ /*printf("RotateObjectOverwrite(%s, %.2f, %.2f, %.2f)\n",o->Name,ax,ay,az);*/
+ Rot = RotateMatrix(ax,ay,az);
+ if (o!=NULL){
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = PointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Rot,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Rotate NULL-object\n");
+ }
+ }
+ void
+ ScaleObjectAdd(ObjPtr o, double sx, double sy, double sz)
+ {
+ Matrix *Scale = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ /*printf("ScaleObjectAdd(%s, %.2f, %.2f, %.2f)\n",o->Name,sx,sy,sz);*/
+ Scale = ScaleMatrix(sx,sy,sz);
+ if (o!=NULL){
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = TPointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Scale,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Scale NULL-object\n");
+ }
+ }
+ void
+ ScaleObjectOverwrite(ObjPtr o, double sx, double sy, double sz)
+ {
+ Matrix *Scale = NULL;
+ HPoint hp;
+ PointListPtr index = NULL;
+ /*printf("ScaleObjectOverwrite(%s, %.2f, %.2f, %.2f)\n",o->Name,sx,sy,sz);*/
+ Scale = ScaleMatrix(sx,sy,sz);
+ if (o!=NULL){
+ index = o->Points;
+ while (index!=NULL)
+ {
+ hp = PointToHPoint(*index->P);
+ hp = MultMatrixHPoint(Scale,hp);
+ index->P->tx = hp.x;
+ index->P->ty = hp.y;
+ index->P->tz = hp.z;
+ index = index->NextPoint;
+ }
+ }else{
+ fprintf(stderr,"Cannot Scale NULL-object\n");
+ }
+ }
+
+ /***********************Converted GL Routines ****************************/
+ void
+ SetObjectColor(ObjPtr o, float R, float G, float B)
+ {
+ if(o!=NULL)
+ /* printf("SetColor(%s)\n",o->Name);*/
+ o->Color.R=R;
+ o->Color.G=G;
+ o->Color.B=B;
+ }
+ void
+ Draw_Children(ObjPtr o)
+ {
+ ObjPtr tmp = NULL;
+ if (o!=NULL){
+ /* printf("Draw_Children(%s)",o->Name);*/
+ PrintObject(o);
+ tmp = o->Children;
+ while (tmp != NULL){
+ Draw_Children(tmp);
+ tmp = tmp -> next;
+ }
+ }
+ }
+ void
+ Draw_Object(ObjPtr o)
+ {
+ if (o!=NULL){
+ /* printf("Draw_Object(%s)\n",o->Name);*/
+ PrintObject(o);
+ /*printf("o->Children: %x\n",(unsigned) o->Children);*/
+ Draw_Children(o->Children);
+ }
+ }
+ void
+ Draw_All_Nexts(ObjPtr o)
+ {
+ ObjPtr tmp=NULL;
+ if(o!=NULL) {
+ /* printf("Draw_All_Nexts(%s)\n",o->Name);*/
+ tmp = o->next;
+ while(tmp!=NULL){
+ CalcObject(tmp);
+ Draw_Object(tmp);
+ tmp=tmp->next;
+ }
+ }
+ }
+ void
+ Draw_All_Prevs(ObjPtr o)
+ {
+ ObjPtr tmp=NULL;
+ if(o!=NULL) {
+ /* printf("Draw_All_Prevs(%s)\n",o->Name);*/
+ tmp = o->prev;
+ while(tmp!=NULL){
+ CalcObject(tmp);
+ Draw_Object(tmp);
+ tmp=tmp->prev;
+ }
+ }
+ }
+ void
+ Draw_All(ObjPtr o)
+ {
+ if(o!=NULL)
+ /* printf("Draw_all(%s)\n",o->Name);*/
+ CalcObject(o);
+ Draw_All_Prevs(o);
+ Draw_Object(o);
+ Draw_All_Nexts(o);
+ }
+
+
+
Index: llvm/test/Programs/MultiSource/McCat-08-main/trig.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/trig.c:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/trig.c Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,163 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ /*****************************************************************************/
+ /* Author: Peter Riishoej Brinkler (riishigh at daimi.aau.dk) */
+ /*****************************************************************************/
+
+ #include "header.h"
+ void
+ MultMatrixMatrix(Matrix *A, Matrix *B, Matrix *C)
+ {
+ int i=0,j=0,k=0;
+ for(i=0;i<4;i++){
+ for(j=0;j<4;j++){
+ (*C)[i][j] = 0;
+ for(k=0;k<4;k++){
+ (*C)[i][j] += (*A)[i][k] * (*B)[k][j];
+ }
+ }
+ }
+ }
+
+ HPoint
+ MultMatrixHPoint(Matrix *mat,HPoint P) /* Array of Horiz Rows in Matrix */
+ {
+ HPoint Res;
+ Res.x = P.x * (*mat)[0][0] + P.y * (*mat)[0][1]
+ + P.z * (*mat)[0][2] + P.w * (*mat)[0][3];
+ Res.y = P.x * (*mat)[1][0] + P.y * (*mat)[1][1]
+ + P.z * (*mat)[1][2] + P.w * (*mat)[1][3];
+ Res.z = P.x * (*mat)[2][0] + P.y * (*mat)[2][1]
+ + P.z * (*mat)[2][2] + P.w * (*mat)[2][3];
+ Res.w = P.x * (*mat)[3][0] + P.y * (*mat)[3][1]
+ + P.z * (*mat)[3][2] + P.w * (*mat)[3][3];
+ return Res;
+ }
+ Matrix *
+ CopyMatrix(Matrix *Mat)
+ {
+ int i,j;
+ Matrix *Res=NULL;
+ if (Mat!=NULL) {
+ Res = malloc(sizeof(Matrix));
+ for(i=0;i<4;i++){
+ for(j=0;j<4;j++){
+ /*printf("Copying Mat[%i][%i] = %.2f\n",i,j,(*Mat)[i][j]);*/
+ (*Res)[i][j] = (*Mat)[i][j];
+ }
+ }
+ }
+ return Res;
+ }
+ Matrix *
+ IdentMatrix(void)
+ {
+ Matrix SI = { { 1.00, 0.00, 0.00, 0.00 },
+ { 0.00, 1.00, 0.00, 0.00 },
+ { 0.00, 0.00, 1.00, 0.00 },
+ { 0.00, 0.00, 0.00, 1.00 }};
+ Matrix *I;
+ I = malloc(sizeof(Matrix));
+
+ I = CopyMatrix(&SI);
+ /*PrintMatrix(*I);*/
+ return I;
+ }
+
+ Matrix *
+ TranslateMatrix( double dx, double dy, double dz)
+ {
+ Matrix *TMat;
+ TMat = IdentMatrix();
+ (*TMat)[0][3] = dx;
+ (*TMat)[1][3] = dy;
+ (*TMat)[2][3] = dz;
+ return TMat;
+ }
+ Matrix *
+ RotateMatrix( double rx, double ry, double rz)
+ {
+ Matrix *RMatX, *RMatY, *RMatZ;
+ Matrix *RMatXY, *RMatXYZ;
+ double cosrx, sinrx;
+ double cosry, sinry;
+ double cosrz, sinrz;
+
+ cosrx = cos(DTOR(rx));
+ sinrx = sin(DTOR(rx));
+ cosry = cos(DTOR(ry));
+ sinry = sin(DTOR(ry));
+ cosrz = cos(DTOR(rz));
+ sinrz = sin(DTOR(rz));
+
+ /*printf("cosrx = %.2f, sinrx = %.2f\n",cosrx,sinrx);
+ printf("cosry = %.2f, sinry = %.2f\n",cosry,sinry);
+ printf("cosrz = %.2f, sinrz = %.2f\n",cosrz,sinrz);*/
+
+ RMatX = IdentMatrix();
+ RMatY = IdentMatrix();
+ RMatZ = IdentMatrix();
+ RMatXY = IdentMatrix();
+ RMatXYZ = IdentMatrix();
+ (*RMatX)[1][1] = cosrx; /* 1 0 0 0 */
+ (*RMatX)[1][2] = -sinrx; /* 0 cos -sin 0 */
+ (*RMatX)[2][1] = sinrx; /* 0 sin cos 0 */
+ (*RMatX)[2][2] = cosrx; /* 0 0 0 1 */
+
+ (*RMatY)[0][0] = cosry; /* cos 0 sin 0 */
+ (*RMatY)[0][2] = sinry; /* 0 1 0 0 */
+ (*RMatY)[2][0] = -sinry; /* -sin 0 cos 0 */
+ (*RMatY)[2][2] = cosry; /* 0 0 0 1 */
+
+ (*RMatZ)[0][0] = cosrz; /* cos -sin 0 0 */
+ (*RMatZ)[0][1] = -sinrz; /* sin cos 0 0 */
+ (*RMatZ)[1][0] = sinrz; /* 0 0 1 0 */
+ (*RMatZ)[1][1] = cosrz; /* 0 0 0 1 */
+ MultMatrixMatrix( RMatX, RMatY, RMatXY );
+ MultMatrixMatrix( RMatXY, RMatZ, RMatXYZ );
+ return RMatXYZ;
+ }
+ Matrix *
+ ScaleMatrix( double sx, double sy, double sz )
+ {
+ Matrix *I;
+ I = IdentMatrix();
+ (*I)[0][0] = sx;
+ (*I)[1][1] = sy;
+ (*I)[2][2] = sz;
+ return I;
+ }
+
+
+ ObjPoint
+ RotatePoint( ObjPoint a, double rx, double ry, double rz)
+ {
+ Matrix *Mat;
+ /*MultMatrixHPoint(Matrix *mat,HPoint P) Array of Horiz Rows in Matrix */
+ HPoint A;
+ A = PointToHPoint(a);
+ Mat = RotateMatrix(rx,ry,rz);
+ A = MultMatrixHPoint(Mat,A);
+ return a;
+ }
+ void
+ PrintMatrix( Matrix Mat)
+ {
+ printf(" [[ %.2f, %.2f, %.2f, %.2f] \n",Mat[0][0],Mat[0][1],Mat[0][2],Mat[0][3]);
+ printf(" [ %.2f, %.2f, %.2f, %.2f] \n",Mat[1][0],Mat[1][1],Mat[1][2],Mat[1][3]);
+ printf(" [ %.2f, %.2f, %.2f, %.2f] \n",Mat[2][0],Mat[2][1],Mat[2][2],Mat[2][3]);
+ printf(" [ %.2f, %.2f, %.2f, %.2f]]\n",Mat[3][0],Mat[3][1],Mat[3][2],Mat[3][3]);
+ }
Index: llvm/test/Programs/MultiSource/McCat-08-main/types.h
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-08-main/types.h:1.1
*** /dev/null Mon May 12 13:26:53 2003
--- llvm/test/Programs/MultiSource/McCat-08-main/types.h Mon May 12 13:26:43 2003
***************
*** 0 ****
--- 1,193 ----
+ /********************************************************************************
+ * Point definition and pointlist definition *
+ ********************************************************************************/
+ typedef struct PointStruct *PointPtr;
+ typedef struct PointStruct
+ {
+ double x;
+ double y;
+ double z;
+ }Point;
+
+ typedef struct ObjPointStruct *ObjPointPtr;
+ typedef struct ObjPointStruct
+ {
+ double x;
+ double y;
+ double z;
+ double tx;
+ double ty;
+ double tz;
+ }ObjPoint;
+ typedef struct HPointStruct *HPointPtr;
+ typedef struct HPointStruct
+ {
+ double x;
+ double y;
+ double z;
+ double w;
+ }HPoint;
+ typedef struct PointListStruct *PointListPtr;
+ typedef struct PointListStruct
+ {
+ ObjPointPtr P;
+ PointListPtr NextPoint;
+ PointListPtr PrevPoint;
+ }PointList;
+ typedef double Matrix[4][4];
+ typedef Matrix *MatrixPtr;
+
+ /********************************************************************************
+ * Texture, Mateial and Bitmap definitions and listdefinitions *
+ ********************************************************************************/
+
+ typedef struct BitMapStruct
+ {
+ unsigned char *bitmap;
+ }BitMap;
+
+ typedef struct BitMapListStruct *BitMapListPtr;
+ typedef struct BitMapListStruct
+ {
+ BitMap current;
+ BitMapListPtr NextBitMap;
+ BitMapListPtr PrevBitMap;
+ }BitMapList;
+
+ typedef struct Texture *TexturePtr;
+ typedef struct Texture
+ {
+ Point Color;
+ BitMapListPtr Textures;
+ /*float DiffuseIndex;
+ BitMapListPtr DiffuseBitmaps;
+ float SpecularIndex;
+ enum{ low, medium, high}
+ int spectag;
+ float Reflectivity;
+ BitMapListPtr ReflectionBitmaps;
+ float transparency
+ enum{ edge, opaque }
+ int transptag;
+ BitMapList BumpMaps;*/
+ /*******************************Texture Coords*********************************/
+ Point center;
+ Point direction;
+ Point scale;
+ /*******************************End of Texture*********************************/
+ TexturePtr next;
+ TexturePtr prev;
+ }Texture;
+
+ typedef struct Material *MaterialPtr;
+ typedef struct Material
+ {
+ float Elasticity;
+ float Airness;
+ float Softness;
+ MaterialPtr next;
+ MaterialPtr prev;
+ } Material;
+
+ /********************************************************************************
+ * Poly definition and polylist definition *
+ ********************************************************************************/
+ typedef struct Poly3Struct *Poly3Ptr;
+ typedef struct Poly3Struct
+ {
+ ObjPointPtr P[3];
+ MaterialPtr Mat;
+ TexturePtr Txt;
+ Poly3Ptr Next;
+ Poly3Ptr Prev;
+ }Poly3;
+
+ typedef struct Poly4Struct *Poly4Ptr;
+ typedef struct Poly4Struct
+ {
+ ObjPointPtr P[4];
+ MaterialPtr Mat;
+ TexturePtr Txt;
+ Poly4Ptr Next;
+ Poly4Ptr Prev;
+ }Poly4;
+
+ typedef struct RGBStruct
+ {
+ double R;
+ double G;
+ double B;
+ }RGB;
+
+ /********************************************************************************
+ * Object definition and objectlist definition *
+ ********************************************************************************/
+ typedef struct ObjectStruct *ObjPtr;
+ typedef struct ObjectStruct
+ {
+ char Name[57]; /* Chosen to 57, since the future platform supports 57 chars*/
+
+ PointListPtr Points;
+ Poly3Ptr Poly3s;
+ Poly4Ptr Poly4s;
+ TexturePtr Textures;
+ MaterialPtr Material;
+
+ RGB Color; /* In layout */
+ int ReNo;
+ enum style {FULL,HALF,NONE} styletag;
+
+ Point Origin;
+ Point Rotation;
+ Point Scale;
+
+ ObjPtr Children;
+ ObjPtr Parent;
+ int Number_of_Children;
+
+ int Number_of_Points;
+ int Number_of_Poly3s;
+ int Number_of_Poly4s;
+ int Number_of_Textures;
+ int Number_of_Materials;
+ int Number_of_BitMaps;
+ ObjPtr next;
+ ObjPtr prev;
+ }object;
+
+ /********************************************************************************
+ * Various definitions *
+ ********************************************************************************/
+ typedef struct LightStruct *LightPtr;
+ typedef struct LightStruct
+ {
+ char Name[57];
+ int Number;
+ RGB Color; /* In LayOut */
+
+ float pos_x,pos_y,pos_z; /* Position */
+ float rot_x,rot_y,rot_z; /* X,Y,Z Rotation factor */
+
+ float amb_r,amb_g,amb_b,amb_a; /* Ambient Intensity */
+ float spec_r,spec_g,spec_b,spec_a; /* Specular Intensity */
+ float diff_r,diff_g,diff_b,diff_a; /* Diffuseness */
+
+ float Spot_Exponent, Spot_Cutoff;
+ float Const_Attenuation, Linear_Attenuation, Quad_Attenuation;
+
+ enum LightTypes { POINT, SPOT, DIR } light_tag;
+
+ LightPtr next;
+ LightPtr prev;
+ }Light;
+
+ typedef struct ButtonMotionStruct
+ {
+ enum button {N,B1,B2,B3} Tag;
+ float x0;
+ float y0;
+
+ float x;
+ float y;
+ }ButtonMotion;
+
More information about the llvm-commits
mailing list