Package com.jme3.scene

Examples of com.jme3.scene.Node


          if (geom != null) {
            log.fine("picked " + geom.getName());
            Integer id = geom.getUserData(Entity.ENTITY_ID);
            if (id != null) {
              //Just create a target component rest is done in the jmeupdatesystem
              Node n = res.getGeometry().getParent();
              String na = n.getName();
              log.fine("picked " + na + " id:"+ id);
              Vector3f loc = n.getLocalTranslation();
              sin.getClientFacade().sendAction(id, loc.x, loc.y, loc.z, false, true);
              results.clear();
              return;
            } else {//FIXME click on anything, check nav, then send request
              // this is the one
View Full Code Here


    //spool all anims
    for (final File name : file.listFiles(meshFilter)) {
      //new loader each time, yes
      try {
        String fName = name.getName().substring(0,name.getName().length()-".mesh.xml".length());
        Node n =  (Node) assetMan.loadAsset(name.getAbsolutePath());
        if(n.getChildren().size() > 1)
          throw new Throwable("Mesh with more children detected than one on "+name.getName());
       
        Spatial s = n.getChild(0);
        String mat = "default";
        if(s instanceof Geometry) {
          Geometry g = ((Geometry)s);
          g.setName(fName);
          g.updateModelBound();
View Full Code Here

   *
   * @param template  name of the model template from the partset configuration
   * @return a @see Node below which the 3d model and the animation controller is present
   */
  public static Node getModel(String template){
    Node n = getModelInternal(JMEAnimationController.class, template, false, false);
    return n;
  }
View Full Code Here

   *
   * @param template  name of the model template from the partset configuration
   * @return a @see Node below which the 3d model and the animation controller is present
   */
  public static Node getModel3(String template){
    Node n = getModelInternal(JMEAnimationController.class, template, false, false);
    n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    n.updateGeometricState();
   
    return n;
  }
View Full Code Here

   * @param optimized combine all mesh parts into one mesh using batch factory (should use same material)
   * @param hwSkinning hwSkinning desired or not
   * @return a @see Node below which the 3d model and the animation controller is present
   */
  public static Node getModel4(String template, boolean optimized, boolean hwSkinning){
    Node n = getModelInternal(JMEAnimationController.class, template, optimized, hwSkinning);
    n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    n.updateGeometricState();
   
    return n;
  }
View Full Code Here

    PartSet top = getTopPart(template);
    //FIMXE error handling
    if(top == null) {
      new Exception("Failed to find temple <"+template+"> in megaset").printStackTrace();
      return new Node("NULL");
    }
   
    HashMap<String, Asset> materials = getMaterials(top);

    WeaponSet weapons = getWeaponset(top);

    HashMap<Asset, String> meshArray = getMeshesWithMaterial(top);
   
    addWeaponSetToMeshMap(top, weapons, meshArray);

    Skeleton skel = getSkeleton(top);

    getAnimations(/*top, */weapons.getAnimSet(), weapons.getDefaultSet());

    Node n = assembleModel(template,meshArray,materials,skel,weapons.getAnimSet(), optimized, hwSkinning);
       
    return n;
  }
View Full Code Here

    as.setUseHWSkinning(hwSkinnig);
    as.setSkeleton(skel);
    unpackMeshesIntoAssembler(meshArray, materials, as);
     
    as.setAnimParts(animSet);
    Node n = as.getModel();
    n.setName(template);
    return n;
  }
View Full Code Here

  public void doCharCreation() {
   
    Singleton.get().getSceneManager().removeAll();
   
    try{
      Node n = (Node) Singleton.get().getAssetManager().getJmeAssetMan()
          .loadModel(SCENES_CREATE);
      Singleton.get().getSceneManager().changeTerrainNode(n, Action.ADD);
     
//      //this is needed as the ssao pass will other wise only render
//      //the shadow of our attached chars as they are on a different
//      //root (nice for a ghost effect or so)
//      for(Light l : n.getLocalLightList()){
//        if(l instanceof AmbientLight){
//          n.removeLight(l);
//          l.setColor(new ColorRGBA(0.6f,0.6f,0.8f,1.0f));
//          Singleton.get().getSceneManager().changeRootLight(l, Action.ADD);
//        }
//      }
     
      //ARGH !! the troll in the sdk is a standard jme anim troll,
      //it does not work without being loaded by the standard animation package using animationproviders
      //so relaping it here
      Spatial troll = n.getChild("troll")
      if(troll != null){
        n.detachChild(troll);
        VisibleModel newtroll = new VisibleModel(null);
        newtroll.attachVisuals();
        newtroll.setLocalTranslation(troll.getLocalTranslation());
        n.attachChild(newtroll);
      }
      //this is needed as the chars are on a different node and would not be rendered
      //just add, do not remove here..
      for(Light l : n.getLocalLightList()){
          Singleton.get().getSceneManager().changeRootLight(l, Action.ADD);
      }
       
    } catch (Exception e1) {
      logger.log(Level.SEVERE, "Failed to load creation scene file "+SCENES_CREATE, e1);
View Full Code Here

    //load the x representations of the characters into the hall
    //add input handler for choosing a char and functionality to let him step to the front
    //add gui buttons for enter world, exit, options
    //on enter world start game with the chosen, on exit cleanup, on options show options pane

    Node scene = null;
    Vector3f pos = null;
    try{
      scene = (Node) Singleton.get().getAssetManager().getJmeAssetMan()
          .loadAsset(SCENES_SELECT);   
      if(scene != null){
       
        //this is needed as the chars are on a different node and would not be rendered
        //just add, do not remove here..
        for(Light l : scene.getLocalLightList()){
            Singleton.get().getSceneManager().changeRootLight(l, Action.ADD);
        }
   
       
        Singleton.get().getSceneManager().changeTerrainNode(scene, Action.ADD);
       
        //BEWARE !! do not use world pos at that time the node is not attached, and world pos was not computed
        pos = scene.getChild("target").getLocalTranslation().clone();
        camera.setLocation(pos);
        //default, changed to last selected
        camera.lookAt(scene.getChild("pos1").getLocalTranslation(), Vector3f.UNIT_Y);
        int chars = clientInfo.getCharHandler().getCharCount();
        if(chars > 12){
          logger.log(Level.SEVERE, "More than 12 characters present for selection! Check server settings! We can only display 12 chars for selection");
          chars = 12;
        }
       
        for (int i = 0; i < chars; i++) {
          if(clientInfo.getCharHandler().getSelectedChar().isLastUsed()){
            clientInfo.getCharHandler().setSelected(i);
            camera.lookAt(scene.getChild("pos"+(i+1)).getLocalTranslation(), Vector3f.UNIT_Y);
            CameraNode cn;
           
          }
          NewCharacterModel v = new NewCharacterModel(clientInfo.getCharHandler().getCharSummary(i));
          v.attachVisuals();
          pos = scene.getChild("pos"+(i+1)).getLocalTranslation().clone();
          pos.y -= 1.0f;
          v.setLocalTranslation(pos);
          v.setLocalRotation(new Quaternion().fromAngleNormalAxis((float) Math.PI, Vector3f.UNIT_Y.negate()));
          Singleton.get().getSceneManager().changeCharNode(v,Action.ADD);
        }       
      }
    } catch (Exception e1) {
      logger.log(Level.SEVERE, "Failed to load select scene file "+SCENES_SELECT, e1);
    }
     
    final Node refScene = scene;
   
    SwingUtilities.invokeLater(new Runnable() {

      public void run() {
        final JButton left = Singleton.get().getGuiController().displayButton("<", 40, 30, (settings.getWidth()/2)-100, settings.getHeight()-50);
        final JButton b = Singleton.get().getGuiController().displayButton("select", 80, 30, (settings.getWidth()/2)-40, settings.getHeight()-50);
        final JButton bb = Singleton.get().getGuiController().displayButton("create", 80, 30, (settings.getWidth()/2)-40, settings.getHeight()-10);
        final JButton right = Singleton.get().getGuiController().displayButton(">", 40, 30, (settings.getWidth()/2)+70, settings.getHeight()-50);
        left.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int sel = clientInfo.getCharHandler().getSelectedIndex();
            if(sel < 1)
              return;
           
            sel--;
            clientInfo.getCharHandler().setSelected(sel);
            camera.lookAt(refScene.getChild("pos"+(sel+1)).getLocalTranslation(), Vector3f.UNIT_Y);
          }
        });
        right.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int sel = clientInfo.getCharHandler().getSelectedIndex();
            if(sel+1 >= clientInfo.getCharHandler().getCharCount())
              return;
           
            sel++;
            clientInfo.getCharHandler().setSelected(sel);
            camera.lookAt(refScene.getChild("pos"+(sel+1)).getLocalTranslation(), Vector3f.UNIT_Y);
          }
        });
        b.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
View Full Code Here

        Geometry v = (Geometry)n;
        if(n.getQueueBucket().equals(RenderQueue.Bucket.Opaque))
          n.setShadowMode(ShadowMode.CastAndReceive);
//          TangentBinormalGenerator.generate(n);
      } else if (n instanceof Node){
        Node v = (Node)n;
        for(Spatial  child : v.getChildren()){
          setShadowCasterReceiver(child);
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.jme3.scene.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.