How to paint a portion of a mesh with a brush?

Blitz3D Forums/Blitz3D Programming/How to paint a portion of a mesh with a brush?

Jeroen(Posted 2004) [#1]
Hi!

The code below is bullocks, but I wanted to show it anyway. What I am trying is this: When a player digs a hole in the ground (mesh) I'd like to paint that part of the mesh with a ground texture. Now I am adding vertices, but I'd like to paint a part of the mesh. How can I accomplish this?

Thanks!

Jeroen


Graphics3D 800,600,32,2
SetBuffer BackBuffer()


mesh = LoadMesh ("meshes/statue.x")

paintTexture = LoadTexture("images/interface/inventory/playerLocation.png",2) 

PositionEntity mesh,0,3,0

camera= CreateCamera()
PositionEntity camera,0,5,-7
RotateEntity camera,0,10,0
plane=CreatePlane()

brush = CreateBrush()
BrushTexture brush,paintTexture 
BrushShininess brush,1 

surface = CreateSurface(mesh)
v0 = AddVertex (surface , -5,-5,0, 0 ,0) 
v1 = AddVertex (surface , 5,-5,0, 1 ,0) 
v2 = AddVertex (surface , 0, 5,0, 0.5,1) 

tri = AddTriangle (surface,v0,v2,v1) 


PaintSurface surface,brush
PaintMesh



While Not KeyHit(1)
	TurnEntity mesh, 0.5, 0.5, 0.5
	RenderWorld
	Flip

Wend
End



jfk EO-11110(Posted 2004) [#2]
if it's a repetively tiled texture then it isn't possible.

In the examples folder of blitz is a mesh painting source, paintmesh, drawmesh or something like that (who knows the exact name?).


Jeroen(Posted 2004) [#3]
Ah I found it! Never seen the demo..

But meanwhile I realised I'm aiming for a wrong course.
It's better to add a sprite beneath the players feet.
But...the mesh ain't flat. Basicly I need to know the steepness of a certain section.
I can Linepick for the Y coordinate: left top, left right, bottom left, bottom right.

But then I need to use the four coordinates to calculate the rotation of the sprite.

Eg: I am standing on a hill, and I want to place a sprite aligned to the steepness of the hill.


jfk EO-11110(Posted 2004) [#4]
use aligntovector. check the gun-fire code of the castle demo. Also, after a linepick you can get the surface angle aka the "normals" with PickedNX(), pickedny() and pickednz()
after positioning the sprite at the picked position you need to move it a tiny bit away from the mesh to prevent it flickering.