private void createTrack(Vector3f trackLocation) { track = physicsSpace.createStaticNode(); track.setLocalTranslation(trackLocation); track.setLocalScale(1f); track.attachChild( ModelUtil.convertOBJToStatial(ResourcesPath.MODELS_PATH + "obj/raceTrack.obj")); track.generatePhysicsGeometry(true); track.setMaterial(Material.IRON); this.attachChild(track); }
/** * a simple helper method to create a static physic wall. * * @param name node name * @param x x extent * @param y y extent * @param z z extent * @param loc location * @param type type of material/texture * @return staticPhysicNode with the attached box */ public StaticPhysicsNode makeWall( String name, float x, float y, float z, Vector3f loc, MaterialType type) { Box box = new Box(name, new Vector3f(), x, y, z); box.setModelBound(new BoundingBox()); box.updateModelBound(); if (type != null) ObjectFactory.get().applyRenderStates(box, type); StaticPhysicsNode physicWall = getPhysicsSpace().createStaticNode(); physicWall.attachChild(box); physicWall.setLocalTranslation(loc); physicWall.generatePhysicsGeometry(); return physicWall; }
/* * (non-Javadoc) * * @see org.rifidi.designer.entities.Entity#init() */ @Override public void init() { if (!(getNode() instanceof StaticPhysicsNode)) { StaticPhysicsNode phys = physicsSpace.createStaticNode(); phys.setLocalTranslation(getNode().getWorldTranslation()); for (Spatial spatial : new ArrayList<Spatial>(getNode().getChildren())) { phys.attachChild(spatial); } getNode().removeFromParent(); setNode(phys); phys.generatePhysicsGeometry(); loaded(); fieldService.registerField(this); } }