2 registered members (AndrewAMD, Ayumi),
838
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Ent_setvertex, multiple points
#288846
09/09/09 02:37
09/09/09 02:37
|
Joined: Sep 2008
Posts: 68
Tai
OP
Junior Member
|
OP
Junior Member
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. // 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]
#289010
09/09/09 22:28
09/09/09 22:28
|
Joined: Jan 2007
Posts: 1,619 Germany
Scorpion
Serious User
|
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.:
//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: Tai]
#289013
09/09/09 22:54
09/09/09 22:54
|
Joined: Sep 2008
Posts: 68
Tai
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 68
|
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.
|
|
|
|