tex_render.bb example but on mesh

Blitz3D Forums/Blitz3D Beginners Area/tex_render.bb example but on mesh

artie(Posted 2003) [#1]
I've no trouble applying the method in tex_render.bb to entities I create but I can't figure out how to render to a mesh's brush. All I'm trying to do is render to a 2-poly plane created with mesh commands, as follows:

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

HidePointer

camera = CreateCamera()
PositionEntity camera,10,10,-10

mirrorCam = CreateCamera()
PositionEntity mirrorCam,0,5,0
CameraViewport mirrorCam,0,0,128,128

light = CreateLight()
PositionEntity light,5,5,-5

tex = LoadTexture("Images/plant.bmp")
brush = CreateBrush()
BrushTexture brush,tex

cube = CreateCube()
PaintMesh cube,brush

ground = CreateCube()
PaintMesh ground,brush
ScaleEntity ground,50,0.25,50
PositionEntity ground,0,-2,0

mirror = CreateMesh()
mirrorSurf = CreateSurface(mirror)
v1 = AddVertex(mirrorSurf,-5.0,5.0,-10.0)
v2 = AddVertex(mirrorSurf,-5.0,5.0,10.0)
v3 = AddVertex(mirrorSurf,-5.0,0.0,10.0)
v4 = AddVertex(mirrorSurf,-5.0,0.0,-10.0)
tri1 = AddTriangle(mirrorSurf,v1,v2,v3)
tri2 = AddTriangle(mirrorSurf,v3,v4,v1)
mirrorTex = CreateTexture(128,128)
mirrorBrush = CreateBrush()
BrushTexture mirrorBrush,mirrorTex
PaintMesh mirror,mirrorBrush

PointEntity camera,cube
PointEntity mirrorCam,cube
HideEntity mirrorCam
ShowEntity camera

angle# = 1

AntiAlias True

While Not KeyHit(16)
angle = angle + 1
If angle > 360 Then angle = 1
RotateEntity cube,angle,angle,angle

UpdateWorld

HideEntity camera
ShowEntity mirrorCam
RenderWorld

CopyRect 0,0,128,128,0,0,0,TextureBuffer(mirrorTex)

ShowEntity camera
HideEntity mirrorCam
RenderWorld

Flip
Wend

What am I doing wrong? Thanks for any replies.


artie(Posted 2003) [#2]
Ok, forget the above...it seems I'm having trouble even painting a mesh. For example,

sheet = CreateMesh()
sheetSurf = CreateSurface(sheet)
v0 = AddVertex(sheetSurf,0.0,5.0,5.0)
v1 = AddVertex(sheetSurf,5.0,5.0,5.0)
v2 = AddVertex(sheetSurf,0.0,0.0,5.0)
v3 = AddVertex(sheetSurf,5.0,0.0,5.0)
tri1 = AddTriangle(sheetSurf,v0,v1,v2)
tri2 = AddTriangle(sheetSurf,v2,v1,v3)
sheetTex = LoadTexture("Images/tv.bmp")
sheetBrush = CreateBrush()
BrushTexture sheetBrush,sheetTex
PaintMesh sheet,sheetBrush

...the above creates a simple plane but does not paint it...or at least, not in a way I understand. Maybe only a corner of the texture gets applied...?? Anyway, I'll search out some basic painting tutorials.


artie(Posted 2003) [#3]
Ok, almost got it. Fiddling with the u#,v# parameters of AddVertex (I assume that's the area to fiddle in). Texture showing up, being updated by second camera, but tiled...so I gotta study the aforementioned params. Gotta say, Blitz is pretty interesting.


artie(Posted 2003) [#4]
Ok, got it.