Nextrek
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
package min3d.core;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import min3d.vos.Face;
public class FacesBufferedList
{
public static final int PROPERTIES_PER_ELEMENT = 3;
public static final int BYTES_PER_PROPERTY = 2;
private ShortBuffer _b;
private int _numElements;
private int _renderSubsetStartIndex = 0;
private int _renderSubsetLength = 1;
private boolean _renderSubsetEnabled = false;
public FacesBufferedList(ShortBuffer $b, int $size)
{
ByteBuffer bb = ByteBuffer.allocateDirect($b.limit() * BYTES_PER_PROPERTY);
bb.order(ByteOrder.nativeOrder());
_b = bb.asShortBuffer();
_b.put($b);
_numElements = $size;
}
public FacesBufferedList(int $maxElements)
{
ByteBuffer b = ByteBuffer.allocateDirect($maxElements * PROPERTIES_PER_ELEMENT * BYTES_PER_PROPERTY);
b.order(ByteOrder.nativeOrder());
_b = b.asShortBuffer();
}
/**
* The number of items in the list.
*/
public int size()
{
return _numElements;
}
/**
* The _maximum_ number of items that the list can hold, as defined on instantiation.
* (Not to be confused with the Buffer's capacity)
*/
public int capacity()
{
return _b.capacity() / PROPERTIES_PER_ELEMENT;
}
/**
* Clear object in preparation for garbage collection
*/
public void clear()
{
_b.clear();
}
public Face get(int $index)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
return new Face( _b.get(), _b.get(), _b.get() );
}
public void putInFace(int $index, Face $face)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
$face.a = (short)_b.get();
$face.b = (short)_b.get();
$face.c = (short)_b.get();
}
public short getPropertyA(int $index)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
return (short)_b.get();
}
public short getPropertyB(int $index)
{
_b.position($index * PROPERTIES_PER_ELEMENT + 1);
return (short)_b.get();
}
public float getPropertyC(int $index)
{
_b.position($index * PROPERTIES_PER_ELEMENT + 2);
return (short)_b.get();
}
/**
* Enables rendering only a subset of faces (renderSubset must be set to true)
* This mechanism could be expanded to render multiple 'subsets' of the list of faces...
*/
public void renderSubsetStartIndex(int $num)
{
_renderSubsetStartIndex = $num;
}
public int renderSubsetStartIndex()
{
return _renderSubsetStartIndex;
}
public void renderSubsetLength(int $num)
{
_renderSubsetLength = $num;
}
public int renderSubsetLength()
{
return _renderSubsetLength;
}
/**
* If true, Renderer will only draw the faces as defined by
* renderSubsetStartIndex and renderSubsetLength
*/
public boolean renderSubsetEnabled()
{
return _renderSubsetEnabled;
}
public void renderSubsetEnabled(boolean $b)
{
_renderSubsetEnabled = $b;
}
//
public void add(Face $f)
{
set( _numElements, $f );
_numElements++;
}
public void add(int $a, int $b, int $c) {
add((short)$a, (short)$b, (short)$c);
}
public void add(short $a, short $b, short $c)
{
set(_numElements, $a, $b, $c);
_numElements++;
}
public void set(int $index, Face $face)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
_b.put($face.a);
_b.put($face.b);
_b.put($face.c);
}
public void set(int $index, short $a, short $b, short $c)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
_b.put($a);
_b.put($b);
_b.put($c);
}
public void setPropertyA(int $index, short $a)
{
_b.position($index * PROPERTIES_PER_ELEMENT);
_b.put($a);
}
public void setPropertyB(int $index, short $b)
{
_b.position($index * PROPERTIES_PER_ELEMENT + 1);
_b.put($b);
}
public void setPropertyC(int $index, short $c)
{
_b.position($index * PROPERTIES_PER_ELEMENT + 2);
_b.put($c);
}
//
public ShortBuffer buffer()
{
return _b;
}
public FacesBufferedList clone()
{
_b.position(0);
FacesBufferedList c = new FacesBufferedList(_b, size());
return c;
}
}
|
Revision |
Author |
Commited |
Message |
4
|
FMMortaroli
|
Fri 19 Apr, 2013 16:54:38 +0000 |
|