| ent | model or terrain entity pointer. |
| num | vertex number, beginning with 1. |
| c | Pointer to a pre-filled CONTACT* struct (defined in atypes.h) for setting or reading the vertex content. With ent_getvertex, NULL can be given for returning the pointer to an internal static CONTACT struct. |
The following members of the CONTACT struct are used (see also hit):
| c.v | D3DVERTEX* pointer of the current animated and interpolated mesh position, set by ent_getvertex and used by ent_setvertex for updating the mesh. Note that the vertex position is float instead of var and uses the DX coordinate system. The D3DVERTEX format is described in the shader section and defined in atypes.h. |
| c.x,y,z | VECTOR containing the vertex position in local entity coordinates, set by ent_getvertex. On non animated entities, the position is the same as in c.v; on vertex animated entities, it's the vertex position in the current non-interpolated frame; on bones animated entities, it's the vertex position of the base frame. Set c.v to NULL when ent_setvertex should update this vector rather than c.v. Updating c.v is faster, but won't work for animated entities. |
| c.nx,ny,nz | VECTOR containing the vertex normal, set by ent_getvertex. For changing the vertex normal, use c.v. |
| c.vertex | Local vertex number within the sub-mesh. Set by by ent_getvertex and used by ent_setvertex for multi-mesh entities. |
| c.chunk | Sub-mesh number in case of multi-mesh entities, such as map entities or chunked terrain. Set by ent_getvertex and used by ent_setvertex. |
| c.model | Sub-mesh pointer, set by by ent_getvertex. If this pointer is nonzero, ent_getvertex uses the c.vertex value for the vertex number, instead of the num parameter. This speeds up the function on multi-mesh entities. Set this pointer to NULL when ent_getvertex was not called before ent_setvertex. |
// raise all terrain vertices by 5 units
function raise_terrain(ENTITY* terrain)
{
int i = ent_status(terrain,0); // number of vertices
for (; i>0; i--) {
CONTACT* c = ent_getvertex(terrain,NULL,i);
c.v.y += 5.0; // raise the vertex (y is the height in DX coorcinates)
ent_setvertex(terrain,c,i);
}
}
// use a gun to produce mole-hills in terrain
function mole_gun()
{
while (1)
{
// 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);
c.z += 10; // 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
}
wait(1);
}
}
See also:
ent_status, ent_nextvertex, ent_getmesh, ent_buffers, hit