233 |
233 |
}
|
234 |
234 |
|
235 |
235 |
////// cornerPush ///////////////////////////////////////////////
|
236 |
|
JSONArray jsonCornerPush= jsonShape.getJSONArray("cornerPush");
|
237 |
|
int numCornerP = jsonCornerPush.length();
|
238 |
|
corners[i] = new float[numCornerP][2];
|
|
236 |
JSONArray jsonCornerPush= jsonShape.optJSONArray("cornerPush");
|
239 |
237 |
|
240 |
|
for(int j=0; j<numCornerP; j++)
|
|
238 |
if( jsonCornerPush!=null )
|
241 |
239 |
{
|
242 |
|
JSONObject jsonC = jsonCornerPush.getJSONObject(j);
|
243 |
|
corners[i][j][0] = (float)jsonC.getDouble("strength");
|
244 |
|
corners[i][j][1] = (float)jsonC.getDouble("radius");
|
|
240 |
int numCornerP = jsonCornerPush.length();
|
|
241 |
corners[i] = new float[numCornerP][2];
|
|
242 |
|
|
243 |
for(int j=0; j<numCornerP; j++)
|
|
244 |
{
|
|
245 |
JSONObject jsonC = jsonCornerPush.getJSONObject(j);
|
|
246 |
corners[i][j][0] = (float)jsonC.getDouble("strength");
|
|
247 |
corners[i][j][1] = (float)jsonC.getDouble("radius");
|
|
248 |
}
|
245 |
249 |
}
|
246 |
250 |
|
247 |
251 |
////// centerPush ///////////////////////////////////////////////
|
248 |
|
JSONArray jsonCenterPush= jsonShape.getJSONArray("centerPush");
|
249 |
|
int numCenterP = jsonCenterPush.length();
|
250 |
|
centers[i] = new float[numCenterP][3];
|
|
252 |
JSONArray jsonCenterPush= jsonShape.optJSONArray("centerPush");
|
251 |
253 |
|
252 |
|
for(int j=0; j<numCenterP; j++)
|
|
254 |
if( jsonCenterPush!=null )
|
253 |
255 |
{
|
254 |
|
JSONObject jsonC = jsonCenterPush.getJSONObject(j);
|
255 |
|
centers[i][j][0] = (float)jsonC.getDouble("x");
|
256 |
|
centers[i][j][1] = (float)jsonC.getDouble("y");
|
257 |
|
centers[i][j][2] = (float)jsonC.getDouble("z");
|
|
256 |
int numCenterP = jsonCenterPush.length();
|
|
257 |
centers[i] = new float[numCenterP][3];
|
|
258 |
|
|
259 |
for(int j=0; j<numCenterP; j++)
|
|
260 |
{
|
|
261 |
JSONObject jsonC = jsonCenterPush.getJSONObject(j);
|
|
262 |
centers[i][j][0] = (float)jsonC.getDouble("x");
|
|
263 |
centers[i][j][1] = (float)jsonC.getDouble("y");
|
|
264 |
centers[i][j][2] = (float)jsonC.getDouble("z");
|
|
265 |
}
|
258 |
266 |
}
|
259 |
267 |
|
260 |
268 |
////// convexity ///////////////////////////////////////////////
|
261 |
|
try
|
|
269 |
JSONObject jsonConvexity = jsonShape.optJSONObject("convexity");
|
|
270 |
|
|
271 |
if( jsonConvexity!=null )
|
262 |
272 |
{
|
263 |
|
JSONObject jsonConvexity = jsonShape.getJSONObject("convexity");
|
264 |
273 |
convexity[i] = new float[3];
|
265 |
274 |
convexity[i][0] = (float)jsonConvexity.getDouble("x");
|
266 |
275 |
convexity[i][1] = (float)jsonConvexity.getDouble("y");
|
267 |
276 |
convexity[i][2] = (float)jsonConvexity.getDouble("z");
|
268 |
277 |
}
|
269 |
|
catch(JSONException ex)
|
270 |
|
{
|
271 |
|
// ignore
|
272 |
|
}
|
273 |
278 |
}
|
274 |
279 |
|
275 |
280 |
for(int i=0; i<mNumCubitVariants; i++)
|
Correect JSON reading and writing: shape corners and centers are optional!