Originally Posted By: JerahYalyn
I think vec_rotate is not needed when using vec_for_screen. If I use it the ray tracer will rotate away from where I'm actually pointing. I tried your code rayp but I doesn't make any difference, there is still no hit.vertex returned.
I don't think 'vec_rotate' is needed for a line tracing from camera to the mouse position too. Cause mouse position will be infront of the camera anyway.

Originally Posted By: JerahYalyn
I actually use USE_POLYGON first and set terrain flags to POLYGON before changing my code since it still returns the sams result.
About USE_POLYGON and POLYGON flag for terrains, I couldn't post this via cellphone, but take a look at this:

So once again, I want to aware you to do not use such SLOW things when they aren't needed.

Originally Posted By: JerahYalyn
@3run, Thanks for pointing that out to me man. I was able to fix it by using ent_nextvertex. I need to keep the GS manual open all the time for the list of all the functions.

Now I just have to figure how to get all the the vertex near the hit position at a given radius without looping through each indices. I use Markus's real time terrain deforming library in A7 but it no longer work for A8 so I have to make my own function for terraform.
There was an example of terrain deforming somewhere around the forum:
Terrain Deform realTime
[Contest entry] DEFORM TERRAIN

Ask people in those threads, maybe someone still have any of those demos and can upload them for you.

About the working example I've made yesterday, here it is:
Code:
#define USE_FOR_LOOP

void main(){
	
	fps_max = 60;
	
	level_load("");
	
	BMAP* skinBmp = bmap_createblack(64, 64, 24);
	bmap_fill(skinBmp, COLOR_WHITE, NULL);
	
	
	ENTITY* terrainEnt = ent_createterrain(NULL, nullvector, 6, 6, 24);
	ent_setskin(terrainEnt, skinBmp, 0);
	
	d3d_lines = 3;
	
	vec_set(camera.x, vector(-180, 77, 166));
	vec_set(camera.pan, vector(339, -49, 0));
	
	mouse_mode = 4;
	
	VECTOR tempVec, vertexVec;
	
	var total_vertices = ent_vertices(terrainEnt);
	var hit_vertex = 0;
	
	int i = 0;
	
	while(terrainEnt){
		
		DEBUG_VAR(total_vertices, 10);
		DEBUG_VAR(hit_vertex, 40);
		
		vec_set(tempVec, mouse_dir3d);
		vec_scale(tempVec, 1000);
		vec_add(tempVec, mouse_pos3d);
		
		if(c_trace(mouse_pos3d, tempVec, IGNORE_PASSABLE + SCAN_TEXTURE) > 0){
			
			hit_vertex = hit.vertex;
			
			draw_point3d(hit.x, COLOR_RED, 100, 3);
		}
		
		if(HIT_TARGET && you && ent_type(you) == 4){
			
			#ifdef USE_FOR_LOOP
				
				for(i = 1; i < total_vertices + 1; i++){
					
					vec_for_vertex(vertexVec, terrainEnt, i);
					
					if(vec_dist(vertexVec.x, hit.x) < 10){
						
						CONTACT* contact = ent_getvertex(terrainEnt, NULL, i);
						contact.z += time_step;
						contact.v = NULL;
						ent_setvertex(terrainEnt, contact, i);					
						
						draw_point3d(vertexVec.x, COLOR_GREEN, 100, 5);
					}
				}
				
			#else
				
				CONTACT* contact = ent_getvertex(terrainEnt, NULL, hit_vertex);
				
				draw_point3d(contact.x, COLOR_GREEN, 100, 5);
				
				contact.z += time_step;
				contact.v = NULL;
				ent_setvertex(terrainEnt, contact, hit_vertex);					
				
			#endif
		}
		
		wait(1);
	}
}



If I remember correctly in most of those terrain deforming demos, they took 'hit' position and the nearest vertex, but then they create a square or circle around it, via some simple math calculations. I can't really help at this point, cause I've never made terrain deformation tools. You can also ask sivan if he is in a good mood, he might help you with this, since he is working on his MapEd for a few years now.

Originally Posted By: JerahYalyn
I use Markus's real time terrain deforming library in A7 but it no longer work for A8 so I have to make my own function for terraform.
BTW, why doesn't it work? Crashes?

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung