Examples of PbShape


Examples of org.box2d.proto.Box2D.PbShape

    PbShape.Builder builder = serializeShape(argShape);
    if (builder == null) {
      return null;
    }
    // should we do lazy building?
    final PbShape shape = builder.build();
    return new SerializationResult() {
      @Override
      public void writeTo(OutputStream argOutputStream) throws IOException {
        shape.writeTo(argOutputStream);
      }

      @Override
      public Object getValue() {
        return shape;
View Full Code Here

Examples of org.box2d.proto.Box2D.PbShape

    return fixture;
  }

  @Override
  public Shape deserializeShape(InputStream argInput) throws IOException {
    PbShape s = PbShape.parseFrom(argInput);
    return deserializeShape(s);
  }
View Full Code Here

Examples of org.box2d.proto.Box2D.PbShape

    PbShape s = PbShape.parseFrom(argInput);
    return deserializeShape(s);
  }

  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;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.