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 / May 2006

Tip: Looking for answers? Try searching our database.

add shape3D to scene

Thread view: 
matthiasvangorp - 26 Apr 2006 13:21 GMT
Hi,

I'm trying to add a Shape 3d to an object, but I get a
nullpointerexception.

i have a class displaypoints and a class simplebehavior. When
simplebehavior is called upon I would like to see the new shape appear.

the code for displaypoints is like this

public class DisplayPoints extends Applet {

   private  SimpleUniverse u;
   private Canvas3D c;
   private BranchGroup objRoot;

   public BranchGroup createSceneGraph() {

       objRoot = new BranchGroup();

       Transform3D rotate = new Transform3D();
       Transform3D tempRotate = new Transform3D();
       rotate.rotX(Math.PI / 7.0d);
       tempRotate.rotY(Math.PI / 4.0d);
       rotate.mul(tempRotate);
       TransformGroup objRotate = new TransformGroup(rotate);

       objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
       objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
       objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
       objRoot.setCapability(BranchGroup.ALLOW_DETACH);

       //add behavior
       SimpleBehavior myRotationBehavior = new
SimpleBehavior(objRotate);
       myRotationBehavior.setSchedulingBounds(new BoundingSphere());
       objRoot.addChild(myRotationBehavior);
       //end of adding behavior

       objRoot.addChild(objRotate);

      //then i add some shape3D's to the transformgroup
      // like this : objRotate.addChild(Shape3D);

      objRoot.compile();
      return objRoot;
      }

   public DisplayPoints() {
       setLayout(new BorderLayout());
       GraphicsConfiguration config =
          SimpleUniverse.getPreferredConfiguration();

       c = new Canvas3D(config);
       add("Center", c);

       // Create a simple scene and attach it to the virtual universe
       BranchGroup scene = createSceneGraph();

       u = new SimpleUniverse(c);
       // This will move the ViewPlatform back a bit so the
       // objects in the scene can be viewed.
       u.getViewingPlatform().setNominalViewingTransform();

       u.addBranchGraph(scene);

   }
} //so much for the class DisplayPoints

//the class simplebehavior looks like this.

public class SimpleBehavior extends Behavior {

       private BranchGroup objRoot;
       SimpleBehavior(BranchGroup objRoot){
               this.objRoot = objRoot;
       }

   //initialize the behavior
   // set initial wakeup condition
   // called when behavior becomes live
   public void initialize(){
       //set initial wakeup condition
       this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
   }

   //called by Java3D when appropriate stimulus occurs
   public void processStimulus(Enumeration criteria){

       //create another transformgroup
       TransformGroup anotherBranch = new TransformGroup();

        QuadArray qaEnvironment = new QuadArray(4,
QuadArray.COORDINATES);
        float coordsSquareEnvironment [] = {
                                      -0.2f, -0.4f, 0.4f, //de eerste
coordinaat van elk punt bepaalt waar
                                      -0.2f, 0.4f, 0.4f, //de "plaat"
zich bevindt op de environment-as
                                      -0.2f, 0.4f, -0.4f,
                                      -0.2f, -0.4f, -0.4f,
       };

       qaEnvironment.setCoordinates(0, coordsSquareEnvironment);
       Appearance appEnvironment = new Appearance();
       ColoringAttributes caEnvironment = new ColoringAttributes();
       caEnvironment.setColor(1.0f, 0.0f, 0.0f);
       appEnvironment.setColoringAttributes(caEnvironment);
       Shape3D squareEnvironment = new Shape3D(qaEnvironment,
appEnvironment);
       anotherBranch.addChild(squareEnvironment);
       objRoot.addChild(anotherBranch);

       this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
   }
}

Could someone please take a look at it and tell me what i'm doing
wrong? I've got the feeling it's something stupid, but I guess i'm even
more stupid 'cause i can't find it.

Thx a lot,

Matthias
Oliver Wong - 26 Apr 2006 19:50 GMT
> Hi,
>
> I'm trying to add a Shape 3d to an object, but I get a
> nullpointerexception.

[CODE SNIPPED]

Do you get a stack trace? If so, can you pinpoint on which line the
NullPointerException is occuring?

See http://tinyurl.com/kry2x or
http://riters.com/JINX/index.cgi/Suggestions_20for_20Asking_20Questions_20on_20N
ewsgroups#RepeatErrorsExactly

for more information.

   - Oliver
matthiasvangorp - 27 Apr 2006 13:08 GMT
Hi,

thx for the tip about the stack trace.

i get the following :

Exception occurred during Behavior execution:

javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup
node may be added

    at javax.media.j3d.Group.addChild(Unknown Source)

    at punten.SimpleBehavior.processStimulus(SimpleBehavior.java:86)

    at javax.media.j3d.BehaviorScheduler.doWork(Unknown Source)

    at javax.media.j3d.J3dThread.run(Unknown Source)

my processtimulus code in simplebehavior looks like this :

public void processStimulus(Enumeration criteria){

       //create another transformgroup
       TransformGroup anotherBranch = new TransformGroup();

        QuadArray qaEnvironment = new QuadArray(4,
QuadArray.COORDINATES);
        Canvas3D canvas3D = new
Canvas3D(SimpleUniverse.getPreferredConfiguration());
        float coordsSquareEnvironment [] = {
                                      -0.2f, -0.4f, 0.4f,
                                      -0.2f, 0.4f, 0.4f,
                                      -0.2f, 0.4f, -0.4f,
                                      -0.2f, -0.4f, -0.4f,
       };

       qaEnvironment.setCoordinates(0, coordsSquareEnvironment);
       Appearance appEnvironment = new Appearance();
       ColoringAttributes caEnvironment = new ColoringAttributes();
       caEnvironment.setColor(1.0f, 0.0f, 0.0f);
       appEnvironment.setColoringAttributes(caEnvironment);
       Shape3D squareEnvironment = new Shape3D(qaEnvironment,
appEnvironment);
       anotherBranch.addChild(squareEnvironment);
       objRoot.addChild(anotherBranch); //line 86

       this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
   }

When i change my code and first add the transformgroup to another
branchgroup before adding that branchgroup to the objRoot i get another
error. I'll give an example of the modified code below and the error
below that.

/************************changed code*****************/

       anotherBranch.addChild(squareEnvironment);
       BranchGroup bg = new BranchGroup();
       bg.addChild(anotherBranch);
       objRoot.addChild(bg);

/*************end of changed code***************/

this is the error.

# Problematic frame:
# C  [i81xgicd.dll+0x682e]
#
# An error report file with more information is saved as
hs_err_pid1996.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

the errorlog looks like this :

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0756682e, pid=1996,
tid=2164
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode,
sharing)
# Problematic frame:
# C  [i81xgicd.dll+0x682e]
#

---------------  T H R E A D  ---------------

Current thread (0x0307bbb0):  JavaThread "J3D-Renderer-1"
[_thread_in_native, id=2164]

siginfo: ExceptionCode=0xc0000005, reading address 0x00129534

Registers:
EAX=0x00128f68, EBX=0x6d82f270, ECX=0x0307b701, EDX=0x6d84c5d4
ESP=0x0795fa80, EBP=0x0795fb18, ESI=0x245bc7a0, EDI=0x0307bc70
EIP=0x0756682e, EFLAGS=0x00010202

Top of Stack: (sp=0x0795fa80)
0x0795fa80:   0352bc02 245bc7a0 0307bbb0 28075230
0x0795fa90:   28075230 00000000 035230b4 3f800000
0x0795faa0:   3f800000 03523822 03523828 0307bbb0
0x0795fab0:   28075000 28075000 00b364a2 0307bbb0
0x0795fac0:   28075000 0795fb6c 0795fad0 00b3826f
0x0795fad0:   0307bc70 0795fb6c 07551fb0 00000000
0x0795fae0:   00000000 00000000 3f800000 3f800000
0x0795faf0:   3f800000 0000018e 0000012a ffffffff

Instructions: (pc=0x0756682e)
0x0756681e:   cc cc 64 a1 18 00 00 00 03 05 f0 63 71 07 8b 00
0x0756682e:   ff a0 cc 05 00 00 cc cc cc cc cc cc cc cc cc cc

Stack: [0x07920000,0x07960000),  sp=0x0795fa80,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C  [i81xgicd.dll+0x682e]
j  javax.media.j3d.Canvas3D.setProjectionMatrix(J[D)V+0
j  javax.media.j3d.Renderer.doWork(J)V+5407
j  javax.media.j3d.J3dThread.run()V+19
v  ~StubRoutines::call_stub
V  [jvm.dll+0x845a9]
V  [jvm.dll+0xd9317]
V  [jvm.dll+0x8447a]
V  [jvm.dll+0x841d7]
V  [jvm.dll+0x9ed69]
V  [jvm.dll+0x109fe3]
V  [jvm.dll+0x109fb1]
C  [MSVCRT.dll+0x85bc]
C  [KERNEL32.dll+0xb388]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  javax.media.j3d.Canvas3D.setProjectionMatrix(J[D)V+0
j  javax.media.j3d.Renderer.doWork(J)V+5407
j  javax.media.j3d.J3dThread.run()V+19
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
 0x02fb1678 JavaThread "J3D-InputDeviceScheduler-1" [_thread_blocked,
id=2288]
 0x02faeb88 JavaThread "J3D-SoundSchedulerUpdateThread-1"
[_thread_blocked, id=2048]
 0x02fdcbd0 JavaThread "J3D-RenderStructureUpdateThread-1"
[_thread_blocked, id=496]
 0x03133140 JavaThread "J3D-BehaviorScheduler-1" [_thread_blocked,
id=1700]
 0x0334fda0 JavaThread "J3D-TransformStructureUpdateThread-1"
[_thread_blocked, id=1868]
 0x0301dc20 JavaThread
"J3D-RenderingEnvironmentStructureUpdateThread-1" [_thread_blocked,
id=2412]
 0x03387008 JavaThread "J3D-SoundStructureUpdateThread-1"
[_thread_blocked, id=2308]
 0x02fa1e40 JavaThread "J3D-GeometryStructureUpdateThread-1"
[_thread_blocked, id=2328]
 0x030f58e8 JavaThread "J3D-BehaviorStructureUpdateThread-1"
[_thread_blocked, id=1696]
 0x00738070 JavaThread "DestroyJavaVM" [_thread_blocked, id=1808]
 0x03145e48 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=2324]
 0x00ae1968 JavaThread "AWT-Shutdown" [_thread_blocked, id=2392]
=>0x0307bbb0 JavaThread "J3D-Renderer-1" [_thread_in_native, id=2164]
 0x03073410 JavaThread "J3D-MasterControl-1" [_thread_blocked,
id=2408]
 0x0301e230 JavaThread "J3D-TimerThread" [_thread_blocked, id=2420]
 0x00aece10 JavaThread "J3D-RenderingAttributesStructureUpdateThread"
[_thread_blocked, id=2316]
 0x00b04ed8 JavaThread "Java2D Disposer" daemon [_thread_blocked,
id=2340]
 0x00ac2d38 JavaThread "AWT-Windows" daemon [_thread_in_native,
id=2284]
 0x00ad18f0 JavaThread "Low Memory Detector" daemon [_thread_blocked,
id=2344]
 0x00738ce8 JavaThread "CompilerThread0" daemon [_thread_blocked,
id=1844]
 0x00acf968 JavaThread "Signal Dispatcher" daemon [_thread_blocked,
id=2364]
 0x00aa8e30 JavaThread "Finalizer" daemon [_thread_blocked, id=2312]
 0x00aa8130 JavaThread "Reference Handler" daemon [_thread_blocked,
id=2296]

Other Threads:
 0x00ac9128 VMThread [id=2120]
 0x00ad2e88 WatcherThread [id=2172]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation   total 576K, used 451K [0x24010000, 0x240b0000,
0x244f0000)
 eden space 512K,  75% used [0x24010000, 0x24070d60, 0x24090000)
 from space 64K, 100% used [0x24090000, 0x240a0000, 0x240a0000)
 to   space 64K,   0% used [0x240a0000, 0x240a0000, 0x240b0000)
tenured generation   total 2256K, used 2138K [0x244f0000, 0x24724000,
0x28010000)
  the space 2256K,  94% used [0x244f0000, 0x24706a00, 0x24706a00,
0x24724000)
compacting perm gen  total 8192K, used 3130K [0x28010000, 0x28810000,
0x2c010000)
  the space 8192K,  38% used [0x28010000, 0x2831ea78, 0x2831ec00,
0x28810000)
   ro space 8192K,  66% used [0x2c010000, 0x2c56bcc0, 0x2c56be00,
0x2c810000)
   rw space 12288K,  46% used [0x2c810000, 0x2cdb2060, 0x2cdb2200,
0x2d410000)

Dynamic libraries:
0x00400000 - 0x0040c000     C:\Program
Files\Java\jdk1.5.0_06\bin\javaw.exe
0x77f80000 - 0x77ffc000     C:\WINNT\system32\ntdll.dll
0x7c2d0000 - 0x7c335000     C:\WINNT\system32\ADVAPI32.dll
0x7c570000 - 0x7c623000     C:\WINNT\system32\KERNEL32.dll
0x77d30000 - 0x77da8000     C:\WINNT\system32\RPCRT4.dll
0x77e10000 - 0x77e79000     C:\WINNT\system32\USER32.dll
0x77f40000 - 0x77f7c000     C:\WINNT\system32\GDI32.dll
0x78000000 - 0x78045000     C:\WINNT\system32\MSVCRT.dll
0x6d6e0000 - 0x6d874000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\client\jvm.dll
0x77570000 - 0x775a0000     C:\WINNT\system32\WINMM.dll
0x69f00000 - 0x69f14000     C:\WINNT\system32\sxgb.dll
0x690a0000 - 0x690ab000     C:\WINNT\system32\PSAPI.DLL
0x10000000 - 0x10009000     C:\WINNT\system32\SXGBSYS.DLL
0x6d2f0000 - 0x6d2f8000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\hpi.dll
0x6d6b0000 - 0x6d6bc000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\verify.dll
0x6d370000 - 0x6d38d000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\java.dll
0x6d6d0000 - 0x6d6df000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\zip.dll
0x6d070000 - 0x6d1d7000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\awt.dll
0x77800000 - 0x7781e000     C:\WINNT\system32\WINSPOOL.DRV
0x76620000 - 0x76631000     C:\WINNT\system32\MPR.DLL
0x75e60000 - 0x75e7a000     C:\WINNT\system32\IMM32.dll
0x7ce20000 - 0x7cf0f000     C:\WINNT\system32\ole32.dll
0x51000000 - 0x5104a000     C:\WINNT\system32\ddraw.dll
0x728a0000 - 0x728a6000     C:\WINNT\system32\DCIMAN32.dll
0x6e420000 - 0x6e426000     C:\WINNT\system32\INDICDLL.dll
0x7cf30000 - 0x7d176000     C:\WINNT\system32\shell32.dll
0x70a70000 - 0x70ad6000     C:\WINNT\system32\SHLWAPI.dll
0x71710000 - 0x71794000     C:\WINNT\system32\COMCTL32.dll
0x6d2b0000 - 0x6d2ed000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\fontmanager.dll
0x6d530000 - 0x6d543000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\net.dll
0x75030000 - 0x75044000     C:\WINNT\system32\WS2_32.dll
0x75020000 - 0x75028000     C:\WINNT\system32\WS2HELP.DLL
0x6d550000 - 0x6d559000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\nio.dll
0x6d3d0000 - 0x6d3d6000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\jawt.dll
0x03520000 - 0x03546000     C:\Program
Files\Java\jdk1.5.0_06\jre\bin\j3dcore-ogl.dll
0x69510000 - 0x695d7000     C:\WINNT\system32\OPENGL32.dll
0x6fac0000 - 0x6fadf000     C:\WINNT\system32\GLU32.dll
0x07560000 - 0x07731000     C:\WINNT\system32\i81xgicd.dll
0x07960000 - 0x079bb000     C:\WINNT\system32\i81xGDEV.DLL

VM Arguments:
java_command: com.borland.jbuilder.runtime.applet.AppletTestbed 400 300
punten.DisplayPoints
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_06
CLASSPATH=.;C:\Program Files\Java\jdk1.5.0_06\jre\bin;C:\Program
Files\Java\jre1.5.0_06\lib\ext\QTJava.zip
PATH=C:\WINNT\system32;.;C:\Borland\JBuilder2005\bin;C:\Borland\JBuilder2005\jdk1.4\bin;C:\WINNT\SYSTEM32;C:\WINNT;C:\WINNT\SYSTEM32\WBEM;C:\PROGRAM
FILES\COMMON FILES\ADAPTEC
SHARED\SYSTEM;C:\DMI\WIN32\BIN;c:\matlab6p5\bin\win32;C:\Program
Files\MySQL\MySQL Server 4.1\bin;C:\Program
Files\QuickTime\QTSystem\;C:\Sun\AppServer\bin;C:\Borland\JBuilder2005\debug\sa;C:\Borland\JBuilder2005\lib
USERNAME=u0040810
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 11 Stepping 1, GenuineIntel

---------------  S Y S T E M  ---------------

OS: Windows 2000 Build 2195 Service Pack 4

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse

Memory: 4k page, physical 260112k(3652k free), swap 711068k(165104k
free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_06-b05) for windows-x86,
built on Nov 10 2005 11
Oliver Wong - 28 Apr 2006 20:15 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> at punten.SimpleBehavior.processStimulus(SimpleBehavior.java:86)

[snip]

>        TransformGroup anotherBranch = new TransformGroup();
[snip]
>        objRoot.addChild(anotherBranch); //line 86

   As the error message says, you have to add a BranchGroup, and not a
TransformGroup.

> When i change my code and first add the transformgroup to another
> branchgroup before adding that branchgroup to the objRoot i get another
[quoted text clipped - 21 lines]
> #   http://java.sun.com/webapps/bugreport/crash.jsp
> #

   Sounds like a bug in the JVM. You should submit a bug report to Sun as
the message says.

   - Oliver
Oliver Wong - 28 Apr 2006 20:16 GMT
>> # Problematic frame:
>> # C  [i81xgicd.dll+0x682e]
[quoted text clipped - 8 lines]
>    Sounds like a bug in the JVM. You should submit a bug report to Sun as
> the message says.

   Actually, since this is a problem with Java3D, you might want to submit
the bug report here:

https://java3d.dev.java.net/#Reporting_Issues

   Might be a good idea to read their "How to write a good bug report" at
https://javadesktop.dev.java.net/reportbug.html first.

   - Oliver
matthiasvangorp - 02 May 2006 10:10 GMT
I'll do that.

thx for the advice.


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.