Hello~
Has any function could set the ViewPort into the special region?
I try to use the ‘cam.setViewPort’ to cut the screen into two triangles (drawed as below), but I can only cut the viewport into two squares (just like what we can see in “Dynasty Warriors”, 2 players).
Unfortunately there are no tests showing off stencil buffer functionality (as you can tell, its not commonly used these days).
You will need to go based on non jME3 tutorials, e.g. OpenGL / DirectX.
Render to texture as a workaround? (works now, test case available, lose about 50% of fps, but hey…)
Btw … what’s with the timing of two view ports or two cameras? I mean, at 10 fps - is one image 10% in the past compared to the other image? (just curious, because this whole timings question will become interesting for me soon)
I’m not sure who you are asking exactly… but you may need to rephrase the question. I read it three times and still I’m not sure what you meant. What does 10% in the past mean?
Sorry, did not want to derail this thread, but did not want to lose that thought either.
The thought is as follows:
a) render two viewports or two textures
b) have a situation where fps are low (e.g. 10)
c) 1st render is 0.1 seconds prior to the 2nd render
d) result: time gap: one image is 0.1 sec old, other image 0.2 sec old.
d) if both should be at same point in time - how to fix it?
(idea 1: stop time, render both, continue)
(idea 2: prevent low frame rates at all cost)
:chimpanzee_confused:
I just did not need so much fine control until now and assumed that you can’t render into two textures in parallel at exactly the same time. Maybe I will open a new topic when my “frozen game logic” feature is about to be needed. Thanks for now, but I think I officially derailed this thread - sorry. :chimpanzee_nogood:
One idea is to use “render to texture”.
Here is an example: jme3test.post.TestRenderToTexture.java
You render to texture Texture1 with your Cam1.
You render to texture Texture2 with your Cam2.
You then make a “custom mesh” for triangle Triangle1 for Cam1.
You then make a “custom mesh” for triangle Triangle2 for Cam2.
Triangle1 uses Texture1, and Triangle2 uses Texture2.
You then attach the Triangle1 and Triangle2 to the “guiNode”.
Understand me?
It is a little bit slow - you will lose some “frames per second” because you render 2 images and will not use the full image (only one half is used - triangle instead of rectangle). But it can be done.
Maybe someone can make an example. Maybe I can make an example during this week.
Thank you for your prompt reply.
I learned the documents and tried to use the following codes, but the screen is blank.
I’m not sure whether the codes is correct.
[Codes start]
Mesh mesh = new Mesh();
Vector2f[] coord = new Vector2f[ 4 ];
coord[0] = new Vector2f( 0, 0 );
coord[1] = new Vector2f( 1, 0 );
coord[2] = new Vector2f( 0, 1 );
Your mesh is only 1 pixel big and it has no texture coordinates.
Probably better just to use Quad since it will setup all of the mesh-related stuff properly.
(Edit: I see now that you are making a triangle… still, the rest of the stuff I said is true. You can look at Quad.java to see how to set things up for a single triangle… though from your original screen shot you actually want a trapezoid so a Quad may be a better place to start.)
Geometry geom = new Geometry( “TriangleMesh”, mesh );
Material mat = new Material( assetManager, “Common/MatDefs/Misc/Unshaded.j3md” );
mat.setColor( “Color”, ColorRGBA.Red );
geom.setMaterial( mat );