[SOLVED] Quad and BOX seem to use different units of length

package com.mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Quad;

 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
public class Main extends SimpleApplication {
    public static void main(String[] args) {
        Main app = new Main();

    public void simpleInitApp() {
        cam.setLocation(new Vector3f(5.677198f, 0.8635068f, 36.81089f));
        cam.setRotation(new Quaternion(3.5052074E-4f, 0.9996065f, -0.02392198f, 0.014644632f));
        Box b = new Box(5f, 5f, 5f);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Red);
        geom.move(new Vector3f(0,0,10));
        quadBOX(new Vector3f(5,-5,5));

    public void simpleUpdate(float tpf) {
        //TODO: add update code

    public void simpleRender(RenderManager rm) {
        //TODO: add render code
          public void quadBOX(Vector3f loc) {

       // 创建一个蓝色四边形
        Quad quad =new Quad(10f,10f);
        Geometry quadBoxGeometry = new Geometry("quadBox", quad);
        // 创建一个蓝色材质
        Material boxMaterial1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        boxMaterial1.setColor("Color", ColorRGBA.Blue);
//        boxMaterial1.getAdditionalRenderState().setWireframe(true);
//        boxMaterial1.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);

       // Quaternion y=  new Quaternion().fromAngleAxis(90*FastMath.DEG_TO_RAD,Vector3f.UNIT_X);
       // quadBoxGeometry.setLocalRotation(y);
        // 将盒子添加到场景中
       // instancedNode.onTransformChange(quadBoxGeometry);
       // MapNode.attachChild(quadBoxGeometry);

I created 10 * 10 quad with 5 * 5 * 5 box

Create a quad with sides 5 * 5 != BOX with 5 * 5 * 5 sides.

Box plane is twice the size of the quad!

Is this something jme is doing deliberately?


Have a look at the javadocs for Box and Quad


 * Creates a new box.
 * <p>
 * The box has a center of 0,0,0 and extends in the out from the center by
 * the given amount in <em>each</em> direction. So, for example, a box
 * with extent of 0.5 would be the unit cube.
 * @param x the size of the box along the x axis, in both directions.
 * @param y the size of the box along the y axis, in both directions.
 * @param z the size of the box along the z axis, in both directions.
public Box(float x, float y, float z) {
    updateGeometry(Vector3f.ZERO, x, y, z);

And Quad:

 * Create a quad with the given width and height. The quad
 * is always created in the XY plane.
 * @param width The X extent or width
 * @param height The Y extent or width
public Quad(float width, float height) {
    updateGeometry(width, height);

I.e. yes, it’s deliberate

1 Like

Well thank you very much for the quick reply, it’s embarrassing that I didn’t notice the code comment .


Also an important difference:


1 Like