[Solved]Has any function could set the ViewPort into the special region?

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)

Well, why are you rendering them at different frames in the first place? It doesn’t make any sense.

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:

Could override the some functions or extends the class has reach this effects?
Thanks everyone!!!

Take a look on this code :

Its not working for me because I am using bones, but for your game using 2d it probably will work.

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? :chimpanzee_smile:

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 );

mesh.setBuffer( Type.TexCoord, 2, BufferUtils.createFloatBuffer( coord ) );

Geometry triangle1 = new Geometry(“Triangle”, mesh );

Material mat = new Material( assetManager, “Common/MatDefs/Misc/Unshaded.j3md” );
Texture texture = assetManager.loadTexture( “Textures/Monkey.jpg” );
mat.setTexture( “texture1”, texture );
triangle1.setMaterial( mat );
guiNode.attachChild( triangle1 );

[Codes end]

Thank you very much!

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.)

I tried to fix this problem, but still has no any effects.
Could you help me check this?
Thank you very much.

[Codes start]
Mesh mesh = new Mesh();

Vector2f[] coord = new Vector2f[3];
coord[0] = new Vector2f(0,0);
coord[1] = new Vector2f(200,0);
coord[2] = new Vector2f(0,200);

mesh.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(coord));
mesh.scaleTextureCoordinates(new Vector2f(200 , 200));
[Codes end]

I fix it.

But I have some problems.
How do I do to render the scene to the mesh?

Thanks everyone~

[Codes start]
Mesh mesh = new Mesh();

Vector2f[] vertices = new Vector2f[ 3 ];
vertices[ 0 ] = new Vector2f( 0, 0 );
vertices[ 1 ] = new Vector2f( 500, 0 );
vertices[ 2 ] = new Vector2f( 0, 500 );

Vector2f[] texCoord = new Vector2f[ 3 ];
texCoord[ 0 ] = new Vector2f( 0, 0 );
texCoord[ 1 ] = new Vector2f( 1, 0 );
texCoord[ 2 ] = new Vector2f( 0, 1 );

mesh.setBuffer( Type.Position, 2, BufferUtils.createFloatBuffer( vertices ) );
mesh.setBuffer( Type.TexCoord, 2, BufferUtils.createFloatBuffer( texCoord ) );

Geometry geom = new Geometry( “TriangleMesh”, mesh );
Material mat = new Material( assetManager, “Common/MatDefs/Misc/Unshaded.j3md” );
mat.setColor( “Color”, ColorRGBA.Red );
geom.setMaterial( mat );

guiNode.attachChild( geom );
[Codes end]

You render the scene to a texture as has already been linked here and is done in the TestRenderToTexture example included with JME.

In the SDK → File → New Project → JME3 → JME3 Tests → package jme3test.post → file TestRenderToTexture.java

Why is the package jme3test.post not in this javadoc? I only found jme3test.android


I have no idea. I will make sure to dock the documentation staff’s pay. :wink:

LOL :chimpanzee_closedlaugh: so it’s “we forgot it” and not “it’s somewhere else” :chimpanzee_amused:

Looking, that stuff is automatically generated so I imagine that the jme3tests are just left out. Android is a bit of a different project and so may not have that filtered out or somehow includes it by default.

I just thought it was funny to ask me specifically about JME documentation because you already basically know as much about it as I do. :slight_smile:

Ehm you’d be surprised about all the things that I don’t know (yet). I still need to learn a lot and I hope to delegate the admin stuff and some coding stuff as soon as things started to rock’n’roll. :chimpanzee_laugh:

I learning the ‘TestRenderToTexture.java’ example.
And tried to add this effect.
But has strange effect.


Your code looks fine from here. (What we can see of it.)

Thats weird, did you try it with out any modifications ?
I am using this heavily in my new game, and its working fine even in the android…