本文整理汇总了Java中org.poly2tri.Poly2Tri.triangulate方法的典型用法代码示例。如果您正苦于以下问题:Java Poly2Tri.triangulate方法的具体用法?Java Poly2Tri.triangulate怎么用?Java Poly2Tri.triangulate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.poly2tri.Poly2Tri
的用法示例。
在下文中一共展示了Poly2Tri.triangulate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initExample
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
@Override
protected void initExample()
{
super.initExample();
Mesh mesh;
Node node = new Node();
node.setRenderState( new WireframeState() );
_node.attachChild( node );
Polygon poly;
poly = createSquare();
mesh = new Mesh();
mesh.setDefaultColor( ColorRGBA.GREEN );
mesh.setTranslation( 0, 0, 0 );
node.attachChild( mesh );
Poly2Tri.triangulate( poly );
ArdorMeshMapper.updateTriangleMesh( mesh, poly );
}
示例2: initExample
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
@Override
protected void initExample()
{
super.initExample();
Mesh mesh = new Mesh();
mesh.setDefaultColor( ColorRGBA.BLUE );
_node.attachChild( mesh );
double scale = 100;
int size = 1000;
int index = (int)(Math.random()*size);
List<TriangulationPoint> points = PointGenerator.uniformDistribution( size, scale );
// Lets add a constraint that cuts the uniformDistribution in half
points.add( new TPoint(0,scale/2) );
points.add( new TPoint(0,-scale/2) );
index = size;
ConstrainedPointSet cps = new ConstrainedPointSet( points, new int[]{ index, index+1 } );
Poly2Tri.triangulate( cps );
ArdorMeshMapper.updateTriangleMesh( mesh, cps );
}
示例3: initExample
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
@Override
protected void initExample()
{
super.initExample();
Node node = new Node();
node.setRenderState( new WireframeState() );
_node.attachChild( node );
Polygon circle;
Polygon hole;
circle = createCirclePolygon( 64, 25, 1 );
hole = createCirclePolygon( 32, 25, 0.25, -0.5, -0.5 );
circle.addHole( hole );
hole = createCirclePolygon( 64, 25, 0.5, 0.25, 0.25 );
circle.addHole( hole );
Mesh mesh = new Mesh();
mesh.setDefaultColor( ColorRGBA.RED );
mesh.setTranslation( 0, 0, 0.01 );
node.attachChild( mesh );
Mesh mesh2 = new Mesh();
mesh2.setDefaultColor( ColorRGBA.BLUE );
_node.attachChild( mesh2 );
Poly2Tri.triangulate( circle );
ArdorMeshMapper.updateTriangleMesh( mesh, circle );
ArdorMeshMapper.updateTriangleMesh( mesh2, circle );
}
示例4: main
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
public static void main(final String[] args)
throws Exception
{
PointSet ps = new PointSet( PointGenerator.uniformDistribution( 50, 500000 ) );
for( int i=0; i<1; i++ )
{
Poly2Tri.triangulate( ps );
}
Thread.sleep( 10000000 );
}
示例5: DoTriangulation
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
void DoTriangulation() {
if (points.size() < 3)
return;
Polygon polygon = new Polygon(points);
Poly2Tri.triangulate(polygon);
triangles = polygon.getTriangles();
println("DT: " + triangles);
bShowTriangulation = true;
}
示例6: doTriangulation
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
void doTriangulation() {
Polygon polygon = new Polygon(points);
// polygon.
try {
Poly2Tri.triangulate(polygon);
triangles = polygon.getTriangles();
// println("DT: " + triangles);
} catch(NullPointerException e) {
}
}
示例7: setVertices
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
/**
* Sets the polygonal shape of this node
*
* @param vertices Vertex positions
* @param textureCoordinates Corresponding vertex texture coordinates
*/
public void setVertices( Vector2f[] vertices, Vector2f[] textureCoordinates ) {
if ( vertices.length > positionBuffer.capacity() ) {
updateMaxVertexCount( Math.max( vertices.length, positionBuffer.capacity() + 20 ) ); // update by at least 20
}
positionBuffer.clear();
textureBuffer.clear();
indexBuffer.clear();
// fill the position buffer
for ( Vector2f vertex : vertices ) {
positionBuffer.put( new float[] { vertex.x, vertex.y, 0 } );
}
positionBuffer.limit( positionBuffer.position() );
normalBuffer.limit( positionBuffer.position() ); // also set the limit on the normal buffer to the same position
// fill the texture buffer
for ( Vector2f textureCoordinate : textureCoordinates ) {
textureBuffer.put( new float[] { textureCoordinate.x, textureCoordinate.y } );
}
textureBuffer.limit( textureBuffer.position() );
// ignore polygons with less than 3 vertices
if ( vertices.length >= 3 ) {
// make a list of polygon points that we can refer to later
PolygonPoint[] points = new PolygonPoint[vertices.length];
for ( short i = 0; i < points.length; i++ ) {
points[i] = new IndexedPolygonPoint( i, vertices[i].getX(), vertices[i].getY() );
}
// create and triangulate our polygon
Polygon polygon = new Polygon( points );
Poly2Tri.triangulate( polygon );
// iterate through the triangles, and add their indices into the index buffer
List<DelaunayTriangle> triangles = polygon.getTriangles();
for ( DelaunayTriangle triangle : triangles ) {
// find the indices of the points
short[] indices = new short[] {
( (IndexedPolygonPoint) triangle.points[0] ).index,
( (IndexedPolygonPoint) triangle.points[1] ).index,
( (IndexedPolygonPoint) triangle.points[2] ).index };
// add the indices into the index buffer
indexBuffer.put( indices );
}
}
indexBuffer.limit( indexBuffer.position() );
// update the underlying vertex buffers
getBuffer( Type.Position ).updateData( positionBuffer );
getBuffer( Type.Normal ).updateData( normalBuffer );
getBuffer( Type.TexCoord ).updateData( textureBuffer );
getBuffer( Type.Index ).updateData( indexBuffer );
// update various statistics and counts
updateBound();
updateCounts();
}
示例8: initExample
import org.poly2tri.Poly2Tri; //导入方法依赖的package包/类
@Override
protected void initExample()
{
super.initExample();
try
{
importShape(100);
}
catch( IOException e )
{
}
_canvas.getCanvasRenderer().getCamera().setLocation(200, 200, 200);
_canvas.getCanvasRenderer().getCamera().lookAt( 0, 0, 0, Vector3.UNIT_Z );
_worldNode = new Node("shape");
// _worldNode.setRenderState( new WireframeState() );
_node.attachChild( _worldNode );
buildSkyBox();
Sphere seas = new Sphere("seas", Vector3.ZERO, 64, 64, 100.2f);
seas.setDefaultColor( new ColorRGBA(0,0,0.5f,0.25f) );
seas.getSceneHints().setRenderBucketType( RenderBucketType.Transparent );
BlendState bs = new BlendState();
bs.setBlendEnabled( true );
bs.setEnabled( true );
bs.setBlendEquationAlpha( BlendEquation.Max );
bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
seas.setRenderState( bs );
ZBufferState zb = new ZBufferState();
zb.setEnabled( true );
zb.setWritable( false );
seas.setRenderState( zb );
_worldNode.attachChild( seas );
Sphere core = new Sphere("seas", Vector3.ZERO, 16, 16, 10f);
core.getSceneHints().setLightCombineMode( LightCombineMode.Replace );
MaterialState ms = new MaterialState();
ms.setEmissive( new ColorRGBA(0.8f,0.2f,0,0.9f) );
core.setRenderState( ms );
_worldNode.attachChild( core );
Mesh mesh;
for( PolygonSet ps : _countries )
{
Poly2Tri.triangulate( ps );
float value = 1-0.9f*(float)Math.random();
for( Polygon p : ps.getPolygons() )
{
mesh = new Mesh();
mesh.setDefaultColor( new ColorRGBA( value, value, value, 1.0f ) );
_worldNode.attachChild( mesh );
ArdorMeshMapper.updateTriangleMesh( mesh, p, _wgs84 );
}
}
}