Сообщения

Сообщения за март, 2023

set display statistic

         this.app.setDisplayFps(false);         this.app.setDisplayStatView(false);

sound

  shootSound.setLooping(false); // activate continuous playing shootSound.setPositional(false); rootNode.attachChild(shootSound);

bitmap text

  BitmapFont guiFont = assetManager.loadFont( "Interface/Fonts/Default.fnt" ); hpText = new BitmapText (guiFont, false ); hpText.setSize(guiFont.getCharSet().getRenderedSize()); hpText.setColor(ColorRGBA.Red); hpText.setText( "HP:" + Integer.toString(hp)); hpText.setLocalTranslation( 0 , height- 160 , 0 ); guiNode.attachChild(hpText);

get width get height

     app.getContext().getSettings().getWidth() / 2 - ch.getLineWidth()/2, app.getContext().getSettings().getHeight() / 2 + ch.getLineHeight()/2, 0);

jmoneky threading

  Thread thread = new Thread ( new Runnable () { // <- Never override classes if it is not required. public void run () { GameLevel appLevel = new GameLevel (levelName,id,x,y,z); appLevel.setEnabled( true ); app.enqueue( new Runnable () { @Override public void run () { app.getStateManager().attach(appLevel); app.getGuiNode().detachChild(pic); } }); } });

java gradle jar dependecy

  dependencies { implementation files ( 'libs/something_local.jar' ) }

groovy dependency

     implementation 'org.codehaus.groovy:groovy-all:2.4.15'

jmonkey custom crursor

 Texture cursorTexture = assetManager.loadTexture("Textures/action.png");                 Image image = cursorTexture.getImage();                 ByteBuffer imgByteBuff = image.getData(0);                 imgByteBuff.rewind();                 IntBuffer imgIntBuff = imgByteBuff.asIntBuffer();                 JmeCursor c = new JmeCursor();                 c.setHeight(image.getHeight());                 c.setWidth(image.getWidth());                 c.setNumImages(1);                 c.setyHotSpot(image.getHeight()-3);                 c.setxHotSpot(3);                 c.setImagesData(imgIntBuff);                                  inputManager.setMouseCursor(c);

spatial childs

  ArrayList<Spatial> nodes = new ArrayList(localRootNode.getChildren()); > > for (Spatial item:nodes){ > > Node rootScene= (Node) item; > > ArrayList<Spatial> nodesChild = new ArrayList(rootScene.getChildren()); > for (Spatial itemChild:nodesChild){ > System.out.println(itemChild.getName()); > } > > }

get geometry from spatial 2

     public Geometry getGeometry(Node itemNode){         ArrayList<Spatial> nodes = new ArrayList(itemNode.getChildren());            for(Spatial item:nodes){              if(item.getClass().getName().equals("com.jme3.scene.Geometry")){                 return (Geometry)item;             }             Node rootScene= (Node) item;              return getGeometry( rootScene);                                       }         return null;     }

jmoneky get geometry from spatil

  public Geometry getMyGeometry(Spatial spatial){             //System.out.println("getMyGeometry()");             Node node = (Node)spatial;             Geometry g = null;             final List<Spatial> ants = new LinkedList<Spatial>();             //node.breadthFirstTraversal(new SceneGraphVisitor() {             node.depthFirstTraversal(new SceneGraphVisitor() {                     @Override                     public void visit(Spatial spatial) {                             //System.out.println("visit class is " + spatial.getClass().getName());                             //System.out.println("visit spatial is " + spatial);                             if (spatial.getClass().getName().equals("com.jme3.scene.Geometry")) {                                     ants.add(spatial);                             }                     }             });             if (!ants.isEmpty()) {                     //redundant - borrowed from Quixote

jmonkey Cloth system

https://hub.jmonkeyengine.org/t/cloth-system/46547/8 The boots also need to have vertex groups setup properly to match the Armature that they’re being added to.  @Override     public void simpleInitApp() {         Node player= (Node)assetManager.loadModel("Models/test.glb");         Node playerArmature = (Node)player.getChild("Armature");                  AnimComposer playerAnim = playerArmature.getControl(AnimComposer.class);          rootNode.attachChild(player);                  Node boots= (Node)assetManager.loadModel("Models/test2.j3o");         Geometry bootsGeom= (Geometry)boots.getChild("Sphere");                  //1. Attach clothing to the animated model.         playerArmature.attachChild(bootsGeom);                  //2 Detach the animated model from the scene         rootNode.detachChild(player);                  //3 reload          SkinningControl skinningControl = ((Node) playerArmature).getControl(SkinningControl.class);          

Move character on mouse click (like lineage 2) tutorial

https://hub.jmonkeyengine.org/t/move-character-on-mouse-click-like-lineage-2-tutorial/46550 https://github.com/nnpa/jmonkey-move-character-on-mouse-click/blob/main/src/main/java/tests/Tests.java