当前位置: 首页>>代码示例>>Java>>正文


Java EdgeShape类代码示例

本文整理汇总了Java中org.jbox2d.collision.shapes.EdgeShape的典型用法代码示例。如果您正苦于以下问题:Java EdgeShape类的具体用法?Java EdgeShape怎么用?Java EdgeShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EdgeShape类属于org.jbox2d.collision.shapes包,在下文中一共展示了EdgeShape类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);


	eshape = new EdgeShape();
	eshape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
	shape = new PolygonShape();
	shape.setAsBox(0.6f, 0.125f);
	fixtureDef = new FixtureDef();
	fixtureDef.shape = shape;
	fixtureDef.density = 20.0f;
	fixtureDef.friction = 0.2f;
	bodyDef = new BodyDef();
	anchor = new Vec2(0, 0);
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:17,代码来源:ChainHighVP.java

示例2: createBorder

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
private void createBorder(boolean top,boolean left, boolean bottom, boolean right) {
	

	BodyDef bd = new BodyDef();
	Body border = world.createBody(bd);
	EdgeShape es = new EdgeShape();
	if (left) {
		es.set(new Vec2(0, 0), new Vec2(0, screenHeight / RATE));
		border.createFixture(es, 0.0f);
	}
	if (bottom) {
		es.set(new Vec2(screenWidth / RATE, 0), new Vec2(screenWidth / RATE,
				screenHeight / RATE));
		border.createFixture(es, 0.0f);
	}
	if (right) {
		es.set(new Vec2(0, screenHeight / RATE), new Vec2(screenWidth / RATE,
				screenHeight / RATE));
		border.createFixture(es, 0.0f);
	}
	if (top) {
		es.set(new Vec2(0, 0), new Vec2(screenWidth / RATE, 0));
		border.createFixture(es, 0.0f);
	}
}
 
开发者ID:Jvaeyhcd,项目名称:Cut-Polygon,代码行数:26,代码来源:Stage4View.java

示例3: createBorder

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
private void createBorder(boolean top,boolean left, boolean bottom, boolean right) {

		BodyDef bd = new BodyDef();
		Body border = world.createBody(bd);
		EdgeShape es = new EdgeShape();
		if (left) {
			es.set(new Vec2(0, 0), new Vec2(0, screenHeight / RATE));
			border.createFixture(es, 0.0f);
		}
		if (bottom) {
			es.set(new Vec2(screenWidth / RATE, 0), new Vec2(screenWidth / RATE,
					screenHeight / RATE));
			border.createFixture(es, 0.0f);
		}
		if (right) {
			es.set(new Vec2(0, screenHeight / RATE), new Vec2(screenWidth / RATE,
					screenHeight / RATE));
			border.createFixture(es, 0.0f);
		}
		if (top) {
			es.set(new Vec2(0, 0), new Vec2(screenWidth / RATE, 0));
			border.createFixture(es, 0.0f);
		}
	}
 
开发者ID:Jvaeyhcd,项目名称:Cut-Polygon,代码行数:25,代码来源:Stage1View.java

示例4: setupBox2d

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
protected void setupBox2d(){
	float startbox2Dx = (float) (start.x/Simulation.meterToPixel);
	float startbox2Dy = (float) (start.y/Simulation.meterToPixel);
	float endbox2Dx = (float) (end.x/Simulation.meterToPixel);
	float endbox2Dy = (float) (end.y/Simulation.meterToPixel);
			
	Vec2 point1 = new Vec2(startbox2Dx,startbox2Dy);
	Vec2 point2 = new Vec2(endbox2Dx,endbox2Dy);

	EdgeShape wall = new EdgeShape();
	wall.set(point1, point2);
	
    BodyDef bd = new BodyDef();
    bd.position = new Vec2();
    bd.type = BodyType.STATIC;
    
	 FixtureDef fd = new FixtureDef();
	 fd.shape = wall;
	 fd.density = 1.0f;
	 fd.filter.categoryBits = (letsThrough == -1 ? Collision.TYPE_WALL : letsThrough);
	 fd.userData = this;
	 body = world.createBody(bd);
	 body.createFixture(fd);
}
 
开发者ID:RuthRainbow,项目名称:anemone,代码行数:25,代码来源:Wall.java

示例5: buildShape

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
@Override
protected void buildShape() 
{        
    if (m_Data == null)
        return;
    
    List<Float> lineVisualizerVertexes = null;
    
    if (getDrawDebugLines() && m_LineVisualizer == null)
    {
        m_LineVisualizer = (LineVisualizer)getGameObject().get().addComponent(LineVisualizer.class);
        m_LineVisualizer.setDrawPrimitiveMode(LinePrimitive.Lines);
        lineVisualizerVertexes = new ArrayList<>();
        
    }
        
    List<FixtureDef> fixtureDefinitions = new ArrayList<>();
    
    for(int y=0;y<m_DataHeight;y++)
        for(int x=0;x<m_DataWidth;x++)
        {
            int dataIndex = (y*m_DataWidth)+x;
            
            GridColliderDefinition currentColDef = m_GridColliderDefinitions[m_Data[dataIndex]];
            
            for(int i=0;i<currentColDef.edgeDefinitions.length;i++)
            {
                EdgeDefinition currentEdgeDef = currentColDef.edgeDefinitions[i];
                
                FixtureDef currentFixtureDef = new FixtureDef();
                currentFixtureDef.shape      = new EdgeShape();
                
                currentFixtureDef.setDensity    (currentEdgeDef.density);
                currentFixtureDef.setFriction   (currentEdgeDef.friction);
                currentFixtureDef.setRestitution(currentEdgeDef.restitution);
                currentFixtureDef.setSensor(ColliderType.Collidable.toB2TriggerBool());
                
                buildAFixture(x,y,m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes,null,currentFixtureDef);
                fixtureDefinitions.add(currentFixtureDef);
                
                if (getDrawDebugLines())
                    for(int j=0;j<m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes.length;j++)
                    {
                        lineVisualizerVertexes.add(m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes[j].x+x-0.3f);
                        lineVisualizerVertexes.add(0.1f);
                        lineVisualizerVertexes.add(m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes[j].y+y-m_DataHeight+0.5f);
                        
                    }
                            
            }
            
        }
    
    //Convert to array
    m_FixtureDefinitions = fixtureDefinitions.toArray(new FixtureDef[fixtureDefinitions.size()]);
    
    //update linevisualizer//lineVisualizerVertexes.toArray(new float[lineVisualizerVertexes.size()]
    if (getDrawDebugLines())
    {
        float[] visdata = new float[lineVisualizerVertexes.size()];
    
        for(int i=0;i<lineVisualizerVertexes.size();i++)
            visdata[i] = lineVisualizerVertexes.get(i);

        m_LineVisualizer.setVertexData(visdata);
    
    }
               
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:70,代码来源:GridCollider.java

示例6: buildAFixture

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
private void buildAFixture(final int aTileX, final int aTileY, Vector2[] m_Vertices, LineVisualizer aLineVisualizer, FixtureDef m_FixtureDefinition)
{
    Vec2[] b2verts;
    EdgeShape currentShape = (EdgeShape)m_FixtureDefinition.shape;//PolygonShape m_Shape = (PolygonShape)m_FixtureDefinition.shape;
            
    Vector3 scale = getGameObject().get().getTransform().get().getScale();
    
    //some kind of sanity check?
    if (m_Vertices == null || m_Vertices.length == 0)
    {
        if (aLineVisualizer!=null)
            getGameObject().get().removeComponent(aLineVisualizer);
        
        return;
    
    }
    else
    {
        b2verts = new Vec2[m_Vertices.length];
        
        for(int i=0,s=m_Vertices.length;i<s;i++)
            b2verts[i] = new Vec2((m_Vertices[i].x+m_Offset.x-0.35f+aTileX)*scale.x,(m_Vertices[i].y+m_Offset.y-0.5f+(aTileY-m_DataHeight+1))*scale.z);
        
    }
    
    //HERE
    //create top l
    currentShape.set(b2verts[0],b2verts[1]);//m_Shape.set(b2verts, b2verts.length);
            
    //m_Shape.m_centroid.set(b_Vec2Buffer.set((m_Offset.x),(m_Offset.y)));

    //Generate the line mesh
    float[] visualVerts = new float[(b2verts.length*3)+3];
    for(int i=0,s=b2verts.length,j=0;i<s;++i,j=i*3)
    {
        visualVerts[j+0] = b2verts[i].x/scale.x; 
        visualVerts[j+1] = 0.0f; 
        visualVerts[j+2] = b2verts[i].y/scale.z;
        
    }
    //The first vert has to be repeated due to visualizer using GL_LINE_STRIP not "_LOOP
    visualVerts[visualVerts.length-3] = b2verts[0].x/scale.x; 
    visualVerts[visualVerts.length-2] = 0.0f; 
    visualVerts[visualVerts.length-1] = b2verts[0].y/scale.z;
            
    if (aLineVisualizer != null)
    {
        aLineVisualizer.setVertexData(visualVerts);

    }
        
    m_FixtureDefinition.density = 1;
    
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:55,代码来源:GridCollider.java

示例7: collideEdgeAndPolygon

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
public void collideEdgeAndPolygon(Manifold manifold, final EdgeShape edgeA, final Transform xfA,
    final PolygonShape polygonB, final Transform xfB) {
  collider.collide(manifold, edgeA, xfA, polygonB, xfB);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:5,代码来源:Collision.java

示例8: set

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
/**
 * Initialize the proxy using the given shape. The shape must remain in scope while the proxy is
 * in use.
 */
public final void set(final Shape shape, int index) {
  switch (shape.getType()) {
    case CIRCLE:
      final CircleShape circle = (CircleShape) shape;
      m_vertices[0].set(circle.m_p);
      m_count = 1;
      m_radius = circle.m_radius;

      break;
    case POLYGON:
      final PolygonShape poly = (PolygonShape) shape;
      m_count = poly.m_count;
      m_radius = poly.m_radius;
      for (int i = 0; i < m_count; i++) {
        m_vertices[i].set(poly.m_vertices[i]);
      }
      break;
    case CHAIN:
      final ChainShape chain = (ChainShape) shape;
      assert (0 <= index && index < chain.m_count);

      m_buffer[0] = chain.m_vertices[index];
      if (index + 1 < chain.m_count) {
        m_buffer[1] = chain.m_vertices[index + 1];
      } else {
        m_buffer[1] = chain.m_vertices[0];
      }

      m_vertices[0].set(m_buffer[0]);
      m_vertices[1].set(m_buffer[1]);
      m_count = 2;
      m_radius = chain.m_radius;
      break;
    case EDGE:
      EdgeShape edge = (EdgeShape) shape;
      m_vertices[0].set(edge.m_vertex1);
      m_vertices[1].set(edge.m_vertex2);
      m_count = 2;
      m_radius = edge.m_radius;
      break;
    default:
      assert (false);
  }
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:49,代码来源:Distance.java

示例9: evaluate

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collideEdgeAndPolygon(manifold, (EdgeShape) m_fixtureA.getShape(), xfA,
      (PolygonShape) m_fixtureB.getShape(), xfB);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:6,代码来源:EdgeAndPolygonContact.java

示例10: evaluate

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collideEdgeAndCircle(manifold, (EdgeShape) m_fixtureA.getShape(), xfA,
      (CircleShape) m_fixtureB.getShape(), xfB);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:6,代码来源:EdgeAndCircleContact.java

示例11: deserializeShape

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
public Shape deserializeShape(PbShape argShape) {
  PbShape s = argShape;

  Shape shape = null;
  switch (s.getType()) {
    case CIRCLE:
      CircleShape c = new CircleShape();
      c.m_p.set(pbToVec(s.getCenter()));
      shape = c;
      break;
    case POLYGON:
      PolygonShape p = new PolygonShape();
      p.m_centroid.set(pbToVec(s.getCentroid()));
      p.m_count = s.getPointsCount();
      for (int i = 0; i < p.m_count; i++) {
        p.m_vertices[i].set(pbToVec(s.getPoints(i)));
        p.m_normals[i].set(pbToVec(s.getNormals(i)));
      }
      shape = p;
      break;
    case EDGE:
      EdgeShape edge = new EdgeShape();
      edge.m_vertex0.set(pbToVec(s.getV0()));
      edge.m_vertex1.set(pbToVec(s.getV1()));
      edge.m_vertex2.set(pbToVec(s.getV2()));
      edge.m_vertex3.set(pbToVec(s.getV3()));
      edge.m_hasVertex0 = s.getHas0();
      edge.m_hasVertex3 = s.getHas3();
      shape = edge;
      break;
    case CHAIN: {
      ChainShape chain = new ChainShape();
      chain.m_count = s.getPointsCount();
      chain.m_vertices = new Vec2[chain.m_count];
      for (int i = 0; i < chain.m_count; i++) {
        chain.m_vertices[i] = new Vec2(pbToVec(s.getPoints(i)));
      }
      chain.m_hasPrevVertex = s.getHas0();
      chain.m_hasNextVertex = s.getHas3();
      chain.m_prevVertex.set(pbToVec(s.getPrev()));
      chain.m_nextVertex.set(pbToVec(s.getNext()));
      shape = chain;
      break;
    }
    default: {
      UnsupportedObjectException e =
          new UnsupportedObjectException("Unknown shape type: " + s.getType(), Type.SHAPE);
      if (ulistener == null || ulistener.isUnsupported(e)) {
        throw e;
      }
      return null;
    }
  }
  shape.m_radius = s.getRadius();

  if (listener != null && s.hasTag()) {
    listener.processShape(shape, s.getTag());
  }
  return shape;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:61,代码来源:PbDeserializer.java

示例12: serializeShape

import org.jbox2d.collision.shapes.EdgeShape; //导入依赖的package包/类
public PbShape.Builder serializeShape(Shape argShape) {
  final PbShape.Builder builder = PbShape.newBuilder();
  if (signer != null) {
    Long tag = signer.getTag(argShape);
    if (tag != null) {
      builder.setTag(tag);
    }
  }
  builder.setRadius(argShape.m_radius);

  switch (argShape.m_type) {
    case CIRCLE:
      CircleShape c = (CircleShape) argShape;
      builder.setType(PbShapeType.CIRCLE);
      builder.setCenter(vecToPb(c.m_p));
      break;
    case POLYGON:
      PolygonShape p = (PolygonShape) argShape;
      builder.setType(PbShapeType.POLYGON);
      builder.setCentroid(vecToPb(p.m_centroid));
      for (int i = 0; i < p.m_count; i++) {
        builder.addPoints(vecToPb(p.m_vertices[i]));
        builder.addNormals(vecToPb(p.m_normals[i]));
      }
      break;
    case EDGE:
      EdgeShape e = (EdgeShape) argShape;
      builder.setType(PbShapeType.EDGE);
      builder.setV0(vecToPb(e.m_vertex0));
      builder.setV1(vecToPb(e.m_vertex1));
      builder.setV2(vecToPb(e.m_vertex2));
      builder.setV3(vecToPb(e.m_vertex3));
      builder.setHas0(e.m_hasVertex0);
      builder.setHas3(e.m_hasVertex3);
      break;
    case CHAIN:
      ChainShape h = (ChainShape) argShape;
      builder.setType(PbShapeType.CHAIN);
      for (int i = 0; i < h.m_count; i++) {
        builder.addPoints(vecToPb(h.m_vertices[i]));
      }
      builder.setPrev(vecToPb(h.m_prevVertex));
      builder.setNext(vecToPb(h.m_nextVertex));
      builder.setHas0(h.m_hasPrevVertex);
      builder.setHas3(h.m_hasNextVertex);
      break;
    default:
      UnsupportedObjectException ex = new UnsupportedObjectException(
          "Currently only encodes circle and polygon shapes", Type.SHAPE);
      if (listener == null || listener.isUnsupported(ex)) {
        throw ex;
      }
      return null;
  }

  return builder;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:58,代码来源:PbSerializer.java


注:本文中的org.jbox2d.collision.shapes.EdgeShape类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。