Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 889 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
possible bugs.. #447225
11/26/14 20:28
11/26/14 20:28
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

Joined: Mar 2012
Posts: 927
cyberspace
if I publish to a folder , it seems that cudart32_41_22.dll is not copied over in to the folder ,the engine then obviously complains about this ,I have to manually copy it .

something else that may be a bug also , when I create terrain at runtime or load terrain from file , and terrain lod is set above 0 , I cannot change the mesh with set_vertex , except for adding a frame wait of one for each vertex change inside the loop , if I didn't do it ,the terrain remains unchanged..

if I set terrain lod to zero ,I can apply vertex changes with set_vertex as usual but it means I have no lod for terrain .
in the manual I read that set_vertex automatically updates lod meshes .
it seems wrong to me somehow .

it would really help if wed-created regions could be iterated over from a list of type region ,instead of finding them by name perhaps ?

jb

Last edited by Wjbender; 12/01/14 12:09.

Compulsive compiler
Re: possible bugs.. [Re: Wjbender] #447292
12/02/14 08:22
12/02/14 08:22
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Thanks for the report! For automatically copying the right cudart DLL, please edit ackphysX.h and replace the file name in the PRAGMA_BIND statement. This will be fixed.

You can modify lod meshes with ent_setvertex. The change just needs 1 frame for being in effect on the terrain. So you can only modify the same vertex again in the next frame.

Re: possible bugs.. [Re: jcl] #447299
12/02/14 14:27
12/02/14 14:27
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

Joined: Mar 2012
Posts: 927
cyberspace
thank you jcl , and sorry I meant ent_setvertex , well I guess it makes sense to have 1 frame of update time needed , I then only need to find a way to apply hightmaps faster because I am stepping 1 pixel at a time which obviously takes ages from 1 vertex to the next with a frame wait of 1 in real time per step , anyone have any advice on how to step directly to each vertex in distance vs the step amount on the heightmap image in pixels ?

jb


Compulsive compiler
Re: possible bugs.. [Re: Wjbender] #447313
12/04/14 08:40
12/04/14 08:40
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
What do you mean, "stepping 1 pixel at a time"? Mesh manipulation is very fast. There are many examples in the manual and the sample scripts for changing a mesh.

Re: possible bugs.. [Re: jcl] #447318
12/04/14 11:51
12/04/14 11:51
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

Joined: Mar 2012
Posts: 927
cyberspace
I mean , if I need to apply a hightmap to a terrain with lod above 0 , if I had to step one pixel on the heightmap image to read its value ,then apply the height to the nearest vertex of the terrain ,how could I speed it up such that I skip directly to the next vertex instead of stepping 1 quant in 3d per pixel on the heightmap image ?

I have tried this but the wait(1) inside this loop makes it impossible for realtime , the reason I was trying to accomplish it in real time is because I wanted to generate terrains from coherent noise ,such that I only generate about 3x3 terrains at a time ,while moving through a large scale world ..

but ,I think it's going to be best to pre create the terrains and only load and unload them as I move through the world,because the fastest is to apply the hightmap on a terrain with lod set at 0 , then save it and then load it in the game with lod set above 0.

I thought the wait (1) and lod speed issue was clear from your response so what do you mean "what do I mean" ;-)


Compulsive compiler
Re: possible bugs.. [Re: Wjbender] #447319
12/04/14 11:55
12/04/14 11:55
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I meant that I still did not understand your problem. A wait inside a loop is certainly very slow and definitely not a good idea, especially for mesh manipulation. Just check out the examples. Nowhere is a wait in a loop. I'm sure you can modify them easily for reading the heights from your heightmap image.

Re: possible bugs.. [Re: jcl] #447322
12/04/14 13:59
12/04/14 13:59
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Wjbender you currently go from heightmap data and try to convert that into mesh data, right? Why not just take a vertex position and calculate the corresponding pixel position, like
px = (int)(clamp((vertex.x-min_terrain_x)/size_terrain_x,0,1)*(bitmap_size_x-1);
then read the height at the position via pixel instructions?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: possible bugs.. [Re: Superku] #447323
12/04/14 14:23
12/04/14 14:23
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
it works for me without waits, even with terrain lod:

Code:
int j;
	for (j=1; j<=ent_status(terrain_entity,0); j++)
		{
			CONTACT* c = ent_getvertex(terrain_entity,NULL,j);   			// vertex number begins with 1 !

			c.v.y += (float)worklevel;										// DirectX coordinate ! y up ! float !					
					
			ent_setvertex(terrain_entity,c,j);
			
											
		}



the only thing does not work is auto-update terrain vertex normals after deformation (which is not needed in case of the example above)


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: possible bugs.. [Re: sivan] #447330
12/04/14 16:58
12/04/14 16:58
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

Joined: Mar 2012
Posts: 927
cyberspace
since i havent worked with heightmaps before attempting this
i took a piece of code from the tust library that apply's the
heightmap to the terrain , it is this piece of code wich i cannot
understand why lod doesnt work with it unless a wait(1) is added .

the code in test_1 i took from the forum from sivan works fine
with lod bigger than 0 .

the code in test_2 is the one i attempted to use from a tust example
but it does not work with lod above 0, in test_3 you can see it works
fine with lod at 0 , in test_4 you can see it only works with lod above 0
if a wait(1) is added inside the loops ,why would this happen ? its not my own
code because i needed an example and i encountered the lod thingy with it ,so
i am not saying its supposed to work but i cannot quite understand why it does'nt ??


Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

//#define test_1 
//#define test_2
//#define test_3
//#define test_4

function main()
{
  	vec_set(screen_size,vector(800,600,0));
  	vec_set(screen_color,vector(50,1,1)); // dark blue
  	vec_set(sky_color,vector(50,1,1)); // dark blue
  	video_window(NULL,NULL,0,"terrain test");
 
  	level_load("");	
  	def_debug();
	def_move();
	
	vec_set(d3d_lodfactor,vector(1,2,3)); 

	BMAP* hm = "noise.jpg";

#ifdef test_1
	//test 1 works fine with lod>0
	terrain_lod=4;
#endif

#ifdef test_2
	//test 2 does not work with lod>0
	terrain_lod=4;
#endif

#ifdef test_3
	//test 3 is the same as test 2 but with lod==0 it works fine
	terrain_lod=0;
#endif

#ifdef test_4
	//test 4 is the same as test 2 but with a wait(1) in the loop is
	//needed for every update before it works ???
	terrain_lod=4;
#endif

	ENTITY *terrain=ent_createterrain(hm,nullvector,128,128,10);

//--------------------------------------------------------------

#ifdef test_1

	//works fine with lod >0

	int i=0;
	for(i;i<ent_status(terrain,0);i++)
	{
		CONTACT *pos=ent_getvertex(terrain,NULL,i);
		pos.v.y+=random(32);
		ent_setvertex(terrain,pos,i);
	}
	
#endif

//--------------------------------------------------------------

#ifdef test_2

	//does not work with lod>0

	int sx = bmap_width(hm);
	int sy = bmap_height(hm);
	int x=0,y=0;
	
	VECTOR pos;
	COLOR pixcol;

	var format = bmap_lock(hm, 0);	
	for(x=0; x<sx; x++) 
	{
		for(y=0; y<sx; y++) 
		{
			VECTOR* pos = vector(
				(terrain.x - terrain.min_x) - x * ((terrain.max_x - terrain.min_x) / sx),
				(terrain.y - terrain.min_y) - y * ((terrain.max_y - terrain.min_y) / sy),0);
				
			var v = ent_nextvertex(terrain, pos);
			CONTACT* cpos = ent_getvertex(terrain,NULL,v);

			var pix = pixel_for_bmap(hm, sx -x, y);
			pixel_to_vec(pixcol, NULL, format, pix);

			cpos.z = 0.1+(pixcol.blue );
			cpos.v=NULL;
			ent_setvertex(terrain,cpos,v);
		}
	}
	bmap_unlock(hm);	

#endif

//--------------------------------------------------------------

#ifdef test_3

	//the same as test 2 but with no lod it works fine

	int sx = bmap_width(hm);
	int sy = bmap_height(hm);
	int x=0,y=0;
	
	VECTOR pos;
	COLOR pixcol;

	var format = bmap_lock(hm, 0);	
	for(x=0; x<sx; x++) 
	{
		for(y=0; y<sx; y++) 
		{
			VECTOR* pos = vector(
				(terrain.x - terrain.min_x) - x * ((terrain.max_x - terrain.min_x) / sx),
				(terrain.y - terrain.min_y) - y * ((terrain.max_y - terrain.min_y) / sy),0);
				
			var v = ent_nextvertex(terrain, pos);
			CONTACT* cpos = ent_getvertex(terrain,NULL,v);

			var pix = pixel_for_bmap(hm, sx -x, y);
			pixel_to_vec(pixcol, NULL, format, pix);

			cpos.z = 0.1+(pixcol.blue );
			cpos.v=NULL;
			ent_setvertex(terrain,cpos,v);
		}
	}
	bmap_unlock(hm);	

#endif


//--------------------------------------------------------------

#ifdef test_4

	//the same as test 2 but needs a wait(1) in the loop before it works ??

	int sx = bmap_width(hm);
	int sy = bmap_height(hm);
	int x=0,y=0;
	
	VECTOR pos;
	COLOR pixcol;

	var format = bmap_lock(hm, 0);	
	for(x=0; x<sx; x++) 
	{
		for(y=0; y<sx; y++) 
		{
			VECTOR* pos = vector(
				(terrain.x - terrain.min_x) - x * ((terrain.max_x - terrain.min_x) / sx),
				(terrain.y - terrain.min_y) - y * ((terrain.max_y - terrain.min_y) / sy),0);
				
			var v = ent_nextvertex(terrain, pos);
			CONTACT* cpos = ent_getvertex(terrain,NULL,v);

			var pix = pixel_for_bmap(hm, sx -x, y);
			pixel_to_vec(pixcol, NULL, format, pix);

			cpos.z = 0.1+(pixcol.blue );
			cpos.v=NULL;
			ent_setvertex(terrain,cpos,v);
			
			wait(1);////why ???
		}
	}
	bmap_unlock(hm);	

#endif

}




uncomment the defines for each test

Last edited by Wjbender; 12/04/14 17:12.

Compulsive compiler
Re: possible bugs.. [Re: Wjbender] #447336
12/05/14 07:09
12/05/14 07:09
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline OP
User
Wjbender  Offline OP
User
W

Joined: Mar 2012
Posts: 927
cyberspace
@superku that sounds good ,working from the vertex side towards the bmap instead of the other way around , thanks I will try this out with iteration over the terrain vertices directly ,any way of doing something faster and more efficient is super in my book .


Compulsive compiler
Page 1 of 2 1 2

Moderated by  jcl, Nems, Spirit, Tobias 

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