Revision 9cbe58b0
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java | ||
---|---|---|
54 | 54 |
{ |
55 | 55 |
private static final float DIST = 0.5f; |
56 | 56 |
|
57 |
private static Static3D[] AXIS = new Static3D[] |
|
58 |
{ |
|
59 |
new Static3D(1,0,0), |
|
60 |
new Static3D(0,1,0), |
|
61 |
new Static3D(0,0,1) |
|
62 |
}; |
|
63 |
|
|
57 | 64 |
private static final int[] FACE_COLORS = new int[] |
58 | 65 |
{ |
59 | 66 |
0xffffff00, 0xffffffff, // (right-YELLOW) (left -WHITE) |
... | ... | |
104 | 111 |
private VertexEffectRotate mRotate; |
105 | 112 |
private Dynamic1D mAngleDyn; |
106 | 113 |
private Static1D mAngle; |
114 |
private Static3D mAxis; |
|
107 | 115 |
|
108 | 116 |
Static4D mQuat1, mQuat2; |
109 | 117 |
int mScreenMin; |
... | ... | |
121 | 129 |
sink.add( new Static1D(0.5f) ); |
122 | 130 |
sink.add( new Static1D(2.0f) ); |
123 | 131 |
|
124 |
mQuat1 = new Static4D(0,0,0,1); // unity
|
|
125 |
mQuat2 = new Static4D(0,0,0,1); // quaternions
|
|
132 |
mQuat1 = new Static4D(0,0,0,1); |
|
133 |
mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
|
|
126 | 134 |
|
127 | 135 |
DynamicQuat quatInt1 = new DynamicQuat(0,0.5f); |
128 | 136 |
DynamicQuat quatInt2 = new DynamicQuat(0,0.5f); |
... | ... | |
131 | 139 |
quatInt2.add(mQuat2); |
132 | 140 |
|
133 | 141 |
mAngle = new Static1D(0); |
142 |
mAxis = new Static3D(1,0,0); |
|
134 | 143 |
|
135 | 144 |
mAngleDyn = new Dynamic1D(2000,0.5f); |
136 | 145 |
mAngleDyn.add(new Static1D(0)); |
137 | 146 |
mAngleDyn.add( mAngle ); |
138 | 147 |
|
139 |
mRotate = new VertexEffectRotate( mAngleDyn, new Static3D(1,0,0), new Static3D(0,0,0) );
|
|
148 |
mRotate = new VertexEffectRotate( mAngleDyn, mAxis, new Static3D(0,0,0) );
|
|
140 | 149 |
|
141 | 150 |
mEffects = new DistortedEffects(); |
142 | 151 |
mEffects.apply( mRotate ); |
... | ... | |
192 | 201 |
|
193 | 202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
194 | 203 |
|
195 |
void apply(int number)
|
|
204 |
void apply(int andAssoc, int axisIndex)
|
|
196 | 205 |
{ |
197 |
mRotate.setMeshAssociation(0,number); |
|
206 |
mRotate.setMeshAssociation(andAssoc,-1); |
|
207 |
|
|
198 | 208 |
mAngle.set(360); |
209 |
|
|
210 |
mAxis.set0(AXIS[axisIndex].get0()); |
|
211 |
mAxis.set1(AXIS[axisIndex].get1()); |
|
212 |
mAxis.set2(AXIS[axisIndex].get2()); |
|
213 |
|
|
199 | 214 |
mAngleDyn.resetToBeginning(); |
200 | 215 |
} |
201 | 216 |
|
... | ... | |
348 | 363 |
|
349 | 364 |
MeshBase result = new MeshJoined(cubits); |
350 | 365 |
|
366 |
result.setEffectAssociation( 0, (1<<4) + (1<<2) + 1, 0); |
|
367 |
result.setEffectAssociation( 1, (1<<4) + (1<<2) + 2, 0); |
|
368 |
result.setEffectAssociation( 2, (1<<4) + (2<<2) + 1, 0); |
|
369 |
result.setEffectAssociation( 3, (1<<4) + (2<<2) + 2, 0); |
|
370 |
result.setEffectAssociation( 4, (2<<4) + (1<<2) + 1, 0); |
|
371 |
result.setEffectAssociation( 5, (2<<4) + (1<<2) + 2, 0); |
|
372 |
result.setEffectAssociation( 6, (2<<4) + (2<<2) + 1, 0); |
|
373 |
result.setEffectAssociation( 7, (2<<4) + (2<<2) + 2, 0); |
|
374 |
|
|
351 | 375 |
return result; |
352 | 376 |
} |
353 | 377 |
} |
Also available in: Unified diff
Library: make setEffectAssociation a deferred job (because we do copy the uniforms during join!)
SingleMesh App: almost finished.