My CubeMapping Doesn't look right

Blitz3D Forums/Blitz3D Programming/My CubeMapping Doesn't look right

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

k.. just so u know I switched this over to minib3d, same code, but its still not workin in either..

Cube Map Code..


Function UpdateCubemap(tex:TTexture,camera:TCamera,entity:TMesh,lma:Int)
Local tex_sz=TextureWidth(tex)
ShowEntity camera
HideEntity entity
PositionEntity camera,EntityX#(entity),EntityY#(entity),EntityZ#(entity)
CameraClsColor camera,0,0,0
CameraClsMode camera,True,True
CameraViewport camera,0,0,tex_sz,tex_sz

lma = lma Mod 6
Select lma
	Case 1
		RotateEntity camera,0,90,0
		RenderWorld
		SetCubeFace tex,0
		BackBufferToTex(tex)
	Case 2
		RotateEntity camera,0,0,0
		RenderWorld	
		SetCubeFace tex,1
		BackBufferToTex(tex)
	Case 3
		RotateEntity camera,0,-90,0
		RenderWorld
		SetCubeFace tex,2
		BackBufferToTex(tex)
	Case 4
		RotateEntity camera,0,180,0
		RenderWorld
		SetCubeFace tex,3
		BackBufferToTex(tex)
	Case 5
		RotateEntity camera,-90,0,0
		RenderWorld
		SetCubeFace tex,4
		BackBufferToTex(tex)
	Case 0
		RotateEntity camera,90,0,0
		RenderWorld
		SetCubeFace tex,5
		BackBufferToTex(tex)
	End Select

ShowEntity entity
HideEntity camera
End Function



I found this code in the code arcs, but I have tried like 4 different versions!!


Creating Water plain code...

	Method createwater()
	
		w.camera=CreateCamera()
		w.mesh = CreateMesh()
		w.surf = CreateSurface(w.mesh)
		w.brush = CreateBrush()
		w.addwater(mesh,surf,1,1)
		EntityFX w.mesh,1|2|32
		
		w.texture = CreateTexture(128,128,1|128)
		BrushTexture w.brush,w.texture
		'w.brush = LoadBrush("water.bmp")
		PaintSurface w.surf,w.brush
		BrushFX w.brush,1|2
		
		SetCubeMode w.texture,1

	End Method
	
	Method addwater(mesh:TMesh,surf:TSurface,v:Float=16,u:Float=16,tersize:Int=128)
		
		If tersize > 127 Then tersize = 127
		
		Local vx:Int, vz:Int
		
		For vx = 0 To tersize ; For vz = 0 To tersize 
		
			adata[vx,vz]=1
			wdata[vx,vz] = AddVertex(surf,vx,(128/255.0)*Float(32),vz,vx/Float(v),vz/Float(u))
			VertexColor surf,wdata[vx,vz],255,255,255,adata[vx,vz]
		
		Next ; Next
		
		Local tx:Int, tz:Int
		
		For tx = 0 To tersize - 1 ; For tz = 0 To tersize - 1
			
			AddTriangle surf,wdata[tx+1,tz],wdata[tx,tz],wdata[tx,tz+1]
			AddTriangle surf,wdata[tx+1,tz],wdata[tx,tz+1],wdata[tx+1,tz+1]
		
		Next ; Next
					
	End Method



Sorry for the lack of comments, most of this is coding on the fly type stuff.. Im basicly testing myself so I can make this into a fully functional engine for a few games im planning..

:EDIT:

I got it working sorta, but its not lining up right, I noticed that I forgot to update the normals of the water.. :) but I don't understand why its off..

Okay I just figured out Cubemapping sucks for when you have a camera that moves.. :( because it makes the cube mapping all messed up, but if I was at one height it works fine.. very strange!!