1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
void StaticChunk::createRenderObject(const ivec2 & offset)
{
int count = 0;
uint id;
int index = 0;
float layer = 0;
fvec3 coords[(chunksize*chunksize)*2*3];
fvec3 texcoords[(chunksize*chunksize)*2*3];
for(int x = 0; x<chunksize; x++)
{
for(int y = 0; y<chunksize; y++)
{
id = (*this)[(ivec2(x,y))].id;
layer = float(getGlobalTileSet()->getPrototype(id)->layer);
coords[index] = fvec3(offset.x+x,offset.y+y,0);
texcoords[index] = fvec3(0.f, layer, 0.f);
coords[index+1] = fvec3(offset.x+x+1,offset.y+y,0);
texcoords[index+1] = fvec3(1.f, layer, 1.f);
coords[index+2] = fvec3(offset.x+x+1,offset.y+y+1,0);
texcoords[index+2] = fvec3(1.f, layer, 1.f);
coords[index+3] = fvec3(offset.x+x+1,offset.y+y+1,0);
texcoords[index+3] = fvec3(1.f, layer, 1.f);
coords[index+4] = fvec3(offset.x+x,offset.y+y+1,0);
texcoords[index+4] = fvec3(0.f, layer, 1.f);
coords[index+5] = fvec3(offset.x+x,offset.y+y,0);
texcoords[index+5] = fvec3(0.f, layer, 0.f);
index += 6;
}
renderObject.setGeo(coords);
renderObject.setTextureCoords(texcoords);
}
}
|