Hi :)
How i can paint a terrain texture, with 3D position => 2D coordinate ?
i have try :
Function Trace(Px,Pz)
SetBuffer TextureBuffer(grass_tex)
Color 255,255,0
Oval Px,Pz,15,15,1
SetBuffer BackBuffer()
End Function
but don't work ?
Salut filax!
Function paint_terrain()
CameraPick(camera,MouseX(),MouseY())
xx=TerrainX(terrain,PickedX(),PickedY(),PickedZ())/(t_scalex*t_grid/t_size)
zz=TerrainZ(terrain,PickedX(),PickedY(),PickedZ())/(t_scalez*t_grid/t_size)
LockBuffer TextureBuffer(ombre)
For x#=-paint_size To paint_size
For z#=-paint_size To paint_size
If xx+x#=>0 And xx+x#<t_size And zz+z#=>0 And zz+z#<t_size
Select brtype
Case 0
dist# = (paint_size-Sqr(x#^2+z#^2))*opacite#*2
Case 1
dist# = (paint_size-Sqr(x^2+z^2))*opacite#*2*Rnd(0,1)
Case 2
If Sqr(x#^2+z#^2)<=paint_size Then dist# = paint_size*opacite*2 Else dist#=0
End Select
If dist>0
yy#=MapData(xx+x,zz+z)
yy=yy+dist
If yy#<0 Then yy#=0
If yy#>100 Then yy#=100
r1= 255
g1= 255
b1= 255
r2= R_paint
g2= G_paint
b2= B_paint
r3= R_paint/1.2
g3= G_paint/1.2
b3= B_paint/1.2
If yy#<=50
WritePixel xx+x,t_size-(zz+z),getrgb(r1+(r2-r1)*yy*.02,g1+(g2-g1)*yy*.02,b1+(b2-b1)*yy*.02),TextureBuffer(OMBRE)
MapData(xx+x,zz+z)=yy
Else
WritePixel xx+x,t_size-(zz+z),getrgb(r2+(r3-r2)*(yy-50)*.02,g2+(g3-g2)*(yy-50)*.02,b2+(b3-b2)*(yy-50)*.02),TextureBuffer(ombre)
MapData(xx+x,zz+z)=yy
End If
End If
End If
Next
Next
UnlockBuffer TextureBuffer(ombre)
End Function
the texture "ombre" is in multitexturing.
t_scale= scale du terrain
t_size= size du terrain (64,128,256,...)
Merci poto :) vive la france !
De rien filax!!
Au fait, ca marche bien??
J'ai pas encore eu le temps de tester mais j'ai mis la routine dans un coin.
Take a look at Total Terrain 2 (click the link in my sig) - you can paint textures directly onto the terrain as well as sculpt it...
I have try it ! very good job ! but ?? how i can use TOT files ?