1 registered members (AndrewAMD),
600
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: terrain lod issue
[Re: Wjbender]
#447011
11/12/14 10:50
11/12/14 10:50
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
I can use my terrain deformer for lodded terrain in latest non-published MapBuilder (the deformer code is the same as for non-lodded terrain). however, it uses a vertex based system, and sets all the lod0 vertices under the given area, even if a later lod of the chunk is visible. simply getvertex / set c.v.y / setvertex. and afterwards I set the normals to be proper by a function using c-tracings. here is one that sets a constant height:
void TerEdit_He_SetArea() // not brush based
{
if (proc_status(TerEdit_He_SetArea) > 0) return;
// manage undo array counters
teredit_he_undostep++;
if (teredit_he_undostep>9)
{
teredit_he_undostep = 0;
}
if (teredit_he_undostep==teredit_he_firstundo)
{
teredit_he_firstundo++;
if (teredit_he_firstundo>9)
{
teredit_he_firstundo = 0;
}
}
//---------------------------
// determine upper left and lower right vertex corners, i.e. get x,y vertex count within cube area
sys_marker("R01");
// x,y vertex size of terrain
var vert_count_x = ent_status(terrain_entity,2)+1;
var vert_count_y = ent_status(terrain_entity,3)+1;
// upleft and downright tile corner positions
var upleft_pos_x = teredit_placement_cube.x - integer(teredit_tilesize/2)*GetMapTileSize();
var upleft_pos_y = teredit_placement_cube.y + integer(teredit_tilesize/2)*GetMapTileSize();
var upleft_pos_z = teredit_placement_cube.z; // PosInfo3D(upleft_pos_x, upleft_pos_y);
var dnright_pos_x = teredit_placement_cube.x + integer(teredit_tilesize/2)*GetMapTileSize();
var dnright_pos_y = teredit_placement_cube.y - integer(teredit_tilesize/2)*GetMapTileSize();
var dnright_pos_z = teredit_placement_cube.z; // PosInfo3D(dnright_pos_x, dnright_pos_y);
// corner vertices slosest to corner tile middles
var upleft_vert = ent_nextvertex(terrain_entity,vector(upleft_pos_x,upleft_pos_y,upleft_pos_z));
var dnright_vert = ent_nextvertex(terrain_entity,vector(dnright_pos_x,dnright_pos_y,dnright_pos_z));
// protection - no valid vertex found by ent_nextvertex
if ((upleft_vert==(var)0) || (dnright_vert==(var)0))
{
return;
}
// vertices in a row & column
var width_vert = abs( dnright_vert%( ent_status(terrain_entity,2)+1 ) - upleft_vert%( ent_status(terrain_entity,2)+1 ) );
var height_vert = abs( integer( dnright_vert /( ent_status(terrain_entity,2)+1 )) - integer( upleft_vert /( ent_status(terrain_entity,2)+1 )) );
sys_marker(NULL);
sys_marker("R02");
// do vertex moves
int i,j,k;
var m;
for (i=0;i<width_vert;i++)
{
for (j=0;j<height_vert;j++)
{
// vertex number
k = upleft_vert +j*vert_count_x +i;
// protection
if (k>ent_status(terrain_entity,0))
{
break;
}
m = teredit_set; // temp test - okay
CONTACT* c = ent_getvertex(terrain_entity,NULL,k); // vertex number begins with 1 !
c.v.y = (float)m;
ent_setvertex(terrain_entity,c,k);
// actual
// teredit_vertexarray[k-1].actual = (var)c.v.y;
// new undo step
// teredit_vertexarray[k-1].undo[teredit_he_undostep] = (var)c.v.y; // BAD - whole evrtex array must be copied to not to keep non-corresponding data !
}
}
sys_marker(NULL);
TerEdit_He_StoreUndoStep();
// wait(1);
// c_updatehull(terrain_entity,0); // works fine but slow
// ent_fixnormals(terrain_entity,0); // not okay for chunked terrain - cause error around 1st chunk border
wait(1);
TerEdit_FixNormals_Area(upleft_vert,width_vert,height_vert,vert_count_x);
}
|
|
|
Re: terrain lod issue
[Re: sivan]
#447013
11/12/14 12:12
11/12/14 12:12
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
I use the same functions , however I am using runtime created terrain .
am I misreading the manual in ent_setvertex where it states :
updating shared vertices of terrain chunks ,mesh seams ,OR LOD MESHES ,as well as updating the visual bounding box AUTOMATICALLY HANDLED BY ent_setvertex ...
however like I said when setting lod to 4 the terrain remains flat(no vertices changed) with functional lod ,but setting lod to 0 the terrain vertices is changed successful and no lod.
why do I get the impression that this is a bug according to how I read the manual , lod should automatically update , but it is not doing this .
I know lod is automatically generated for loaded levels , but it also generates for created terrain ,the only issue is it does not allow me to change the terrain vertices with set_vertex ,leaving me with a flat terrain with working lod wich is pretty useless ..
I am starting to think I would have to work with the terrain meshes through theire mesh buffers if I ever are going to get it working ,what a pitty .
jb
Last edited by Wjbender; 11/12/14 12:44.
Compulsive compiler
|
|
|
Re: terrain lod issue
[Re: sivan]
#447020
11/13/14 08:45
11/13/14 08:45
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
i found that the only way I can get setvertex to work is by waiting 1 frame for every vertex change .
Compulsive compiler
|
|
|
|