Author Topic: Red/Cyan 3D[BB3D]  (Read 403 times)

0 Members and 1 Guest are viewing this topic.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Red/Cyan 3D[BB3D]
« on: July 09, 2007 »


I've always been wanting to make a game in RED/CYAN and here is the first step...

What do you think, could i make it better, actually i haven't done any research, just done what felt good:)

Code: [Select]



Graphics3D 1024,768
SetBuffer BackBuffer()

Global camera2d=CreateCamera()
CameraRange(camera2d,0.149,1000)
Global plane=CreatePlane(1,camera2d);make a something pickable
PositionEntity plane,0,0,.15;and stick it in the correct place
RotateEntity plane,-90,0,0
EntityAlpha plane,0
EntityPickMode plane,2

Global Rsprite=CreateSprite()
Global Bsprite=CreateSprite()
EntityColor Bsprite,255,0,0
EntityColor Rsprite,0,255,255
sizesprite(Rsprite,1024,1024)
sizesprite(Bsprite,1024,1024)
Global Rtex=CreateTexture(1024,1024):EntityTexture(Rsprite,Rtex)
Global Btex=CreateTexture(1024,1024):EntityTexture(Bsprite,Btex)

EntityAlpha Bsprite,1
EntityBlend Bsprite,3

EntityOrder Rsprite,-1
EntityOrder Bsprite,-2

Global FPoint=CreatePivot()

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


Dim cubes(4)

For i=0 To 1000
cube=CreateCube()
PositionEntity(cube,Rnd(10,200),Rnd(10,200),Rnd(10,200))
RotateEntity(cube,Rnd(0,359),Rnd(0,359),Rnd(0,359))
;EntityColor cube,Rand(255),Rand(255),Rand(255)
Next

For i=0 To 4
cubes(i)=CreateCube()
PositionEntity(cubes(i),-i*10,-i*10,-i*10)
ScaleEntity(cubes(i),Rnd(1,10),Rnd(1,10),Rnd(1,10))

Next

While Not KeyHit(1)
For i=0 To 4
TurnEntity(cubes(i),(i Mod 4)*4,(i Mod 3)*3 ,(i Mod 2)*4)
Next
mouselook(camera2d)

render3d(.3,30)

Flip
Cls
Wend


Function mouselook(cam)


TurnEntity(cam,300-MouseY(),400-MouseX(),0)
MoveMouse(400,300)


If KeyDown(200) Then MoveEntity(cam,0,0,1)
If KeyDown(208) Then MoveEntity(cam,0,0,-1)
MoveEntity(cam,KeyDown(205)-KeyDown(203),0,KeyDown(200)-KeyDown(208))
TurnEntity(cam,0,0,-EntityRoll(cam))

End Function


Function render3d(dist#=0.5,focusRange#=50)
HideEntity(Rsprite)
HideEntity(Bsprite)
rt=MilliSecs()

Local spitch#=EntityPitch#(camera2d)
Local syaw#=EntityYaw#(camera2d)
Local sroll#=EntityRoll#(camera2d)

MoveEntity(camera2d,0,0,focusRange#)
Local x#=EntityX(camera2d)
Local y#=EntityY(camera2d)
Local z#=EntityZ(camera2d)
PositionEntity(FPoint,x,y,z)
RotateEntity(FPoint,spitch,syaw,sroll)
MoveEntity(FPoint,0,0,dist#/2)


MoveEntity(camera2d,dist/2,0,-focusRange#)
PointEntity(camera2d,FPoint)
RenderWorld()
CopyRect 0,0,1024,768,0,0,BackBuffer(),TextureBuffer(Rtex)
RotateEntity(camera2d,spitch,syaw,sroll)

MoveEntity(FPoint,0,0,-dist#)
MoveEntity(camera2d,-dist,0,0)
PointEntity(camera2d,FPoint)
RenderWorld()
CopyRect 0,0,1024,768,0,0,BackBuffer(),TextureBuffer(Btex)
MoveEntity(camera2d,dist/2,0,0)
RotateEntity(camera2d,spitch,syaw,sroll)

ShowEntity(Rsprite)
ShowEntity(Bsprite)
positionsprite(Rsprite,512,512)
positionsprite(Bsprite,512,512)
RenderWorld()
Return MilliSecs()-rt
End Function


;---------------
Function positionsprite(sprite,x,y)
Local picked=CameraPick(camera2d,x,y)
If picked<>0
PositionEntity(sprite,PickedX(),PickedY(),PickedZ())
EndIf
End Function

Function sizesprite(sprite,sizex#,sizey#)
ScaleSprite sprite,sizex#/5330,sizey#/5330
End Function


Edit: had my glasses on the wrong way round :P, now it might work for somebody else too..
got rid of the colours as jim suggested and i think it runns great. The only bottleneck is the copyrect  which takes about 20*2 ms.
« Last Edit: July 21, 2007 by Shockwave »
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Online Stonemonkey

  • Pentium
  • *****
  • Posts: 1215
  • Karma: 92
    • View Profile
Re: Red/Cyan 3D
« Reply #1 on: July 09, 2007 »
Nice idea but I cant find my glasses to try it out, I think you have more colours than should be there though and for the best effect I'd do some research into what the camera angles and positions should be.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2531
  • Karma: 82
  • Pirate Monkey!
    • View Profile
Re: Red/Cyan 3D
« Reply #2 on: July 14, 2007 »
:) i've always wanted to have a go at that, i'll have to try it with my glasses when i get home.

Theres a lot of info about calculating the camera angles on the net, you mite want to look into flicker glasses examples. I was lucky enought in 2001 to get to use a top quality flicker glasses with a highend pc with some c++ and openGL programing. NeHe mite even have an example. I sent my eyes crazzy many times with it :D
Challenge Trophies Won: