Paint Terrain

Blitz3D Forums/Blitz3D Programming/Paint Terrain

EmerGki(Posted 2006) [#1]
How I Paint terrain tiles with textures?
the tiles must be selected by mouse position.


DJWoodgate(Posted 2006) [#2]
Perhaps do a CameraPick to select the surface tile of the Mesh based terrain based on a 2d mouse cursor position.
PaintSurface the PickedSurface with a Brush that you have applied a texture to using BrushTexture.


EmerGki(Posted 2006) [#3]
If MouseDown(1)
CameraPick (ocamera,MouseX(),MouseY())
surf=PickedSurface ()
PaintSurface surf,brush
EndIf

I try this code, but, "Memory Access Violation" in the line "PaintSurface surf,brush"


DJWoodgate(Posted 2006) [#4]
Have you made it pickable?
EntityPickMode myterrainmesh,2

Are you picking it?
if MouseHit(1) Then
Picked=CameraPick(ocamera,MouseX(),MouseY())
If Picked=myterrainmesh Then..


EmerGki(Posted 2006) [#5]
et=CameraPick (ocamera,MouseX(),MouseY())
PositionEntity esfera,PickedX(),PickedY(),PickedZ()
If et=oTerrain
ShowEntity esfera
If MouseHit(1)
CameraPick (ocamera,MouseX(),MouseY())
surf=PickedSurface ()
PaintSurface surf,brush
EndIf
EndIf


Yeah, I'm making all of this.


John Blackledge(Posted 2006) [#6]
But have you actually created the brush, ready for use?


EmerGki(Posted 2006) [#7]
I tried:

Global brush=LoadBrush ("texture.bmp",1)

and

Brush=CreateBrush (250,0,0)


EmerGki(Posted 2006) [#8]
Can Someone post any example of how to do this?


Damien Sturdy(Posted 2006) [#9]
I bet you didnt read the original response:

How are you making your terrain?


EmerGki(Posted 2006) [#10]
;Create Terrain
oTerrain=CreateTerrain (128)
EntityPickMode oTerrain,2
textura=LoadTexture ("emerson\mossy.bmp")
EntityTexture oterrain,textura

Global brush=LoadBrush ("emerson\cur.bmp",1)


et=CameraPick (ocamera,MouseX(),MouseY())
PositionEntity esfera,PickedX(),PickedY(),PickedZ()
If et=oTerrain
ShowEntity esfera
If MouseHit(1)
CameraPick (ocamera,MouseX(),MouseY())
surf=PickedSurface ()
PaintSurface surf,brush
EndIf
EndIf


DJWoodgate(Posted 2006) [#11]
Ah well I suppose I should have been clearer and I am sorry I did not fully understand the question. From your previous posts I thought you were going with mesh based terrains.

By Mesh based terrain I meant a terrain you create yourself using CreateMesh (and the associated Mesh and Surface functions) or create externally and load with LoadMesh. Blitz terrains are based on a special sort of LOD (level of detail) mesh that is constructed on the fly for each camera based on heightmap data and camera position. The general idea is that more verts are created close to the camera. Although this probably does not preclude tiling, the implementation blitz employs does not allow terrains to be segmented like this. You can of course tile entire blitz terrains together but that incurs additional processing cost to calculate the LOD. (There is another little gotcha as well involving how the heightmap data is mapped to the terrain).

So perhaps the best way to achieve tiling is to build the meshes yourself. Undoubtably this will cost you a lot more polys, but as I understand things it saves having to calculate the LOD and send the modified geometry to the graphics card every frame and this is more efficient given the processing power and memory on modern cards.

If you do want to try blitz terrains though, to texture them just use EntityTexture as you are already doing.

I think however you already understand much of this and were just confused about how blitz terrains work so please excuse my rambling.


EmerGki(Posted 2006) [#12]
Thank's, I'll try to do this with a mesh.

But, my problemm continue, Now, How I paint the mouse selected point with one specified texture?


Dreamora(Posted 2006) [#13]
The point must be put into the surface which to which you assigned the texture (ie per texture you need one surface on the terrain)


DJWoodgate(Posted 2006) [#14]
I suggest you explore the code archives, there is a lot of stuff on there which may help you achieve what you want to do.