[Solved(bad driver settings)]Arrow.setLineWidth() random culling and low fps when >1 ? jme3 r7236

Hi again lol, I seem to have a flair for doing things wrong, or something

when I set Arrow.setLineWidth(1) in the following example, all works well, 59-60 fps all the time and no culling of the coordinate system (made by Arrows)<br /> but, when I set ie. Arrow.setLineWidth(4) aka thicker lines, then I get constant 34-35 fps and some random culling (disappearing) of the line that has this width<br /> ===<br /> Here, all lines have Arrow.setLineWidth(1) so all works well:<br /> <img src='http://i.imgur.com/mpqd8.png'>http://i.imgur.com/mpqd8.png</img><br /> =======<br /> Here, the red line has Arrow.setLineWidth(4) the rest are 1, and the line shows at first, although the fps is low:<br /> <img src='http://i.imgur.com/1CCYP.png'>http://i.imgur.com/1CCYP.png</img><br /> ==========<br /> Here, the red line disapeared soon after program start(after above) and it only appears from certain camera angles, the fps remains low:<br /> <img src='http://i.imgur.com/HRZRf.png'>http://i.imgur.com/HRZRf.png</img><br /> ====<br /> And here is the code, the line marked with "XXX:" "arrow.setLineWidth(4);" is the key line to be changed from 4 to 1 if you want it working well:<br /> pre type=“java”`
package org.jme3.tests;





import com.jme3.app.SimpleApplication;


import com.jme3.material.Material;


import com.jme3.math.ColorRGBA;


import com.jme3.math.FastMath;


import com.jme3.math.Spline;


import com.jme3.math.Vector3f;


import com.jme3.scene.Geometry;


import com.jme3.scene.Mesh;


import com.jme3.scene.Node;


import com.jme3.scene.Spatial.CullHint;


import com.jme3.scene.debug.Arrow;


import com.jme3.scene.shape.Box;


import com.jme3.scene.shape.Curve;





/**

  • Sample 2 - How to use nodes as handles to manipulate objects in the scene

  • graph. You can rotate, translate, and scale objects by manipulating their

  • parent nodes. The Root Node is special: Only what is attached to the Root

  • Node appears in the scene.


    /


    public class HelloNode5 extends SimpleApplication {





    private Vector3f cornerPos;





    private Geometry geoCurve;





    private Geometry geoBox;





    private final Spline spline = new Spline();


    private Node coord;


    Box box;





    public static void main(String[] args) {


    HelloNode5 app = new HelloNode5();


    app.setShowSettings(false);


    app.start();


    }





    /


    • (non-Javadoc)



    • @see com.jme3.app.SimpleApplication#simpleUpdate(float)


      */


      @Override


      public void simpleUpdate(float tpf) {


      // calculating by how much to rotate now(relative to previous position),


      // not the exact rotation position(as it was in


      // prev. revision)


      float yaw = (FastMath.DEG_TO_RAD * 4 * tpf) % (FastMath.PI * 2);


      float roll = (FastMath.DEG_TO_RAD * 7 * tpf) % (FastMath.PI * 2);


      float pitch = (FastMath.DEG_TO_RAD * 11 * tpf) % (FastMath.PI * 2);


      // rotating the box by this much


      geoBox.rotate(yaw, roll, pitch);


      // move box “forward” too, that is, forward relative to itself ie.


      // spaceship moving forward


      geoBox.move(geoBox.getLocalRotation().getRotationColumn(2).mult(tpf));





      Vector3f clonedCornerPos = cornerPos.clone();


      // now applying the same transform (pos/rot/scale) to the corner as the


      // box has


      geoBox.getLocalTransform().transformVector(clonedCornerPos,// in,


      clonedCornerPos// store


      );


      // even if I comment the following “coord” related updates still low fps


      // when setLineWidth(4)


      Vector3f f = box.getCenter().clone();


      geoBox.getLocalTransform().transformVector(f, f);


      coord.setLocalTransform(geoBox.getLocalTransform());


      coord.setLocalTranslation(f);


      // coord.setLocalTransform( geoBox.getLocalTransform() );


      // til here





      // we have the corner’s exact pos now, relative to the Node the geoBox &


      // geoCurve are both in


      // we add that pos to the curve


      spline.addControlPoint(clonedCornerPos);// must be cloned!


      // we must create new Curve object because we can’t add/update the


      // spline in existing one (?!)


      geoCurve.setMesh(new Curve(spline, 1));


      }





      @Override


      public void simpleInitApp() {


      flyCam.setMoveSpeed(20f);





      Node subNode = new Node();


      subNode.setLocalTranslation(new Vector3f(2, 0.5f, 1));


      subNode.rotate(1f, -2f, 4f);


      // a box with non 0,0,0 center which means a position of x,y,z relative


      // to it’s parent geoBox(below)


      box = new Box(new Vector3f(2, 3, 4), 0.5f, 0.9f, 1.3f);


      geoBox = new Geometry(“Box”, box);


      geoBox.setLocalTranslation(1f, 2f, 3f);


      geoBox.scale(1.3f, 1.2f, 1.1f);// always ok


      geoBox.rotate(2f, -4f, 0.4f);


      Material mat2 = new Material(assetManager,


      “Common/MatDefs/Misc/WireColor.j3md”);


      mat2.setColor(“Color”, ColorRGBA.Red);


      geoBox.setMaterial(mat2);





      Material curveMat = new Material(assetManager,


      “Common/MatDefs/Misc/WireColor.j3md”);


      curveMat.setColor(“Color”, ColorRGBA.Green);


      geoCurve = new Geometry(“trails”);


      geoCurve.setMaterial(curveMat);


      subNode.attachChild(geoCurve);


      subNode.attachChild(geoBox);





      rootNode.setLocalTranslation(-1, -2, -4);


      rootNode.rotate(-1f, 2f, -4f);





      rootNode.attachChild(subNode);


      rootNode.scale(1.5f);// this is always ok


      subNode.scale(0.4f);// this is always ok too


      // subNode.scale(1.3f, 0.7f, 0.4f);// XXX: bug when uncommented


      // rootNode.scale(0.4f, 1.4f, 1.1f);// XXX: or/and this





      // doing this here only once


      cornerPos = new Vector3f();


      // calculating position of corner, first getting corner as it were if


      // box were at 0,0,0 and no rotation/scale


      cornerPos.set(





      box.getXExtent(), box.getYExtent(), box.getZExtent());


      // now considering box may have a different than 0,0,0 center


      cornerPos.addLocal(box.getCenter());


      coord = new Node();


      coord.setCullHint(CullHint.Never);


      attachCoordinateAxes(Vector3f.ZERO, coord);


      subNode.attachChild(coord);


      // coord.setLocalTranslation( geoBox.getLocalTranslation() );//


      // box.getCenter() );


      }





      private void attachCoordinateAxes(Vector3f pos, Node toNode) {


      Arrow arrow = new Arrow(Vector3f.UNIT_X);


      // make arrow thicker,


      // XXX:set this from 1 to 4 to see culling and 35 of 60 fps


      arrow.setLineWidth(4);


      putShape(arrow, ColorRGBA.Red, toNode).setLocalTranslation(pos);





      arrow = new Arrow(Vector3f.UNIT_Y);


      arrow.setLineWidth(1); // make arrow thicker


      putShape(arrow, ColorRGBA.Green, toNode).setLocalTranslation(pos);





      arrow = new Arrow(Vector3f.UNIT_Z);


      arrow.setLineWidth(1); // make arrow thicker


      putShape(arrow, ColorRGBA.Blue, toNode).setLocalTranslation(pos);


      }





      private Geometry putShape(Mesh shape, ColorRGBA color, Node onNode) {


      Geometry g = new Geometry(“coordinate axis”, shape);


      Material mat = new Material(assetManager,


      “Common/MatDefs/Misc/Unshaded.j3md”);


      mat.getAdditionalRenderState().setWireframe(true);


      mat.setColor(“Color”, color);


      g.setMaterial(mat);


      onNode.attachChild(g);


      g.setCullHint(CullHint.Inherit);


      return g;


      }


      }



      /pre

      Again, it may be something I’m doing wrong, let me know if so, beat me with a stick :)) I really like jme3! honestly
Momoko_Fan said:
Can't reproduce this issue. The red line is always visible, even with 4 thickness. Also the fps remains fairly the same for me (500 fps) regardless of the thickness of the line.

Now with up to date drivers (catalyst 11.3 3/29/2011) the issue is still the same for me, ATI 4800 Series (not sure the exact card type)
The arrow with thickness 4 appears at the beginning and disappears after like 4 seconds, appears again later or depending on camera angles....
Though much appreciated that you tried !
Did you also try with VSync on? I'll try with off, for now, even with VSync off it acts like it's on, most likely due to some setting in my drivers which I had set VSync always on, will uncheck it!
Ok, with VSync off I have like 1333fps more or less when lineWidth is 1, but when it's 4 it's back to as if it had 4 and VSync on, like 37 fps all the time... most likely my drivers again? even though they are up to date again, I'll see what happens if I revert all my driver settings to defaults...

Ok I found it, geeez, I had non-defaultly unselected "Use application settings" on SMOOTHVISION HD:Anti-Aliasing and set to Samples:2X and Filter Box, and this caused the low fps AND disappearing of the red 4 width line, and to fix it I just had to tick/select/enable the "Use application settings" and Filter remained on Box, and bam like 1032 fps and works well !
Again, my fault :-" and again I thank you, this was much much helpful!

the bad setting:
http://i.imgur.com/yLFz7.png
=====
the good setting that fixed it:
http://i.imgur.com/wr5QO.png

Glad you found it :slight_smile:

1 Like

Can’t reproduce this issue. The red line is always visible, even with 4 thickness. Also the fps remains fairly the same for me (500 fps) regardless of the thickness of the line.

1 Like