scaling and coordinates headache:

Blitz3D Forums/Blitz3D Programming/scaling and coordinates headache:

Haylp!

The theory is quite simple. I want a large 3D grid area which is encased in a primitive cube with a grid textre on the outsidev(Alphad and with backfaces not culled to give it a see-through appearance). Another primitive, alphad a bit acts as a cursor which shouldmove around the grid.

My problem:

After scaling to fit the cube to the grid texture,( i want a large play area too) Im finding that my coordinates just aren't making sense...

can anyoine have a look and possibly modify it so it all fits? PWEEEASE!

Sorry to ask this, but Ive been beaten by this all day, no matter how many times I come back to it...

All code is self-contained (i.e textures etc)
Graphics3D 800,600,32,0
SetBuffer BackBuffer()
AmbientLight 128,128,128

campivot= CreatePivot()

cam=CreateCamera()
CameraViewport cam,400,10,385,335
CameraClsColor cam,0,0,0
CameraFogColor cam,0,0,0
CameraRange cam,1,20000
CameraFogRange cam,19900,20000

gridtext=CreateTexture(256,256)
SetBuffer TextureBuffer(gridtext)
ClsColor 0,0,0
Cls
Color 180,180,180
For f=0 To 255 Step 32
For g=0 To 255 Step 32
For x=0 To 255 Step 32
Line f,x,f,4+x
Line f,8+x,f,12+x
Line f,16+x,f,20+x
Line f,24+x,f,28+x
Line x,g,4+x,g
Line 8+x,g,12+x,g
Line 16+x,g,20+x,g
Line 24+x,g,28+x,g
Next
Next
Next

SetBuffer BackBuffer()

grid=CreateCube()
EntityTexture grid,gridtext
EntityAlpha grid,0.1
ScaleEntity grid,80,80,80
EntityFX grid,29

PositionEntity cam,-60,-50,-410
PositionEntity grid,-40,-40,-40

PositionEntity campivot,0,0,0

cursor=CreateCube()
EntityAlpha cursor,0.1
ScaleMesh cursor,20,20,20
EntityFX cursor,29
EntityColor cursor,128,192,160

PositionEntity cursor,0,0,0
EntityParent cursor,grid

PointEntity cam,campivot
EntityParent cam,campivot

While Not KeyDown(1)

MoveEntity cursor,0,(KeyDown(16)-KeyDown(30))*40,0
MoveEntity cursor,0,0,(KeyDown(200)-KeyDown(208))*40
MoveEntity cursor,(KeyDown(205)-KeyDown(203))*40,0,0

If EntityX(cursor)>110 Then PositionEntity cursor,120,EntityY(cursor),EntityZ(cursor)
If EntityY(cursor)>110 Then PositionEntity cursor,EntityX(cursor),120,EntityZ(cursor)
If EntityZ(cursor)>110 Then PositionEntity cursor,EntityX(cursor),EntityY(cursor),120

If EntityX(cursor)<-70 Then PositionEntity cursor,-80,EntityY(cursor),EntityZ(cursor)
If EntityY(cursor)<-70 Then PositionEntity cursor,EntityX(cursor),-80,EntityZ(cursor)
If EntityZ(cursor)<-70 Then PositionEntity cursor,EntityX(cursor),EntityY(cursor),-80

PointEntity cam,campivot
MoveEntity cam,0,0,MouseDown(1)-(MouseDown(2))

RenderWorld

Flip

Wend