Last change
on this file since 2817 was
2811,
checked in by bensch, 20 years ago
|
orxonox/trunk: merged the ObjectImporter to trunk: merged with
svn merge branches/importer/src/ trunk/src/ -r 2794:HEAD
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "array.h" |
---|
2 | |
---|
3 | Array::Array () |
---|
4 | { |
---|
5 | createArray (); |
---|
6 | } |
---|
7 | |
---|
8 | void Array::createArray () |
---|
9 | { |
---|
10 | if (verbose >= 2) |
---|
11 | printf ("crating new Array\n"); |
---|
12 | firstEntry = new Entry; |
---|
13 | firstEntry->next =NULL; |
---|
14 | currentEntry=firstEntry; |
---|
15 | finalized = false; |
---|
16 | entryCount = 0; //0 means one entry |
---|
17 | return; |
---|
18 | } |
---|
19 | |
---|
20 | void Array::finalizeArray (void) |
---|
21 | { |
---|
22 | if (verbose >= 3) |
---|
23 | printf ("Finalizing array.\n"); |
---|
24 | if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) |
---|
25 | printf ("could not allocate %i data Blocks\n", entryCount); |
---|
26 | Entry* walker = firstEntry; |
---|
27 | for (int i=0; i<entryCount; i++) |
---|
28 | { |
---|
29 | array[i] = walker->value; |
---|
30 | walker = walker->next; |
---|
31 | } |
---|
32 | finalized = true; |
---|
33 | return; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | void Array::addEntry (GLfloat entry) |
---|
38 | { |
---|
39 | if (!finalized) |
---|
40 | { |
---|
41 | if (verbose >= 3) |
---|
42 | printf ("adding new Entry to Array: %f\n", entry); |
---|
43 | |
---|
44 | entryCount++; |
---|
45 | currentEntry->value = entry; |
---|
46 | currentEntry->next = new Entry; |
---|
47 | currentEntry = currentEntry->next; |
---|
48 | currentEntry->next = NULL; |
---|
49 | } |
---|
50 | else |
---|
51 | if (verbose >= 1) |
---|
52 | printf ("adding failed, because list has been finalized\n"); |
---|
53 | } |
---|
54 | |
---|
55 | void Array::addEntry (GLfloat entry0, GLfloat entry1, GLfloat entry2) |
---|
56 | { |
---|
57 | addEntry (entry0); |
---|
58 | addEntry (entry1); |
---|
59 | addEntry (entry2); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | GLfloat* Array::getArray () |
---|
64 | { |
---|
65 | return array; |
---|
66 | } |
---|
67 | |
---|
68 | int Array::getCount() |
---|
69 | { |
---|
70 | return entryCount; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | void Array::debug () |
---|
76 | { |
---|
77 | printf ("entryCount=%i, address=%p\n", entryCount, array); |
---|
78 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.