first of all i'm so so so sorry,Florin and Gilson,
i made mistake,i wanted to send to whole group my
messages but i sent emails by mistake to 2 u who
helped me with their ideas/code..sorry to disturb u
:(:(

its what i did up to now,its code of my 3DWorld
class..i created everything here..if anyone wants i
can send all my package to have a look how it
works,how it looks like..



package ver0_0;


  // Java core packages
        import java.awt.event.*;
        import java.awt.*;
        import java.net.*;

 // Java extension packages
        import javax.swing.event.*;
        import javax.media.j3d.*;
        import javax.vecmath.*;

 // Java 3D utility packages
 //Importing Java 3D utility packages that simplify
scene creation.
        import com.sun.j3d.utils.universe.*;
        import com.sun.j3d.utils.image.*;
        import com.sun.j3d.utils.geometry.*;
        import com.sun.j3d.utils.behaviors.mouse.*;

        //Canvas3D is a java.awt.Canvas subclass used for 3D
rendering
 public class Java3DWorld extends Canvas3D {
        private Appearance appearance; // 3D object's
appearance
        private Cylinder shape;  // 3D object to manipulate
        private static Color3f lightColor;  // Light color
        private Light ambientLight;  // ambient scene
lighting
        private static Light directionalLight; //directional
light
        private Material material; // 3D objects color object
        private SimpleUniverse simpleUniverse; // 3D scene
environment
        private static TextureLoader textureLoader; // 3D
object's texture

        // holds 3D transformation information
        private TransformGroup transformGroup;

        private String imageName; // texture-image file name

        // Java3DWorld constructor
        public Java3DWorld( String imageFileName )
        {
           super( SimpleUniverse.getPreferredConfiguration()
);

           imageName = imageFileName;

           // create SimpleUniverse (3D Graphics environment)
           simpleUniverse = new SimpleUniverse( this );
//SimpleUniverse creates a Java 3D scene and
encapsulates
                                                                                       
                 //all objects in virtual universe and
viewing platform

           // set default view point and direction
           ViewingPlatform viewPlatform =
                  simpleUniverse.getViewingPlatform();  //Configure
viewing distance (length between viewer and canvas)
                                                                                       
         //for 3D scene

           viewPlatform.setNominalViewingTransform();

           // create 3D scene
           BranchGroup branchGroup = createScene();

           // attach BranchGroup to SimpleUniverse
           simpleUniverse.addBranchGraph( branchGroup );

        } // end Java3DWorld constructor

        // create 3D scene
        public BranchGroup createScene()
        {
           BranchGroup scene = new BranchGroup();
//BranchGroup is the root node of a scene graph in a
Java 3D scene

           ////TransformGroup specifies transformational
behavior,
           //such as rotation, scaling and translation.
           // initialize TransformGroup
           transformGroup = new TransformGroup();
       //Capability bits are integer flags that
specify whether a given object should allow
           //its properties to be read or written during
execution.
           // set TransformGroup's READ and WRITE permission
           transformGroup.setCapability(
                  TransformGroup.ALLOW_TRANSFORM_READ );

           transformGroup.setCapability(
                  TransformGroup.ALLOW_TRANSFORM_WRITE );

           // add TransformGroup to BranchGroup
           scene.addChild( transformGroup );

           //BoundingSphere creates bounding volume, which
specifies the volume in which Lights
           //and Behaviors affect geometry in the scene.
          // create BoundingSphere
           BoundingSphere bounds = new BoundingSphere(
                  new Point3d( 0.0f, 0.0f, 0.0f ), 100.0 );

           appearance = new Appearance(); // create object
appearance
           material = new Material(); // create texture
matieral
           appearance.setMaterial( material );

           String rgb = new String( "RGB" );

           // load texture for scene object
           textureLoader = new TextureLoader(
                  Java3DWorld.class.getResource( imageName ), rgb,
this ); //Load texture for texture mapping

           // set capability bits for enabling texture
           textureLoader.getTexture().setCapability(
                  Texture.ALLOW_ENABLE_WRITE );

          // initial texture will not show
          textureLoader.getTexture().setEnable( false );

          // set object's texture
         // appearance.setTexture( textureLoader.getTexture()
);

          // create object geometry
          //Cylinder shape = new Cylinder( 0.3f, 1.0f,
          //Cylinder.GENERATE_NORMALS |
Cylinder.GENERATE_TEXTURE_COORDS,  //Create Cylinder
to rotate, scale and translate
                // appearance );

                Cylinder shape = new Cylinder(0.3f,1.0f);
                Shape3D wireframedCylinder =
shape.getShape(Cylinder.BODY);
                Appearance appearance = new Appearance();
                PolygonAttributes polAttr = new PolygonAttributes();

polAttr.setPolygonMode(PolygonAttributes.POLYGON_LINE);
                appearance.setPolygonAttributes(polAttr);
                wireframedCylinder.setAppearance(appearance);



        // add geometry to TransformGroup


                transformGroup.addChild( shape );

          // initialize Ambient lighting
         ambientLight = new AmbientLight();  //AmbientLight
is a uniform light source that illuminates all objects
within its boundary
          ambientLight.setInfluencingBounds( bounds );

          // initialize directionalLight
         directionalLight = new DirectionalLight();
//DirectionalLight is a light source that travels
between two points


          lightColor = new Color3f(); // initialize light
color

          // set initial DirectionalLight color
          directionalLight.setColor( lightColor );

          // set capability bits to allow DirectionalLight's
          // Color and Direction to be changed
          directionalLight.setCapability(
                 DirectionalLight.ALLOW_DIRECTION_WRITE );

          directionalLight.setCapability(
                 DirectionalLight.ALLOW_DIRECTION_READ );

          directionalLight.setCapability(
                 DirectionalLight.ALLOW_COLOR_WRITE );

          directionalLight.setCapability(
                 DirectionalLight.ALLOW_COLOR_READ );

          directionalLight.setInfluencingBounds( bounds );

          // add light nodes to BranchGroup
          scene.addChild( ambientLight );
          scene.addChild( directionalLight );

      //Create behavior that controls rotation of the
Cylinder via the mouse.
          // initialize rotation behavior
          MouseRotate rotateBehavior = new MouseRotate();
          rotateBehavior.setTransformGroup( transformGroup );
          rotateBehavior.setSchedulingBounds( bounds );

      //Create behavior that controls translation of
the Cylinder via the mouse.
          // initialize translation behavior
         MouseTranslate translateBehavior = new
MouseTranslate();
          translateBehavior.setTransformGroup( transformGroup
);
          translateBehavior.setSchedulingBounds(
                 new BoundingBox( new Point3d( -1.0f, -1.0f, -1.0f
),
                 new Point3d( 1.0f, 1.0f, 1.0f ) ) );

          //Create behavior that controls scalability of the
Cylinder via the mouse
          // initialize scaling behavior
          MouseZoom scaleBehavior = new MouseZoom();
          scaleBehavior.setTransformGroup( transformGroup );

          scaleBehavior.setSchedulingBounds( bounds );

          // add behaviors to BranchGroup
          scene.addChild( scaleBehavior );
          scene.addChild( rotateBehavior );
          scene.addChild( translateBehavior );

          scene.compile(); //Compiling a BranchGroup informs
the Java 3D engine to optimize rendering the scene
                                          //using the capability bits set by the
developer

          return scene;

   } // end method createScene

   // change DirectionLight color
   public static void changeColor( Color color )
   {
          lightColor.set( color );
          directionalLight.setColor( lightColor );
   }

   // change geometry surface to textured imag color
   public static void updateTexture( boolean
textureValue )
   {
          textureLoader.getTexture().setEnable( textureValue
);
   }

   // change image used for texture
   public void setImageName( String imageFileName )
   {
          imageName = imageFileName;
   }

   // get image file name
   public String getImageName()
   {
          return imageName;
   }

        // return preferred dimensions of Container
        public Dimension getPreferredSize()
        {
           return new Dimension( 500, 500 );
        }

        // return minimum size of Container
        public Dimension getMinimumSize()
        {
           return getPreferredSize();
        }
}






__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

===========================================================================
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".

Reply via email to