Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (844) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 need help with making a TriangleStripArray...  (Read 1321 times) 0 Members and 1 Guest are viewing this topic.
dexteroids

Innocent Bystander

Java games rock!

 « Posted 2003-05-19 17:53:38 »

Hello,

i wanted some help with some code i wrote. i want to make a surface which should act like water. i'm using a trianglestriparray with coordinates by reference. that way i can move the points of my surface up and down to make it look like water waves. for some reason it doesn't work correctly. my surface it not created right.

below is the geometry creation part:
[code]
eg. resolution = 10

{
int N = resolution * 2;
geometry = new TriangleStripArray(N,
GeometryArray.COORDINATES |
GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.BY_REFERENCE,
2, new int[]{0, 1}, new int[]{N}
); // GeometryArray.NORMALS |

vertices = new float[(resolution - 1) * resolution * 6];
texCoords1 = new float[(resolution - 1) * resolution * 4];
texCoords2 = new float[(resolution - 1) * resolution * 4];

for (int i = 0; i < resolution - 1; i += 1)
{
for (int j = 0; j < resolution; j++)
{
vertices[i * N + j * 2] = i;
vertices[i * N + j * 2 + 1] = 0.0f;
vertices[i * N + j * 2 + 2] = j;
vertices[i * N + j * 2 + 3] = i + 1;
vertices[i * N + j * 2 + 4] = 0.0f;
vertices[i * N + j * 2 + 5] = j;

texCoords1[i * 2 + 0] = (float) i / (float) (resolution - 1);
texCoords1[i * 2 + 1] = (float) j / (float) (resolution - 1);
texCoords1[i * 2 + 2] = ((float) i + 1.0f) / (float) (resolution - 1);
texCoords1[i * 2 + 3] = (float) j / (float) (resolution - 1);
}
if (i % (resolution / 10) == 0)
{
//lf.setValue(lf.getValue() + 10);  // change value of progressbar
}
}

geometry.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);

geometry.setCoordRefFloat(vertices);
//geometry.setNormalRefFloat(normals);
geometry.setTexCoordRefFloat(0, texCoords1);
geometry.setTexCoordRefFloat(1, texCoords2);
}

the code doesn't work correctly. it shows a surface with some angles and wrongly oriented. but it should be flat (since all Y values are 0, should be altered by referencing them).
Pages: [1]
 ignore  |  Print

 EgonOlsen (79 views) 2018-06-10 19:43:48 EgonOlsen (59 views) 2018-06-10 19:43:44 EgonOlsen (78 views) 2018-06-10 19:43:20 DesertCoockie (261 views) 2018-05-13 18:23:11 nelsongames (159 views) 2018-04-24 18:15:36 nelsongames (158 views) 2018-04-24 18:14:32 ivj94 (901 views) 2018-03-24 14:47:39 ivj94 (162 views) 2018-03-24 14:46:31 ivj94 (813 views) 2018-03-24 14:43:53 Solater (177 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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