Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java3D and frame updates  (Read 3768 times)
0 Members and 1 Guest are viewing this topic.
Offline King_of_Men

Senior Newbie




EUII player


« Posted 2005-02-27 16:02:00 »

I'm just starting to learn Java3D, so please be patient if I ask stupid questions.

I have a bunch of objects to be drawn to a Canvas3D, but first their positions and rotations need to be updated. As I understand it, if I call a method in the object that changes its associated Transform3D, the Java3D renderer will immediately render the change. What I would like to do, however, is to first update each object, and then render all the objects together.

I have looked at the documentation for immediate mode, but I must admit I find it rather confusing. It also seems that the Behaviour class could do what I want; but that means giving the graphics engine, rather than my game engine, control over when my objects are updated, and I'm not happy with that idea.

Do I need to extend the Canvas3D class and explicitly call its rendering methods, and if so, in what order? Can I use stopRenderer() and startRenderer() methods to stop the graphics engine while I do my updates, or would that involve fantastic amounts of overhead? Is there a good tutorial out there? Should I be using an offscreen buffer, perhaps? (I found the documentation for that rather difficult to follow also. Perhaps someone could simplify it for me?)

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #1 - Posted 2005-02-27 16:28:49 »

The easiest way to go is to put all updates into a Behavior and run it with a suitable WakeUpOnXXXX policy.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline birinhos

Junior Newbie




Java games rock!


« Reply #2 - Posted 2005-04-06 13:27:52 »

Im having the same problem .... Can anyone tell how can we solve this problem !!!!!!!!!!!!!!

My e-mail is :birinhos@hotmail.com

The problem is very well explain in this post :

http://archives.java.sun.com/cgi-bin/wa?A2=ind9906&L=java3d-interest&F=&S=&P=127314


I allredy contact the author and he tell-me that never resolve the problem....(since 1999).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2005-04-15 03:22:27 »

This is a common Java3D issue as it lieks to do things asynchronously.

The answer is a WakeupOnFrame(0) behavior.

This behavior is gauranteed to be called synchronously with frame update.

Edit: note that not everything has to be synchronous ina game.  Generally synchronicity is only an issue when dealing with collision.  Im intending to run my particle systems asynchronously because they are all really just visual candy.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #4 - Posted 2005-04-15 06:58:29 »

Quote

note that not everything has to be synchronous ina game.  Generally synchronicity is only an issue when dealing with collision.  Im intending to run my particle systems asynchronously because they are all really just visual candy.



Synchronicity is always important when relations between object are concerned. E.g. a camera following an object. It is bad when camera and object positions are updated in different frames.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #5 - Posted 2005-04-15 07:02:46 »

Quote

The answer is a WakeupOnFrame(0) behavior.


This has the ugly side effect of (a) 100% CPU-usage + very uncoherent frametiming! Not good for smooth animation. This always has been a major issue in the development of FlyingGuns.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2005-04-15 16:31:02 »

Quote


This has the ugly side effect of (a) 100% CPU-usage + very uncoherent frametiming! Not good for smooth animation. This always has been a major issue in the development of FlyingGuns.



Im not sure I follow, maybe Im misunderstandiong something.

Games typically burn all the CPU they can.  they also typically vary wildly in frame rates-- watch the FPS on any version of Quake (1-N).

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2005-04-18 11:29:43 »

Quote
Games typically burn all the CPU they can.


... which I think is bad style, but thats not the point here....


Quote

they also typically vary wildly in frame rates-- watch the FPS on any version of Quake (1-N).


The framerats may vary, but not on a per-frame basis. Means: measuring the time needed for the last frame give some expectations for the frame coming next. Not exactly, but roughly.

This normally is the deltaT that is used to propagate motion/animation. It is measured from the *last* frame but used for the calculation of the *next* frame. This can only work if *last* and *next* are correlated somehow ... that's whats I was calling 'coherence'. Coherence is important for smoothness.

In Q[n], mayby turning the avatar causes a sequence of frametimes like [10,10,12,13,13,15,17,17,17,19,20] which means cutting the FPS to half.

In Java3D, I observed [12,12,12,197,12,63,12,10,10,11,10,10,12,164,10,10...] which still gives a nice framerate but make any animation choppy, esp. those motivated by physics (a looong dT can tense a spring badly).


See the point? It seems the unpredictable times are *not* caused by GC. I assume it is the multithreaded nature of Java3D, whith some threads kicking in here and there.



HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #8 - Posted 2005-04-18 11:34:49 »

We had a prototype of FG running the singlethreaded Xith3D engine ... and it was absolutely smooth.

What I find suspicous: look at the HelloUniverse example with the spinning cube. Look closely. It is *not* smooth!

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #9 - Posted 2005-04-18 11:42:15 »

In FG, I fooled around with that a lot (and it is very annoying). I found that thing get better when framerate gets throttled either by WakeupOnElapsedTime or by setMinimumFrameTime().

Is it freeing some CPU resources for other threads to run not disturbing my gameloop so much?

Things got better, yet not good. Additionally I had to introduce a smoothing timing framework which can grow counterproductive on certain configurations .... bah. Ugly.

In the end, FG still isn't smooth. And I hate that. It gives bad reputation to the game and to Java itself. Unfortunately I lack of resources, knowledge and tools to really analyze the problem. Someone should.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2005-04-18 16:08:46 »

Quote

rved [12,12,12,197,12,63,12,10,10,11,10,10,12,164,10,10...] which still gives a nice framerate but make any animation choppy, esp. those motivated by physics (a looong dT can tense a spring badly).


See the point? It seems the unpredictable times are *not* caused by GC. I assume it is the multithreaded nature of Java3D, whith some threads kicking in here and there.




Hmm. Im not sure what was causing such wide variation in frame rate, but it doesnt seem to be a general problem.  Ive seen a great many Java3D games (such as all Shawn Kendall's work) and noen of them have seemed choppy or shown that kind of variation. Is this rendering the same scene or were you wildly changing what was on screen at the time?


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline birinhos

Junior Newbie




Java games rock!


« Reply #11 - Posted 2005-04-27 13:45:20 »

can anybody send an simple example of using WakeupOnFrame(0) tecnic ... Huh Huh

(i think I   understand the tecnic but I need some example in Java3D...)

by the way ... can we get the coordenate int X , int Y on the screen(canvas3d) having an Point3d (coodenates) in the universe

Point3d ---->to----> (X,Y)

tanks
Offline Jeff

JGO Coder




Got any cats?


« Reply #12 - Posted 2005-04-27 18:31:56 »

Look at ChaseCameraBehavior in the JNWN project.

I just wrote that code yesterday Smiley

Also, if you want to understand behaviors, read the J3D tutorial on the java3d.dev.java.net site.  Alternately the J3D spec is availabel in book form and has all the info, albiet in a mreo eference-orienetd form.

Edit: Note that ChaseCameraBehvior is a sub-class of  ViewPlatformBehavior, which is a special kind. Unless you are trying to write camera behaviors yo uwant to sub-class Behavior instead.  All the wake up and processing stuff though is pretty much the same.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #13 - Posted 2005-05-05 08:29:34 »

Quote

Edit: Note that ChaseCameraBehvior is a sub-class of  ViewPlatformBehavior, which is a special kind. Unless you are trying to write camera behaviors yo uwant to sub-class Behavior instead.


ViewPlatformBehavior only makes sense when ViewingPlatform is used a utility to setup a universe, right?

BTW, what is the difference between PlatformGeometry and avatar?

Both seems to be BranchGroups and added to the same TransformGroup?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #14 - Posted 2005-05-05 08:41:39 »

Quote

Hmm. Im not sure what was causing such wide variation in frame rate, but it doesnt seem to be a general problem.  Ive seen a great many Java3D games (such as all Shawn Kendall's work) and noen of them have seemed choppy or shown that kind of variation. Is this rendering the same scene or were you wildly changing what was on screen at the time?


No, there is not much changed in the scene and as I said, even HelloUniverse seems to be unsmooth in that way.

Unfortunately, my new machine is THAT fast, that the effect is hardly percievable. So I need to setup a suitable environment for further measurements first.

Yes, I saw Shawns stuff on J1 2003 and talked to him about that. We fully agreed about the way the gameloop has to be driven in Java3D.

The has been the artifact that his stuff performed really well on the J1 demo machine, whereas FG dropped to about 20FPS on a hardware that was good for 100FPS. So I assume *something* is wrong with my setup, but I cannot figure out what it could be.
I'm not using SimpleUniverse but my own setup. Can I make something wroing there? (de.hardcode.threed.frame)

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Jeff

JGO Coder




Got any cats?


« Reply #15 - Posted 2005-05-05 18:11:41 »

Quote

The has been the artifact that his stuff performed really well on the J1 demo machine, whereas FG dropped to about 20FPS on a hardware that was good for 100FPS. So I assume *something* is wrong with my setup, but I cannot figure out what it could be.
I'm not using SimpleUniverse but my own setup. Can I make something wroing there? (de.hardcode.threed.frame)


Hm.  I woudl be surprised if anything you coudl do there woudl make that much of a difference but i always strt from SimpleUniverse myself.

What kidn of machine is this?  if this is Linux have your run glxgears or something similar to prove that you are really getting hardware accelerated 3D from your card?  because thats what an order of magnitude difference liek that sounds like to me-- software rendering.

Ona  modern video card glxgears should report frame rates of somewhere around 10,000 fps.  If you see hundreds, your doing software render.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #16 - Posted 2005-05-06 05:23:42 »

Please don't think I'm stupid. I'm working with 3D hardware since the days of voodoo and DX3.

And no, IIRC the demo machine was your personal laptop. Windows.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #17 - Posted 2005-05-06 06:11:27 »

Off topic: here is the Linux story!

FlyingGuns ranked second in last years java gaming contest. The price has been a PC and a JavaDektopSystem2. 6 month later, the PC has been delivered. 9 month later, I received the JDS2. Had to pay $25 customs/taxes for that $50 software.

First, I had to contact Sun support to make the installer work. Switch to text mode early, switch off ACPI - otherwise the installer just crashed.

Next step ... surprise surprise ... my PC obviously has no harddrives! Linux/JDS (which is a historic SuSE8.1) and SATA/RAID0? No way. The support asked for cryptic info, so I preferred to buy an IDE disk ($100).

Now, installation started. Surprise surprise ... my PC obviously neither has a graphics card nor a monitor. Grmpf. I get a desktop 640x480 in 16 colors. Tried to start mozilla there for www.nvidia.com. Mozilla crashes on that site. Maybe nvidia expects browsers to support at least 17 colors.

Back to windows, google, read ... hard stuff. Following some descriptions on howto install NVidia drivers. All of them cryptic of course (install kernel sources, make this make that ...). WHERE IS THE SETUP.EXE?? Support tells me to follow the guide for SuSE8.1 (there is no hint otherwise on which Linux JDS is based!). Ok, following this instructions ('make install') halts the machine. Completely. Finished. Reset-button.
Desperately I followed instructions for SuSE8.2 .... and surprise surprise ... I get a 1600x1200 desktop!! Looks nice!
Unfortunately, no 3D hardware support. Gears crashes with something like 'libGL.so.1. missing'. I installed MESA GL  which makes gears run, yet still without hardware.
I looked around a bit, managed to link the supplied NVidia  libs ... GLX missing! What the f**k?

Now I'm waiting for the answer of the support guys again.

Getting a *free* JDS can be a very expensive experience....

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Jeff

JGO Coder




Got any cats?


« Reply #18 - Posted 2005-05-08 20:31:40 »

I cannot honestly recommend JDS for 3D development today.
The back-version kernel is too much of an issue.  Hopefully at
some point that will chnage.

And I can't say any more then that for obvious reasons.



Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #19 - Posted 2005-05-10 06:08:31 »

The Sun support guys are really brave: with some special NVidia driver version I have 3D now!

jake2 and wurmonline are really smooth (in fact jake2 is a *bit* smoother Smiley ).

FlyingGuns starts with 60fps (synced) but after a couple of seconds succeedingly drops down to 10fps. Sigh. I cannot tell wether Linux, Java3D or FlyingGuns is responsible for that....

Does somebody have another link to a webstartable Java3D app at hand?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline shawnkendall

Senior Member





« Reply #20 - Posted 2005-05-10 17:40:29 »

Quote
The Sun support guys are really brave: with some special NVidia driver version I have 3D now!

jake2 and wurmonline are really smooth (in fact jake2 is a *bit* smoother Smiley ).

FlyingGuns starts with 60fps (synced) but after a couple of seconds succeedingly drops down to 10fps. Sigh. I cannot tell wether Linux, Java3D or FlyingGuns is responsible for that....

Does somebody have another link to a webstartable Java3D app at hand?



I know this really off topic now but...
Herc, could you PLEASE post a walkthough of how to get accel 3D on JDS?
I have a great JDS2.0  machine sitting here dead to me without 3D accel.
Thanks in advance!

Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Offline Jeff

JGO Coder




Got any cats?


« Reply #21 - Posted 2005-05-10 18:09:51 »

Quote
The Sun support guys are really brave: with some special NVidia driver version I have 3D now!

jake2 and wurmonline are really smooth (in fact jake2 is a *bit* smoother Smiley ).

FlyingGuns starts with 60fps (synced) but after a couple of seconds succeedingly drops down to 10fps. Sigh. I cannot tell wether Linux, Java3D or FlyingGuns is responsible for that....

Does somebody have another link to a webstartable Java3D app at hand?


Its not web stratble yet but I could make you a JWN jar.  You need a copy of Nevrewinter Nights to run it though as thats where the data coems from.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #22 - Posted 2005-05-11 04:35:02 »

Quote

Herc, could you PLEASE post a walkthough of how to get accel 3D on JDS?
I have a great JDS2.0  machine sitting here dead to me without 3D accel.


I try to translate what the support told me and what did the trick (at least for my NV6800GT):



Quote

Please use the following driver:
http://download.nvidia.com/XFree86/Linux-x86/1.0-6106/NVIDIA-Linux-x86 -1.0-6106-pkg1.run

In BIOS the option Plug&OS installed should be NO.

Please execute the command ldconfig.

Please confirm that the correct extensions are available - 'xdpyinfo' should report "GLX", "NV-GLX" and
"NVIDIA-GLX".

These are the file of the Accelerated
Linux Driver Sets by NVIDIA plus their resp. symlinks:

/usr/X11R6/lib/modules/drivers/nvidia_drv.o

/usr/X11R6/lib/modules/extensions/libglx.so.x.y.z
/usr/X11R6/lib/modules/extensions/libglx.so -> libglx.so.x.y.z

/usr/lib/libGL.so.x.y.z
/usr/lib/libGL.so.x -> libGL.so.x.y.z
/usr/lib/libGL.so -> libGL.so.x

/usr/lib/libGLcore.so.x.y.z
/usr/lib/libGLcore.so.x -> libGLcore.so.x.y.z

/lib/modules/`uname -r`/video/nvidia.o, or
/lib/modules/`uname -r`/kernel/drivers/video/nvidia.o

During installation these /dev-files are created:

crw-rw-rw- 1 root root 195, 0 Feb 15 17:21 nvidia0
crw-rw-rw- 1 root root 195, 1 Feb 15 17:21 nvidia1
crw-rw-rw- 1 root root 195, 2 Feb 15 17:21 nvidia2
crw-rw-rw- 1 root root 195, 3 Feb 15 17:21 nvidia3
crw-rw-rw- 1 root root 195, 255 Feb 15 17:21 nvidiactl


HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #23 - Posted 2005-05-11 04:50:46 »

Quote
Its not web stratble yet but I could make you a JWN jar.  You need a copy of Nevrewinter Nights to run it though as thats where the data coems from.


Would be helpful. The NWN-demo is OK?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Jeff

JGO Coder




Got any cats?


« Reply #24 - Posted 2005-05-11 16:23:53 »

I havent tried it with the NWN demo.  I can grab it and give it a try though.

As long as the cat mdoel is in the NWN demo it *aught* to work,,,

JK

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #25 - Posted 2005-05-11 18:29:22 »

Okay all you should need is the 1.3GB NWN resources for Linux bundle
thats freely donwlaodable.

Im downloading it now and Il lprepare a quick release that works with it Smiley


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #26 - Posted 2005-05-11 22:45:20 »

Okay well teh good news is it runs fine with the freely downloadable
Linux resource bundle.

The bad news is that you need to go to FilePlanet or FileShack for that, which means eaither paying them or wiating in lien to use their
free servers.

The seconds pecie of bad news is that *compressed* that is a 1.18GB download :/

I havent tried it with the demo because I cant find a Linux demo, only windows, and its really a pain for me to get Windows stuff over to Linux.

ANyway if that 1.18GB dl isnt a show stopepr for you I can make th rest of what yo uneed and ship it to you. if it IS a show stopepr then your going to hgave tow ait for a tiem weh  I cn boot over to Windwos, install the demo, then boot back and copy the info over to Linux.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline otelo

Junior Member





« Reply #27 - Posted 2006-02-28 11:03:58 »

In FG, I fooled around with that a lot (and it is very annoying). I found that thing get better when framerate gets throttled either by WakeupOnElapsedTime or by setMinimumFrameTime().

After playing around a little, I settled with using Viev.setMinimumFrameTime(33) and implementing a WakeupOnElapsedFrames(0) behavior as my main loop timer ... no other system timer calls if possible (screws things up again).  I'm running my odejava physics simulation at 30fps, so no visuals get lost anyway and there's enough time even for slower systems to keep up. Using WakeupOnElapsedTime caused stuttering and terrible hickups while operating swing components.

Saw it suggested here.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (13 views)
2014-08-28 09:26:30

CopyableCougar4 (25 views)
2014-08-22 10:31:30

atombrot (38 views)
2014-08-19 00:29:53

Tekkerue (31 views)
2014-08-15 21:45:27

Tekkerue (31 views)
2014-08-15 21:22:17

Tekkerue (19 views)
2014-08-15 21:20:21

Tekkerue (29 views)
2014-08-15 21:12:11

Rayexar (66 views)
2014-08-10 17:49:23

BurntPizza (42 views)
2014-08-09 12:09:32

BurntPizza (34 views)
2014-08-07 17:01:56
List of Learning Resources
by Longor1996
2014-08-16 01:40:00

List of Learning Resources
by SilverTiger
2014-08-05 10:33:27

Resources for WIP games
by CogWheelz
2014-08-01 07:20:17

Resources for WIP games
by CogWheelz
2014-08-01 07:19:50

List of Learning Resources
by SilverTiger
2014-07-31 07:29:50

List of Learning Resources
by SilverTiger
2014-07-31 07:26:06

List of Learning Resources
by SilverTiger
2014-07-31 02:54:12

HotSpot Options
by dleskov
2014-07-07 16:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!