VertexColor not working as it should

Blitz3D Forums/Blitz3D Programming/VertexColor not working as it should

PaulJG(Posted 2003) [#1]
Would some kind person, please look through the below code and tell me what I'm doing wrong ?. Just trying out the vertexcolor command on a textured surface, but it doesnt seem to do anything.


Graphics3D 800,600

SetBuffer BackBuffer()

camera=CreateCamera()
CameraViewport camera,0,0,800,600
light=CreateLight()

Tex=LoadTexture("facetexture.bmp")

   brush=CreateBrush()                           
   BrushTexture brush,tex
   mesh=CreateMesh()                           
   surf=CreateSurface( mesh)    

   AddVertex surf,-1,1,0, 0,0                           
   AddVertex surf,1,1,0, 1,0 
   AddVertex surf,1,-1,0, 1,1 
   AddVertex surf,-1,-1,0, 0,1

   AddTriangle surf,0,1,2
   AddTriangle surf,0,2,3

   UpdateNormals mesh 

PaintMesh mesh,brush 
PositionEntity mesh,0,0,4
;EntityFX mesh,32 - not needed yet !

surface=GetSurface(mesh,CountSurfaces(mesh))

VertexColor surface,1,255,0,0

While Not KeyHit(1)

   TurnEntity mesh,0,0,.3

   UpdateWorld
   RenderWorld

   Flip

Wend
End



Ross C(Posted 2003) [#2]
you need to use the command Entityfx

entity - entity handle

fx -
0: nothing (default)
1: full-bright
2: use vertex colors instead of brush color
4: flatshaded
8: disable fog
16: disable backface culling

use

EntityFx entity,2 ;for vertex colors instead of brush colors


PaulJG(Posted 2003) [#3]
Thankyou !.

Not too sure what the alpha value does, but I'm sure I can live without it. (yes, I know its for transparency.. but it doesnt effect the texture thats on it)

I had thought about using vertexcoloring on my terrain routine rather than using a lightmap, but it seems alittle to crude on the positioning.


Ross C(Posted 2003) [#4]
np. i really need to start working on adjusting vertexs and such. it's one area of blitz i have avoided :D

What does your terrain routine do btw?


PaulJG(Posted 2003) [#5]
Nothing much.. just small fragments of test code.

I've got a few test textures loaded into one big texture.. then accessing the one I need, sorta like a sprite bank - with a lightmap over the top.

But.. I'm just playing with the vertex commands, to see if I can get away with using them instead of the lightmap. (so I can adjust the terrain mesh, lighting and darkening areas as needed)

Think I might have to write my own terrain editor, as I'd like to include entity placement for objects, as well as precalc shadows for them (on the lightmap) - I just cant find an editor already written that does this.


Ross C(Posted 2003) [#6]
i didn't think vertex colors would work on a terrain. sounds interesting tho :o)