String data = attribs.getValue("data"); if (type.equals("BOOL")) { node.setUserData(name, Boolean.parseBoolean(data) || data.equals("1")); } else if (type.equals("FLOAT")) { node.setUserData(name, Float.parseFloat(data)); } else if (type.equals("STRING")) { node.setUserData(name, data); } else if (type.equals("INT")) { node.setUserData(name, Integer.parseInt(data));
myPlayer.setUserData("name", "Mario"); myPlayer.setUserData("health", 100.0f); myPlayer.setUserData("points", 0);
/** * Access the attachments node of this bone. If this bone doesn't already * have an attachments node, create one. Models and effects attached to the * attachments node will follow this bone's motions. * * @param boneIndex this bone's index in its skeleton (≥0) * @param targets a list of geometries animated by this bone's skeleton (not * null, unaffected) */ Node getAttachmentsNode(int boneIndex, SafeArrayList<Geometry> targets) { targetGeometry = null; /* * Search for a geometry animated by this particular bone. */ for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimatedByBone(boneIndex)) { targetGeometry = geometry; break; } } if (attachNode == null) { attachNode = new Node(name + "_attachnode"); attachNode.setUserData("AttachedBone", this); //We don't want the node to have a numBone set by a parent node so we force it to null attachNode.addMatParamOverride(new MatParamOverride(VarType.Int, "NumberOfBones", null)); } return attachNode; }
/** * Access the attachments node of this joint. If this joint doesn't already * have an attachments node, create one. Models and effects attached to the * attachments node will follow this bone's motions. * * @param jointIndex this bone's index in its armature (≥0) * @param targets a list of geometries animated by this bone's skeleton (not * null, unaffected) */ Node getAttachmentsNode(int jointIndex, SafeArrayList<Geometry> targets) { targetGeometry = null; /* * Search for a geometry animated by this particular bone. */ for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimatedByJoint(jointIndex)) { targetGeometry = geometry; break; } } if (attachedNode == null) { attachedNode = new Node(name + "_attachnode"); attachedNode.setUserData("AttachedBone", this); //We don't want the node to have a numBone set by a parent node so we force it to null attachedNode.addMatParamOverride(new MatParamOverride(VarType.Int, "NumberOfBones", null)); } return attachedNode; }
linkedData.putAll(blenderContext.getLinkedFeatures()); modelRoot.setUserData("linkedData", linkedData);
continue; node.setUserData(userDataKey, userDataValue); break;
/** * Returns the attachment node. * Attach models and effects to this node to make * them follow this bone's motions. */ Node getAttachmentsNode() { if (attachNode == null) { attachNode = new Node(name + "_attachnode"); attachNode.setUserData("AttachedBone", this); } return attachNode; }
return; objectNode.setUserData("hasEffect", false); objectNode.setUserData("hasEffect", true);
void createBodyPresenceSensor(String id, Vector3f pos, Vector3f dir) { Node devicePS1 = new Node(); devicePS1.setUserData("ROLE", "PresenceSensor"); devicePS1.setUserData("ID", id); devicePS1.move(pos); devicePS1.rotate(new Quaternion().fromAngles(dir.x, dir.y, dir.z)); app.getRootNode().attachChild(devicePS1); }
public static Node createAccelGeometry(String sensorId, Vector3f dimensions) { Node sensor = new Node(sensorId); sensor.setUserData("ID", sensorId); sensor.setUserData("ROLE", "Accelerometer"); sensor.setUserData("TYPE", "Sensor"); Box box = new Box(dimensions.x, dimensions.y, dimensions.z); Geometry deviceBody = new Geometry(sensorId, box); deviceBody.setMaterial(blackMat); sensor.attachChild(deviceBody); RigidBodyControl rbc = new RigidBodyControl(new BoxCollisionShape(), 5f); sensor.addControl(rbc); rbc.setFriction(1f); return sensor; }
public static void setupNodeByType(Node jmeNode, Graphics3DNodeType nodeType) { if(DEBUG) System.out.println("JMEGraphics3DNode: setting up Node by type"); switch (nodeType) { case TRANSFORM : jmeNode.setShadowMode(ShadowMode.Off); case ROOTJOINT : case JOINT : jmeNode.setShadowMode(ShadowMode.CastAndReceive); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.OPAQUE.toString()); break; case VISUALIZATION : jmeNode.setShadowMode(ShadowMode.Off); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.TRANSPARENT.toString()); break; case GROUND : jmeNode.setShadowMode(ShadowMode.CastAndReceive); if(DEBUG) System.out.println("JMEGraphics3DNode: setupNodeByType: This is a GroundNode: " +jmeNode.getName()); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.OPAQUE.toString()); break; } if(DEBUG) System.out.println("JMEGraphics3DNode: node is set with RayCastOpacity: "+jmeNode.getUserData(JMERayCastOpacity.USER_DATA_FIELD)); }
public static void setupNodeByType(Node jmeNode, Graphics3DNodeType nodeType) { if(DEBUG) System.out.println("JMEGraphics3DNode: setting up Node by type"); switch (nodeType) { case TRANSFORM : jmeNode.setShadowMode(ShadowMode.Off); case ROOTJOINT : case JOINT : jmeNode.setShadowMode(ShadowMode.CastAndReceive); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.OPAQUE.toString()); break; case VISUALIZATION : jmeNode.setShadowMode(ShadowMode.Off); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.TRANSPARENT.toString()); break; case GROUND : jmeNode.setShadowMode(ShadowMode.CastAndReceive); if(DEBUG) System.out.println("JMEGraphics3DNode: setupNodeByType: This is a GroundNode: " +jmeNode.getName()); jmeNode.setUserData(JMERayCastOpacity.USER_DATA_FIELD, JMERayCastOpacity.OPAQUE.toString()); break; } if(DEBUG) System.out.println("JMEGraphics3DNode: node is set with RayCastOpacity: "+jmeNode.getUserData(JMERayCastOpacity.USER_DATA_FIELD)); }
String data = attribs.getValue("data"); if (type.equals("BOOL")) { node.setUserData(name, Boolean.parseBoolean(data) || data.equals("1")); } else if (type.equals("FLOAT")) { node.setUserData(name, Float.parseFloat(data)); } else if (type.equals("STRING")) { node.setUserData(name, data); } else if (type.equals("INT")) { node.setUserData(name, Integer.parseInt(data));
public static Node createSmartphoneGeometry(String smartphoneId, Vector3f dimensions) { Node smartphone = new Node(smartphoneId); smartphone.setUserData("ID", smartphoneId); smartphone.setUserData("ROLE", "AndroidDevice"); smartphone.setUserData("TYPE", "Smartphone"); Box box = new Box(dimensions.x, dimensions.y, dimensions.z); Geometry deviceBody = new Geometry(smartphoneId, box); //deviceBody.rotate(0f, 0f, FastMath.DEG_TO_RAD*90f); deviceBody.setMaterial(blackMat); smartphone.attachChild(deviceBody); Geometry screen = createDisplayGeometry("Screen1", dimensions.x*2f*0.9f, dimensions.y*2f*0.9f); //screen.rotate(0f, FastMath.DEG_TO_RAD*180f, FastMath.DEG_TO_RAD*90f); screen.setMaterial(screenMat); smartphone.attachChild(screen); //screen.move(0f, 0f, dimensions.z+0.001f); screen.move(-dimensions.x, -dimensions.y, dimensions.z+0.001f); RigidBodyControl rbc = new RigidBodyControl(new BoxCollisionShape(), 5f); smartphone.addControl(rbc); rbc.setFriction(1f); return smartphone; }
/** * Access the attachments node of this bone. If this bone doesn't already * have an attachments node, create one. Models and effects attached to the * attachments node will follow this bone's motions. * * @param boneIndex this bone's index in its skeleton (≥0) * @param targets a list of geometries animated by this bone's skeleton (not * null, unaffected) */ Node getAttachmentsNode(int boneIndex, SafeArrayList<Geometry> targets) { targetGeometry = null; /* * Search for a geometry animated by this particular bone. */ for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimatedByBone(boneIndex)) { targetGeometry = geometry; break; } } if (attachNode == null) { attachNode = new Node(name + "_attachnode"); attachNode.setUserData("AttachedBone", this); //We don't want the node to have a numBone set by a parent node so we force it to null attachNode.addMatParamOverride(new MatParamOverride(VarType.Int, "NumberOfBones", null)); } return attachNode; }
((Node)usedObject).setUserData("Animation", true); animChannels = new HashMap<String, AnimChannel>(); for(String c : channels)
public Control cloneForSpatial(Spatial spatial) { Node clonedNode = (Node) spatial; AnimControl ctrl = spatial.getControl(AnimControl.class); SkeletonControl clone = new SkeletonControl(); clone.skeleton = ctrl.getSkeleton(); clone.setSpatial(clonedNode); // Fix attachments for the cloned node for (int i = 0; i < clonedNode.getQuantity(); i++) { // go through attachment nodes, apply them to correct bone Spatial child = clonedNode.getChild(i); if (child instanceof Node) { Node clonedAttachNode = (Node) child; Bone originalBone = (Bone) clonedAttachNode.getUserData("AttachedBone"); if (originalBone != null) { Bone clonedBone = clone.skeleton.getBone(originalBone.getName()); clonedAttachNode.setUserData("AttachedBone", clonedBone); clonedBone.setAttachmentsNode(clonedAttachNode); } } } return clone; }
if(ob == null) _tmpNode.setUserData("height", height); _tmpNode.setUserData("height", height);
Bone clonedBone = clone.skeleton.getBone(originalBone.getName()); clonedAttachNode.setUserData("AttachedBone", clonedBone); clonedBone.setAttachmentsNode(clonedAttachNode);
public Spatial draw(DrawableCombiner3d dc, Primitive3d primitive, SpaceObject sobj, ViewportJMonkey vp) { Vector3f lightDir = new Vector3f(1f, 1f, 1f); WaterFilter water = new WaterFilter(waterNode, lightDir); water.setWaterHeight(-0.2f); water.setUseFoam(false); water.setUseRipples(true); water.setDeepWaterColor(ColorRGBA.Black.mult(0.1f)); water.setWaterColor(ColorRGBA.Black.mult(0.15f)); water.setWaterTransparency(0.001f); water.setMaxAmplitude(0.3f); water.setWaveScale(0.008f); water.setSpeed(0.5f); water.setShoreHardness(1.0f); water.setRefractionConstant(0.2f); water.setShininess(0.3f); water.setSunScale(1.0f); water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f)); waterNode.setUserData("water", water); return waterNode; }