1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.objectlib.helpers;
|
21
|
|
22
|
import org.distorted.objectlib.main.ObjectControl;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class ObjectShape
|
27
|
{
|
28
|
private final double[][] mVertices;
|
29
|
private final int[][] mVertIndices;
|
30
|
private final int[] mBandIndices;
|
31
|
private final float[][] mCorners;
|
32
|
private final int[] mCornerIndices;
|
33
|
private final float[][] mCenters;
|
34
|
private final int[] mCenterIndices;
|
35
|
private final int mNumComponents;
|
36
|
private final float[] mConvexityCenter;
|
37
|
|
38
|
private float[][] mBands;
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
public ObjectShape(double[][] vertices, int[][] vertIndices, float[][] bands, int[] bandIndices,
|
43
|
float[][] corners, int[] cornIndices, float[][] centers, int[] centIndices,
|
44
|
int numComponents, float[] convexityCenter)
|
45
|
{
|
46
|
mVertices = vertices;
|
47
|
mVertIndices = vertIndices;
|
48
|
mBands = bands;
|
49
|
mBandIndices = bandIndices;
|
50
|
mCorners = corners;
|
51
|
mCornerIndices = cornIndices;
|
52
|
mCenters = centers;
|
53
|
mCenterIndices = centIndices;
|
54
|
mNumComponents = numComponents;
|
55
|
mConvexityCenter = convexityCenter;
|
56
|
|
57
|
if( ObjectControl.isInIconMode() )
|
58
|
{
|
59
|
int len = bands.length;
|
60
|
mBands = new float[len][];
|
61
|
|
62
|
for(int i=0; i<len; i++)
|
63
|
{
|
64
|
int l = bands[i].length;
|
65
|
mBands[i] = new float[l];
|
66
|
mBands[i][0] = 0.01f;
|
67
|
if (l>=1) System.arraycopy(bands[i], 1, mBands[i], 1, l-1);
|
68
|
}
|
69
|
}
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
public double[][] getVertices()
|
75
|
{
|
76
|
return mVertices;
|
77
|
}
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
|
81
|
public int[][] getVertIndices()
|
82
|
{
|
83
|
return mVertIndices;
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
public float[][] getBands()
|
89
|
{
|
90
|
return mBands;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
public int[] getBandIndices()
|
96
|
{
|
97
|
return mBandIndices;
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
public float[][] getCorners()
|
103
|
{
|
104
|
return mCorners;
|
105
|
}
|
106
|
|
107
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108
|
|
109
|
public int[] getCornerIndices()
|
110
|
{
|
111
|
return mCornerIndices;
|
112
|
}
|
113
|
|
114
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115
|
|
116
|
public float[][] getCenters()
|
117
|
{
|
118
|
return mCenters;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
public int[] getCenterIndices()
|
124
|
{
|
125
|
return mCenterIndices;
|
126
|
}
|
127
|
|
128
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129
|
|
130
|
public int getNumComponents()
|
131
|
{
|
132
|
return mNumComponents;
|
133
|
}
|
134
|
|
135
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136
|
|
137
|
public float[] getConvexityCenter()
|
138
|
{
|
139
|
return mConvexityCenter;
|
140
|
}
|
141
|
}
|