/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path) { super(); spatial.addControl(this); this.path = path; }
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, LoopMode loopMode) { super(); spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, float initialDuration) { super(initialDuration); spatial.addControl(this); this.path = path; }
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode) { super(initialDuration); spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
/** * Constructs the chase camera * @param cam the application camera * @param target the spatial to follow */ public ChaseCamera(Camera cam, final Spatial target) { this(cam); target.addControl(this); }
/** * Internal use only. */ @Override public void setSpatial(Spatial spatial) { if (spatial == null && skeletonControl != null) { this.spatial.removeControl(skeletonControl); } super.setSpatial(spatial); //Backward compatibility. if (spatial != null && skeletonControl != null) { spatial.addControl(skeletonControl); } }
spatial.addControl(skinData.animComposer); spatial.addControl(skinData.skinningControl); if (skinData.morphControl != null) { spatial.addControl(skinData.morphControl);
@Override public void visit(Spatial spatial) { SkeletonControl control = spatial.getControl(SkeletonControl.class); if (control != null) { Armature armature = skeletonArmatureMap.get(control.getSkeleton()); SkinningControl skinningControl = new SkinningControl(armature); Map<String, List<Spatial>> attachedSpatials = new HashMap<>(); for (int i = 0; i < control.getSkeleton().getBoneCount(); i++) { Bone b = control.getSkeleton().getBone(i); Node n = control.getAttachmentsNode(b.getName()); n.removeFromParent(); if (!n.getChildren().isEmpty()) { attachedSpatials.put(b.getName(), n.getChildren()); } } spatial.removeControl(control); spatial.addControl(skinningControl); for (String name : attachedSpatials.keySet()) { List<Spatial> spatials = attachedSpatials.get(name); for (Spatial child : spatials) { skinningControl.getAttachmentsNode(name).attachChild(child); } } } }
private void buildPlayer() { spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml"); CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft); spaceCraft.setShadowMode(ShadowMode.CastAndReceive); spaceCraft.setLocalTranslation(new Vector3f(-140, 50, -23)); spaceCraft.setLocalRotation(new Quaternion(new float[]{0, 0.01f, 0})); hoverControl = new PhysicsHoverControl(colShape, 500); spaceCraft.addControl(hoverControl); rootNode.attachChild(spaceCraft); getPhysicsSpace().add(hoverControl); hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02); ChaseCamera chaseCam = new ChaseCamera(cam, inputManager); spaceCraft.addControl(chaseCam); flyCam.setEnabled(false); }
if (composer == null) { composer = new AnimComposer(); spatial.addControl(composer); spatial.addControl(new MorphControl());
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule in = im.getCapsule(this); skeleton = (Skeleton) in.readSavable("skeleton", null); HashMap<String, Animation> loadedAnimationMap = (HashMap<String, Animation>) in.readStringSavableMap("animations", null); if (loadedAnimationMap != null) { animationMap = loadedAnimationMap; } if (im.getFormatVersion() == 0) { // Changed for backward compatibility with j3o files generated // before the AnimControl/SkeletonControl split. // If we find a target mesh array the AnimControl creates the // SkeletonControl for old files and add it to the spatial. // When backward compatibility won't be needed anymore this can deleted Savable[] sav = in.readSavableArray("targets", null); if (sav != null) { // NOTE: allow the targets to be gathered automatically skeletonControl = new SkeletonControl(skeleton); spatial.addControl(skeletonControl); } } } }
jmeSpatial.addControl(animControl);
spatial.addControl(composer);
jmeSpatial.addControl(new AnimControl(fbxNode.skeleton)); jmeSpatial.addControl(new SkeletonControl(fbxNode.skeleton));
public void makeMissile() { Vector3f pos = spaceCraft.getWorldTranslation().clone(); Quaternion rot = spaceCraft.getWorldRotation(); Vector3f dir = rot.getRotationColumn(2); Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); missile.rotate(0, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound(); final Vector3f extent = box.getExtent(null); BoxCollisionShape boxShape = new BoxCollisionShape(extent); missile.setName("Missile"); missile.rotate(rot); missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0)); missile.setLocalRotation(hoverControl.getPhysicsRotation()); missile.setShadowMode(ShadowMode.Cast); RigidBodyControl control = new BombControl(assetManager, boxShape, 20); control.setLinearVelocity(dir.mult(100)); control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03); missile.addControl(control); rootNode.attachChild(missile); getPhysicsSpace().add(missile); }
rootNode.getChild(0).addControl(control); cam.setLocation(new Vector3f(-1.0748308f, 1.35778f, -1.5380064f)); cam.setRotation(new Quaternion(0.18343268f, 0.34531063f, -0.069015436f, 0.9177962f));
CollisionShapeFactory.createMeshShape((Node) sceneModel); landscape = new RigidBodyControl(sceneShape, 0); sceneModel.addControl(landscape);
AnimControl control = new AnimControl(); control.addAnim(factory.buildAnimation()); teapot.addControl(control);