本文整理汇总了Java中org.jbox2d.collision.shapes.ShapeType类的典型用法代码示例。如果您正苦于以下问题:Java ShapeType类的具体用法?Java ShapeType怎么用?Java ShapeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShapeType类属于org.jbox2d.collision.shapes包,在下文中一共展示了ShapeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addType
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private void addType(IDynamicStack<Contact> creator, ShapeType type1, ShapeType type2) {
ContactRegister register = new ContactRegister();
register.creator = creator;
register.primary = true;
contactStacks[type1.ordinal()][type2.ordinal()] = register;
if (type1 != type2) {
ContactRegister register2 = new ContactRegister();
register2.creator = creator;
register2.primary = false;
contactStacks[type2.ordinal()][type1.ordinal()] = register2;
}
}
示例2: initializeRegisters
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private void initializeRegisters() {
addType(pool.getCircleContactStack(), ShapeType.CIRCLE, ShapeType.CIRCLE);
addType(pool.getPolyCircleContactStack(), ShapeType.POLYGON, ShapeType.CIRCLE);
addType(pool.getPolyContactStack(), ShapeType.POLYGON, ShapeType.POLYGON);
addType(pool.getEdgeCircleContactStack(), ShapeType.EDGE, ShapeType.CIRCLE);
addType(pool.getEdgePolyContactStack(), ShapeType.EDGE, ShapeType.POLYGON);
addType(pool.getChainCircleContactStack(), ShapeType.CHAIN, ShapeType.CIRCLE);
addType(pool.getChainPolyContactStack(), ShapeType.CHAIN, ShapeType.POLYGON);
}
示例3: pushContact
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
public void pushContact(Contact contact) {
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
if (contact.m_manifold.pointCount > 0 && !fixtureA.isSensor() && !fixtureB.isSensor()) {
fixtureA.getBody().setAwake(true);
fixtureB.getBody().setAwake(true);
}
ShapeType type1 = fixtureA.getType();
ShapeType type2 = fixtureB.getType();
IDynamicStack<Contact> creator = contactStacks[type1.ordinal()][type2.ordinal()].creator;
creator.push(contact);
}
示例4: render
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private static void render() {
renderingContext2D.clear();
renderingContext2D.save();
renderingContext2D.translate(0, 600);
renderingContext2D.scale(1, -1);
renderingContext2D.scale(100, 100);
renderingContext2D.lineWidth(0.01f);
for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
Vec2 center = body.getPosition();
renderingContext2D.save();
renderingContext2D.translate(center.x, center.y);
renderingContext2D.rotate(body.getAngle());
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape();
if (shape.getType() == ShapeType.CIRCLE) {
CircleShape circle = (CircleShape) shape;
renderingContext2D.beginPath();
renderingContext2D.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
renderingContext2D.closePath();
renderingContext2D.stroke();
} else if (shape.getType() == ShapeType.POLYGON) {
PolygonShape poly = (PolygonShape) shape;
Vec2[] vertices = poly.getVertices();
renderingContext2D.beginPath();
renderingContext2D.moveTo(vertices[0].x, vertices[0].y);
for (int i = 1; i < poly.getVertexCount(); ++i) {
renderingContext2D.lineTo(vertices[i].x, vertices[i].y);
}
renderingContext2D.closePath();
renderingContext2D.stroke();
}
}
renderingContext2D.restore();
}
renderingContext2D.restore();
}
示例5: setShape
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
/**
* Any Shape given as a brush. Use (0,0) as center.
* only ShapeType.CIRCLE and ShapeType.POLYGON can be used
*
*/
public void setShape(Shape shape){
boolean is_circle = ShapeType.CIRCLE == shape.getType();
boolean is_polygon = ShapeType.POLYGON == shape.getType();
if(is_circle || is_polygon){
this.shape = shape;
}
}
示例6: setShape
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
/**
* Any Shape given as a brush. Use (0,0) as center.
* only ShapeType.CIRCLE and ShapeType.POLYGON can be used
*
*/
public void setShape(Shape shape){
boolean is_circle = ShapeType.CIRCLE == shape.getType();
boolean is_polygon = ShapeType.POLYGON == shape.getType();
if(is_circle || is_polygon){
group_def.shape = shape;
}
}
示例7: addType
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private void addType(IDynamicStack<Contact> creator, ShapeType type1,
ShapeType type2) {
ContactRegister register = new ContactRegister();
register.creator = creator;
register.primary = true;
contactStacks[type1.intValue][type2.intValue] = register;
if (type1 != type2) {
ContactRegister register2 = new ContactRegister();
register2.creator = creator;
register2.primary = false;
contactStacks[type2.intValue][type1.intValue] = register2;
}
}
示例8: pushContact
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
public void pushContact(Contact contact) {
if (contact.m_manifold.pointCount > 0) {
contact.getFixtureA().getBody().setAwake(true);
contact.getFixtureB().getBody().setAwake(true);
}
ShapeType type1 = contact.getFixtureA().getType();
ShapeType type2 = contact.getFixtureB().getType();
IDynamicStack<Contact> creator = contactStacks[type1.intValue][type2.intValue].creator;
creator.push(contact);
}
示例9: pushContact
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
public void pushContact(Contact contact) {
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
if (contact.m_manifold.pointCount > 0 && !fixtureA.isSensor() && !fixtureB.isSensor()) {
fixtureA.getBody().setAwake(true);
fixtureB.getBody().setAwake(true);
}
ShapeType type1 = fixtureA.getType();
ShapeType type2 = fixtureB.getType();
IDynamicStack<Contact> creator = contactStacks[type1.ordinal()][type2.ordinal()].creator;
creator.push(contact);
}
示例10: addType
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private void addType(MutableStack<Contact> creator, ShapeType type1,
ShapeType type2) {
ContactRegister register = new ContactRegister();
register.creator = creator;
register.primary = true;
contactStacks[type1.intValue][type2.intValue] = register;
if (type1 != type2) {
ContactRegister register2 = new ContactRegister();
register2.creator = creator;
register2.primary = false;
contactStacks[type2.intValue][type1.intValue] = register2;
}
}
示例11: pushContact
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
public void pushContact(Contact contact) {
if (contact.m_manifold.pointCount > 0) {
contact.getFixtureA().getBody().setAwake(true);
contact.getFixtureB().getBody().setAwake(true);
}
ShapeType type1 = contact.getFixtureA().getType();
ShapeType type2 = contact.getFixtureB().getType();
MutableStack<Contact> creator = contactStacks[type1.intValue][type2.intValue].creator;
creator.push(contact);
}
示例12: getType
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
/** Get the type of the child shape. You can use this to down cast to the concrete shape.
* @return the shape type. */
public Type getType () {
ShapeType type = fixture.getType();
if (type == ShapeType.CIRCLE) return Type.Circle;
if (type == ShapeType.EDGE) return Type.Edge;
if (type == ShapeType.POLYGON) return Type.Polygon;
if (type == ShapeType.CHAIN) return Type.Chain;
return Type.Circle;
}
示例13: getShape
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
/** Returns the shape of this fixture */
public Shape getShape () {
if (shape == null) {
org.jbox2d.collision.shapes.Shape shape2 = fixture.getShape();
ShapeType type = shape2.getType();
if (type == ShapeType.CHAIN) shape = new ChainShape((org.jbox2d.collision.shapes.ChainShape)shape2);
if (type == ShapeType.CIRCLE) shape = new CircleShape((org.jbox2d.collision.shapes.CircleShape)shape2);
if (type == ShapeType.EDGE) shape = new EdgeShape((org.jbox2d.collision.shapes.EdgeShape)shape2);
if (type == ShapeType.POLYGON) shape = new PolygonShape((org.jbox2d.collision.shapes.PolygonShape)shape2);
}
return shape;
}
示例14: render
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private static void render() {
WasmCanvas.save();
setupCanvas();
for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
Vec2 center = body.getPosition();
WasmCanvas.save();
WasmCanvas.translate(center.x, center.y);
WasmCanvas.rotate(body.getAngle());
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape();
if (shape.getType() == ShapeType.CIRCLE) {
CircleShape circle = (CircleShape) shape;
WasmCanvas.beginPath();
WasmCanvas.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
WasmCanvas.closePath();
WasmCanvas.stroke();
} else if (shape.getType() == ShapeType.POLYGON) {
PolygonShape poly = (PolygonShape) shape;
Vec2[] vertices = poly.getVertices();
WasmCanvas.beginPath();
WasmCanvas.moveTo(vertices[0].x, vertices[0].y);
for (int i = 1; i < poly.getVertexCount(); ++i) {
WasmCanvas.lineTo(vertices[i].x, vertices[i].y);
}
WasmCanvas.closePath();
WasmCanvas.stroke();
}
}
WasmCanvas.restore();
}
WasmCanvas.restore();
}
示例15: render
import org.jbox2d.collision.shapes.ShapeType; //导入依赖的package包/类
private static void render() {
CanvasRenderingContext2D context = (CanvasRenderingContext2D) canvas.getContext("2d");
context.setFillStyle("white");
context.setStrokeStyle("grey");
context.fillRect(0, 0, 600, 600);
context.save();
context.translate(0, 600);
context.scale(1, -1);
context.scale(100, 100);
context.setLineWidth(0.01);
for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
Vec2 center = body.getPosition();
context.save();
context.translate(center.x, center.y);
context.rotate(body.getAngle());
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape();
if (shape.getType() == ShapeType.CIRCLE) {
CircleShape circle = (CircleShape) shape;
context.beginPath();
context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
context.closePath();
context.stroke();
} else if (shape.getType() == ShapeType.POLYGON) {
PolygonShape poly = (PolygonShape) shape;
Vec2[] vertices = poly.getVertices();
context.beginPath();
context.moveTo(vertices[0].x, vertices[0].y);
for (int i = 1; i < poly.getVertexCount(); ++i) {
context.lineTo(vertices[i].x, vertices[i].y);
}
context.closePath();
context.stroke();
}
}
context.restore();
}
context.restore();
}