• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChildCollisionShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: buildForImpl

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent,
                            @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) {

    if (object instanceof ChildCollisionShape) {
        build((ChildCollisionShape) object, container, changeConsumer);
    }

    if (!(object instanceof CollisionShape)) return;

    if (object instanceof BoxCollisionShape) {
        build((BoxCollisionShape) object, container, changeConsumer);
    } else if (object instanceof SphereCollisionShape) {
        build((SphereCollisionShape) object, container, changeConsumer);
    } else if (object instanceof CapsuleCollisionShape) {
        build((CapsuleCollisionShape) object, container, changeConsumer);
    } else if (object instanceof ConeCollisionShape) {
        build((ConeCollisionShape) object, container, changeConsumer);
    } else if (object instanceof CylinderCollisionShape) {
        build((CylinderCollisionShape) object, container, changeConsumer);
    }

    build((CollisionShape) object, container, changeConsumer);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:CollisionShapePropertyBuilder.java


示例2: build

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
@FXThread
private void build(@NotNull final ChildCollisionShape shape, @NotNull final VBox container,
                   @NotNull final ModelChangeConsumer changeConsumer) {

    final Vector3f location = shape.location;
    final Matrix3f rotation = shape.rotation;

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Vector3f> locationControl =
            new DefaultSinglePropertyControl<>(location, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);

    locationControl.setSyncHandler(collisionShape -> collisionShape.location);
    locationControl.setToStringFunction(Vector3f::toString);
    locationControl.setEditObject(shape);

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Matrix3f> rotationControl =
            new DefaultSinglePropertyControl<>(rotation, Messages.MODEL_PROPERTY_ROTATION, changeConsumer);

    rotationControl.setSyncHandler(collisionShape -> collisionShape.rotation);
    rotationControl.setToStringFunction(matrix3f -> new Quaternion().fromRotationMatrix(matrix3f).toString());
    rotationControl.setEditObject(shape);
    rotationControl.reload();

    FXUtils.addToPane(locationControl, container);
    FXUtils.addToPane(rotationControl, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:CollisionShapePropertyBuilder.java


示例3: create

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
private void create(Spatial s, VHACDParameters p, CompoundCollisionShape out) {
	if(s instanceof Geometry){
		Geometry geo=(Geometry)s;
		CompoundCollisionShape ccs=create(geo.getMesh(),p);
		for(ChildCollisionShape cc:ccs.getChildren()){
			CollisionShape ccc=cc.shape;
			ccc.setScale(geo.getLocalScale());
			out.addChildShape(ccc,new Vector3f());
		}
	}else if(s instanceof Node){
		Node n=(Node)s;
		Collection<Spatial> cs=n.getChildren();
		for(Spatial c:cs){
			create(c,p,out);
		}
	}
}
 
开发者ID:riccardobl,项目名称:jme3-bullet-vhacd,代码行数:18,代码来源:VHACDCollisionShapeFactory.java


示例4: createFor

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
@Override
@FXThread
public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) {

    if (element instanceof ChildCollisionShape) {
        return unsafeCast(new ChildCollisionShapeTreeNode((ChildCollisionShape) element, objectId));
    } else if (element instanceof CollisionShape) {
        if (element instanceof BoxCollisionShape) {
            return unsafeCast(new BoxCollisionShapeTreeNode((BoxCollisionShape) element, objectId));
        } else if (element instanceof CapsuleCollisionShape) {
            return unsafeCast(new CapsuleCollisionShapeTreeNode((CapsuleCollisionShape) element, objectId));
        } else if (element instanceof CompoundCollisionShape) {
            return unsafeCast(new ComputedCollisionShapeTreeNode((CompoundCollisionShape) element, objectId));
        } else if (element instanceof ConeCollisionShape) {
            return unsafeCast(new ConeCollisionShapeTreeNode((ConeCollisionShape) element, objectId));
        } else if (element instanceof CylinderCollisionShape) {
            return unsafeCast(new CylinderCollisionShapeTreeNode((CylinderCollisionShape) element, objectId));
        } else if (element instanceof GImpactCollisionShape) {
            return unsafeCast(new GImpactCollisionShapeTreeNode((GImpactCollisionShape) element, objectId));
        } else if (element instanceof HullCollisionShape) {
            return unsafeCast(new HullCollisionShapeTreeNode((HullCollisionShape) element, objectId));
        } else if (element instanceof MeshCollisionShape) {
            return unsafeCast(new MeshCollisionShapeTreeNode((MeshCollisionShape) element, objectId));
        } else if (element instanceof PlaneCollisionShape) {
            return unsafeCast(new PlaneCollisionShapeTreeNode((PlaneCollisionShape) element, objectId));
        } else if (element instanceof SphereCollisionShape) {
            return unsafeCast(new SphereCollisionShapeTreeNode((SphereCollisionShape) element, objectId));
        }
    }

    return null;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:CollisionTreeNodeFactory.java


示例5: getChildren

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final ChildCollisionShape element = getElement();
    final CollisionShape shape = element.shape;

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class, 1);
    result.add(FACTORY_REGISTRY.createFor(shape));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:ChildCollisionShapeTreeNode.java


示例6: getChildren

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final CompoundCollisionShape element = getElement();
    final List<ChildCollisionShape> children = element.getChildren();
    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
    children.forEach(childCollisionShape -> result.add(FACTORY_REGISTRY.createFor(childCollisionShape)));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:12,代码来源:ComputedCollisionShapeTreeNode.java


示例7: addChildShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
 * adds a child shape at the given local translation
 * @param shape the child shape to add
 * @param location the local location of the child shape
 */
public void addChildShape(CollisionShape shape, Vector3f location) {
    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(location, transA.origin);
    children.add(new ChildCollisionShape(location.clone(), new Matrix3f(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:CompoundCollisionShape.java


示例8: removeChildShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
 * removes a child shape
 * @param shape the child shape to remove
 */
public void removeChildShape(CollisionShape shape) {
    ((CompoundShape) cShape).removeChildShape(shape.getCShape());
    for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        if (childCollisionShape.shape == shape) {
            it.remove();
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:CompoundCollisionShape.java


示例9: read

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
    loadChildren();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:CompoundCollisionShape.java


示例10: shiftCompoundShapeContents

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
 * This method moves each child shape of a compound shape by the given vector
 * @param vector
 */
public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector) {
    for (Iterator<ChildCollisionShape> it = new LinkedList(compoundShape.getChildren()).iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        CollisionShape child = childCollisionShape.shape;
        Vector3f location = childCollisionShape.location;
        Matrix3f rotation = childCollisionShape.rotation;
        compoundShape.removeChildShape(child);
        compoundShape.addChildShape(child, location.add(vector), rotation);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:CollisionShapeFactory.java


示例11: addChildShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
     * adds a child shape at the given local translation
     * @param shape the child shape to add
     * @param location the local location of the child shape
     */
    public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
        if(shape instanceof CompoundCollisionShape){
            throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
        }
//        Transform transA = new Transform(Converter.convert(rotation));
//        Converter.convert(location, transA.origin);
//        Converter.convert(rotation, transA.basis);
        children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
        addChildShape(objectId, shape.getObjectId(), location, rotation);
//        ((CompoundShape) objectId).addChildShape(transA, shape.getObjectId());
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:CompoundCollisionShape.java


示例12: removeChildShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
     * removes a child shape
     * @param shape the child shape to remove
     */
    public void removeChildShape(CollisionShape shape) {
        removeChildShape(objectId, shape.getObjectId());
//        ((CompoundShape) objectId).removeChildShape(shape.getObjectId());
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            if (childCollisionShape.shape == shape) {
                it.remove();
            }
        }
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:15,代码来源:CompoundCollisionShape.java


示例13: read

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    setScale(scale);
    setMargin(margin);
    loadChildren();
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:9,代码来源:CompoundCollisionShape.java


示例14: getDebugShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
 * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
 * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 * @param collisionShape
 * @return
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();                
            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:46,代码来源:DebugShapeFactory.java


示例15: ChildCollisionShapeTreeNode

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public ChildCollisionShapeTreeNode(@NotNull final ChildCollisionShape element, final long objectId) {
    super(element, objectId);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:4,代码来源:ChildCollisionShapeTreeNode.java


示例16: getChildren

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public List<ChildCollisionShape> getChildren() {
    return children;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:CompoundCollisionShape.java


示例17: write

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public void write(JmeExporter ex) throws IOException {
    super.write(ex);
    OutputCapsule capsule = ex.getCapsule(this);
    capsule.writeSavableArrayList(children, "children", new ArrayList<ChildCollisionShape>());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:CompoundCollisionShape.java


示例18: loadChildren

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
private void loadChildren() {
    for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
        ChildCollisionShape child = it.next();
        addChildShapeDirect(child.shape, child.location, child.rotation);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:CompoundCollisionShape.java


示例19: getDebugShape

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
/**
 * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
 * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 * @param collisionShape
 * @return
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();

            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:47,代码来源:DebugShapeFactory.java


示例20: areColliding

import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; //导入依赖的package包/类
public static boolean areColliding(Asset asset1, Asset asset2, boolean debug){
		Spatial s1 = getSpatialFromAsset(asset1); 
		Spatial s2 = getSpatialFromAsset(asset2);

		PhysicsSpace space = new PhysicsSpace();
		
		RigidBodyControl ghost1 = new RigidBodyControl(getCollisionShape(asset1));
		s1.addControl(ghost1);
		space.add(ghost1);

		RigidBodyControl ghost2 = new RigidBodyControl(getCollisionShape(asset2));
		s2.addControl(ghost2);
//		ghost2.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02);
//		space.add(ghost2);

		space.update(1);
		
//		int numCollision = ghost1.getOverlappingCount();
//		boolean collision = numCollision > 0;
		Transform t = new Transform();
		t.setRotation(s2.getLocalRotation());
		t.setTranslation(s2.getLocalTranslation());
		boolean collision = false;
		for(ChildCollisionShape hull : getCollisionShape(asset2).getChildren())
			if(!space.sweepTest(hull.shape, Transform.IDENTITY, t).isEmpty()){
				collision = true;
				break;
			}
				
		
		space.remove(ghost1);
//		space.remove(ghost2);

//		if(!collision){
//			Spatial debugS2 = DebugShapeFactory.getDebugShape(ghost2.getCollisionShape());
//			debugS2.setLocalRotation(ghost2.getPhysicsRotation());
////			Spatial debugS2 = s2;
//			Material m = new Material(am, "Common/MatDefs/Misc/Unshaded.j3md");
//			m.getAdditionalRenderState().setWireframe(true);
//			m.setColor("Color", ColorRGBA.Red);
//			debugS2.setMaterial(m);
//			debugS2.setLocalTranslation(ghost2.getPhysicsLocation());
//			asset2.s = debugS2;
//			//EventManager.post(new GenericEvent(debugS2));
//		}
			
		if(!collision){// && debug){
			Material m = new Material(am, "Common/MatDefs/Misc/Unshaded.j3md");
			m.getAdditionalRenderState().setWireframe(true);
			m.setColor("Color", ColorRGBA.Red);
			Spatial debugS2 = DebugShapeFactory.getDebugShape(getCollisionShape(asset2));
			debugS2.setLocalTransform(t);
//			debugS2.setLocalRotation(ghost2.getPhysicsRotation());
//			debugS2.setLocalTranslation(ghost2.getPhysicsLocation());
			debugS2.setMaterial(m);

			Material m2 = new Material(am, "Common/MatDefs/Misc/Unshaded.j3md");
			m2.getAdditionalRenderState().setWireframe(true);
			m2.setColor("Color", ColorRGBA.Blue);
			Geometry linegeom = new Geometry();
			Line l = new Line(debugS2.getLocalTranslation().add(0,  0, 1), ghost1.getPhysicsLocation().add(0,  0, 1));
			linegeom.setMesh(l);
			linegeom.setMaterial(m2);
	
			asset2.s = debugS2;
			if(l.getStart().distance(l.getEnd())<2)
				asset2.links.add(linegeom);
//			EventManager.post(new GenericEvent(debugS2));
//			EventManager.post(new GenericEvent(linegeom));
			
			
		}

		return collision; 
	}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:76,代码来源:CollisionTester.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CollectionWrapper类代码示例发布时间:2022-05-22
下一篇:
Java ComponentVillageStartPiece类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap