Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (604) Games in Android Showcase (171) games submitted by our members Games in WIP (652) 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 904 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

You cannot reply to this message, because it is very, very old.

 SHC (24 views) 2015-08-01 03:58:20 Jesse (19 views) 2015-07-29 04:35:27 Riven (40 views) 2015-07-27 16:38:00 Riven (21 views) 2015-07-27 15:35:20 Riven (24 views) 2015-07-27 12:26:13 Riven (14 views) 2015-07-27 12:23:39 BurntPizza (36 views) 2015-07-25 00:14:37 BurntPizza (46 views) 2015-07-24 22:06:39 BurntPizza (28 views) 2015-07-24 06:06:53 NoxInc (36 views) 2015-07-22 22:16:53
 theagentd 51x wessles 47x basil_ 35x KaiHH 26x orangepascal 26x ags1 21x Riven 19x mooman219 17x bornander 14x KudoDEV 13x CelestialCreator 11x princec 11x klaus 11x Jesse 11x pquiring 9x chrislo27 8x
 List of Learning Resourcesby gouessej2015-07-09 11:29:36How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21
 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