|
Hi,
I want to rotate a cube in pure immediate mode with/out using
SimpleUniverse. My init() function sets up what I believe to be need for
my virtual universe, but the call to setModelTransform() throws a
NullPointerException. This does work if I use SimpleUniverse, so I guess
I'm not seting up something right with my virtual universe. Can anyone
tell me what it is? Or point me to an example of PureImmediate rendering
with out the use of SimpleUniverse class?
Thanks
Demetrius
public class ImmediateNonSimpleUniverse extends Applet
implements Runnable
{ Thread t = null; VirtualUniverse universe = null; View view = null; Canvas3D canvas = null; NonPrimativeBox Box = null; GraphicsContext3D gc = null; long nLastRunTime = 0; long nStartRunTime = 0; int nCounter = 0; boolean bIncrease = true; public void run()
{ nLastRunTime = nStartRunTime = System.currentTimeMillis(); while(true) { long nCurrent = System.currentTimeMillis(); long elapseTime = nCurrent - nLastRunTime; gc = canvas.getGraphicsContext3D(); gc.clear(); Transform3D t3d = new Transform3D(); t3d.set(0.1,new Vector3d(0,0,-0.5)); view.setVpcToEc(t3d); t3d.set(0.1, new Vector3d(-1,0,0)); gc.multiplyModelTransform(t3d); gc.setModelTransform(t3d); <-----------------------This is the line that throws a NullPointerException gc.draw(Box); t3d.set(0.1, new Vector3d(1,0,0)); gc.setModelTransform(t3d); gc.draw(Box); canvas.swap(); Thread.yield(); } } public void init()
{ setLayout(new BorderLayout()); canvas = new Canvas3D(null); canvas.stopRenderer(); add("Center", canvas); /* // Create a simple scene and attach it to the virtual universe SimpleUniverse u = new SimpleUniverse(canvas); // This will move the ViewPlatform back a bit so
the
// objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); */ canvas = new Canvas3D(null); canvas.setDoubleBufferEnable(true); canvas.stopRenderer(); add("Center",canvas); universe = new VirtualUniverse(); view = new View(); view.addCanvas3D(canvas); view.setPhysicalBody(new PhysicalBody()); view.setPhysicalEnvironment(new PhysicalEnvironment()); ViewPlatform vp = new ViewPlatform(); view.attachViewPlatform(vp); view.setCompatibilityModeEnable(true); Locale locale = new Locale(universe); Box = new NonPrimativeBox(1,1,1,new
Appearance());
gc = canvas.getGraphicsContext3D(); Thread t = new
Thread(this);
t.start(); } }
|
- [JAVA3D] Philipp Gerhold
- Re: [JAVA3D] Olivier fillon
- Re: [JAVA3D] Nazrul
- [JAVA3D] Matthew Flagg
- [JAVA3D] Chen Lu
- Re: [JAVA3D] Mojtaba Hosseini
- [JAVA3D] detatch branchgroup Chen Lu
- [JAVA3D] Andrei Karii
- [JAVA3D] Vincent Erickson
- Re: [JAVA3D] Olivier fillon
- [JAVA3D] Demetrius
- [JAVA3D] Leonid Perlov
- Re: [JAVA3D] i�igo recio
- [JAVA3D] Yiannis Tenediotis
- [JAVA3D] Sterling Wright
- Re: [JAVA3D] Ahmed Shakil
- [JAVA3D] Tim Pijpops
- [JAVA3D] the Cubist
- Re: [JAVA3D] Pondrom, Pierre L
- [JAVA3D] Michael Gene Anderson
- [JAVA3D] BROADBEAR MICHAEL W. (FIN1MWB)
