Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
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 Offline
Expert
sivan  Offline
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:

Code:
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);
}



Free world editor for 3D Gamestudio: MapBuilder Editor
Re: terrain lod issue [Re: sivan] #447013
11/12/14 12:12
11/12/14 12:12
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

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: Wjbender] #447014
11/12/14 12:50
11/12/14 12:50
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I nearly never use created terrains, but plannig to use a heightmap based system to fine tune performance by setting terrain mesh resolution, so if you can make a simple example for Jcl he might help. he resolved when we reported the missing auto hull updating functionality.

currently only normals are not set automatically after vertex movements, but I think the engine default terrain vertex normal calculation is wrong, as my c-trace based solution looks very differently, and much better (except at some very sharp position which cannot be found in case of a real terrain).


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: terrain lod issue [Re: sivan] #447020
11/13/14 08:45
11/13/14 08:45
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

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
Re: terrain lod issue [Re: Wjbender] #447021
11/13/14 10:33
11/13/14 10:33
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
very strange.


Free world editor for 3D Gamestudio: MapBuilder Editor
Page 2 of 2 1 2

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