Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ozgur), 1,526 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
terrain_pixel_for_pos or any formula, no work #425864
07/11/13 21:04
07/11/13 21:04
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I'm not managing to get the exact position of the pixels of the skin of my terrain.

after trying to make the calculations manually and not succeed I tried using the function, terrain_setpixel and resulted in the same problem I was having manually.


As you can see in the picture above, when I try to post the position indicated by the position of the mouse in the 3D world, he paints in a wrong position.

I have a another project that working .
In this project that works correctly, the difference it is on creation of this terrain.
In the functional project, I created the terrain from a existing HMP. ent_createlocal()...

In this current project which I can not get the correct coordinates, I am using dynamic terrain. ent_createterrain...

SAMPLE
Code:
function terrain_paintPixel(ENTITY* terrain,x,y,BMAP* skin, var brushSize, COLOR* color)
{
		

	if(!skin) skin = ent_getskin(terrain,1);
	
	//Convert word for pixel cordenate
	VECTOR* pos = terrain_pixel_for_pos(terrain,x,y,skin);
	if (!pos) return;

	var range = 64; //Range of the brush
	
	var format = bmap_lock(skin,0);	
	var i,j,fx,fy,ex,ey;	
	
	fx = pos.x -range; //X from
	ex = pos.x + range; //Y from	
	
	fy = pos.y - range; //X End
	ey = pos.y + range; //Y End

	VECTOR skinpos; //receive pixel for word cordenates for vec_dist
	var pixel;
	
	for(j=fx; j<= ex; j++)
	for(i=fy; i<= ey; i++)
	{		
//Convert pixel for word cordenate    
vec_set(skinpos,terrain_pixel_to_pos(terrain,j,i,skin));	
		
                //round brush
		if(vec_dist(_vec(x,y,0),_vec(skinpos.x,skinpos.y,0))<=(range/2))
		{			
			pixel = pixel_for_vec(color,100,format);
			pixel_to_bmap(skin,j,i,pixel);	//No correct position		
			
		}
		
		
	}
	
	bmap_unlock(skin);
	
}



I can not understand why it is not working correctly.
Does anyone know tell me if the problem is in USE dynamic terrain? (ent_createterrain...).


Last edited by NeoNeper; 07/11/13 22:09.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: terrain_pixel_for_pos or any formula, no work [Re: NeoNeper] #425867
07/11/13 22:03
07/11/13 22:03
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
for testing, i decreases the function and i use draw_point3d to verify if the location of the coordinates 3D were correct.
It worked perfectly, and the 3Dpoints were placed exactly in the desired locations.

Code:
function terrain_paintest(...)
{
		

	if(!skin) skin = ent_getskin(terrain,1);

	var range = 64;
	
	var format = bmap_lock(skin,0);	
	var i,j,fx,fy,ex,ey;	
	
        //x and y is the mouse cordenate in word 3D
	fx = x -range; //X from
	ex = x + range; //Y from	
	
	fy = y - range; //X End
	ey = y + range; //Y End
	
	for(j=fx; j<= ex; j++)
	for(i=fy; i<= ey; i++)
	{		
		
		if(vec_dist(_vec(x,y,0),_vec(j,i,0))<=(range/2))
		{			
	
			draw_point3d(_vec(j,i,2), _vec(0,0,255), 100,2);
			
			
		}
		
		
	}	

	
}




So the problem really is in receiving the correct coordinates of pixels!
Can anyone help me?

Using the same function but now instead of using points i use terrain_setpixel(terrain,j,i,skin,color);[b][/b]
the positions of the painting are wrong!. no WOrk Fine.

Code:
for(j=fx; j<= ex; j++)
	for(i=fy; i<= ey; i++)
	{		
		
		if(vec_dist(_vec(x,y,0),_vec(j,i,0))<=(range/2))
		{			
	        //no working fine
		terrain_setpixel(terrain,j,i,skin,color);
			
			
		}
		
		
	}


Last edited by NeoNeper; 07/11/13 22:08.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________

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