Revision d1d5d7e2
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
|---|---|---|
| 48 | 48 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
| 49 | 49 |
import org.distorted.objectlib.helpers.ObjectShape; |
| 50 | 50 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
| 51 |
import org.distorted.objectlib.main.InitData; |
|
| 52 |
import org.distorted.objectlib.main.TwistyObject; |
|
| 53 |
import org.distorted.objectlib.objects.*; |
|
| 54 | 51 |
|
| 55 | 52 |
import java.io.DataInputStream; |
| 56 | 53 |
import java.io.IOException; |
| ... | ... | |
| 358 | 355 |
|
| 359 | 356 |
private void createMesh() |
| 360 | 357 |
{
|
| 361 |
Static4D quat = new Static4D(0,0,0,1); |
|
| 362 |
Static3D move = new Static3D(0,0,0); |
|
| 363 |
float scale = 1.0f; |
|
| 364 |
int variant = 1; |
|
| 365 |
|
|
| 366 |
InitData data = new InitData(new int[] {2,3,2});
|
|
| 367 |
TwistyObject puzzle = new TwistyCuboid(MESH_NICE,MODE_NORM,quat,move,scale,data,null); |
|
| 368 |
|
|
| 369 |
ObjectShape shape = puzzle.getObjectShape(variant); |
|
| 370 |
ObjectFaceShape face = puzzle.getObjectFaceShape(variant); |
|
| 371 |
ObjectVertexEffects effects = puzzle.getVertexEffects(variant); |
|
| 372 |
|
|
| 373 |
int[][] indices = shape.getVertIndices(); |
|
| 374 |
int numComponents = indices.length; |
|
| 375 |
int[] outer = new int[numComponents]; |
|
| 358 |
float[][] vertices = |
|
| 359 |
{
|
|
| 360 |
{ 0.5f, 0.5f, 0.5f },
|
|
| 361 |
{ 0.5f, 0.5f,-0.5f },
|
|
| 362 |
{ 0.5f,-0.5f, 0.5f },
|
|
| 363 |
{ 0.5f,-0.5f,-0.5f },
|
|
| 364 |
{-0.5f, 0.5f, 0.5f },
|
|
| 365 |
{-0.5f, 0.5f,-0.5f },
|
|
| 366 |
{-0.5f,-0.5f, 0.5f },
|
|
| 367 |
{-0.5f,-0.5f,-0.5f },
|
|
| 368 |
|
|
| 369 |
{-0.5f, 0.0f, 0.5f },
|
|
| 370 |
{ 0.5f, 0.0f, 0.5f },
|
|
| 371 |
}; |
|
| 372 |
|
|
| 373 |
int[][][] vertIndices = |
|
| 374 |
{
|
|
| 375 |
{ {2,3,1,0} },
|
|
| 376 |
{ {7,6,4,5} },
|
|
| 377 |
{ {4,0,1,5} },
|
|
| 378 |
{ {7,3,2,6} },
|
|
| 379 |
{ {6,2,0,4} },
|
|
| 380 |
{ {3,7,5,1} }
|
|
| 381 |
}; |
|
| 382 |
|
|
| 383 |
float height = 0.05f; |
|
| 384 |
int num = 5; |
|
| 385 |
int extraI = 1; |
|
| 386 |
int extraV = 1; |
|
| 387 |
|
|
| 388 |
float[][] bands= { {height,35,0.5f,0.7f,num,extraI,extraV} };
|
|
| 389 |
|
|
| 390 |
int[] bandIndices = {0,0,0,0,0,0};
|
|
| 391 |
float[] convex = null; |
|
| 392 |
|
|
| 393 |
float[][] corners= { {0.036f,0.12f} };
|
|
| 394 |
float[][] centers= { {0.0f, 0.0f, 0.0f} };
|
|
| 395 |
int[] ind = { 0,0,0,0,0,0,0,0,-1,-1 };
|
|
| 396 |
|
|
| 397 |
ObjectShape shape = new ObjectShape(vertices, vertIndices); |
|
| 398 |
ObjectFaceShape face = new ObjectFaceShape(bands, bandIndices, convex); |
|
| 399 |
ObjectVertexEffects effects = FactoryCubit.generateVertexEffect(vertices,corners,ind,centers,ind); |
|
| 400 |
|
|
| 401 |
int numFaces = shape.getNumFaces(); |
|
| 402 |
int[] outer = new int[numFaces]; |
|
| 376 | 403 |
|
| 377 | 404 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 378 | 405 |
factory.clear(); |
| 379 | 406 |
factory.createNewFaceTransform(shape,outer); |
| 380 |
mMesh = factory.createRoundedSolid(shape,face,effects,MESH_NICE,numComponents);
|
|
| 407 |
mMesh = factory.createRoundedSolid(shape,face,effects,MESH_NICE,numFaces);
|
|
| 381 | 408 |
|
| 382 | 409 |
int numEff = mMesh.getNumEffComponents(); |
| 383 | 410 |
|
Also available in: Unified diff
use MeshMultigon in puzzle cubits (FactoryCubit)