Skip to main content

Urgent - Java3d stops mysteriously

7 replies [Last post]
yomeng
Offline
Joined: 2004-06-21
Points: 0

Hi, I am doing a simple game and below is the function to remove a character's branch whenever he gets killed:

-------------------------------------------------------
public boolean removeCharacter(String _dataTag) {
int charBranchLength = charBranch.numChildren();
for(int i = 0; i < charBranchLength; i++) {

System.out.println(" A ");
BranchGroup targetBranch = (BranchGroup) charBranch.getChild(i);
System.out.println(" B ");

if(targetBranch.getUserData().equals(_dataTag)) {

System.out.println(" C ");
charBranch.removeChild(i);
System.out.println("D ");
return true;
}

}
System.out.println("E");
return false;
}
-------------------------------------------------------

As you can see there are several printouts (A to E). Usually, it runs from "A" to "D" and returns true to indicate it has remove the child successfully. But then, sometimes the method stops at "C" and nvr gets to print "D". So I guess it got stucked at this line:

charBranch.removeChild(i);

Then, if i minimize the JFrame containing the J3D, the canvas turns grey.

I am not sure if any threads would disrupt the method. But there is no thread that deletes the class that holds that method.

Please help. Thank you =|

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
yomeng
Offline
Joined: 2004-06-21
Points: 0

Sorry for doing this, but I really need some help urgently so I got to keep this thread at the top of the forum.

please help...

yomeng
Offline
Joined: 2004-06-21
Points: 0

i got this info from some forum

"4355332 Require Thread safe removeChild in BranchGroup"

is this bug/problem still present in java3d 1.3.1? is there any workaround beside synchronzing threads?

yomeng
Offline
Joined: 2004-06-21
Points: 0

i found this link that says the bug is solved

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4355332

but i did wat they said, changed all removeChild(int i) to removeChild(node n) but i still get j3d freezing quite often... i suppose getChild(int i) is safe rite?

yomeng
Offline
Joined: 2004-06-21
Points: 0

Jus to add on something but I am not sure if it is in anyway related.

I remember the times when I see people complaining about Java3D using 100% cpu usage and I experienced this before.

But for now, my game doesnt require 100% cpu usage anymore. I can run more than 2 Java3D programs with cpu usage around 20%. I am not sure what I did that resulted in the change nor do I remember when this started happening.

I am jus wondering if there is anything wrong with my Java3D or is the problem mentioned some software or hardware prob.

yomeng
Offline
Joined: 2004-06-21
Points: 0

please help...

miles
Offline
Joined: 2004-06-05
Points: 0

Only two things that come to mind offhand:
- Check the console for exceptions.
- Make sure the BranchGroup had ALLOW_DETACH capability enabled before you compiled it (assuming you compiled it.)

yomeng
Offline
Joined: 2004-06-21
Points: 0

thanks for replying...

however...
1. there is no exception reported, even with I wrap the try and catch statements around that line.

2. I already set the extend/write/read capability and the branch is not compiled. As for the branch to be detached, I already set the detach capability

Is there any way to track what is the flow of threads? I am using JBuilder X Personal but the debugger doesnt seem to be useful