Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
terrain deformation with a cursor #447483
12/15/14 21:55
12/15/14 21:55
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Howdy! I am trying to make a red dot move along the surface of this terrain while it's position is controlled by the mouse cursor. The player is in first person mode controlled by WASD keys but NOT the mouse. It's been a while since I used this engine and would appreciate some help. I am very glad to be back though! laugh

Is there maybe a template anyone has for this?

So far here is what I got.(This is all in a while loop):

Code:
VECTOR mouse_trace;//vector that will glide along terrain's surface moved by mouse

c_trace();//what to do here?

draw_point3d(mouse_trace,COLOR_RED,100,3);//draw the vector to be drawn along trerrain surface	

if (mouse_left && HIT_TARGET && you && ent_type(you) == 4) // click onto terrain
{
	var vertex_num = ent_nextvertex(you,hit.x);      
	CONTACT* c = ent_getvertex(you,NULL,vertex_num);  
	c.z += 3;  // increase the vertex height
	c.v = NULL; // c.x,y,z was changed, instead of c.v   
	ent_setvertex(you,c,vertex_num);    // update the mesh
	wait(-0.5); // reload
}



boolean my.awesomeness = so true;
Re: terrain deformation with a cursor [Re: Dega] #447490
12/16/14 09:18
12/16/14 09:18
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
a little snippet, just call it where you put the c-trace (and instead of the mouse_trace vector you can read simply the hit.x vector what you should put after the if statements):

Code:
// get mouse position on terrain surface
void	Camera_Mouse3D1()
{
	VECTOR pos1, pos2;

	vec_set( pos1 , vector(mouse_pos.x,mouse_pos.y,0) );
	vec_for_screen (pos1, camera);
	
	vec_set( pos2 , vector(mouse_pos.x,mouse_pos.y,15000) ); // should be a big value       		
	vec_for_screen (pos2, camera);

	c_trace (pos1.x, pos2.x, IGNORE_ME | IGNORE_CONTENT | IGNORE_SPRITES | IGNORE_PASSABLE | IGNORE_MODELS | IGNORE_MAPS | IGNORE_FLAG2); 
	// if there is a HIT_TARGET event, now "target" and "hit.x" hold the coordinates of the hit point 
	// ignoring tile sprites, models, map-entities and other passable entities including passable terrains (water)      
}



moreover I would use a separate if for the ent_type, because >as I know< in lite-c all the AND-ed comparisons are checked, unlike in C/C++.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: terrain deformation with a cursor [Re: sivan] #447497
12/16/14 16:35
12/16/14 16:35
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Just what I wanted. Although I am lowering the value because I don't want the player editing the terrain from far away but thanks. I appreciate those skills and effort. Much thanks friend!


boolean my.awesomeness = so true;

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1