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