Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  Mixing parallel and perspective projection in the same frame  (Read 3447 times)
0 Members and 1 Guest are viewing this topic.
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Posted 2005-08-23 22:27:34 »

Hi

is it possible to render a scene using perspective projection, then switch to parallel and render a few more things over the top each frame?

Endolf

Offline Spasi
« Reply #1 - Posted 2005-08-24 10:46:17 »

Yes, of course.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #2 - Posted 2005-08-24 18:12:42 »

This is possible? How? I think you have to set parallel and perspective mode in View - and you can't change it during rendering, because that's jogl/lwjgl doing and only one call in Xith3d.

:: JOODE :: Xith3d :: OdeJava ::
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #3 - Posted 2005-08-24 19:27:01 »

Any hints as to how? Smiley

I mean, I can figure out that I do something like
1  
2  
3  
4  
view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
view.renderOnce();

view.setProjectionPolicy(View.PARALLEL_PROJECTION);


but at that point, if I call view.renderOnce() again, the scene has the 3d parts in it, and not the 2d parts. I don't want to have to start removing objects from the scene tree and placing other ones in it, twice a frame, every frame. Also, I have a background, and if I renderOnce again I'll lose what I rendered the first time won't i?

Endolf

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2005-08-24 19:35:12 »

I've never worked with Java3D or Xith3D but...

Can't you use the SwitchNode to switch between the 2D/3D branches then?

If this sounds like I completely missed the point, I probably did Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #5 - Posted 2005-08-24 19:40:01 »

I could yes, I just want to make sure that when I draw the second part of the frame, that I don't end up clearing the buffer at the same time, ie, I still need what I last rendered. I *think* xith does an equivelant of a glClear

Endolf

Offline Spasi
« Reply #6 - Posted 2005-08-24 20:18:05 »

Whoops, sorry, I just noticed this is the Xith3D forums. Grin
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #7 - Posted 2005-08-25 21:41:40 »

So does anyone know how to tell xith to 'draw this frame over the top of the prvious one, allowing any transparent objects to show what was drawn the frame before'?

Endolf

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #8 - Posted 2005-08-26 15:49:35 »

So does anyone know how to tell xith to 'draw this frame over the top of the prvious one, allowing any transparent objects to show what was drawn the frame before'?

Endolf
I think this would require a modification in the Xith code, because the screen shouldn't be filled with the background color between the 2 renders.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #9 - Posted 2005-08-31 08:34:28 »

This sounds like an issue relating to multi-pass.  Unfortuantely Xith3D has never really implemented this feature -- there are other nice things like render to texture that fall in the same bucket (I think).  Yuri has raised this topic previously on a few occasions.

If you have an idea on how best to implement this, please start a dialog on the topic Smiley

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #10 - Posted 2005-09-18 12:57:06 »

I looked at the CanvasPeerImpl code for jogl. There is a function called setDisableClearBuffer(boolean disable), which turns the glClear off.
So you can mix parallel and perspective, you'll only have to remember your CanvasPeerImpl and switch setDisableClearBuffer on and off.

Arne

:: JOODE :: Xith3d :: OdeJava ::
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #11 - Posted 2005-09-24 02:03:28 »

endolf have you tried this?

Perhaps we should make it an abstract RenderOption so LWJGL can implement it too.  Potentially you could simply have two RenderOptions objects lying around and just swich them in and out each frame.

Will.

Offline jaakko777

Senior Newbie





« Reply #12 - Posted 2006-01-17 23:24:13 »

Ok so i got this kind of rendering loop. It's working very nicely exept for one small but annoying thing (which is obious) - the hud flickers a bit.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
         // run the rendering loops
        mySceneGraph.setRenderable(true);
         myHud.setRenderable(false);
         view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
         canvasPeer.setDisableClearBuffer(false);
         view.renderOnce();
         
         mySceneGraph.setRenderable(false);
         myHud.setRenderable(true);
         view.setProjectionPolicy(View.PARALLEL_PROJECTION);
         canvasPeer.setDisableClearBuffer(true);
         view.renderOnce();


How can i do in xith so that the buffers dont get swapped automatically, intsead i would swap it after im done rendering the hud.
Can this be done? Yes.  Roll Eyes
How?

---
Edit:

Ok I found out how to disable the automatic swapping.
1  
canvasPeer.setForceNoSwap(true);


But now i dont know how to swap it manually..  Embarrassed
Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #13 - Posted 2006-01-18 09:09:41 »

may be exposing the glFlush() instruction ?

(search for renderDone() in canvas peer impl)

Lilian

Offline jaakko777

Senior Newbie





« Reply #14 - Posted 2006-01-18 15:38:33 »

I have tried this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
canvasPeer.setForceNoSwap(true);

while(true)
{
    // run the rendering loops
   mySceneGraph.setRenderable(true);
    myHud.setRenderable(false);
    view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
    canvasPeer.setDisableClearBuffer(false);
    view.renderOnce();

    mySceneGraph.setRenderable(false);
    myHud.setRenderable(true);
    view.setProjectionPolicy(View.PARALLEL_PROJECTION);
    canvasPeer.setDisableClearBuffer(true);
    view.renderOnce();

    canvasPeer.getGl().glFlush();


... but it didnt work.
Offline jaakko777

Senior Newbie





« Reply #15 - Posted 2006-01-19 12:52:44 »

Ok, i figured out a way to do it Smiley
Thanks to all that helped!!

Here is what i did in case someone finds this useful:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
// render loop
while(true)
{
    // render the scene, clearing the buffer before doing it
   mySceneGraph.setRenderable(true);
    myHud.setRenderable(false);
    canvasPeer.setDisableClearBuffer(false);
    canvasPeer.setForceNoSwap(true);
    view.renderOnce();
    view.setProjectionPolicy(View.PARALLEL_PROJECTION);

    // render the hud, not clearing the buffer before
   mySceneGraph.setRenderable(false);
    myHud.setRenderable(true);
    canvasPeer.setDisableClearBuffer(true);
    canvasPeer.setForceNoSwap(false);
    view.renderOnce();
    view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);

}


So sum it up i keep the setForceNoSwap as true as long as i still want ro render more frames and finally set it to false before the final frame rendering.
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #16 - Posted 2006-01-19 13:22:35 »

Great ! and does it work really well ?
Your GUI is made of textured quads, aren't there ? But are they simply foreground nodes ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #17 - Posted 2006-01-19 13:42:32 »

Now we should try and encapsulate it ...

may be with a Switch node and a MultiPassView(View) (each switch beeing a pass) ?

Lilian

Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #18 - Posted 2006-01-19 15:07:07 »

nice ... very nice Cheesy

MultiPassView sounds nice...
maybe we could do it like this?:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
class MultiPassView extends View {
  ArrayList<Switch> renderpasses;
  public void addRenderPass(Switch s) { renderpasses.add(s); }
  public void removeRenderPass(Switch s) ..
  public void render() {
    for(Switch s : renderpasses) {
      // set settings, activate switch and render
    // deactivate switch
   }
  }
}


or we could also add a class RenderPass, where we can set the combination of switches, that should be set during that render pass.

Anybody even better ideas?

Arne

:: JOODE :: Xith3d :: OdeJava ::
Offline jaakko777

Senior Newbie





« Reply #19 - Posted 2006-01-19 17:17:32 »

Thanks. Smiley
Great ! and does it work really well ?
Your GUI is made of textured quads, aren't there ? But are they simply foreground nodes ?

Yes it works quite well indeed with no performance loss.
Or, hmm.. I havent faced any problems yet but also havent had the time to test it extensively.

I havent really built up the gui yet (just two foreground node shapes so i can see that it renders).
Infact i still havent really decided how ill implement the gui..  Roll Eyes
Textured quads sounds like a good idea for a traditional gui.
Though, I cant get over the idea to make a really 3D ui with interactive components...  Tongue Something like switches and such things. It would be cool but lets see, maybe ill end up with a "simple 2D" gui.

nice ... very nice Cheesy

MultiPassView sounds nice...
maybe we could do it like this?:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
class MultiPassView extends View {
 ArrayList<Switch> renderpasses;
 public void addRenderPass(Switch s) { renderpasses.add(s); }
 public void removeRenderPass(Switch s) ..
 public void render() {
 for(Switch s : renderpasses) {
 // set settings, activate switch and render
// deactivate switch
}
 }
}


or we could also add a class RenderPass, where we can set the combination of switches, that should be set during that render pass.

Anybody even better ideas?

Arne

Sounds great!
But let me ask (maybe) a stupid question:
Why need multiple Switches? Wouldnt just one do if it contains for example BranchGroups that represent the different passes?
Please correct me if i missed something..  Wink
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #20 - Posted 2006-01-19 18:23:05 »

Probably switches are faster than de/reactivating BranchGroups.
jaakko777, I soon will arrive in the GUI implementation phase in my game. I would be pleased if we could, with the others Java Games gurus, think about that, and why not make a "reutilisable" system for Xith. (I had this project some weeks ago, but I didn't concretized it)
So, 2D (textured quads) or 3D ? Or maybe both ? Can we mix them ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #21 - Posted 2006-01-19 18:33:55 »

Quote
So, 2D (textured quads) or 3D ? Or maybe both ? Can we mix them ?

It's only parallel perspective, so you should be able to mix it.

Parallel perspective has the advantage, that you don't have to use picks to determine, where you've clicked on the gui.

:: JOODE :: Xith3d :: OdeJava ::
Offline jaakko777

Senior Newbie





« Reply #22 - Posted 2006-01-20 07:31:45 »

Probably switches are faster than de/reactivating BranchGroups.

Ok but wouldnt this be exactly using the speed of a swich?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
class MultiPassView extends View {
   Switch renderpasses;
   public void addRenderPass(Node n) { renderpasses.addChild(n); }
   public void removeRenderPass(Node n) ..
   public void render() {
      for(int i = 0; i < renderpasses.numChildren(); i++) {
         // set correct node
        renderpasses.setWhichChild(i);
         // set other settings and render
        ...
      }
   }
}


If multiple switches are faster, could someone explain to me why.. 


jaakko777, I soon will arrive in the GUI implementation phase in my game. I would be pleased if we could, with the others Java Games gurus, think about that, and why not make a "reutilisable" system for Xith. (I had this project some weeks ago, but I didn't concretized it)
So, 2D (textured quads) or 3D ? Or maybe both ? Can we mix them ?

If you suggest some sort of joint effort you can count me in if we can pull it off relatively quickly, meaning that i dont want to get stuck in long debates (referring to the existing threads about GUI implementation*)  since im working on a game project and there are other's that are going to need some sort of gui soon.  Apart from that i would really much like to contribute to this great API!

*) Not that i wouldnt hold them in value, on the contrary thanks to those threads i got started on the right track in the firts place   Smiley
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #23 - Posted 2006-01-20 17:14:24 »

If multiple switches are faster, could someone explain to me why.. 
Oh excuse me I didn't understood really what you were talking about. Multiple switches aren't necessary

If you suggest some sort of joint effort...
Yes indeed.

you can count me in if we can pull it off relatively quickly, meaning that i dont want to get stuck in long debates (referring to the existing threads about GUI implementation*)  since im working on a game project and there are other's that are going to need some sort of gui soon.  Apart from that i would really much like to contribute to this great API!
Yes me too. Okay, so I propose to start another subject talking about that.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline jaakko777

Senior Newbie





« Reply #24 - Posted 2006-01-22 22:49:20 »

Looking into the source of View.renderNode() it actually seems to return faster from there if a Node is set as not renderable than it returns if its a Switch.

Could someone familiar with the rendering engine confirm this? Especially regarding the case we are dealing with in this thread.
Offline jaakko777

Senior Newbie





« Reply #25 - Posted 2006-01-25 00:42:14 »

It seems that by default in PARALLEL_PROJECTION the coordinate system is such that the edges of the screen on the x-axis are allways 1.0f and -1.0f.
It's quite practical from one point of view but what if i want to draw something on the screen that does not get resized if the screen is resized. Can the coordinate system be somehow made "ignorant" of the screen size?
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.

pw (25 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (19 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!