Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / September 2003

Tip: Looking for answers? Try searching our database.

Very newbie question!

Thread view: 
hinoy - 15 Sep 2003 23:57 GMT
Why doesn't it work?

       I can' t see the triangles !

###############################################################################

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Event;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.Cone;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloJava3Da extends Applet{
 
       public HelloJava3Da(){
       
               setLayout(new BorderLayout());
               Canvas3D canvas3D=new Canvas3D(null);
               add("Center",canvas3D);
               
               BranchGroup scene=createSceneGraph();
               scene.compile();
               
               SimpleUniverse simpleU=new SimpleUniverse(canvas3D);
               
               simpleU.getViewingPlatform().setNominalViewingTransform();
               
               simpleU.addBranchGraph(scene);
               }
               
       public static void main(String[] args){
               
               Frame frame=new MainFrame(new HelloJava3Da(), 256, 256);
       }
       
               
       public BranchGroup createSceneGraph(){
       
               BranchGroup objroot=new BranchGroup();
                               
               TriangleArray punta=new TriangleArray(6,TriangleArray.COORDINATES);
               
               Point3f uno=new Point3f(-0.4f,0.0f,0.4f);
               Point3f due=new Point3f(0.4f,0.0f,0.4f);
               Point3f tre=new Point3f(0.4f,0.0f,-0.4f);
               Point3f quattro=new Point3f(-0.4f,0.0f,-0.4f);
               Point3f cinque=new Point3f(-0.4f,0.0f,0.4f);
               Point3f sei=new Point3f(0.0f,0.4f,0.0f);
               
               punta.setCoordinate(0,uno);
               punta.setCoordinate(1,due);
               punta.setCoordinate(2,tre);
               punta.setCoordinate(3,quattro);
               punta.setCoordinate(4,cinque);
               punta.setCoordinate(5,sei);
               
               Shape3D p=new Shape3D();
               
               p.setGeometry(punta);
               
               Appearance aa=new Appearance();
               
               p.setAppearance(aa);
               
               objroot.addChild(p);
                       
               return objroot;
               }
               }
       
               
#################################################################################################

                                                                       THANKS!
--
P. Flavin - 16 Sep 2003 15:39 GMT
 "Hello World" programs and files are intro programs for newbies
 ---------------------- and Web3d.org & Java3d have their versions.

Sun Loaders Work where 'new' ( Yumetech ) Loaders Fail
------------------------------------------------------
| Problem files with the "new" X3D Loaders often are
| NO PROBLEM with the old, reliable Sun VRML Loaders.
[quoted text clipped - 30 lines]
| |
| |   Why ... is it still not working properly ?

http://archives.java.sun.com/cgi-bin/wa?A2=ind0301&L=java3d-interest&P=R18442

|  Use what works best, the Sun's VRML Loaders have
| been working reliabably ( not perfectly ) since
[quoted text clipped - 4 lines]
| Web3d.org's  __ " Hello World " __  VRML file Works Great
| ----------------------------------------------------------
  http://www.frontiernet.net/~imaging/vrml_loaders_working.html
  http://www.frontiernet.net/~imaging/sc_web3d_org_hello_world.jpg


http://archives.java.sun.com/cgi-bin/wa?A2=ind0301&L=java3d-interest&P)553

 http://www.web3d.org/TaskGroups/x3d/translation/examples/HelloWorld.html
http://www.web3d.org/TaskGroups/x3d/translation/examples/HelloWorld.wrl

| The AppearanceExplorer shows the attributes
| which are included in an Appearance object.
[quoted text clipped - 7 lines]
| The source to these programs is included in the zip
| file available here.

 http://web3dbooks.com/java3d/jumpstart/Java3DExplorer.html
 http://web3dbooks.com/java3d/jumpstart/AppearanceExplorer.html
 http://web3dbooks.com/java3d/jumpstart/J3DJumpStart.zip

 |
 | Why doesn't it work?
 |
 |   I can' t see the triangles !
 |
http://groups.google.com/groups?group=comp.lang.java.3d&selm=Otr9b.319606%24Ny5.
10073629%40twister2.libero.it


  If it's too dark to see, turn on some lights.

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Event;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.Cone;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloJava3Da extends Applet{

  public HelloJava3Da(){

      setLayout(new BorderLayout());
      Canvas3D canvas3D=new Canvas3D(null);
      add("Center",canvas3D);

      BranchGroup scene=createSceneGraph();
      scene.compile();

      SimpleUniverse     simpleU = new SimpleUniverse(canvas3D);

                         simpleU.getViewingPlatform(
            ).setNominalViewingTransform();

                 simpleU.addBranchGraph(scene);
  }

  public static void main(String[] args){

        Frame frame=new MainFrame(new HelloJava3Da(), 256, 256);
  }

  public BranchGroup createSceneGraph(){

      BranchGroup objroot=new BranchGroup();

                                                    // add light
    Color3f whiteLight = new Color3f( 1f, 1f, 1f );
        AmbientLight ambientLight = new AmbientLight( whiteLight  );

        objroot.addChild( ambientLight );                               

        TriangleArray punta = new
                    TriangleArray(6,TriangleArray.COORDINATES);

       Point3f uno        =new Point3f( -0.4f,0.0f,0.4f  );
       Point3f due        =new Point3f(  0.4f,0.0f,0.4f  );
       Point3f tre        =new Point3f(  0.4f,0.0f,-0.4f );
       Point3f quattro    =new Point3f( -0.4f,0.0f,-0.4f );
       Point3f cinque    =new Point3f( -0.4f,0.0f,0.4f  );
       Point3f sei        =new Point3f(  0.0f,0.4f,0.0f  );

           punta.setCoordinate(0,uno);
        punta.setCoordinate(1,due);
        punta.setCoordinate(2,tre);
        punta.setCoordinate(3,quattro);
        punta.setCoordinate(4,cinque);
        punta.setCoordinate(5,sei);

        Shape3D p=new Shape3D();

                p.setGeometry(punta);

                Appearance aa=new Appearance();

                                            // add polygon attributes
                Color3f greenColor = new Color3f( 0f, 1f, 0f );

                ColoringAttributes ca = new ColoringAttributes( );
                ca.setColor( greenColor );

        PolygonAttributes  pa = new PolygonAttributes( );
                pa.setPolygonMode( pa.POLYGON_LINE );
                pa.setCullFace(    pa.CULL_NONE );

        aa.setColoringAttributes( ca );
                 aa.setPolygonAttributes(  pa );

                p.setAppearance(aa);

                objroot.addChild(p);

                return objroot;
                }

   }            //___ end ____

Demos with VRML & Human Animation
---------------------------------
http://www.frontiernet.net/~imaging/sourcecode/Human.java
http://www.frontiernet.net/~imaging/sourcecode/HumanWithControlledArm_VRML.java

http://www.frontiernet.net/~imaging/sourcecode/VrmlPickingTest.java

 -- Paul, Java Developer & Web Animator
 --------------------------------------
Imaging the Imagined: Modeling with Math & a Keyboard
P. Flavin - 16 Sep 2003 16:13 GMT
hinoy wrote in thread:  Very newbie question!

> Why doesn't it work?
>
>         I can' t see the triangles !

http://news.ege.edu.tr/article.php?id=1538&group=comp.lang.java.3d

full reply ( with full program ) in thread:

Hello World ! : Getting Started: Web3d.org's HelloWorld ... Java3d
------------------------------------------------------------------

|  If it's too dark to see, turn on some lights.

    Color3f     greenColor = new Color3f( 0f, 1f, 0f );

    ColoringAttributes     ca = new ColoringAttributes( );

                ca.setColor(     greenColor );

    PolygonAttributes  pa = new PolygonAttributes( );

                 pa.setPolygonMode( pa.POLYGON_LINE );
                 pa.setCullFace(    pa.CULL_NONE    );

        aa.setColoringAttributes( ca );
                 aa.setPolygonAttributes(  pa );

                         p.setAppearance( aa );

                 objroot.addChild( p );

http://news.ege.edu.tr/article.php?id=1539&group=comp.lang.java.3d

VRML & Java are portable and support 3d animation on the web.

Web3d.org's  __ " Hello World " __  VRML file Works Great
----------------------------------------------------------
http://www.frontiernet.net/~imaging/vrml_loaders_working.html

-- Paul, Java Developer & Web Animator
--------------------------------------
Imaging the Imagined: Modeling with Math & a Keyboard


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.