Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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), 838 guests, and 2 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
Ent_setvertex, multiple points #288846
09/09/09 02:37
09/09/09 02:37
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
So, having advanced my skills in coding a bit, I was thinking about how an in-game map editor could work. I looked around in the manual and found this snippet.
Quote:

// calculate the target vector
VECTOR trace_target;
vec_set(trace_target,vector(5000,0,0)); // firing range 5000 quants
vec_rotate(trace_target, camera.pan);
vec_add(trace_target, camera.x);

// display a red spot at the target position
if (c_trace(camera.x,trace_target, IGNORE_PASSABLE | USE_POLYGON| SCAN_TEXTURE) > 0) // hit something?
draw_point3d(hit.x,vector(50,50,255),100,3);
if (key_ctrl && HIT_TARGET && you && ent_type(you) == 4) // fire onto terrain
{
// create a mole-hill by elevating the closest terrain vertex
var vertex_num = ent_nextvertex(you,hit.x);
CONTACT* contact = ent_getvertex(you,NULL,vertex_num);
hit.z += 10; // increase the vertex height
hit.v = NULL; // c.x,y,z was changed, instead of c.v
ent_setvertex(you,hit,vertex_num); // update the mesh

wait(-0.5); // reload
}


I added this to my code with some tweaking, but obviously one vertex being manipulated was hardly good enough. I was trying to puzzle out a way of getting say, a circle of vertices selected. I found ent_nextvertex, but this seems rather unwieldy to use (defining that many different vertices?) Can anyone help me out with this? Suggestions would be nice.

Last edited by Tai; 09/09/09 02:37.
Re: Ent_setvertex, multiple points [Re: Tai] #288917
09/09/09 11:47
09/09/09 11:47
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
you are on the right path. Just cycle through all vertices of the model, check their position and displace them in the way you want.

This is the fastest (and probably only) way you can achieve that with the engine functions. If you need it faster or something you have to look into the dx functions.

Scorpion

Re: Ent_setvertex, multiple points [Re: Scorpion] #289008
09/09/09 22:11
09/09/09 22:11
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
Interestingly enough, trying to add vertices next the hit location doesn't seem to be working. I tried simply adding 1 to the vertex number, but that doesn't seem to work. Since the vertices in a terrain are numbered in x+y patterns, shouldn't I be able to do something like...
Code:
var vertex_num = ent_nextvertex(you,hit.x+1);



Re: Ent_setvertex, multiple points [Re: Tai] #289010
09/09/09 22:28
09/09/09 22:28
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hit.x gives the position, where the trace hit and because a position is a vector of 3 variables, it doesn't make much sense to add 1. If you want to change the position, you have to change the components of it. e.g.:
Code:
//move the position up by one quant
var vertex_num = ent_nextvertex(you, vector(hit.x, hit.y, hit.z+1));



PS: this function doesn't affect the position of a vertex. it just looks for the vertex that is nearest to the given position

Re: Ent_setvertex, multiple points [Re: Scorpion] #289012
09/09/09 22:44
09/09/09 22:44
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
I was assuming that hit.x was a literal vector(xyz), so that makes sense.

(I also knew that wouldn't change the position of the vertex, I just needed to get it so I could modify it.)

I'll test that out and post back with results.

Re: Ent_setvertex, multiple points [Re: Tai] #289013
09/09/09 22:54
09/09/09 22:54
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
Code:
while (mouse_left && HIT_TARGET && you && ent_type(you) == 4) // fire onto terrain
    	{
			// create a mole-hill by elevating the closest terrain vertex         
			var vertex_num = ent_nextvertex(you,hit.x);  
			var vertex_num_vert_1 = ent_nextvertex(you, vector(hit.x+1, hit.y+1, hit.z+1));
			var vertex_num_vert_2 = ent_nextvertex(you, vector(hit.x+2, hit.y+2, hit.z+2));
			var vertex_num_vert_3 = ent_nextvertex(you, vector(hit.x+3, hit.y+3, hit.z+3));
			var vertex_num_vert_4 = ent_nextvertex(you, vector(hit.x+4, hit.y+4, hit.z+4));
			var vertex_num_vert_5 = ent_nextvertex(you, vector(hit.x+5, hit.y+5, hit.z+5));
			var vertex_num_vert_6 = ent_nextvertex(you, vector(hit.x+6, hit.y+6, hit.z+6));
			var vertex_num_vert_7 = ent_nextvertex(you, vector(hit.x+7, hit.y+7, hit.z+7));
			var vertex_num_vert_8 = ent_nextvertex(you, vector(hit.x+8, hit.y+8, hit.z+8));
			CONTACT* contact = ent_getvertex(you,NULL,vertex_num);   
			hit.z += 5 * time_step;  // increase the vertex height
      	hit.v = NULL; // c.x,y,z was changed, instead of c.v     
      	ent_setvertex(you,hit,vertex_num);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_1);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_2);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_3);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_4);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_5);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_6);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_7);    // update the mesh
 			ent_setvertex(you,hit,vertex_num_vert_8);    // update the mesh
      	//bmap_blit(bmap_for_entity(terrain_basic,0),terrain_paint_grass,hit.u1,NULL);
      	wait(1); // reload
    	}



Ack, I feel so stupid, but it's still not working! I'm wondering if I'm overlooking something.

PS. I know the vertexes that are selected are going to be very random, it was a test to see if any more would be.

Last edited by Tai; 09/09/09 23:45.
Re: Ent_setvertex, multiple points [Re: Tai] #289123
09/10/09 16:44
09/10/09 16:44
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
looks somehow weird, but since I used ent_setvertex last, it somehow changed. would have to read into it.

But what i see directly is that you don't even use the contact struct you defined. maybe you confused contact and hit?


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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