Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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  
  Best way to wrap behaviors?  (Read 1721 times)
0 Members and 1 Guest are viewing this topic.
Offline Captain-Goatse

Junior Devvie




I suck at teh 2D. XBOX IS BIG LOL!111


« Posted 2002-11-29 10:31:40 »

I want all the behaviours to be syncronized so that they all are called in one single main behaviour or so called "behaviour listener".

Now I have multiple different behaviours such as animation, mouse handling, keyboard navigation and the behaviours occur as they wish.

Now I have all my behaviours the same style as j3D raw java suggested, but all the multiple "threads" (oops behaviours" don't work as I want them to. They are all extending from behaviour and going downwards from that, however this is not the most ideal sollution.

Should I make one general behaviour that has all the behaviours in it or some sort of behaviour manager, which syncronizes the behaviours? In 2D it was best to have one thread that manages everything, would one behaviour be good that manages everything?

Is there any whitepaper about the internal processes on the behaviours that would explain what happens and where so that I could write my own behaviour system.

Writing everything in one behaviour class isn't very good oop, but it would produce the best speed as I understand. Is there any middle ground? Do I have completely wrong picture about the behaviors?

Behaviour = Behavior.
Offline Mithrandir

Senior Devvie




Cut from being on the bleeding edge too long


« Reply #1 - Posted 2002-12-07 17:09:50 »

The only way to guarantee all of your application behaviours work correctly is to use a *single* WakeUpOnElapsedFrames(0). When this gets called you go and perform all the handling that you want. Once you start trying to build arbitrary behaviours into the scene graph all over the place, the performance really starts to drag. - not only from the synchronisation aspects, but also all the calculation J3D has to do internally to decide if your behaviour should run. The only way to build  high-performance j3d apps is to maintain all your own application logic called through the single j3d behaviour.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #2 - Posted 2002-12-08 08:23:30 »

Agreed in principle, but WakeUpOnElapsedFrames(0) leads to unsmooth animation due to GC pauses and MT.
I'd prefer WakeUpOnElapsedTime(30) or so, safely undercommitting the abilities of the computer, bc. smooth animation needs first of all CONSTANT framerate, second HIGH framerate.

Our gaming prototype completey runs in a single behaviour callback.

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 Captain-Goatse

Junior Devvie




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #3 - Posted 2002-12-08 14:09:11 »

Hercules has a good point. What is the use of high frame rate if the animation is not smooth.

Btw, I know this is kind of retarded question, but will there ever be option to turn GC off and do the memory management by yourself? I think it would help a lot in some situations.
Offline Mithrandir

Senior Devvie




Cut from being on the bleeding edge too long


« Reply #4 - Posted 2002-12-16 00:36:23 »

If you are getting GC pauses, it's certainly not due to using elapsedFrame(0) calls.  Before you criticise a piece of code for "creating garbage", first understand what you are talking about.  Limiting your own internal framerate is not the way to build scalable applications.

We run profilers and decompilers over the J3D internals on an extremely regular basis (ie almost daily) and there is, with one exception in the picking utils, almost zero garbage generated by the Java3D runtime engine under normal circumstances. There is a call during the matrix inversion that sets up the view projection matrix each frame and that's about it. The other times garbage may be generated is due to your use of geometry. For example, if you used any of the indexed geometry primitives, and change _just_ the coordinate array, it will throw the entire internal structure away and rebuild the arrays. So, you dont use those structures and build your own unindexed arrays.  I can get quite nice, smooth framerates (20-30) on my 800MHz laptop with 40K polygons with every coordinate being updated every frame, and never see a GC pause. Understand your tools first, before you blame them for causing problems.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #5 - Posted 2002-12-16 07:12:14 »

Who said that Java3D creates garbage?

But it's good news that it doesn't.

Anyway, elapsedFrame(0) causes one thread always ready to run. So there's a race condition with other threads. If they get execution times, the elapsedFrame(0)-thread neccesarily does NOT run (assuming singleCPU boxes). If theres no sync in scheduling, this MUST lead to irregular frametimes varying on a one-by-one basis -> animation gets unsmooth (regardless of the framerate you achieve. Framerate says NOTHING about smoothness).

This problem vanishes if the app runs with more 85Hz or so and the painting thread get to sleep due to a vsync-wait. That's where we see perfectly smooth 2D-games...

BTW, is there a 50Hz-limit within Java3D somewhere for a onscreen, windowed apps? Couldn't see any framerated higher....


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

Junior Devvie




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #6 - Posted 2002-12-16 07:55:24 »

That sounds strange... I get constant 85 with windowed onscreen rendering...
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #7 - Posted 2002-12-16 08:22:23 »

hm, yes, I suppose it's in my code....
Maybe the firerate of elapsedTime() is limited...

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

Senior Devvie




for great justice!


« Reply #8 - Posted 2002-12-16 09:08:55 »

Quote
Understand your tools first, before you blame them for causing problems.

But they're complicated!
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.

Mr.CodeIt (6 views)
2014-12-27 04:03:04

TheDudeFromCI (12 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (91 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

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

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

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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!