本文整理汇总了Java中org.box2d.proto.Box2D.PbShapeType类的典型用法代码示例。如果您正苦于以下问题:Java PbShapeType类的具体用法?Java PbShapeType怎么用?Java PbShapeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PbShapeType类属于org.box2d.proto.Box2D包,在下文中一共展示了PbShapeType类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeShape
import org.box2d.proto.Box2D.PbShapeType; //导入依赖的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;
}