Revision e3c87517
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/inflate/InflateActivity2.java | ||
---|---|---|
49 | 49 |
private TextView mTextLevel; |
50 | 50 |
private DistortedTexture mTexture; |
51 | 51 |
private MeshBase mMesh; |
52 |
private int mNumRows, mNumCols, mNumSlic; |
|
52 | 53 |
|
53 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 55 |
|
... | ... | |
94 | 95 |
String str = b.getString("string"); |
95 | 96 |
int objectType = b.getInt("type"); |
96 | 97 |
int bitmapID = b.getInt("bitmap"); |
97 |
int numCols = b.getInt("cols");
|
|
98 |
int numRows = b.getInt("rows");
|
|
99 |
int numSlic = b.getInt("slices");
|
|
98 |
mNumCols = b.getInt("cols");
|
|
99 |
mNumRows = b.getInt("rows");
|
|
100 |
mNumSlic = b.getInt("slices");
|
|
100 | 101 |
|
101 |
int maxsize = numCols > numRows ? (Math.max(numCols, numSlic)) : (Math.max(numRows, numSlic));
|
|
102 |
int maxsize = mNumCols > mNumRows ? (Math.max(mNumCols, mNumSlic)) : (Math.max(mNumRows, mNumSlic));
|
|
102 | 103 |
createBitmap(maxsize,bitmapID); |
103 |
mMesh = InflateMeshList.createMesh(objectType, numCols, numRows, numSlic, bitmapID, str); |
|
104 |
mMesh = InflateMeshList.createMesh(objectType, mNumCols, mNumRows, mNumSlic, bitmapID, str); |
|
105 |
|
|
104 | 106 |
mTexture = new DistortedTexture(); |
105 | 107 |
|
106 | 108 |
setContentView(R.layout.inflatelayout); |
... | ... | |
131 | 133 |
{ |
132 | 134 |
if( bitmapID!=-1) |
133 | 135 |
{ |
134 |
InputStream is = getResources().openRawResource(bitmapID); |
|
135 |
|
|
136 |
try |
|
136 |
try (InputStream is = getResources().openRawResource(bitmapID)) |
|
137 | 137 |
{ |
138 | 138 |
mBitmap = BitmapFactory.decodeStream(is); |
139 | 139 |
} |
140 |
finally |
|
141 |
{ |
|
142 |
try |
|
143 |
{ |
|
144 |
is.close(); |
|
145 |
} |
|
146 |
catch(IOException e) { } |
|
147 |
} |
|
140 |
catch( IOException ex ) { android.util.Log.e("act", "failed to open resource "+bitmapID); } |
|
148 | 141 |
} |
149 | 142 |
else |
150 | 143 |
{ |
... | ... | |
170 | 163 |
} |
171 | 164 |
} |
172 | 165 |
|
166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
167 |
|
|
168 |
int getRows() |
|
169 |
{ |
|
170 |
return mNumRows; |
|
171 |
} |
|
172 |
|
|
173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
174 |
|
|
175 |
int getCols() |
|
176 |
{ |
|
177 |
return mNumCols; |
|
178 |
} |
|
179 |
|
|
180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
|
182 |
int getSlic() |
|
183 |
{ |
|
184 |
return mNumSlic; |
|
185 |
} |
|
186 |
|
|
173 | 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
174 | 188 |
|
175 | 189 |
public Bitmap getBitmap() |
... | ... | |
184 | 198 |
InflateSurfaceView v = this.findViewById(R.id.inflateSurfaceView); |
185 | 199 |
InflateRenderer renderer = v.getRenderer(); |
186 | 200 |
|
187 |
switch(parent.getId())
|
|
201 |
if( parent.getId()==R.id.inflateSpinnerMode)
|
|
188 | 202 |
{ |
189 |
case R.id.inflateSpinnerMode: renderer.setRenderModeToOIT(pos==1); |
|
190 |
break; |
|
203 |
renderer.setRenderModeToOIT(pos==1); |
|
191 | 204 |
} |
192 | 205 |
} |
193 | 206 |
|
Also available in: Unified diff
Convert the first app, Inflate, to the new MeshBase.setStretch-less API ( use VertexEffectScale instead )