wonder Expert Licensed User Longtime User Nov 16, 2016 #1 @Informatix (or any of the other LibGDX/OpenGL gurus out there)... Using the basic template, I'm able to draw a textured polygon shape. The problem is, no matter what I try, I can't seem to center and scale the texture to the polygon size... Code: 'This kinda works, but I have no idea how to center and scale the texture 'I've tried DrawRegion2 and DrawRegion3 as well polyBatch.DrawRegion2(reg, 30, 30, 300, 300) Code: 'I'd like to try this function, but I have no idea how to add the extra values to ShapeVertices2(), 'as each vertex is required to be composed of 5 elements (x, y, color?, u?, v?) polyBatch.DrawPolygon(...???????? Clearly NOT the expected result!! I'd like the texture to be centered and scaled. PS: I am well aware of the lgMesh alternative, but it seems more complicated. I'm willing to take a chance at it only if there is no way to solve this problem using lgPolygonBatch. Attached my test project. Attachments polygonBatch.zip polygonBatch.zip 34.4 KB · Views: 727
@Informatix (or any of the other LibGDX/OpenGL gurus out there)... Using the basic template, I'm able to draw a textured polygon shape. The problem is, no matter what I try, I can't seem to center and scale the texture to the polygon size... Code: 'This kinda works, but I have no idea how to center and scale the texture 'I've tried DrawRegion2 and DrawRegion3 as well polyBatch.DrawRegion2(reg, 30, 30, 300, 300) Code: 'I'd like to try this function, but I have no idea how to add the extra values to ShapeVertices2(), 'as each vertex is required to be composed of 5 elements (x, y, color?, u?, v?) polyBatch.DrawPolygon(...???????? Clearly NOT the expected result!! I'd like the texture to be centered and scaled. PS: I am well aware of the lgMesh alternative, but it seems more complicated. I'm willing to take a chance at it only if there is no way to solve this problem using lgPolygonBatch. Attached my test project.
wonder Expert Licensed User Longtime User Nov 16, 2016 #2 Looks like I'm not alone in this: http://www.java-gaming.org/index.php?topic=33785.0 EDIT: Alright, I found the answer. The problem was my vertices coordinates. They have to be relative to the texture width/height. Last edited: Nov 16, 2016
Looks like I'm not alone in this: http://www.java-gaming.org/index.php?topic=33785.0 EDIT: Alright, I found the answer. The problem was my vertices coordinates. They have to be relative to the texture width/height.
melonZgz Active Member Licensed User Longtime User Nov 16, 2016 #3 So, if you double the texture size in gimp/photoshop it looks correct... I'm interested in this, as I'll have to use it in a game I'm thinking...
So, if you double the texture size in gimp/photoshop it looks correct... I'm interested in this, as I'll have to use it in a game I'm thinking...
melonZgz Active Member Licensed User Longtime User Nov 23, 2016 #5 So... any advance in this? Is there any way vertices coordinates can be independent from texture size? If I'm using Box2D and my polygons will be measured in meters, so one meter - one pixel is not good for my purposes
So... any advance in this? Is there any way vertices coordinates can be independent from texture size? If I'm using Box2D and my polygons will be measured in meters, so one meter - one pixel is not good for my purposes
wonder Expert Licensed User Longtime User Nov 23, 2016 #6 I haven't been working on this lately... Sorry... Really busy with network protocols...
melonZgz Active Member Licensed User Longtime User Nov 23, 2016 #7 Don't worry! I've been doing some testing, but no results. I'm also busy finishing 2 games...
ilan Expert Licensed User Longtime User Nov 23, 2016 #8 melonZgz said: So... any advance in this? Is there any way vertices coordinates can be independent from texture size? If I'm using Box2D and my polygons will be measured in meters, so one meter - one pixel is not good for my purposes Click to expand... just convert your vertices to world coordinates.
melonZgz said: So... any advance in this? Is there any way vertices coordinates can be independent from texture size? If I'm using Box2D and my polygons will be measured in meters, so one meter - one pixel is not good for my purposes Click to expand... just convert your vertices to world coordinates.