Revision 23c35a5d
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java | ||
|---|---|---|
| 110 | 110 |
|
| 111 | 111 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
| 112 | 112 |
{
|
| 113 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
|
|
| 113 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.grid);
|
|
| 114 | 114 |
Bitmap bitmap; |
| 115 | 115 |
|
| 116 | 116 |
try |
| ... | ... | |
| 131 | 131 |
|
| 132 | 132 |
if( mMesh==null ) mMesh = createJoinedMesh(); |
| 133 | 133 |
|
| 134 |
mMesh.setShowNormals(true); |
|
| 134 |
// mMesh.setShowNormals(true);
|
|
| 135 | 135 |
|
| 136 | 136 |
mScreen.detachAll(); |
| 137 | 137 |
mScreen.attach(mTexture,mEffects,mMesh); |
| ... | ... | |
| 150 | 150 |
|
| 151 | 151 |
private MeshBase createJoinedMesh() |
| 152 | 152 |
{
|
| 153 |
/* |
|
| 154 |
MeshBase[] meshes = new MeshBase[2]; |
|
| 155 |
meshes[0] = new MeshQuad(); |
|
| 156 |
meshes[1] = new MeshQuad(); |
|
| 157 |
|
|
| 158 |
MatrixEffect[] effects0 = new MatrixEffect[1]; |
|
| 159 |
effects0[0] = new MatrixEffectMove( new Static3D(0,+0.6f,0)); |
|
| 160 |
|
|
| 161 |
meshes[0].apply(effects0); |
|
| 162 |
|
|
| 163 |
MatrixEffect[] effects1 = new MatrixEffect[1]; |
|
| 164 |
effects1[0] = new MatrixEffectMove( new Static3D(0,-0.6f,0)); |
|
| 165 |
|
|
| 166 |
meshes[1].apply(effects1); |
|
| 167 |
*/ |
|
| 168 |
/* |
|
| 153 | 169 |
MeshBase[] meshes = new MeshBase[2]; |
| 154 | 170 |
meshes[0] = new MeshSphere(5); |
| 155 | 171 |
meshes[1] = new MeshTriangles(5); |
| ... | ... | |
| 165 | 181 |
effects1[1] = new MatrixEffectMove( new Static3D(-0.25f,0,0)); |
| 166 | 182 |
|
| 167 | 183 |
meshes[1].apply(effects1); |
| 168 |
/*
|
|
| 184 |
*/
|
|
| 169 | 185 |
final int MESHES=6; |
| 170 | 186 |
|
| 171 | 187 |
Static3D axisY = new Static3D(0,1,0); |
| ... | ... | |
| 197 | 213 |
meshes[4].apply(effectsX); |
| 198 | 214 |
angle.set(-90); |
| 199 | 215 |
meshes[5].apply(effectsX); |
| 200 |
*/ |
|
| 201 |
return new MeshJoined(meshes); |
|
| 216 |
|
|
| 217 |
MeshJoined result = new MeshJoined(meshes); |
|
| 218 |
|
|
| 219 |
float[][] maps = new float[MESHES][4]; |
|
| 220 |
|
|
| 221 |
maps[0][0] = 3.0f/8; maps[0][1] = 3.0f/8; maps[0][2] = 1.0f/8; maps[0][3] = 2.0f/8; |
|
| 222 |
maps[1][0] = 5.0f/8; maps[1][1] = 3.0f/8; maps[1][2] = 1.0f/8; maps[1][3] = 2.0f/8; |
|
| 223 |
maps[2][0] = 3.0f/8; maps[2][1] = 5.0f/8; maps[2][2] = 1.0f/8; maps[2][3] = 2.0f/8; |
|
| 224 |
maps[3][0] = 1.0f/8; maps[3][1] = 5.0f/8; maps[3][2] = 1.0f/8; maps[3][3] = 2.0f/8; |
|
| 225 |
maps[4][0] = 5.0f/8; maps[4][1] = 1.0f/8; maps[4][2] = 1.0f/8; maps[4][3] = 2.0f/8; |
|
| 226 |
maps[5][0] = 5.0f/8; maps[5][1] = 5.0f/8; maps[5][2] = 1.0f/8; maps[5][3] = 2.0f/8; |
|
| 227 |
|
|
| 228 |
result.setTextureMap(maps); |
|
| 229 |
|
|
| 230 |
maps[0][0] = 3.0f/8; maps[0][1] = 3.0f/8; maps[0][2] = 2.0f/8; maps[0][3] = 2.0f/8; |
|
| 231 |
maps[1][0] = 5.0f/8; maps[1][1] = 1.0f/8; maps[1][2] = 2.0f/8; maps[1][3] = 2.0f/8; |
|
| 232 |
maps[2][0] = 1.0f/8; maps[2][1] = 5.0f/8; maps[2][2] = 2.0f/8; maps[2][3] = 2.0f/8; |
|
| 233 |
maps[3][0] = 1.0f/8; maps[3][1] = 3.0f/8; maps[3][2] = 2.0f/8; maps[3][3] = 2.0f/8; |
|
| 234 |
maps[4][0] = 3.0f/8; maps[4][1] = 1.0f/8; maps[4][2] = 2.0f/8; maps[4][3] = 2.0f/8; |
|
| 235 |
maps[5][0] = 1.0f/8; maps[5][1] = 1.0f/8; maps[5][2] = 2.0f/8; maps[5][3] = 2.0f/8; |
|
| 236 |
|
|
| 237 |
result.setTextureMap(maps); |
|
| 238 |
return result; |
|
| 202 | 239 |
} |
| 203 | 240 |
} |
Also available in: Unified diff
Make MeshBase.setTextureMap() work.