Hello,
I know you have got allready a lot of suggestions about the tileproblem, but I did some testing and have a whole different sollution for you.

Just execute this code and see.
Click onto the rectangle to switch a tile.

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <stdio.h>

///////////////////////////////

void createFile();
void createAdvanced();
void clickAround();

BMAP *sand = "b1.tga";
BMAP *gras = "b2.tga";

STRING *line = "";

ENTITY *wall;

void main()
{
	mouse_mode = 4;
	mouse_pointer = 2;
	mouse_sync = 1;
	video_switch(10, 32, 2);
	wait(1);
	level_load("");
	
	createAdvanced();
	
	camera.pan = 90;
	camera.y = -512;
	camera->flags |= ISOMETRIC;
	camera.arc = 20;
	
	clickAround();
}

void clickAround()
{
	VECTOR to;
	
	while(1)
	{
		if(mouse_left)
		{
			vec_set(to, mouse_dir3d);
			vec_scale(to, 1000);
			vec_add(to,mouse_pos3d);
			c_trace(mouse_pos3d, to, USE_POLYGON | SCAN_TEXTURE);
			if(hit.entity != NULL)
			{
				ENTITY *w = hit.entity;
				var s = hit.triangle;
				if(s % 2 != 0) { s++; }
				s /= 2;
				int v1 = ((s - 1) * 4) + 1;
				CONTACT *c = ent_getvertex(w, NULL, v1);
				c.v = NULL;
				c.x += 8;
				ent_setvertex(w, c, v1);
				
				c = ent_getvertex(w, NULL, v1 + 1);
				c.v = NULL;
				c.x -= 8;
				ent_setvertex(w, c, v1 + 1);
				
				c = ent_getvertex(w, NULL, v1 + 2);
				c.v = NULL;
				c.x += 8;
				ent_setvertex(w, c, v1 + 2);
				
				c = ent_getvertex(w, NULL, v1 + 3);
				c.v = NULL;
				c.x -= 8;
				ent_setvertex(w, c, v1 + 3);
			}
			while(mouse_left) { wait(1); }
		}
		wait(1);
	}
}

void createAdvanced()
{
	int px, py;
	int x, y;
	double rx, ry;
	int i = 0;
	STRING *f = str_create("");
	int mesh = 0;
	
	BMAP *map01 = bmap_createblack(320, 320, 32);
	
	for(px = 0; px < 1; px++)
	{
		for(py = 0; py < 1; py++)
		{
			str_printf(f, "mesh%.0f.obj", (double)mesh);
			
			FILE *file = fopen(f.chars, "wb");
			
			for(y = 0; y < 20; y++)
			{
				for(x = 0; x < 20; x++)
				{
					rx = x * 8;
					ry = -y * 8;
					str_printf(line, "v %.0f %.0f 0\n", rx, ry);
					fputs(line.chars, file);
					str_printf(line, "v %.0f %.0f 0\n", rx + 8, ry);
					fputs(line.chars, file);
					str_printf(line, "v %.0f %.0f 0\n", rx, ry - 8);
					fputs(line.chars, file);
					str_printf(line, "v %.0f %.0f 0\n", rx + 8, ry - 8);
					fputs(line.chars, file);
				}
			}
			
			fputs("\n", file);
			
			for(y = 0; y < 20; y++)
			{
				for(x = 0; x < 20; x++)
				{
					str_printf(line, "vt %.3f %.3f\n", (double)x / 20.0, (double)y / 20.0);
					fputs(line.chars, file);
					str_printf(line, "vt %.3f %.3f\n", ((double)x + 1) / 20.0, (double)y / 20.0);
					fputs(line.chars, file);
					str_printf(line, "vt %.3f %.3f\n", (double)x / 20.0, ((double)y + 1) / 20.0);
					fputs(line.chars, file);
					str_printf(line, "vt %.3f %.3f\n", ((double)x + 1) / 20.0, ((double)y +1) / 20.0);
					fputs(line.chars, file);
					
					bmap_blit(map01, sand, vector(x * 16, y * 16, 0), NULL);
				}
			}
			
			fputs("\n", file);
			
			for(i = 0; i < 400; i++)
			{
				double v1 = i * 4 + 1;
				double v2 = v1 + 1;
				double v3 = v1 + 2;
				double v4 = v1 + 3;
				str_printf(line, "g plane%.0f\n", (double)i);
				fputs(line.chars, file);
				str_printf(line, "f %.0f/%.0f %.0f/%.0f %.0f/%.0f\n", v3, v3, v2, v2, v1, v1);
				fputs(line.chars, file);
				str_printf(line, "f %.0f/%.0f %.0f/%.0f %.0f/%.0f\n", v3, v3, v4, v4, v2, v2);
				fputs(line.chars, file);
			}
			
			fclose(file);
			
			wall = ent_create(f, vector(px * 160, 0, py * 160), NULL);
			
			ent_setskin(wall, map01, 1);
			mesh++;
		}
	}
	
	str_remove(f);
}



Some problems: You can't clone an entity with ent_clone created from an *.obj mesh, because stupid c_trace goes nuts if you do so.
So you have to create a mesh for every chunk of tiles.
Workaround: delete the obj meshes before quitting the programm.
Texturing is a pain in the ass, because ent_create doesn't load the textures of the mtl library connected to the properly. MED does this without problems, but at runtime there is a neat out of memory error. so you have to create a bigger texture for every chunk and blit the tiletexture onto it, then use ent_setskin.

But, I've got maximaml framerates out of this, even with a lot of chunks.

There is a lot of room for improvement. Perhaps it is possible to create the meshes in a virtual filesystem, without bothering the harddrive.
With a lot of chunks, the loading time is very long. I've tested 60 chunks and it took 20 secs to create them.

Edit: Of course you could create a directX mesh. But everytime I've did that and attached it to an entity the engine messed up the clipping the hull the visibility and everything. Of course it could have also been me who messed up the vertice normals, order ...


Last edited by jenGs; 07/27/11 23:06.