Home
/
JavaForum
/
Swing + AWT
Infos
|
Features
|
Gold-Edition
|
Kundenservice
java
Übersicht
Forum
-
Beginner
-
Java allgemein
-
JDBC
-
JNI
-
Networking
-
Online-Ressourcen
-
Swing + AWT
-
XML
-
Meckerecke
Mitglieder
LOGIN
User oder E-Mail
Passwort
·
Passwort vergessen
·
Kostenlos anmelden
Information
Demo
Features
Im Vergleich
Anmeldung
SUCHE
Beiträge, Foren oder Verfasser finden:
Kundenservice
Impressum
Datenschutz
AGB
Status
4.884 User online
0 User eingeloggt
Beiträge
Beginner
Java allgemein
JDBC
JNI
Networking
Online-Ressourcen
Swing + AWT
XML
Meckerecke
Antworten
Neuer Beitrag
Gesamtdarstellung
Detaildarstellung
Einzeldarstellung
Threaddarstellung
Beitrag 66 von 1460 (5%)
Autor
M.ouheddou
Datum
06.11.01, 19:42
Betreff
java3D
Hallo Leute
In meine folgende Programm werden Cylinder so programmiert, das sie in dreidimentional auf Bildschirm escheinbar können.
Aber ist nicht der Fall. woran liegt weiß ich nicht. kann jemand diese Fehler aufheben, ich wurde dafür sehr dankbar.
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.geometry.*;
import javax.vecmath.*;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.util.Enumeration;
import com.sun.j3d.utils.behaviors.keyboard.*;
// BillboardApp renders a simple landscape with billboard //animated trees
public class java3D extends Applet {
public BranchGroup createSceneGraph(SimpleUniverse su) {
// Create the root of the branch graph
TransformGroup vpTrans = null;
BranchGroup objRoot = new BranchGroup();
Vector3f translate = new Vector3f();
Transform3D T3D = new Transform3D();
TransformGroup TGT = null;
TransformGroup TGR = null;
Billboard billboard = null;
BoundingSphere bSphere = new BoundingSphere();
BoundingSphere bounds;
bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),400.0);
Vector3f ldir = new Vector3f(1.0F,1.0F,-1.0F);
Color3f lcouldl = new Color3f(1.0F,1.0F,1.0F);
DirectionalLight dl = new DirectionalLight(lcouldl,ldir);
dl.setInfluencingBounds(bounds);
objRoot.addChild(dl);
Color3f lcoulal = new Color3f(1.F,1.0F,1.0F);
AmbientLight al = new AmbientLight(lcoulal);
al.setInfluencingBounds(bounds);
objRoot.addChild(al);
Appearance app = new Appearance();
Material m = new Material();
m.setDiffuseColor(1.0f,0.0f,0.0f);
m.setAmbientColor(0.0f,1.0f,0.0f);
app.setMaterial(m);
Cylinder cylinder = new Cylinder(0.1f,1.0f,app);
// objRoot.addChild(createLand());
SharedGroup share = new SharedGroup();
//Cylinder cylinder = createCylinder();
// share.addChild(createTree());
share.addChild(cylinder);
float[][] position = {{ 0.05f, -0.1f, 2.0f},
{ 0.0f, -0.5f, 0.0f},
{ -0.750f, -0.1f, 0.0f},
{ -0.8f, -0.05f, 0.0f},
{ 1.10f, 0.0f, 0.0f},
{-1.70f, 0.3f, 0.0f},
{-1.70f, 0.3f, 0.0f},
{ -0.80f, 1.1f, 0.0f}};
for (int i = 0; i < position.length; i++){
translate.set(position[i]);
T3D.setTranslation(translate);
TGT = new TransformGroup(T3D);
TGR = new TransformGroup();
TGR.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
billboard = new Billboard(TGR);
billboard.setSchedulingBounds(bSphere);
billboard.setAlignmentMode(Billboard.ROTATE_ABOUT_POINT);
objRoot.addChild(TGT);
objRoot.addChild(billboard);
TGT.addChild(TGR);
// Cylinder cylinder =createCylinder();
TGR.addChild(new Link(share));
}
vpTrans = su.getViewingPlatform().getViewPlatformTransform();
translate.set( 0.0f, 1.0f,8.0f);
T3D.setTranslation(translate);
vpTrans.setTransform(T3D);
KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(),10000.0));
objRoot.addChild(keyNavBeh);
Background background = new Background();
background.setColor(0.3f, 0.3f, 1.0f);
background.setApplicationBounds(new BoundingSphere());
objRoot.addChild(background);
// Let Java 3D perform optimizations on thisscene //graph.
objRoot.compile();
return objRoot;
} // end of CreateSceneGraph method ofBillboardApp
public java3D() {
setLayout(new BorderLayout());
Canvas3D canvas3D = new Canvas3D(null);
add("Center", canvas3D);
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
BranchGroup scene = createSceneGraph(simpleU);
simpleU.addBranchGraph(scene);
} // Ende von konstruktor java3D()
public static void main(String[] args)
{
Frame frame = new MainFrame(new java3D(),800,700);
} // end of main (method of BillboardApp)
} // Ende von java3D
Diskussionsverlauf:
java3D
Hinweis (Re: java3D)
Re: java3D
Auf diesen Beitrag antworten
Neuen Beitrag verfassen
Impressum
·
Datenschutz
·
AGB
·
Infos
·
Presse
Ein modernes Forum:
teamturn.com