java - Feed Shader Program with World Units instead of (0f,1f) values -


I am using a simple rectangular trap using libgdx, and other geometric elements which are similar to simplicity. Are going to interact with the sprites set in The state of prestats and other properties are set up in units of the world and before each phantom draw session I set up the camera like this:

  camera.update (); Batch.setProjectionMatrix (camera.combined);  

All this works well, but I need to make a table to use world units. Instead of replacing (0f, 1f) instead, how can I feed the shadowy program World Coordinator (12.5 F, 30F, etc.) based on the world statistics of my game? I want to draw several textures mess, so I need coordinates in relation to other elements in the game.

Here's how to draw a simple rectangle:

  trap = new mesh (true, 4, 6, new vertex attribute (use composition, 3, "a_position" ), New Vertex AutoTit (Usage Function Coordinates, 2, "Atext Cord")); Mesh.setVertices (new float [] {-1.0 F, -1.0 f, 0, 0,1, 0.0 f, -1.0 f, 0,1,1, 0.0 f, 0.0 f, 0, 1,0, -1.0 F, 0.0F, 0, 0,0}); Mesh.setIndices (new small [] {0, 1, 2, 2, 3, 0}); . Gdx.graphics.getGL20 () glEnable (GL20.GL_TEXTURE_2D); Gdx.gl20.glActiveTexture (GL20.GL_TEXTURE); CreateShader (); Shader.begin (); Trap Render (Shadar, GL 20.GMTRNNG); Shader.end ();  

In any way can I feed the Aries vertical array to world units?

You can change the vertices in vertical shader. It allows you to direct the world to project the 1 to 1 range. This is usually done by multiplying the vertical position with position (projection) matrix. For an example of how to implement it, see.

You can use the camera.combined matrix to multiply these seats in Vertex Shader. As you did when specifying the projection matrix for the printbatch. You have to assign this matrix to the uniform used in your Vertex shader. An example of doing this can also be found.

However, you may want to reconsider your view since you are using a Spratchbatch, you can earn profit from a performance advantage by using Spratchbach rather than manually rendering. This will also make rendering easier for you, because you do not have to mess with shaders and matrices, there is a method in SpriteBatch that allows you to specify manually created mesh (or indeed shorts). Each upper shape is expected to have 5 floats (X, Y, Y, V, color) and a multi-line (although not rectangular shape) should be provided in the four corners (You can use the Color WHITE .toFloatBits () for color).

But, since you are trying to render a simple rectangle, you can use the more convenient methods that allow you to render a rectangle without having to make all the nets For () or, even easier, how is it designed by creating Sprite for its rectangle?

Now, if you are still certain that you want to manually create a net and shader, then I suggest learning to use a tutorial, instead of using a tutorial instead of diving As you can get help in getting started, the wiki also describes how to do this, in which the change corner in the Vertex shader is included.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -