Hello!
I can't get this object (Shape3D) to be visable in an applet.
Can somebody try to se if they can?
It is supposed to be a solid cube.
Best regards
Fredrik
import java.applet.*;
import java.awt.*;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.event.*;
import java.util.Enumeration;
public class Test3dBrickWithGeomInfo extends Shape3D
{
int[] stripCount = {4, 4, 4, 4, 4, 4};
//int[] stripCount = {4, 4};
float[] coordinates;
float x = 2;
float y = 4;
float z = 2;
float posX = 0;
float posY = 0;
float posZ = 0;
public Test3dBrickWithGeomInfo(float x, float y, float z,
Point3f point3f)
{
this.x = x/2;
this.y = y;
this.z = z/2;
posX = point3f.x;
posY = point3f.y;
posZ = point3f.z;
coordinates = getCoordinates();
GeometryInfo geometryInfo = new
GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(coordinates);
geometryInfo.setStripCounts(stripCount);
Triangulator triangulator = new Triangulator();
triangulator.triangulate(geometryInfo);
geometryInfo.recomputeIndices();
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
geometryInfo.recomputeIndices();
Stripifier stripifier = new Stripifier();
stripifier.stripify(geometryInfo);
geometryInfo.recomputeIndices();
setAppearance(createMaterialAppearance());
//setAppearance(createWireFrameAppearance());
setGeometry(geometryInfo.getGeometryArray());
}
public float[] getCoordinates()
{
float[] coordinates = new float[24*3];
int i = 0;
float x = this.x - 0.001f;
float y = this.y - 0.001f;
float z = this.z - 0.001f;
//Botten
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //0
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //1
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //2
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //3
//Toppen
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //4
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //5
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //6
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //7
//Baksida
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //1
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //5
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //6
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //2
//H�ger sida
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //2
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //6
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //7
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //3
//Framsida
coordinates[i++]= posX+(x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //3
coordinates[i++]= posX+(x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //7
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //4
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //0
//V�nstersida
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(z); //0
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(z); //4
coordinates[i++]= posX+(-x); coordinates[i++]= posY+(y);
coordinates[i++]= posZ+(-z); //5
coordinates[i++]= posX+(-x); coordinates[i++]=
posY+(0.001f); coordinates[i++]= posZ+(-z); //1
System.out.println("L�ngden p� cordinat arryen " +
coordinates.length);
return coordinates;
}
Appearance createMaterialAppearance()
{
Appearance materialAppear = new Appearance();
PolygonAttributes polyAttrib = new PolygonAttributes();
polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
materialAppear.setPolygonAttributes(polyAttrib);
Material material = new Material();
material.setDiffuseColor(new Color3f(0.8f, 0.5f, 0.5f));
materialAppear.setMaterial(material);
return materialAppear;
}
Appearance createWireFrameAppearance()
{
Appearance materialAppear = new Appearance();
PolygonAttributes polyAttrib = new PolygonAttributes();
polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_LINE);
materialAppear.setPolygonAttributes(polyAttrib);
ColoringAttributes redColoring = new ColoringAttributes();
redColoring.setColor(0.0f, 1.0f, 0.0f);
materialAppear.setColoringAttributes(redColoring);
return materialAppear;
}
public int[] getStripCount()
{
return stripCount;
}
}
==========================================================================To
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".