Alpha help needed

Blitz3D Forums/Blitz3D Programming/Alpha help needed

Makepool(Posted 2004) [#1]
Ok below is some code that is supposed to change the alpha of the terrain when the user presses Z instead it does nothing and Mr Carver wants to know why (fake noise of car door slamming)

Graphics3D 800,600

SetBuffer BackBuffer()


camera=CreateCamera()
CameraRange camera,0.1,1000 
CameraZoom camera,1.4
PositionEntity camera,4,10,0
RotateEntity camera,35,0,0
CameraX = 4
CameraZ = 0


light=CreateLight(1)
PositionEntity light,0,0,-500
AmbientLight 150,150,150


;SkyBox=LoadMesh ("C:\Documents and Settings\Chewy\My Documents\Models\Skybox.3ds")
;ScaleMesh SkyBox,10,10,10
;EntityOrder SkyBox,1
;tex=LoadTexture( "C:\Documents and Settings\Chewy\My Documents\Models\Room\bo.bmp" ) 
;EntityTexture SkyBox,tex 


side=CreateSphere(16)

terrain=LoadMesh("C:\Documents and Settings\Chewy\My Documents\Models\TerrainForFog.3ds")
ScaleEntity terrain,0.70,0.7,0.70
EntityFX terrain,32

;CountSurfaces ( terrain)
sur=GetSurface ( terrain, 1)



CameraY=25
CameraZ=-25
While Not KeyDown(1)
	PositionEntity camera,CameraX,CameraY,CameraZ
;	PositionEntity SkyBox,EntityX(camera),EntityY(camera),EntityZ(camera)
	
	x=x+MouseXSpeed()
	y=y+MouseYSpeed()
	
	MoveMouse 400,300
		
	If x=>800 Then x=799
	If x<0 Then x=0
	If y=>600 Then y=599
	If y<0 Then y=0
	
	If KeyDown(203) Then CameraX = CameraX - 1
	If KeyDown(205) Then CameraX = CameraX + 1
		
	If KeyDown(208) Then CameraZ = CameraZ - 1
	If KeyDown(200) Then CameraZ = CameraZ + 1	

	If KeyDown(30) Then CameraY = CameraY - 1
	If KeyDown(16) Then CameraY = CameraY + 1		

	If KeyDown(44) Then 
		For a = 1 To CountVertices ( terrain)
			VertexColor sur,a,0,255,255,0.1
		Next
	EndIf
	
	UpdateWorld
	RenderWorld
	Text 0,0,"Press Z to change terrain's alpha (supposedly)"
	Flip
Wend



Stevie G(Posted 2004) [#2]
You should be counting the vertices of the surface - not the mesh. e.g.

for a = 1 to countvertices(sur)
vertexcolor sur,a,0,255,255,0.1
next

You may also have to set the entity fx of the terrain mesh to 34 to include vertex colours - maybe not though - can't be sure as at work.

Stevie


aCiD2(Posted 2004) [#3]
cant you jsut do entityalpha? or do terrains not support that?


Stevie G(Posted 2004) [#4]
I assumed that you wanted to use per vertexcolor for a reason - otherwise entityalpha should work fine.


aCiD2(Posted 2004) [#5]
ya i guess... is looping through each vertex slower than using entity alpha on other topics?


Stevie G(Posted 2004) [#6]
I'm sure it would be slower - probably not noticable on meshes with a small no of vertices though.


Makepool(Posted 2004) [#7]
Just to clear up a few things...

The terrain isn't a Blitz terrain but a standard 3D model and yes I do want to do it per vertex for a reason, originally I was altering just one vertex but as I couldn't see any difference I changed it to include all the vertices to make sure it worked, it didn't and then that was the code I posted.


Makepool(Posted 2004) [#8]
Thanks for spotting my error Stevie G! Works now! For that I hope the Reds get 4th spot.....actually.....nagh!!!!