Hi,
I have attached the source code that I have problem with.
Can you tell me what is the problem ?
 
Regards,
Saeed


Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search. Learn more. =========================================================================== 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".
import javax.media.j3d.*;
import java.awt.*;
import javax.vecmath.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
import com.sun.j3d.utils.geometry.GeometryInfo;
import com.sun.j3d.utils.geometry.Triangulator;
import com.sun.j3d.utils.geometry.NormalGenerator;
import com.sun.j3d.utils.geometry.Stripifier;




class TriangleTest extends Frame{
      private Canvas3D c3d;
      private BranchGroup bg;
      private SimpleUniverse su;
      private TransformGroup tg;
    public TriangleTest(){
       c3d=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
       bg=new BranchGroup();
       su=new SimpleUniverse();
       tg=new TransformGroup();
    }
    void exe(){
        add("Center",c3d);
        setSize(600,600);
        Point3d[] points = new Point3d[] {
                 new Point3d(0, 0, 0),new Point3d(1, 0, 0),
                 new Point3d(.5, .5, 0),new Point3d(1, 0, 0),
                 new Point3d(1, 1, 0), new Point3d(.5, .5, 0),
                 new Point3d(1, 1, 0),new Point3d(0, 1, 0),
                 new Point3d(.5, .5, 0),new Point3d(0, 1, 0),
                 new Point3d(0, 0, 0),new Point3d(.5, .5, 0)
                 //new Point3d(-.5, 0, 0),
        };


        //    INTERACTION
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0f,0.0f,0.0f), 100);
        ViewingPlatform viewingPlatform = su.getViewingPlatform();
        OrbitBehavior orbit = new OrbitBehavior( c3d, OrbitBehavior.REVERSE_ALL);
        orbit.setSchedulingBounds(bounds);
        viewingPlatform.setViewPlatformBehavior(orbit);

        //     GEOMETRY
        Shape3D part = new Shape3D();
        TriangleArray geometry = new TriangleArray(12,TriangleArray.COORDINATES|TriangleArray.COLOR_3);
        su.getViewingPlatform().setNominalViewingTransform();
        geometry.setCoordinates(0, points);
        part.setGeometry(geometry);
        for (int i=0;i<12;i++)
            geometry.setColor(i,new Color3f(Color.BLUE));
        //     APPEARANCE
        Appearance appearance = new Appearance();
        ColoringAttributes ca = new ColoringAttributes();
        ca.setColor(new Color3f(Color.BLUE));
        appearance.setColoringAttributes(ca);


        //    LIGHTING
        Material mat=new Material();
        Color3f lightColor = new Color3f (.6f, 0.2f, 0.5f);
        Vector3f light1Direction = new Vector3f (0.5f, 0.5f, 0.0f);
        mat.setAmbientColor(new Color3f(0.0f,0.0f,1.0f));
        mat.setDiffuseColor(new Color3f(0.7f,0.7f,0.7f));
        mat.setSpecularColor(new Color3f(0.7f,0.7f,0.7f));
        DirectionalLight light1  = new DirectionalLight (lightColor, light1Direction);
        light1.setInfluencingBounds (bounds);
        AmbientLight ambientLightNode = new AmbientLight (lightColor);
        ambientLightNode.setInfluencingBounds (bounds);

        //   SETTING
        appearance.setMaterial(mat);
        part.setAppearance(appearance);

        tg.addChild(part);
        tg.addChild (light1);
        tg.addChild (ambientLightNode);
        bg.addChild(tg);
        bg.compile();
        su.addBranchGraph(bg);

    }
    public static void main(String args[]){
         TriangleTest t=new TriangleTest();
         t.exe();
    }
}

Reply via email to