Gizmo Translator not working?

why doesn't my translator gizmo work whenever I add 3d models on my scene…?.. I tried changing my sources that instead of dae, I tried 3ds objects… but still my translator won't work… the mouse can't pick it…thus not making it work…

bump I think I would really need help on this topic… The thing i don't understand is that even that I have detached the imported model from the scene… it looks like the barrier preventing my translators to be picked are still there…

:?



What do you think about a real question with some explanation about your issue so people have a chance to understand what the problem is?!? You have to know we cannot look into your head…(not yet)



Or do you mean a translation tool for this nice little mogway’s language?








oh there you are ttrocha… thanks for the quickie reply… I was on the rush when I posted this question so I didn't have time to elaborate more on my problem… so my post was jumbled with unrelated ideas…



okay, now I shall explain…



I am working on a terrain modeling module for my simulator application via the use of planes, jme shapes and 3DS/Collada models… it would mostly look like the SceneEditorDemo.java on the wiki but maybe a little more upgraded version of it since I could add multiple shapes and models to create a terrain for my app… there are no problems whenever the shapes I attach to my scene are only boxes and spheres… I can translate, rotate and scale via the use of translator gizmo and rotator gizmo… (concept taken from SceneEditorDemo.java)… but whenever I attach 3DS / Collada Models to my scene… my gizmos won't work anymore… it's as if the mouse can't pick them… I can tell that since my mousepicking method highlights the arrow it picks whenever you put the mouse over it… it's as if the model that has been loaded creates a barrier in the whole scene preventing my gizmos to be picked…



have you guys encountered anything same?



here's my addObject and MousePicking  methods if you would like to take a look…


public void addObject(String objectType, URL fileToLoad, Vector3f location, float[] angles, Vector3f scale){
       String objName = "";
       int cnt = 0;
       int highestNum = 0;
       if(objectsList.getItemCount() > 0){
          //get highest Number first
          for(cnt = 0; cnt < objectsList.getItemCount(); cnt++){
             String[] temp = null;
             int getNum = 0;
             temp = objectsList.getItemAt(cnt).toString().split("_");
             if(temp[0].equals("Object")){
                getNum = Integer.parseInt(temp[1]);
             }
             if(getNum > highestNum){
                highestNum = getNum;
             }
          }
          //fill out possible object names
          highestNum++;
          String[][] posObjNames = new String[highestNum][2];
          for(cnt=1; cnt<=highestNum; cnt++){
             posObjNames[cnt-1][0]= "Object_"+cnt;
             posObjNames[cnt-1][1]= "false";
          }
          
          //find non-existent object names
          for(int a=0; a < highestNum; a++){
             for(int b=0; b < objectsList.getItemCount(); b++){
                if(posObjNames[a][0].equals(objectsList.getItemAt(b))){
                   posObjNames[a][1]= "existent";
                }
             }
          }
          //find lowest non-existent object name
          for(cnt = 0; cnt < highestNum; cnt++){
             objName = posObjNames[cnt][0];
             if(posObjNames[cnt][1].equals("false")){
                break;
             }
          }
          
       }
       else{
          objName = "Object_1";
       }
              
       if (objectType == "box"){
          objects = new Box(objName, new Vector3f(0,0,0), 1,1,1);
           objectsList.addItem(objName);
           objects.setLocalScale(scale);
       }
       else if(objectType == "sphere"){
          objects = new Sphere(objName, 30, 30,1);
           objectsList.addItem(objName);
           objects.setLocalScale(scale);
       }
       else if(objectType == "custom"){
             try {
                  MaxToJme C1 = new MaxToJme();
                  ByteArrayOutputStream BO = new ByteArrayOutputStream();
                  C1.convert(new BufferedInputStream(fileToLoad.openStream()), BO);
                  objects = (Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
                 
              } catch (IOException e) {}
             objectsList.addItem(objName);
             objects.setName(objName);
             //objects.lockBounds();
       }
       else if(objectType == "brick"){
          try {
               MaxToJme C1 = new MaxToJme();
               ByteArrayOutputStream BO = new ByteArrayOutputStream();
               C1.convert(new BufferedInputStream(fileToLoad.openStream()), BO);
               objects = (Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
              
           } catch (IOException e) {}
          objectsList.addItem(objName);
          objects.setName(objName);
         //objects.lockBounds();
       }

private void MousePicking(){
   mx = glCanvas.getMousePosition().x;
   my = glCanvas.getHeight()-glCanvas.getMousePosition().y;
   Vector2f screenPosition = new Vector2f(mx, my);
   Vector3f worldCoords = DisplaySystem.getDisplaySystem().getWorldCoordinates(screenPosition, 0);
   Vector3f worldCoords2 = DisplaySystem.getDisplaySystem().getWorldCoordinates(screenPosition, 1);
   mouseRay = new Ray(worldCoords, worldCoords2.subtractLocal(worldCoords));
   results = new TrianglePickResults();
   results.clear();
   results.setCheckDistance(true);
   
   root.findPick(mouseRay, results);
   try{
   if(results.getNumber() > 0){
      for(int cnt=0; cnt < results.getNumber(); cnt++){

         if(results.getPickData(cnt).getTargetMesh().getName().equals("base") || results.getPickData(cnt).getTargetMesh().getName().equals("tip")){
            selectedMesh = results.getPickData(cnt).getTargetMesh();
            selectedObject = selectedMesh.getParent().getName().toString();
            System.out.println(selectedObject);
            
            xArrow.setSolidColor(ColorRGBA.red);
            yArrow.setSolidColor(ColorRGBA.green);
            zArrow.setSolidColor(ColorRGBA.blue);
            if(selectedObject.equals("xArrow")){
               xArrow.setSolidColor(ColorRGBA.randomColor());   
               selectedTranslator = "xArrow";
               }
            else if(selectedObject.equals("yArrow")){
               yArrow.setSolidColor(ColorRGBA.randomColor());
               selectedTranslator = "yArrow";
               }
            else if(selectedObject.equals("zArrow")){
               zArrow.setSolidColor(ColorRGBA.randomColor());
               selectedTranslator = "zArrow";
               }
            xArrow.updateRenderState();
            yArrow.updateRenderState();
            zArrow.updateRenderState();
            
            break;
         }else if(results.getPickData(cnt).getTargetMesh().getName().equals("xCircle") ||
                results.getPickData(cnt).getTargetMesh().getName().equals("yCircle") ||
                results.getPickData(cnt).getTargetMesh().getName().equals("zCircle")){
            selectedMesh = results.getPickData(cnt).getTargetMesh();
            if(selectedMesh.getName() == "xCircle"){
               selectedTranslator = "xCircle";
               yCircle.setSolidColor(ColorRGBA.green);
               zCircle.setSolidColor(ColorRGBA.blue);
                     
               yCircle.updateRenderState();
               zCircle.updateRenderState();
               System.out.println("xCircle selected");
            }
            else if(selectedMesh.getName() == "yCircle"){
               selectedTranslator = "yCircle";
               xCircle.setSolidColor(ColorRGBA.red);
               zCircle.setSolidColor(ColorRGBA.blue);
                     
               xCircle.updateRenderState();
               zCircle.updateRenderState();
               System.out.println("yCircle selected");
            }
            else if(selectedMesh.getName() == "zCircle"){
               selectedTranslator = "zCircle";
               xCircle.setSolidColor(ColorRGBA.red);
               yCircle.setSolidColor(ColorRGBA.green);
                                    
               xCircle.updateRenderState();
               yCircle.updateRenderState();
               System.out.println("zCircle selected");
            }
            selectedMesh.setRandomColors();
            selectedMesh.updateRenderState();
            break;
            }
         }
      
   }
   else{
      
      xArrow.setSolidColor(ColorRGBA.red);
      yArrow.setSolidColor(ColorRGBA.green);
      zArrow.setSolidColor(ColorRGBA.blue);
      
      xArrow.updateRenderState();
      yArrow.updateRenderState();
      zArrow.updateRenderState();
      
      xCircle.setSolidColor(ColorRGBA.red);
      yCircle.setSolidColor(ColorRGBA.green);
      zCircle.setSolidColor(ColorRGBA.blue);
            
      xCircle.updateRenderState();
      yCircle.updateRenderState();
      zCircle.updateRenderState();
   }
   
   }catch(Exception e){}
}





Hmm,…I think the problem might be this line:


if(results.getPickData(cnt).getTargetMesh().getName().equals("base") || results.getPickData(cnt).getTargetMesh().getName().equals("tip")){



I'm not sure if a name can't be null and who knows what this importers do. I assume that there (or maybe somewhere else) an exception is thrown and catched by your incredible try-catch-block:

try{...}catch(Exception e){}


btw: Catching exceptions like this will kill you sooner or later.... :D

Once you catched the exception you left the for-loop
Move the try catch block in the for-loop where you process all the possible picks and it might work again...

If not I will have to take a deeper look.

Good luck...

I tried to delete the try{}catch block from there and added

System.out.println(""+results.getNumber());

before the

if(results.getNumber() > 0){ … }





but whenever I try pick anything when an imported object is added onto the scene… the code above prints 0… that means the method doesn’t pick anything at all and goes to the else



anyway… here’s a couple of images…



picking any arrows of the translator gizmo (works fine here)





translating an object (jme box) in edit mode





attached a new object (imported 3DS)





translator doesn’t work anymore here





by the way, I have two modes “Real View Mode” where you can see the real objects in their respective positions scales and rotations (attached to the sceneNode)

and “Edit Mode” where I detach sceneNode with all its children from the root and add an editNode that consists of gridBoxNodes (on the pic)… as counterpart of the real objects just so I could put the gizmos inside them…



p.s. sorry for the watermark, its the only tool I have that could capture the screen along with the mouse cursor

For the beginning it would be nice to add an


e.printStackTrace();



in your catch-block to ensure that no exception is thrown....
And if there is everything right, debugging is your keyword.
Have a look what happens in die caculate/findpick-method....

Keep on fighting!