summaryrefslogtreecommitdiff
path: root/cubedbusColour.c.in
blob: 714b97c9aaf7874f01866049aec0a9b3af72d278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#define CUBEDBUS_COLOUR_OBJECT 2

typedef struct _CubedbusColourObject CubedbusColourObject;


static bool cubedbusDrawColourObject (CubedbusObject *obj);
static bool cubedbusDeleteColourObject (CubedbusObject *obj);
static bool cubedbusModifyColourObject (CubedbusObject *obj, CompOption *option, int nOption);
static bool cubedbusAddColourObject (CubedbusObject *obj, CompOption *option, int nOption);

struct _CubedbusColourObject
{
GLuint dList;
bool order;
float rotate[4], translate[3], scale[3];
float rotateSpeed;
};


static bool
cubedbusDrawColourObject (CubedbusObject *obj)
{
	glShadeModel (GL_SMOOTH);
	
	CubedbusColourObject *data=obj->data;
	
			if(data->order) glTranslatef (data->translate[0], data->translate[1], data->translate[2]);
		glRotatef ( data->rotate[0], data->rotate[1], data->rotate[2], data->rotate[3]);
			if(!(data->order)) glTranslatef (data->translate[0], data->translate[1], data->translate[2]); 
		
		glScalef( data->scale[0],data->scale[1], data->scale[2]); /* Rotate, translate and scale  */



	glCallList(data->dList);		

    	data->rotate[0]+=data->rotateSpeed;
    	if(data->rotate[0]>360) data->rotate[0]=0;
    	if(data->rotate[0]<0) data->rotate[0]=360;					

					
	return TRUE;
}

static bool
cubedbusDeleteColourObject (CubedbusObject *obj)
{
	CubedbusColourObject *data=obj->data;
		glDeleteLists (data->dList, 1);
		free(obj->data);
		free(obj);
	return TRUE;
}

static bool
cubedbusModifyColourObject (CubedbusObject *obj, CompOption *option, int nOption)
{
	return TRUE;
}

static bool
cubedbusAddColourObject (CubedbusObject *obj, CompOption *option, int nOption)
{
	obj->data= malloc( sizeof(CubedbusColourObject) );
		if(obj->data == NULL) return FALSE;
		
	CubedbusColourObject *colourData=obj->data;	
	
	colourData->rotate[0]=getFloatOptionNamed (option,nOption, "rotateAngle", 0.0);
	colourData->rotate[1]=getFloatOptionNamed (option,nOption, "rotateX", 0.0);
	colourData->rotate[2]=getFloatOptionNamed (option,nOption, "rotateY", 0.0);
	colourData->rotate[3]=getFloatOptionNamed (option,nOption, "rotateZ", 0.0);
	colourData->translate[0]=getFloatOptionNamed (option,nOption, "translateX", 0.0);
	colourData->translate[1]=getFloatOptionNamed (option,nOption, "translateY", 0.0);
	colourData->translate[2]=getFloatOptionNamed (option,nOption, "translateZ", 0.0);
	colourData->scale[0]=getFloatOptionNamed (option,nOption, "scaleX", 1.0);
	colourData->scale[1]=getFloatOptionNamed (option,nOption, "scaleY", 1.0);
	colourData->scale[2]=getFloatOptionNamed (option,nOption, "scaleZ", 1.0);
	colourData->order=getBoolOptionNamed (option, nOption, "order", TRUE);
	colourData->rotateSpeed= getFloatOptionNamed (option, nOption, "rotateSpeed", 0);

	cubedbusGenerateDList(option, nOption, &colourData->dList);

	return TRUE;
}