hit.vertex?

Posted By: Superku

hit.vertex? - 01/14/11 23:43

Ich habe ein Terrain, 60x30 Vertices, und benutze SCAN_TEXTURE, um hit.vertex auszulesen. Die (x-)Richtung scheint jedoch auf 32 Vertices begrenzt zu sein, gehe ich bspw. auf der ersten (y = 1) Zeile von x-Vertices entlang, so wird mir Vertex 33 als 1 angezeigt usw.

Click to reveal..
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////


VECTOR temp;
var i;

action terrain() {
	while(1) {
		for(i = 0; i < ent_status(my,0); i++) { // 
			CONTACT* c = ent_getvertex(my,NULL,i);
			vec_set(temp,c.x);
			if(vec_to_screen(temp,camera)) {
				draw_text(str_printf(NULL,"%d",(int)(i+1)),temp.x,temp.y,COLOR_WHITE);
			}
		}

		wait(1);
	}
}

void main() {
	fps_max = 60;
	video_mode = 11;
	level_load(NULL);
	me = ent_create("ter1.hmp",nullvector,terrain);
	camera.z = 100;
	camera.tilt = -50;
	mouse_mode = 4;
	mouse_range = 9999;
	while(1) {
		vec_set(temp,mouse_dir3d);
		vec_scale(temp,mouse_range);
		vec_add(temp,mouse_pos3d);
		c_trace(mouse_pos3d,temp,IGNORE_MODELS | SCAN_TEXTURE);
		
		
		if(trace_hit) {
			draw_point3d(target,COLOR_RED,50,2);
			CONTACT* c = ent_getvertex(me,NULL,hit.vertex);
			draw_point3d(c.x,COLOR_BLUE,150,2);
		}	
		DEBUG_VAR(hit.vertex,500);
		wait(1);
	}
}



Übrigens, die Decal-Schatten funktionieren seit v8.10.1 nicht mehr richtig (EDIT: Umstände sind mir noch nicht ganz klar, vllt nur bei Block-Untergrund), sie verdecken kleine bis sehr große Teile des eigenen Modells (shadow_mode |= IGNORE_MODELS; bewirkt keinen Unterschied).
Posted By: flits

Re: hit.vertex? - 01/15/11 08:52

maby it has somthing to do with terrain_chunk

terrain_chunk = 0;
Posted By: Superku

Re: hit.vertex? - 01/15/11 11:44

You're right, that's of course the reason for my (first) problem. But is there an easy way to get the vertex number without disabling terrain chunking?
Posted By: wdlmaster

Re: hit.vertex? - 01/15/11 14:39

not tested, but should work (assuming that a terrain chunk is 32*32):
Code:
hit.chunk * 1024 + hit.vertex;


Posted By: Superku

Re: hit.vertex? - 01/15/11 15:14

Thanks but that won't do the trick. The first 32 vertices belong to the first chunk, the next 28 to the second chunk (sums up to the first row of the original terrain) and so on.
Posted By: jcl

Re: hit.vertex? - 01/17/11 13:06

Correct. You need to consider the chunks. Use ent_getvertex, that does this already.
Posted By: Superku

Re: hit.vertex? - 01/17/11 22:06

Stimmt, ich benutze bereits ent_nextvertex für andere Dinge, hätte ich auch so darauf kommen können. (Kann also geschlossen oder verschoben werden.)
© 2024 lite-C Forums