Possible Bug with Spheres

Hello,

There might be a possible bug with spheres.

When generating a Sqhere with Sphere pg = new Sphere(100, 100, 100f); everything is fine, but if i use a larger amount of vertices the sphere gets distorted: (Sphere pg = new Sphere(300, 300, 100f):wink:

http://i.imgur.com/FiwlI.png

1 Like

Weird, I’m getting the same issue. It seems like it starts showing at ~250



Reproducible code:



[java]

package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Sphere;



public class Main extends SimpleApplication {



public static void main(String[] args) {

Main app = new Main();

app.start();

}



@Override

public void simpleInitApp() {

cam.setLocation(new Vector3f(0,0,30f));

flyCam.setMoveSpeed(15);



Sphere sphere = new Sphere(260, 260, 10f);

Geometry geom = new Geometry(“Sphere”, sphere);



Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);

mat.getAdditionalRenderState().setWireframe(true);

geom.setMaterial(mat);



rootNode.attachChild(geom);

}



@Override

public void simpleUpdate(float tpf) {

}



@Override

public void simpleRender(RenderManager rm) {

}

}



[/java]

1 Like

The number of vertices the sphere can support is 65536 because it uses shorts for the index buffer. If you have more verts than that, you will need to make an IntBuffer instead.

@Momoko_Fan said:
The number of vertices the sphere can support is 65536 because it uses shorts for the index buffer. If you have more verts than that, you will need to make an IntBuffer instead.


cool, that explains this

That’s INTeresting… hah, hah, hah.



Is there any reason we can’t auto-detect that when the shape is created?

@sbook said:
That's INTeresting... hah, hah, hah.

Is there any reason we can't auto-detect that when the shape is created?

Yes we can. But the code makes certain assumptions ...

It can be easily added especially since we have the IndexBuffer interface/class abstraction, which actually should be used for this rather than direct ShortBuffers.
@Momoko_Fan said:
Yes we can.


http://www.youtube.com/watch?v=x-pltESWCUU


intresting how the first 50sec matches the topic :)