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


Java GhostControl类代码示例

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


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

示例1: setupJoint

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public void setupJoint() {
    Node holderNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.1f, .1f, .1f)), 0);
    holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, 0, 0f));
    rootNode.attachChild(holderNode);
    getPhysicsSpace().add(holderNode);

    Node hammerNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.3f, .3f, .3f)), 1);
    hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -1, 0f));
    rootNode.attachChild(hammerNode);
    getPhysicsSpace().add(hammerNode);

    //immovable
    collisionNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.3f, .3f, .3f)), 0);
    collisionNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1.8f, 0, 0f));
    rootNode.attachChild(collisionNode);
    getPhysicsSpace().add(collisionNode);

    //ghost node
    ghostControl = new GhostControl(new SphereCollisionShape(0.7f));

    hammerNode.addControl(ghostControl);
    getPhysicsSpace().add(ghostControl);

    joint = new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f, -1, 0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);
    getPhysicsSpace().add(joint);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:TestAttachGhostObject.java

示例2: createSheet

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
@Override
protected Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("GhostControl");
    set.setName(GhostControl.class.getName());
    GhostControl obj = geom;//getLookup().lookup(Spatial.class);
    if (obj == null) {
        return sheet;
    }

    set.put(makeProperty(obj, Vector3f.class, "getPhysicsLocation", "setPhysicsLocation", "Physics Location"));
    set.put(makeProperty(obj, Quaternion.class, "getPhysicsRotation", "setPhysicsRotation", "Physics Rotation"));
    
    set.put(makeProperty(obj, CollisionShape.class, "getCollisionShape", "setCollisionShape", "Collision Shape"));
    set.put(makeProperty(obj, int.class, "getCollisionGroup", "setCollisionGroup", "Collision Group"));
    set.put(makeProperty(obj, int.class, "getCollideWithGroups", "setCollideWithGroups", "Collide With Groups"));

    sheet.put(set);
    return sheet;

}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:23,代码来源:JmeGhostControl.java

示例3: setCollisionBox

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
/**
 * 设置一个BOX用于作为相机碰撞检测的物体。
 * @param box 
 */
public final void setCollisionBox(Box box) {
    // 移除旧的
    if (collisionChecker != null) {
        if (physicsSpace != null) {
            physicsSpace.remove(collisionChecker);
        }
        collisionChecker.removeFromParent();
    }
    
    // 重建新的碰撞检测
    collisionChecker = new Geometry("camCollisionChecker", box);
    collisionChecker.setMaterial(MaterialUtils.createWireFrame());
    collisionChecker.setCullHint(Spatial.CullHint.Always);
    
    // GhostControl
    // 给物理体设置一个不同的碰撞组,这会优化碰撞检测性能.
    GhostControl gc = new GhostControl(CollisionShapeFactory.createBoxShape(collisionChecker));
    collisionChecker.addControl(gc);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:24,代码来源:CollisionChaseCamera.java

示例4: physicsTick

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public void physicsTick(PhysicsSpace space, float tpf) {
    physicsClosestTets = null;
    angleNormals = 0f;
    float closestFraction = centerToBottomHeight * 10f;

    if (this.isActive()) {
        List<PhysicsRayTestResult> results = space.rayTest(this.getPhysicsLocation().add(Vector3f.UNIT_Y.mult(-0.8f * centerToBottomHeight)),
                this.getPhysicsLocation().add(Vector3f.UNIT_Y.mult(-1.3f * centerToBottomHeight)));
        for (PhysicsRayTestResult physicsRayTestResult : results) {

            if (physicsRayTestResult.getHitFraction() < closestFraction && !physicsRayTestResult.getCollisionObject().getUserObject().equals(spatial)
                    && physicsRayTestResult.getCollisionObject() instanceof GhostControl == false) {
                physicsClosestTets = physicsRayTestResult;
                closestFraction = physicsRayTestResult.getHitFraction();
            }
        }
    }
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:19,代码来源:SimpleCharacterControl.java

示例5: AlienShip

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public AlienShip(String name, Material mat, Node target, AssetManager assetManager) {
    s =  assetManager.loadModel("Models/Mothership/drone.j3o");
    s.setLocalTranslation(0f, -1f, 0f);
    s.setLocalScale(0.3f);
    s.setName(name);
    
    // Store handle to the target to pass to alien
    this.target = target;
    
    // Set up the minion queue
    alien = new HashSet<Alien>();
    gball = new HashSet<Gumball>();
    
    // Creates a rough approximation of the shape and makes it float at Y = 35 
    control = new DroneControl(new SphereCollisionShape(innerRadius), 3f, target, 15f);
    control.setLinearDamping(0.7f);
    control.setAngularDamping(1.0f);
    control.setFriction(0f);
    
    // Set up the ghost control as a proximity detector
    gControl = new GhostControl(new SphereCollisionShape(outterRadius));
    
    s.addControl(control);
    s.addControl(gControl);
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:26,代码来源:AlienShip.java

示例6: setDimension

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
/**
 * @param dimension the dimension to set
 */
public void setDimension(Vector3f dimension) {
    Box b = new Box(dimension.mult(-0.5f), dimension.mult(0.5f));
    Geometry geom = new Geometry("Box", b);
    geom.setMaterial(this.getOriginalMaterial());
    detachAllChildren();
    attachChild(geom);
    this.dimension = dimension;

    GhostControl gc = this.getControl(GhostControl.class);
    if (gc != null) {
        gc.setEnabled(false);
        removeControl(gc);
    }
    createControl();
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:19,代码来源:TriggerBox.java

示例7: MegaDrone

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public MegaDrone(String name, Material mat, Node target, AssetManager assetManager) {
    s =  assetManager.loadModel("Models/Mothership/Mothership.j3o");
    s.setLocalTranslation(0f, -1f, 0f);
    s.setLocalScale(6f);
    s.setName(name);
    
    // Store handle to the target to pass to minions
    this.target = target;
    
    // Set up the minion queue
    minions = new HashSet<MicroDrone>();
    
    // Creates a rough approximation of the shape and makes it float at Y = 35 
    control = new DroneControl(new SphereCollisionShape(innerRadius), 3f, target, 35f);
    control.setLinearDamping(0.7f);
    control.setAngularDamping(1.0f);
    control.setFriction(0f);
    
    // Set up the ghost control as a proximity detector
    gControl = new GhostControl(new SphereCollisionShape(outterRadius));
    
    s.addControl(control);
    s.addControl(gControl);
}
 
开发者ID:melombuki,项目名称:JMonkeyGame,代码行数:25,代码来源:MegaDrone.java

示例8: setSpatial

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
@Override
public void setSpatial(Spatial spatial) {
    super.setSpatial(spatial);
    CCharacterPhysics physics =
            spatial.getControl(CCharacterPhysics.class);
    ghost = new GhostControl(physics.getCapsuleShape());
    ghost.setCollisionGroup(CollisionGroups.NONE);
    ghost.setCollideWithGroups(CollisionGroups.CHARACTERS
            | CollisionGroups.WALLS | CollisionGroups.SPIRIT_STONE);

    ghostNode = new Node("Ghost Node");
    ((Node) spatial).attachChild(ghostNode);
    ghostNode.addControl(ghost);
    ghost.setUserObject(spatial);

    physics.getPhysicsSpace().add(ghost);
    physics.getPhysicsSpace().addCollisionListener(this);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:19,代码来源:ACharge.java

示例9: checkExplode

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
private void checkExplode() {
    if (!explodes.isEmpty()) {
        for (int i = 0; i < explodes.size(); i++) {
            if (explodes.get(i).isExplode()) {
                bullet.getPhysicsSpace().remove(explodes.get(i).getControl(GhostControl.class));
                bullet.getPhysicsSpace().remove(explodes.get(i));
                explodes.get(i).getDirt().killAllParticles();
                explodes.get(i).getDirt().removeFromParent();
                explodes.get(i).detachAllChildren();
                explodes.get(i).removeFromParent();
                explodes.remove(explodes.get(i));
                System.out.println("sa " + sa.isIsShield());
                account.setShield(sa.isIsShield());
                System.out.println("account " + account.isShield());
            }
        }
    }
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:19,代码来源:Scene.java

示例10: Sa

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public Sa(Spatial s) {
    super(s);
    setName("Sa");
    CapsuleCollisionShape capsule = new CapsuleCollisionShape(PLACE_HOLDER, PLACE_HOLDER * .8f);
    saChar = new SaGhost(capsule, this);

    AnimControl animationControl = s.getControl(AnimControl.class);
    animationControl.addListener(this);

    GhostControl ghost = new GhostControl(capsule);

    animationChannel = animationControl.createChannel();
    addControl(saChar);
    addControl(ghost);
    speed = (float) (BASIC_V * 0.6);
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:17,代码来源:Sa.java

示例11: Explosion

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
public Explosion(Vector3f position, AssetManager a, Node rootNode) {
    setName("Explode");
    this.position = position;
    this.assetManager = a;
    this.rootNode = rootNode;

    BoxCollisionShape box = new BoxCollisionShape(new Vector3f(PLACE_HOLDER-1, PLACE_HOLDER, PLACE_HOLDER-1));
    
    ghost = new GhostControl(box);
    addControl(ghost);
    
    ghost.setPhysicsLocation(position);

    explode();
    
    shieldBroke = new AudioNode(assetManager, "Sounds/shield broke.wav",false);
    shieldBroke.setLooping(false);
    shieldBroke.setPositional(false);
    shieldBroke.setVolume(.9f);

}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:22,代码来源:Explosion.java

示例12: attachPhysicsSelection

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
protected void attachPhysicsSelection(Spatial geom) {
    PhysicsCollisionObject control = geom.getControl(RigidBodyControl.class);
    if (control == null) {
        control = geom.getControl(VehicleControl.class);
    }
    if (control == null) {
        control = geom.getControl(GhostControl.class);
    }
    if (control == null) {
        control = geom.getControl(CharacterControl.class);
    }
    if (control == null) {
        return;
    }
    Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape());
    if (selectionGeometry != null) {
        selectionGeometry.setMaterial(blueMat);
        selectionGeometry.setLocalTransform(geom.getWorldTransform());
        toolsNode.attachChild(selectionGeometry);
        selectionShape = selectionGeometry;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:SceneToolController.java

示例13: makePhysics

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
@Override
protected void makePhysics(PhysicsSpace physicsSpace) {
	// intialise the real physics control
	CollisionShape cs = new CapsuleCollisionShape(1.5f,5f,1);
	physics = new ForceCharacterControl(cs,4);
	//physics.setGravity(-200f);
	physics.setGravity(200f);
	physics.setFallSpeed(200f);
	physics.setJumpSpeed(50f);
	geometry.addControl(physics);

	// create the ghost control
	ghost = new GhostControl(cs);
	geometry.addControl(ghost);

	// put the ghost physics in a different group actor don't collide with themselves
	geometry.getControl(GhostControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_07);
	geometry.getControl(GhostControl.class).removeCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
	geometry.getControl(GhostControl.class).addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_07);

	physicsSpace.add(ghost);
	physicsSpace.add(physics);

	physicsSpace.addTickListener(physicsTickListener);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:26,代码来源:Actor.java

示例14: createPlayer

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
/**
 * Create a new player.
 * @param parentNode Parent of player. Should be root node.
 * @param playerIdx Order of created player starting at 0.
 * @return Spatial of new player.
 */
private Spatial createPlayer(Node parentNode, int playerIdx) {
  // Currently a simple box is used for the player.
  Box box = new Box(1, 1, 1);
  Geometry player = new Geometry("PLAYER" + playerIdx, box);

  Material mat = new Material(application.getAssetManager(),
      "Common/MatDefs/Misc/Unshaded.j3md");
  mat.setColor("Color", ColorRGBA.Blue);
  player.setMaterial(mat);

  // Move player in front of first course point.
  Spatial[] coursePoints = coursePath.getCoursePoints();
  if (coursePoints.length > 0) {
    Spatial startPoint = coursePoints[0];
    Vector3f forward = startPoint.getWorldRotation().mult(Vector3f.UNIT_Z);
    player.move(forward.mult(PLAYER_START_DISTANCE));
  }

  // Attribute that this is a player.
  player.setUserData(IS_PLAYER_ATTR, true);
  // Add physics to player
  CollisionShape shape = CollisionShapeFactory.createBoxShape(player);
  GhostControl playerPhysics = new GhostControl(shape);
  player.addControl(playerPhysics);
  bullet.getPhysicsSpace().add(playerPhysics);

  // Attach to root node and course path.
  parentNode.attachChild(player);
  coursePath.addPlayer(player);
  return player;
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:38,代码来源:PlayerManager.java

示例15: CoursePath

import com.jme3.bullet.control.GhostControl; //导入依赖的package包/类
/**
 * Course path constructor. Locate the course path and organise the points
 * into an ordered list. Rotate these points to create a smooth path.
 * @param scene Root node of scene.
 */
public CoursePath(Node scene, BulletAppState bullet) {
  // Locate each course point and create an array of those points ordered by
  // the order data in the user data of the spatials.
  Spatial coursePath = scene.getChild(COURSE_PATH_NODE_NAME);
  final TreeMap<Integer, Spatial> points = new TreeMap<Integer, Spatial>();
  coursePath.breadthFirstTraversal(new SceneGraphVisitor() {
    public void visit(Spatial spatial) {
      Integer order = spatial.getUserData(COURSE_ORDER_ATTR);
      if (order != null) {
        points.put(order, spatial);
      }
    }
  });
  coursePoints = points.values().toArray(new Spatial[0]);

  // To create a smooth rotation along the course, each course point is
  // rotated to look in the direction of the vector connecting the preceding
  // point with the succeeding point.
  for (int i = 0; i < coursePoints.length; ++i) {
    Spatial current = coursePoints[i];
    Spatial previous = i > 0
        ? coursePoints[i - 1] : coursePoints[coursePoints.length - 1];
    Spatial next = coursePoints[(i + 1) % coursePoints.length];
    Vector3f lookDirection
        = previous.getLocalTranslation().subtract(next.getLocalTranslation());
    current.getLocalRotation().lookAt(lookDirection,
                                      new Vector3f(0.0f, 1.0f, 0.0f));
    CollisionShape shape = CollisionShapeFactory.createBoxShape(current);
    GhostControl physics = new GhostControl(shape);
    current.addControl(physics);
    bullet.getPhysicsSpace().add(physics);
  }

  // Install listener for collisions between player and node.
  bullet.getPhysicsSpace()
      .addCollisionListener(new CoursePointCollisionListener(this));
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:43,代码来源:CoursePath.java


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