Paint Terrain
Blitz3D Forums/Blitz3D Programming/Paint Terrain
| ||
How I Paint terrain tiles with textures? the tiles must be selected by mouse position. |
| ||
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. |
| ||
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" |
| ||
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.. |
| ||
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. |
| ||
But have you actually created the brush, ready for use? |
| ||
I tried: Global brush=LoadBrush ("texture.bmp",1) and Brush=CreateBrush (250,0,0) |
| ||
Can Someone post any example of how to do this? |
| ||
I bet you didnt read the original response: How are you making your terrain? |
| ||
;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 |
| ||
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. |
| ||
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? |
| ||
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) |
| ||
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. |