Odd Bounding Box Bug

Not really sure where to post about bugs, so its going here.



If you use setLocalRotation(0.0f, 0.0f, 0.0f) on a node, all the nodes bounding volumes get messed up. 



The reason this showed up for me is because I am loading model positioning from a database.





Bounding without setting local rotation:





Bounding setting local rotation (0, 0, 0):





Sample code showing the issue:

import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingSphere;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.ObjToJme;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;


public class TestModelBounding extends SimpleGame
{
  private static final Logger logger = Logger
    .getLogger(TestModelBounding.class.getName());
 
  public static void main(String[] args)
  {
    TestModelBounding app = new TestModelBounding();
    app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
    // Turn the logger off so we can see the XML later on
    app.start();
  }
 
  protected void simpleInitGame()
  {
    showBounds = true;
   
    // Point to a URL of my model
    URL model=TestModelBounding.class.getClassLoader().getResource("jmetest/data/model/maggie.obj");
   
    // Create something to convert .obj format to .jme
    FormatConverter converter=new ObjToJme();
    // Point the converter to where it will find the .mtl file from
    converter.setProperty("mtllib",model);
   
    // This byte array will hold my .jme file
    ByteArrayOutputStream BO=new ByteArrayOutputStream();
    try
    {
      // Use the format converter to convert .obj to .jme
      converter.convert(model.openStream(), BO);
      Node maggie=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
      // shrink this baby down some
      maggie.setLocalScale(.1f);
      maggie.setModelBound(new BoundingSphere());

      /*


*/
      /*      The code that causes the issue  */

      Quaternion temp=new Quaternion();
      temp.fromAngleAxis(FastMath.PI,new Vector3f(0, 0, 0));
    
      maggie.setLocalRotation(temp);
     
      /*      End of the code block           */
      /*
*/
     
     
      maggie.updateModelBound();
      // Put her on the scene graph
      rootNode.attachChild(maggie);
    }
    catch (IOException e)
    {   // Just in case anything happens
      logger.logp(Level.SEVERE, this.getClass().toString(),
        "simpleInitGame()", "Exception", e);
      System.exit(0);
    }
  }
}




Dardzull said:

If you use setLocalRotation(0.0f, 0.0f, 0.0f)

err, you can't do that - if you mean to setLocalRotation(0.0f, 0.0f, 0.0f, 0.0f)... you should not do that. It is not a valid rotation. Call setLocalRotation(0.0f, 0.0f, 0.0f, 1.0f) instead.

also: new Vector3f(0, 0, 0) is not a valid axis

look at the bright side: you got 20 more fps

HamsterofDeath said:

look at the bright side: you got 20 more fps

haha  :D thats a good tradeoff i assume