/** * Sets the transforms of this bone in model space (relative to the root bone) * * Must update all bones in skeleton for this to work. * @param translation translation in model space * @param rotation rotation in model space */ public void setUserTransformsInModelSpace(Vector3f translation, Quaternion rotation) { if (!userControl) { throw new IllegalStateException("You must call setUserControl(true) in order to setUserTransformsInModelSpace to work"); } // TODO: add scale here ??? modelPos.set(translation); modelRot.set(rotation); //if there is an attached Node we need to set its local transforms too. if(attachNode != null){ attachNode.setLocalTranslation(translation); attachNode.setLocalRotation(rotation); } }
node.setLocalRotation(parseQuat(attribs)); } else if (qName.equals("scale")) { node.setLocalScale(SAXUtil.parseVector3(attribs));
/** * Rotate the GUI to the given direction. * @param dir the direction to rotate to. * @param tpf the time per frame. */ private void rotateScreenTo(Quaternion dir, float tpf) { dir.getRotationColumn(2, look).negateLocal(); dir.getRotationColumn(0, left).negateLocal(); orient.fromAxes(left, dir.getRotationColumn(1, up), look); Quaternion rot = tempq.fromRotationMatrix(orient); if( posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH ){ VRUtil.stripToYaw(rot); } if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { // mix pos & dir with current pos & dir EoldDir.nlerp(rot, tpf * guiPositioningElastic); guiQuadNode.setLocalRotation(EoldDir); } else { guiQuadNode.setLocalRotation(rot); } }
/** * rotate the camera around the target */ protected void rotateCamera() { verticalRotation = FastMath.clamp(verticalRotation, minVerticalRotation, maxVerticalRotation); TempVars vars = TempVars.get(); Quaternion rot = vars.quat1; Quaternion rot2 = vars.quat2; rot.fromAngleNormalAxis(verticalRotation, leftVector); rot2.fromAngleNormalAxis(horizontalRotation, upVector); rot2.multLocal(rot); target.setLocalRotation(rot2); vars.release(); }
@Override public void simpleUpdate(float tpf) { time += tpf; int random = rand.nextInt(2000); float mult1 = 1.0f; float mult2 = 1.0f; if (random < 500) { mult1 = 1.0f; mult2 = 1.0f; } else if (random < 1000) { mult1 = -1.0f; mult2 = 1.0f; } else if (random < 1500) { mult1 = 1.0f; mult2 = -1.0f; } else if (random <= 2000) { mult1 = -1.0f; mult2 = -1.0f; } box = batchNode.getChild("Box" + random); if (box != null) { Vector3f v = box.getLocalTranslation(); box.setLocalTranslation(v.x + FastMath.sin(time * mult1) * 20, v.y + (FastMath.sin(time * mult1) * FastMath.cos(time * mult1) * 20), v.z + FastMath.cos(time * mult2) * 20); } terrain.setLocalRotation(new Quaternion().fromAngleAxis(time, Vector3f.UNIT_Y)); } }
attachNode.setLocalRotation(modelRot); attachNode.setLocalScale(modelScale); attachNode.setLocalRotation(modelRot); attachNode.setLocalScale(modelScale); attachNode.getLocalTransform().combineWithParent(attachNode.getParent().getWorldTransform().invert());
model.getLocalRotation().toAngles(angles); q.fromAngleAxis(angles[1], Vector3f.UNIT_Y); model.setLocalRotation(q); if (angles[0] < 0) { animChannel.setAnim("StandUpBack");
@Override public Void call() throws Exception { myNode.setLocalRotation(rotation); return null; } }, qStyle);
ln.setLocalRotation(new Quaternion(-0.18826798f, -0.38304946f, -0.12780227f, 0.895261f)); ln.attachChild(areaGeom); ln.setLocalScale(4,8,5);
private void setRotation(Node device, Quaternion q) { RigidBodyControl rbc = device.getControl(RigidBodyControl.class); if(rbc != null) { rbc.setPhysicsRotation(q); } else { device.setLocalRotation(q); } }
/** * Sets the transforms of this bone in model space (relative to the root bone) * * Must update all bones in skeleton for this to work. * @param translation translation in model space * @param rotation rotation in model space */ public void setUserTransformsInModelSpace(Vector3f translation, Quaternion rotation) { if (!userControl) { throw new IllegalStateException("You must call setUserControl(true) in order to setUserTransformsInModelSpace to work"); } // TODO: add scale here ??? modelPos.set(translation); modelRot.set(rotation); //if there is an attached Node we need to set its local transforms too. if(attachNode != null){ attachNode.setLocalTranslation(translation); attachNode.setLocalRotation(rotation); } }
/** * Must update all bones in skeleton for this to work. * @param translation * @param rotation */ public void setUserTransformsWorld(Vector3f translation, Quaternion rotation) { if (!userControl) { throw new IllegalStateException("User control must be on bone to allow user transforms"); } // TODO: add scale here ??? worldPos.set(translation); worldRot.set(rotation); //if there is an attached Node we need to set it's local transforms too. if(attachNode != null){ attachNode.setLocalTranslation(translation); attachNode.setLocalRotation(rotation); } }
private Node createNode(ModelData data) { Node model = new Node(data.name); model.setLocalTranslation(data.localTranslation); model.setLocalRotation(data.localRotation); model.setLocalScale(data.localScale); return model; }
protected final void updateSkeletonGeoms(Bone bone) { if (guessBonesOrientation && bone.getName().equalsIgnoreCase("Site")) { return; } Node n = boneNodes.get(bone); n.setLocalTranslation(bone.getLocalPosition()); n.setLocalRotation(bone.getLocalRotation()); n.setLocalScale(bone.getLocalScale()); for (Bone childBone : bone.getChildren()) { updateSkeletonGeoms(childBone); } }
/** * rotate the camera around the target */ protected void rotateCamera() { verticalRotation = FastMath.clamp(verticalRotation, minVerticalRotation, maxVerticalRotation); TempVars vars = TempVars.get(); Quaternion rot = vars.quat1; Quaternion rot2 = vars.quat2; rot.fromAngleNormalAxis(verticalRotation, leftVector); rot2.fromAngleNormalAxis(horizontalRotation, upVector); rot2.multLocal(rot); target.setLocalRotation(rot2); vars.release(); }
@Override public void simpleInitApp() { setupExceptionHandling(); setupAssetManger(assetManager); zUpNode = new Node("zUpNode"); zUpNode.setLocalRotation(JMEGeometryUtils.getRotationFromJMEToZupCoordinates()); rootNode.attachChild(zUpNode); setupLighting(); disableMainViewport(); contextManager.initialize(); // setupSky(); synchronized (loadingStatus) { loadingStatus.notify(); } setDisplayFps(true); setDisplayStatView(false); }
public KeeperHand(final AssetManager assetManager, int queueSize) { this.assetManager = assetManager; queue = new KeeperHandQueue(queueSize); node = new Node("Keeper hand"); queueNode = new Node("Queue"); queueNode.setLocalScale(500); Quaternion rotation = new Quaternion(); rotation.fromAngleAxis(-FastMath.QUARTER_PI, new Vector3f(-1, 1, 0)); queueNode.setLocalRotation(rotation); queueNode.addLight(new AmbientLight(ColorRGBA.White)); cursor = new Node("Cursor"); cursor.setLocalTranslation(75, 0, 0); node.attachChild(queueNode); node.attachChild(cursor); }
public Spatial load(AssetManager assetManager, Vector2f pos, PlayerSpell playerSpell, int moneyAmount, int triggerId, short objectId, short playerId, int maxMoney) { Point p = WorldUtils.vectorToPoint(pos); TileData tile = null; if (worldState != null) { tile = worldState.getMapData().getTile(p); } GameObject obj = kwdFile.getObject(objectId); // Load ObjectControl objectControl = getControl(tile, obj, moneyAmount, maxMoney, playerSpell); Node nodeObject = (Node) AssetUtils.loadModel(assetManager, objectControl.getResource().getName()); nodeObject.addControl(objectControl); // Move to the center of the tile nodeObject.setLocalTranslation(pos.x, 0, pos.y); nodeObject.move(0, MapLoader.FLOOR_HEIGHT, 0); // Orientation nodeObject.setLocalRotation(nodeObject.getLocalRotation().fromAngles(0, -objectControl.getOrientation(), 0)); return nodeObject; }
public void makeSinbadStandUp() { Vector3f v = new Vector3f(); Node sceneNode = getFigureNode(); HumanoidFigureConfig hfc = getFigureConfig(); v.set(sceneNode.getLocalTranslation()); v.y = hfc.getInitY(); sceneNode.setLocalTranslation(v); Quaternion q = new Quaternion(); float[] angles = new float[3]; sceneNode.getLocalRotation().toAngles(angles); q.fromAngleAxis(angles[1], Vector3f.UNIT_Y); sceneNode.setLocalRotation(q); AnimChannel animChan = getFigureAnimChannel(); HumanoidRagdollControl ragdollControl = getRagdollControl(); if (angles[0] < 0) { animChan.setAnim(ANIM_STAND_BACK); ragdollControl.blendToKinematicMode(DEFAULT_ANIM_BLEND_RATE); } else { animChan.setAnim(ANIM_STAND_FRONT); ragdollControl.blendToKinematicMode(DEFAULT_ANIM_BLEND_RATE); } } public void runSinbadBoogieAnim() {
private void updateLocation(Spatial spatial) { if(head == null) { head = spatial.getParent().getParent().getChild("male/head/middle_aged"); } loc.set(spatial.getParent().getWorldTranslation()); center.set(SpatialUtils.getCenterBoinding(head)); //System.out.println("Human Loc = "+loc+", head Loc = "+center); center.subtractLocal(loc); center.addLocal(offset); spatial.setLocalTranslation(center); rotation.set(spatial.getParent().getParent().getLocalRotation()); rotation.toAngles(angles); angles[0] *= -1; angles[1] *= -1; angles[2] *= -1; rotation.fromAngles(angles); spatial.getParent().setLocalRotation(rotation); }