Hi. I want to render superellipsoids with jme3. http://paulbourke.net/geometry/superellipse/

I use the following code for calculating one vertex:

[java]public Vector3f EvalSuperEllipse(float t1,float t2,float p1,float p2)

{

float tmp;

float ct1,ct2,st1,st2;

ct1 = (float) Math.cos(t1);

ct2 = (float) Math.cos(t2);

st1 = (float) Math.sin(t1);

st2 = (float) Math.sin(t2);

tmp = (float) Math.pow(fabs(ct1),p1)*sign(ct1);
Vector3f pp = new Vector3f(sign(ct2)* Math.pow(fabs(ct2),p2)),

*15*(float) (tmp

sign(st1)

*15*(float) Math.pow(fabs(st1),p1),

sign(st2)

*15*(float) (tmp * Math.pow(fabs(st2),p2))

);

return pp;

}[/java]

The following code calculates all the vertices and sets the arrays for them, the indexes array and the textures array:

[java]for (int j=0;j<n/2;j++) {

theta1 = j * TWOPI / n - PID2;

theta2 = (j + 1) * TWOPI / n - PID2;

for (int i=0;i<=n;i++) {

if (i == 0 || i == n)

theta3 = 0;

else

theta3 = i * TWOPI / n;

p = EvalSuperEllipse(theta2,theta3,e1,e2);

p1 = EvalSuperEllipse(theta1+delta,theta3,e1,e2);

p2 = EvalSuperEllipse(theta1,theta3+delta,e1,e2);

en = calcNormal(p1,p,p2);

tex = new Vector2f(i/(float)n,2

*j/(float)n);*

textureArray.add(tex);

vertexArray.addÂ§;

p = EvalSuperEllipse(theta1,theta3,e1,e2);

p1 = EvalSuperEllipse(theta2+delta,theta3,e1,e2);

p2 = EvalSuperEllipse(theta2,theta3+delta,e1,e2);

en = calcNormal(p1,p,p2);

tex = new Vector2f(i/(float)n,2(j+1)/(float)n);

textureArray.add(tex);

vertexArray.addÂ§;

p = EvalSuperEllipse(theta1,theta3,e1,e2);

p1 = EvalSuperEllipse(theta2+delta,theta3,e1,e2);

p2 = EvalSuperEllipse(theta2,theta3+delta,e1,e2);

en = calcNormal(p1,p,p2);

tex = new Vector2f(i/(float)n,2

textureArray.add(tex);

vertexArray.addÂ§;

}

}

vertices = new Vector3f[vertexArray.size()];

vertices = vertexArray.toArray(vertices);

texCoord = new Vector2f[textureArray.size()];

texCoord = textureArray.toArray(texCoord);

int k = 0;

while(k < vertices.length) {

int d = k;

for(int j=d; j < d+3; j++) {

if(j < vertices.length) {

indexList.add(j);

k++;

}

}

}

indexList.add(0);

indexes = new int[indexList.size()];

for(int i=0; i<indexes.length; i++) {

indexes

*= indexList.get(i);*

}

setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));

setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));

setBuffer(Type.Index, 3, BufferUtils.createIntBuffer(indexes));

updateBound();

}[/java]

I used these codes from the link given above. In the end i render the mesh a standard way:

[java]SuperEllipsoid se = new SuperEllipsoid(1.0f, 1.0f, 100);

Geometry seGeo = new Geometry(â€śSuperEllipsoidâ€ť, se);

Material seMat = new Material(assetManager, â€śCommon/MatDefs/Misc/Unshaded.j3mdâ€ť);

seMat.setColor(â€śColorâ€ť, ColorRGBA.Blue);

seGeo.setMaterial(seMat);

rootNode.attachChild(seGeo);[/java]

Somehow i get this:

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

What is the problem? Iâ€™ve read the Custom Mesh tutorial. I think the problem is the indexes, but i dont really know how to solve itâ€¦

}

setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));

setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));

setBuffer(Type.Index, 3, BufferUtils.createIntBuffer(indexes));

updateBound();

}[/java]

I used these codes from the link given above. In the end i render the mesh a standard way:

[java]SuperEllipsoid se = new SuperEllipsoid(1.0f, 1.0f, 100);

Geometry seGeo = new Geometry(â€śSuperEllipsoidâ€ť, se);

Material seMat = new Material(assetManager, â€śCommon/MatDefs/Misc/Unshaded.j3mdâ€ť);

seMat.setColor(â€śColorâ€ť, ColorRGBA.Blue);

seGeo.setMaterial(seMat);

rootNode.attachChild(seGeo);[/java]

Somehow i get this:

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

What is the problem? Iâ€™ve read the Custom Mesh tutorial. I think the problem is the indexes, but i dont really know how to solve itâ€¦