OSDN Git Service

chmod -x a lot of .java source files
[mikumikustudio/libgdx-mikumikustudio.git] / extensions / gdx-bullet / jni / swig-src / com / badlogic / gdx / physics / bullet / btIndexedMesh.java
1 /* ----------------------------------------------------------------------------\r
2  * This file was automatically generated by SWIG (http://www.swig.org).\r
3  * Version 2.0.10\r
4  *\r
5  * Do not make changes to this file unless you know what you are doing--modify\r
6  * the SWIG interface file instead.\r
7  * ----------------------------------------------------------------------------- */\r
8 \r
9 package com.badlogic.gdx.physics.bullet;\r
10 \r
11 import com.badlogic.gdx.graphics.Mesh;\r
12 import com.badlogic.gdx.graphics.VertexAttribute;\r
13 import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
14 import com.badlogic.gdx.graphics.g3d.model.MeshPart;\r
15 import com.badlogic.gdx.utils.Array;\r
16 import com.badlogic.gdx.utils.GdxRuntimeException;\r
17 \r
18 public class btIndexedMesh extends BulletBase {\r
19         private long swigCPtr;\r
20         \r
21         protected btIndexedMesh(final String className, long cPtr, boolean cMemoryOwn) {\r
22                 super(className, cPtr, cMemoryOwn);\r
23                 swigCPtr = cPtr;\r
24         }\r
25         \r
26         protected btIndexedMesh(long cPtr, boolean cMemoryOwn) {\r
27                 this("btIndexedMesh", cPtr, cMemoryOwn);\r
28                 construct();\r
29         }\r
30         \r
31         public static long getCPtr(btIndexedMesh obj) {\r
32                 return (obj == null) ? 0 : obj.swigCPtr;\r
33         }\r
34 \r
35         @Override\r
36         protected void finalize() throws Throwable {\r
37                 if (!destroyed)\r
38                         destroy();\r
39                 super.finalize();\r
40         }\r
41 \r
42   @Override protected synchronized void delete() {\r
43                 if (swigCPtr != 0) {\r
44                         if (swigCMemOwn) {\r
45                                 swigCMemOwn = false;\r
46                                 gdxBulletJNI.delete_btIndexedMesh(swigCPtr);\r
47                         }\r
48                         swigCPtr = 0;\r
49                 }\r
50                 super.delete();\r
51         }\r
52 \r
53         protected final static Array<btIndexedMesh> instances = new Array<btIndexedMesh>();\r
54         protected static btIndexedMesh getInstance(final MeshPart meshPart) {\r
55                 final int n = instances.size;\r
56                 for (int i = 0; i < n; i++) {\r
57                         final btIndexedMesh mesh = instances.get(i);\r
58                         if (meshPart.equals(mesh.meshPart))\r
59                                 return mesh;\r
60                 }\r
61                 return null;\r
62         }\r
63         \r
64         /** Create or reuse a btIndexedMesh instance based on the specified {@link MeshPart}.\r
65          * Use {@link #release()} to release the mesh when it's no longer needed. */\r
66         public static btIndexedMesh obtain(final MeshPart meshPart) {\r
67                 if (meshPart == null)\r
68                         throw new GdxRuntimeException("meshPart cannot be null");\r
69                 \r
70                 btIndexedMesh result = getInstance(meshPart);\r
71                 if (result == null) {\r
72                         result = new btIndexedMesh(meshPart);\r
73                         instances.add(result);\r
74                 }\r
75                 result.obtain();\r
76                 return result;\r
77         }\r
78         \r
79         protected MeshPart meshPart;\r
80         \r
81         /** Construct a new btIndexedMesh based on the supplied {@link Mesh}\r
82          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
83          * The buffers for the vertices and indices are shared amonst both. */\r
84         public btIndexedMesh(final Mesh mesh) {\r
85                 this();\r
86                 set(mesh);\r
87         }\r
88         \r
89         /** Construct a new btIndexedMesh based on the supplied {@link MeshPart}\r
90          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
91          * The buffers for the vertices and indices are shared amonst both. */\r
92         public btIndexedMesh(final MeshPart meshPart) {\r
93                 this();\r
94                 set(meshPart);\r
95         }\r
96         \r
97         /** Construct a new btIndexedMesh based on the supplied {@link Mesh}\r
98          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
99          * The buffers for the vertices and indices are shared amonst both. */\r
100         public btIndexedMesh(final Mesh mesh, int offset, int count) {\r
101                 this();\r
102                 set(mesh, offset, count);\r
103         }\r
104         \r
105         /** @return The {@link MeshPart} used to create or set this btIndexedMesh, may be null. */\r
106         public MeshPart getMeshPart() {\r
107                 return meshPart;\r
108         }\r
109         \r
110         /** Convenience method to set this btIndexedMesh to the specified {@link Mesh} \r
111          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
112          * The buffers for the vertices and indices are shared amonst both. */\r
113         public void set(final Mesh mesh) {\r
114                 set(mesh, 0, mesh.getNumIndices());\r
115         }\r
116 \r
117         /** Convenience method to set this btIndexedMesh to the specified {@link MeshPart} \r
118          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
119          * The buffers for the vertices and indices are shared amonst both. */\r
120         public void set(final MeshPart meshPart) {\r
121                 if (meshPart.primitiveType != com.badlogic.gdx.graphics.GL10.GL_TRIANGLES)\r
122                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh must be indexed and triangulated");\r
123                 set(meshPart.mesh, meshPart.indexOffset, meshPart.numVertices);\r
124                 this.meshPart = meshPart;\r
125         }\r
126 \r
127         /** Convenience method to set this btIndexedMesh to the specified {@link Mesh} \r
128          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
129          * The buffers for the vertices and indices are shared amonst both. */\r
130         public void set(final Mesh mesh, int offset, int count) {\r
131                 if ((count <= 0) || ((count % 3) != 0))\r
132                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh must be indexed and triangulated");\r
133 \r
134                 VertexAttribute posAttr = mesh.getVertexAttribute(Usage.Position);\r
135                 \r
136                 if (posAttr == null)\r
137                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh doesn't have a position attribute");\r
138                 \r
139                 setVertices(mesh.getVerticesBuffer(), mesh.getVertexSize(), mesh.getNumVertices(), posAttr.offset);\r
140                 setIndices(mesh.getIndicesBuffer(), offset, count);\r
141                 \r
142                 meshPart = null;\r
143         }\r
144 \r
145   public void setNumTriangles(int value) {\r
146     gdxBulletJNI.btIndexedMesh_numTriangles_set(swigCPtr, this, value);\r
147   }\r
148 \r
149   public int getNumTriangles() {\r
150     return gdxBulletJNI.btIndexedMesh_numTriangles_get(swigCPtr, this);\r
151   }\r
152 \r
153   public void setTriangleIndexBase(java.nio.ByteBuffer value) {\r
154     assert value.isDirect() : "Buffer must be allocated direct.";\r
155     {\r
156       gdxBulletJNI.btIndexedMesh_triangleIndexBase_set(swigCPtr, this, value);\r
157     }\r
158   }\r
159 \r
160   public java.nio.ByteBuffer getTriangleIndexBase() {\r
161     return gdxBulletJNI.btIndexedMesh_triangleIndexBase_get(swigCPtr, this);\r
162 }\r
163 \r
164   public void setTriangleIndexStride(int value) {\r
165     gdxBulletJNI.btIndexedMesh_triangleIndexStride_set(swigCPtr, this, value);\r
166   }\r
167 \r
168   public int getTriangleIndexStride() {\r
169     return gdxBulletJNI.btIndexedMesh_triangleIndexStride_get(swigCPtr, this);\r
170   }\r
171 \r
172   public void setNumVertices(int value) {\r
173     gdxBulletJNI.btIndexedMesh_numVertices_set(swigCPtr, this, value);\r
174   }\r
175 \r
176   public int getNumVertices() {\r
177     return gdxBulletJNI.btIndexedMesh_numVertices_get(swigCPtr, this);\r
178   }\r
179 \r
180   public void setVertexBase(java.nio.ByteBuffer value) {\r
181     assert value.isDirect() : "Buffer must be allocated direct.";\r
182     {\r
183       gdxBulletJNI.btIndexedMesh_vertexBase_set(swigCPtr, this, value);\r
184     }\r
185   }\r
186 \r
187   public java.nio.ByteBuffer getVertexBase() {\r
188     return gdxBulletJNI.btIndexedMesh_vertexBase_get(swigCPtr, this);\r
189 }\r
190 \r
191   public void setVertexStride(int value) {\r
192     gdxBulletJNI.btIndexedMesh_vertexStride_set(swigCPtr, this, value);\r
193   }\r
194 \r
195   public int getVertexStride() {\r
196     return gdxBulletJNI.btIndexedMesh_vertexStride_get(swigCPtr, this);\r
197   }\r
198 \r
199   public void setIndexType(int value) {\r
200     gdxBulletJNI.btIndexedMesh_indexType_set(swigCPtr, this, value);\r
201   }\r
202 \r
203   public int getIndexType() {\r
204     return gdxBulletJNI.btIndexedMesh_indexType_get(swigCPtr, this);\r
205   }\r
206 \r
207   public void setVertexType(int value) {\r
208     gdxBulletJNI.btIndexedMesh_vertexType_set(swigCPtr, this, value);\r
209   }\r
210 \r
211   public int getVertexType() {\r
212     return gdxBulletJNI.btIndexedMesh_vertexType_get(swigCPtr, this);\r
213   }\r
214 \r
215   public btIndexedMesh() {\r
216     this(gdxBulletJNI.new_btIndexedMesh(), true);\r
217   }\r
218 \r
219   public void setTriangleIndexBase(java.nio.ShortBuffer data) {\r
220     assert data.isDirect() : "Buffer must be allocated direct.";\r
221     {\r
222       gdxBulletJNI.btIndexedMesh_setTriangleIndexBase(swigCPtr, this, data);\r
223     }\r
224   }\r
225 \r
226   public void setVertexBase(java.nio.FloatBuffer data) {\r
227     assert data.isDirect() : "Buffer must be allocated direct.";\r
228     {\r
229       gdxBulletJNI.btIndexedMesh_setVertexBase(swigCPtr, this, data);\r
230     }\r
231   }\r
232 \r
233   public void setVertices(java.nio.FloatBuffer vertices, int sizeInBytesOfEachVertex, int vertexCount, int positionOffsetInBytes) {\r
234     assert vertices.isDirect() : "Buffer must be allocated direct.";\r
235     {\r
236       gdxBulletJNI.btIndexedMesh_setVertices(swigCPtr, this, vertices, sizeInBytesOfEachVertex, vertexCount, positionOffsetInBytes);\r
237     }\r
238   }\r
239 \r
240   public void setIndices(java.nio.ShortBuffer indices, int indexOffset, int indexCount) {\r
241     assert indices.isDirect() : "Buffer must be allocated direct.";\r
242     {\r
243       gdxBulletJNI.btIndexedMesh_setIndices(swigCPtr, this, indices, indexOffset, indexCount);\r
244     }\r
245   }\r
246 \r
247 }\r