why my cube.obj object doesn't appear when i run my
application see thiscode please and try to understand.
I've got this code from an example that works
correctly.
Thanks.
package gacivbrowser;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.loaders.objectfile.*;
import com.sun.j3d.loaders.Scene;
public class fraBrowser extends JFrame
{
//********************
ATRIBUTOS**********************************************
JPanel contentPane;
//******************** M�TODOS
***********************************************
//----------------------------------------------------------------------------
//Construtor 1
public fraBrowser()
{
try
{ jbInit(); }
catch(Exception e)
{ e.printStackTrace();}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//Construtor 2 - Monta o Browser com seus
componentes b�sicos
public fraBrowser(int intAltura, int intLargura)
{
//JPanel
//contentPane = (JPanel) this.getContentPane();
//contentPane.setLayout(null);
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
Color cor = new Color(0);
//Title our frame and set its size.
this.setTitle("GaCIV Browser");
//Define a altura e largura do browser
this.setSize(intAltura,intLargura);
//Cria o Canvas3D
GraphicsConfiguration x;
Canvas3D myCanvas3D = new Canvas3D(null);
contentPane.add("Center",myCanvas3D);
//Turn on the visibility of our frame.
setVisible(true);
//Dispose the Frame
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose(); System.exit(0); } }
);
//Construindo uma Scene Graph com seu View Branch e
seu Content Branch
//View myView = constructView(myCanvas3D);
//Locale myLocale = constructViewBranch(myView);
//constructContentBranch(myLocale);
SimpleUniverse myUniverse = new
SimpleUniverse(myCanvas3D);
BranchGroup contentBranchGroup =
constructContentBranch();
myUniverse.addBranchGraph(contentBranchGroup);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//M�todo Principal
public static void main(String args[])
{
new fraBrowser();
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//Construindo a View
private View constructView(Canvas3D myCanvas3D)
{
View myView = new View();
myView.addCanvas3D(myCanvas3D);
myView.setPhysicalBody(new PhysicalBody());
myView.setPhysicalEnvironment(new
PhysicalEnvironment());
return(myView);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//Construindo o View Branch
private Locale constructViewBranch(View myView)
{
// 1 - Necessary coordinate systems
(VirtualUniverse, Locale)
// 2 - Container nodes (BranchGroup,
TransformGroup)
// 3 - Platform which determines our viewing
position and direction (ViewPlatform).
VirtualUniverse myUniverse = new VirtualUniverse();
Locale myLocale = new Locale(myUniverse);
BranchGroup myBranchGroup = new BranchGroup();
TransformGroup myTransformGroup = new
TransformGroup();
ViewPlatform myViewPlatform = new ViewPlatform();
// 1 - Insert the View Platform -> Transform
Group,
// 2 - Insert the Transform group -> Branch Group,
and the branch
// 3 - Insert the Branch Group -> Locale's
Branch Graph portion of the scene graph.
myTransformGroup.addChild(myViewPlatform);
myBranchGroup.addChild(myTransformGroup);
myLocale.addBranchGraph(myBranchGroup);
//Attach our View to the View Platform and return a
reference to our new universe
myView.attachViewPlatform(myViewPlatform);
return(myLocale);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//Construindo um ContentBranch
private BranchGroup constructContentBranch()
{
//1 - Create a regular 2D font
//2 - Create 3D font, 3D text, and 3D shape
//Font myFont = new
Font("TimesRoman",Font.PLAIN,4);
//Font3D myFont3D = new Font3D(myFont,new
FontExtrusion());
//Text3D myText3D = new Text3D(myFont3D, "Gaciv");
//Shape3D myShape3D = new Shape3D(myText3D, new
Appearance());
//Shape3D myCube = new ColorCube();
//Created a new branch group and transform group
to hold our content
//BranchGroup contentBranchGroup = new
BranchGroup();
//Transform3D myTransform3D = new Transform3D();
//myTransform3D.setScale(0.1);
//TransformGroup contentTransformGroup = new
TransformGroup(myTransform3D);
//contentTransformGroup.addChild(myShape3D);
////myTransform3D.setTranslation(new
Vector3f(-1.0f,0.0f,-4.0f));
////myTransform3D.setScale(0.1);
////Transform3D tempTransform3D = new
Transform3D();
////tempTransform3D.rotY(Math.PI/4.0d);
////myTransform3D.mul(tempTransform3D);
////TransformGroup contentTransformGroup = new
TransformGroup(myTransform3D);
////Add our child nodes and insert the branch
group into scene graph.
////contentTransformGroup.addChild(myShape3D);
////contentBranchGroup.addChild(contentTransformGroup);
//// myLocale.addBranchGraph(contentBranchGroup);
////myTransform3D.setIdentity();
////myTransform3D.setTranslation(new
Vector3f(-0.5f,-0.5f,-2.3f));
////myTransform3D.setScale(0.1);
////TransformGroup cubeTransformGroup = new
TransformGroup(myTransform3D);
////cubeTransformGroup.addChild(myCube);
////contentBranchGroup.addChild(cubeTransformGroup);
////return(contentBranchGroup);
//Alpha myAlpha = new Alpha();
//myAlpha.setIncreasingAlphaDuration(10000);
//myAlpha.setLoopCount(-1);
//RotationInterpolator myRotater = new
RotationInterpolator(myAlpha,contentTransformGroup);
//myRotater.setAxisOfRotation(myTransform3D);
//myRotater.setMinimumAngle(0.0f);
//myRotater.setMaximumAngle((float)(Math.PI*0.5));
//BoundingSphere myBounds = new BoundingSphere();
//myRotater.setSchedulingBounds(myBounds);
//contentTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
//contentTransformGroup.addChild(myRotater);
//contentBranchGroup.addChild(contentTransformGroup);
//myTransform3D.setTranslation(new
Vector3f(-0.5f,-0.5f,-2.3f));
//myTransform3D.setScale(0.1);
//TransformGroup cubeTransformGroup = new
TransformGroup(myTransform3D);
//cubeTransformGroup.addChild(myCube);
//contentBranchGroup.addChild(cubeTransformGroup);
//return(contentBranchGroup);
ObjectFile myOBJ = new ObjectFile();
Scene myOBJScene = null;
//Attempt to load in the OBJ content using
ObjectFile.
try {
myOBJScene =
myOBJ.load("c:\\Teste_JAVA3D\\GACIVBrowser\\minimart.obj");
}
catch (Exception e)
{
System.out.println("Could not open OBJ
file...exiting");
//System.exit(1);
}
//Construct and return branch group containing
our OBJ scene.
BranchGroup contentBranchGroup = new
BranchGroup();
contentBranchGroup.addChild(myOBJScene.getSceneGroup());
return(contentBranchGroup);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
private void jbInit() throws Exception
{
contentPane.setBackground(Color.black);
this.getContentPane().setBackground(Color.black);
}
//----------------------------------------------------------------------------
}
//-End of class-----------------------------------------------------------------
_______________________________________________________________________________________________
Yahoo! Empregos
O trabalho dos seus sonhos pode estar aqui. Cadastre-se hoje mesmo no Yahoo! Empregos
e tenha acesso a milhares de vagas abertas!
http://br.empregos.yahoo.com/
===========================================================================
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".