本文整理汇总了Java中com.badlogic.gdx.math.EarClippingTriangulator类的典型用法代码示例。如果您正苦于以下问题:Java EarClippingTriangulator类的具体用法?Java EarClippingTriangulator怎么用?Java EarClippingTriangulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EarClippingTriangulator类属于com.badlogic.gdx.math包,在下文中一共展示了EarClippingTriangulator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setColor
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
public void setColor(int color) {
Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pix.setColor(color);
pix.fill();
Texture tex = new Texture(pix);
TextureRegion region = new TextureRegion(tex);
Point p1 = (Point) parent.getPoints().toArray()[0];
Point p2 = (Point) parent.getPoints().toArray()[1];
Point p3 = (Point) parent.getPoints().toArray()[2];
Point p4 = (Point) parent.getPoints().toArray()[3];
Point p5 = (Point) parent.getPoints().toArray()[4];
Point p6 = (Point) parent.getPoints().toArray()[5];
float[] vertices = new float[]{(
float) p1.getCoordinateX(), (float)p1.getCoordinateY(),
(float)p2.getCoordinateX(), (float)p2.getCoordinateY(),
(float)p3.getCoordinateX(), (float)p3.getCoordinateY(),
(float) p4.getCoordinateX(), (float)p4.getCoordinateY(),
(float)p5.getCoordinateX(), (float)p5.getCoordinateY(),
(float)p6.getCoordinateX(), (float)p6.getCoordinateY()};
EarClippingTriangulator triangulator = new EarClippingTriangulator();
ShortArray triangleIndices = triangulator.computeTriangles(vertices);
PolygonRegion polygonRegion = new PolygonRegion(region, vertices, triangleIndices.toArray());
sprite = new PolygonSprite(polygonRegion);
}
开发者ID:MartensCedric,项目名称:LD38-Compo,代码行数:27,代码来源:TileData.java
示例2: initPolygonRegions
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
private void initPolygonRegions() {
polygonRegions = new ArrayList<>(assetMap.getRegions().size());
for (AssetMap.Region region : assetMap.getRegions()) {
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(texture),
region.getVertices(),
new EarClippingTriangulator().computeTriangles(region.getVertices()).toArray());
regionMap.put(region, polyReg);
regionNameMap.put(region.getName(), region);
polygonRegions.add(polyReg);
}
}
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:16,代码来源:GameObjectMap.java
示例3: prepareActor
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
@Override
public void prepareActor() {
float[] verticesFloat = new float[vertices.size() * 2];
for(int i = 0; i < vertices.size(); i++) {
verticesFloat[i*2] = vertices.get(i).x;
verticesFloat[i*2+1] = vertices.get(i).y;
}
PolygonRegion polyReg = new PolygonRegion(textureRegion, verticesFloat,
new EarClippingTriangulator().computeTriangles(verticesFloat).toArray());
poly = new PolygonSprite(polyReg);
poly.setOrigin(200, 200);
}
开发者ID:devalexx,项目名称:evilrain,代码行数:15,代码来源:Ground.java
示例4: createFixtures
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
/**
* creates {@link Fixture Fixtures} from a {@link MapObject}
*
* @param mapObject the {@link MapObject} to parse
* @return an array of parsed {@link Fixture Fixtures}
*/
public Fixture[] createFixtures(MapObject mapObject) {
Polygon polygon;
if (!(mapObject instanceof PolygonMapObject) || isConvex(polygon = ((PolygonMapObject) mapObject).getPolygon()))
return new Fixture[]{createFixture(mapObject)};
Polygon[] convexPolygons;
if (triangulate) {
if (areVerticesClockwise(polygon)) { // ensure the vertices are in counterclockwise order (not really necessary according to EarClippingTriangulator's javadoc, but sometimes better)
Array<Vector2> vertices = new Array<Vector2>(toVector2Array(polygon.getVertices()));
Vector2 first = vertices.removeIndex(0);
vertices.reverse();
vertices.insert(0, first);
polygon.setVertices(toFloatArray(vertices.items));
}
convexPolygons = toPolygonArray(toVector2Array(new EarClippingTriangulator().computeTriangles(polygon.getTransformedVertices()).toArray()), 3);
} else {
Array<Array<Vector2>> convexPolys = BayazitDecomposer.convexPartition(new Array<Vector2>(toVector2Array(polygon.getTransformedVertices())));
convexPolygons = new Polygon[convexPolys.size];
for (int i = 0; i < convexPolygons.length; i++)
convexPolygons[i] = new Polygon(toFloatArray((Vector2[]) convexPolys.get(i).toArray(Vector2.class)));
}
// create the fixtures using the convex polygons
Fixture[] fixtures = new Fixture[convexPolygons.length];
for (int i = 0; i < fixtures.length; i++) {
PolygonMapObject convexObject = new PolygonMapObject(convexPolygons[i]);
convexObject.setColor(mapObject.getColor());
convexObject.setName(mapObject.getName());
convexObject.setOpacity(mapObject.getOpacity());
convexObject.setVisible(mapObject.isVisible());
convexObject.getProperties().putAll(mapObject.getProperties());
fixtures[i] = createFixture(convexObject);
}
return fixtures;
}
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:44,代码来源:Box2DMapObjectParser.java
示例5: Polygon
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
/**
* Constructor. Note that vertices must be in a clockwise order for
* performance and accuracy.
*
* @param vertices
* All points in x,y pairs. E.g. x1,y1,x2,y2,etc.
*/
public Polygon(float[] vertices) {
super();
this.vertices = vertices;
triangulator = new EarClippingTriangulator();
getNumberOfSides();
}
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:15,代码来源:Polygon.java
示例6: createdPolygonRegion
import com.badlogic.gdx.math.EarClippingTriangulator; //导入依赖的package包/类
protected PolygonRegion createdPolygonRegion(TextureRegion pixel, float[] vertices) {
return new PolygonRegion(pixel, vertices,
new EarClippingTriangulator().computeTriangles(vertices)
.toArray());
}
开发者ID:mganzarcik,项目名称:fabulae,代码行数:6,代码来源:FilledPolygonRenderer.java
注:本文中的com.badlogic.gdx.math.EarClippingTriangulator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论