FPS with 3D Glasses

Community Forums/Showcase/FPS with 3D Glasses

jfk EO-11110(Posted 2003) [#1]
you need one of those Red-Green Glasses (left eye red, right eye green filter) Not sure if it works for all gamma correcture and brightness settings. Note I use Red*255 and Green*155 because Green is usually brighter than red or blue.



I will probably release a complete playable Level.
What do you think, any suggestions? And any Idea on how to get rid of that yellowish overall color? And is it tru that I will have to make a greyscale Level for an optimal look?

BTW. Thanks to Doggie for Inspiration, he came up with the first Version.


Matt2222(Posted 2003) [#2]
I have to give you credit, the idea is very original. Hurts my eyes though. lol.

Anyway, keep up the good work jfk.


Perturbatio(Posted 2003) [#3]
The yellowish colour is caused by Red and Green light mixing, adding a greyscale or colour image also would *help* counter it


jfk EO-11110(Posted 2003) [#4]
I hope you watched this with the glasses.

Matt - yes, it hurts the eyes a bit. Anyway, a game would have custom Stereoscopic Adjustment Menus, so one can find a custom Eye-Distance and -Angle that fits best.

Perturbatio - of course the yellowish colour is caused by red and green :) But how should I add a greyscale Picture or any other Picture that isn't red or green? As I understand it, the whole red-green 3D Thing is based on the fact that each eye can see only one color and the other color becomes invisible, which allows the eyes to virtually focus a hypotetic depth. I tried to use 255,0,255 instead of red, but then I saw a shade of the blue on the "green eye" that was set off, as if you watch it without glasses. Ok, I could use Pink-Green Glasses, that would work, and the Picture would really be white/greyscale! But I think most people own red-green Glasses, that's the problem.

Or is there an other way?


fredborg(Posted 2003) [#5]
Hi,

That's pretty nice :) But you should try to do it with yellow (sligtly orange) and blue (slightly purple) glasses instead, as they are less stressful for the eyes, and allow full color stereoscopic images. Have a look at: Color Code 3D.

Oh, and you can do full color images with red and green glasses as well, but the colors tend to flicker, because of the high color difference between the left and right eye.

This is from some really old tests I did with stereoscopic images.

Red and green channels:


Magenta and cyan channels:



googlemesilly(Posted 2003) [#6]
great idea ! :)


Anthony Flack(Posted 2003) [#7]
Anyone remember Magic Carpet? Not only did it have a red-green 3d option (which actually worked pretty good, and was in full colour - yeah it did look a bit flickery though), but also had a magic eye-style viewing option that was guaranteed to make your brains leak out of your eye sockets.


fredborg(Posted 2003) [#8]
There was also a racing game (forgot the name) on the NES, with a 3D option. I don't remember if it was every other frame with another color, or the colors was interlaced. But it didn't really work, and you got a tremendous headache from it :)


googlemesilly(Posted 2003) [#9]
I remember Magic Carpet but my pc wasn't fast enough
at the time, i played the demo off a PC Format I think ...

jfk : I wonder if you can use one of those non coloured
3D glasses ? you know the type that is just plain
for both eyes..... hope you know what i'm talking about ...


Wiebo(Posted 2003) [#10]
I remember a patch for Duke Nuke Em 3d which did the same.. that was great.


Doggie(Posted 2003) [#11]
Thanks for the mention, jfk.
I did StereoSpun which was homespun completely redone
in red/blue 3D. I took it off of Blitz Showcase
though but if you still have a copy of it feel
free to post it somewhere people can get it.
The problem with red/blue was textures came out nothing but pink and usually killed the 3d effect. As I recall
Duke Nukem 3D has a red/blue 3d version. You go into the config file to turn it on.
Please post a playable level or an improved StereoSpun
editor if you make one!

Doggie


jfk EO-11110(Posted 2003) [#12]
Thanks for your Help, everybody! I think I will do it this way: store the two Colors in an external Config File, so the User will be able to set this individually. First I will use a complete B-W Game (say makeing all textures greyscale etc.) for Maximum Eye-Comfort.

Guess I will not use one of the existing CSP Engine Levels, because this Rendering Method is slower (requires an additional Render of the Scene from a second Angle, plus Texture Transport to two Sprites to achieve that Overlay Effect - maybe I will be able to optimize this a bit), instead I will set up a very simple Level, including some rudimentary Level Stuff and release it as a Demo like in "Demo".

BTW I posted the source as it is, a simple experiment for the Maplet Test Level in the Bug Reports Forum (cause I had some DX Problems, tell me if you know a solution) under "BSOD DDhelp Crash blabla" or something.

@Sunshine Dreamer - what non-coloured Glasses are you talking about, I have no idea. I guess you didn't mean those Stereo-TFT-Glasses? (They would require some kind of multiple Screens or Splitscreen). Although the Method of Rendering 2 individual Pictures is pretty much the same with all those Methods, I would prefere to offer a low cost Solution, probably deliver a Boxed Release bundled with the Glasses.

BTW. did you ever notive that the human eye can focusize the Depth of things even with one Eye only?! Just try this, watch your Finger with one eye, then focus the wall behind the Finger, still with one Eye: the Finger will be blurred! Guess the Pupil is able to alter the Shape of its Lense. We are so incredible perfect![/OT]


Al Mackey(Posted 2003) [#13]
I think I know what he's talking about.. A while ago, there was a fad with graphics card manufacturers to include 3D glasses with their cards. These had one large LCD over each eye, and a cord to keep it in step with your monitor's vertical sync. Every other frame, your monitor would show from a slightly different viewpoint, and the glasses' LCDs would black out alternating eyes. They even built it into the drivers so that any game that did DirectX or OpenGL would attempt to support the glasses.. unfortunately at that time a lot of games used 2D elements as well which totally threw off the effect.

That sort of glasses gives you the benefit that you only have to render one viewpoint every frame, but since each eye gets only half of your refresh rate (30-37 fps intead of 60-75) it can look very flickery and really hurt your head.

I do request that you make a version for red/blue glasses as well as red/green. Red/blue is the more popular choice here in the states.


fredborg(Posted 2003) [#14]
I think Sunshine Dreamer is talking about polaroid glasses. Which you can only really use, if you have two projectors, each fitted a polaroid lens.

The way those fellas work, is that a polaroid lens filters out light waves depending on the rotation of the polaroid film. This means you can fit a projector with a polaroid lens that filters out horizontal light waves, and one that filters out vertical light waves. Then by putting on a pair of glasses, with the lenses fitted in the same rotations as the projectors, you see only one of the projected images with each eye. Pretty cool! But not doable on a monitor :(


Rottbott(Posted 2003) [#15]
I have some of the "stereoscopic" glasses that came with my graphics card.

I haven't been able to try them though, since you require a monitor that can do a 120Hz+ refresh rate, and mine can only do 75Hz or so.


googlemesilly(Posted 2003) [#16]
Yep. Fredborg that's what I meant. Looks like
it can't be done that way ...


Difference(Posted 2003) [#17]
You guys will be interested in the "3D without glasses" laptop from http://www.sharp3d.com


Doggie(Posted 2003) [#18]
Hey! And only $3,300! Let's see...
If I start saving my lunch money right now...
I could get one in about a year and a half.
It's gonna be hard.
3D Laptop? Big Mac?
3D Laptop? Double Whopper with Cheese?
3d Laptop? Chicken Teryaki Sub?

It's never as easy as it seems...
When the 3D TVs come out, then...

Doggie


Techlord(Posted 2003) [#19]
jfk,

Great Stuff. I have been toying around with various Stereoscopic techniques (Anaglyph, Pulfrich, Shutter, and Dual screen) for some time now. I have settled on using the Anaglyph technique. I'm interested in what techniques are being used to produce the R/G imagery.

I'm currently using a single camera with a sprite lens attached. The lens is set to blendmode 2. I create two virtual camera/lens by alternating the between two camera positions/angle per frame. I switch the color of the lens with each camera angle.

I'm currently using a Red/Cyan (R255,G255+B255) combination, but, the colors can be adjusted for various R-G-B combinations. The color ratios are adjusted to equal that of R255,G255,B255 regardless of the combinations (ie: R255+G128,B255+G127). I do not experience the yellow overlap.

The obvious disadvantage of this technique is that it renders a one scene twice, which reduces the fps/2, which can produce some ugly flicker in slower cards.

I took a gander at the ColorCode 3-D Stills. They are appearently using the Yellow/Blue lens combination. I have found it very difficult to locate R/B glasses at the local store. Since the most common R/B glasses are usually disposable, I don't believe folks keep a spare pair around. So, sticking with the good-ole R/B combination may not be necessary.


jfk EO-11110(Posted 2003) [#20]
Hi Frank! Very interesting Point of view there! I agree, multiple Renders are slow, in mine I even use 3! - 2 for the 2 eyes and a quick one of 2 overlapping Sprites, containing those 2 Renders - not so clever, but it works. Should be optimized, of course.

I think it's that simple: if I have the half fps then I will use only the half amount of tris! With a simple Level with low cameraranges it's still possible to make something nice. Like in the Test I did, with the Testlevel that comes with the Maplet Release.

The Source i used is deadly simple too:
; 3D Glasses Demo by JFK of CSP (inspred by Doggie, thx!)

Graphics3D 1024,768,32,1
Collisions 1,2,2,2

player=CreatePivot()
PositionEntity player,0,1,-1
EntityRadius player,.6
EntityType player,1

camera=CreateCamera( player )
CameraRange camera,.1,200

;------- 3D-glasses init
camera2=CreateCamera()
PositionEntity camera2,10000,0,-5

tex=CreateTexture(512,512,256 Or 2)
sp=CreateSprite(camera2)
EntityTexture sp,tex
ScaleSprite sp,4.8,4.8
MoveEntity sp,0,0,5
EntityColor sp,255,0,0
EntityOrder sp,-1

tex2=CreateTexture(512,512,256 Or 2)
sp2=CreateSprite(camera2)
EntityTexture sp2,tex2
ScaleSprite sp2,4.8,4.8
MoveEntity sp2,0,0,5
EntityColor sp2,0,155,0
EntityOrder sp2,-1
EntityAlpha sp2,.5

eyedist#=.05;.03 ;.05
eyeangle#=.03;0;.03

;-------eo glasses init

light=CreateLight()
LightColor light,32,32,32
TurnEntity light,45,45,0
light=CreateLight()
LightColor light,32,32,32
TurnEntity light,45,-45,0


mesh=LoadMesh( "test.b3d" )
EntityFX mesh,1
EntityType mesh,2

spd#=.15
ey#=EntityY(player)

sky=LoadSkyBox( "sky" )
EntityParent sky,camera
;-----------------------------------------------------------------------------------------
While Not KeyHit(1)
If KeyHit(17)
wire=1-wire
WireFrame wire
EndIf

yv#=EntityY(player)-ey
ey=EntityY(player)

If KeyHit(57) yv=.1 
MoveEntity player,0,yv-.005,0
If KeyDown(30) then TurnEntity camera,-2,0,0
If KeyDown(44) then TurnEntity camera,+2,0,0

mxs#=-MouseXSpeed()/4
mys#=MouseYSpeed()/4
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
TurnEntity camera,mys#,0,0
TurnEntity player,0,mxs#,0

If KeyDown(203) TurnEntity player,0,2,0
If KeyDown(205) TurnEntity player,0,-2,0
If KeyDown(200) MoveEntity player,0,0,spd
If KeyDown(208) MoveEntity player,0,0,-spd



RotateEntity sky,0,0,0,True
 UpdateWorld()
 ;----glasses
 HideEntity camera2
 ShowEntity camera

 MoveEntity camera,-eyedist#,0,0
 TurnEntity camera,0,-eyeangle#,0
 RenderWorld()
 CopyRect 144,44,512,512,0,0,BackBuffer(),TextureBuffer(tex)
 TurnEntity camera,0,eyeangle#,0
 MoveEntity camera,eyedist#,0,0
 RenderWorld()
 CopyRect 144,44,512,512,0,0,BackBuffer(),TextureBuffer(tex2)
 HideEntity camera
 ShowEntity camera2
 ;----eo glasses 
 RenderWorld()
;Text 0,0,TrisRendered()
Flip
Wend
End
;-----------------------------------------------------------------------------------------
;skybox code stolen from castle demo!
Function LoadSkyBox( file$ )
m=CreateMesh()
;front face
b=LoadBrush( file$+"_FR.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;right face
b=LoadBrush( file$+"_LF.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;back face
b=LoadBrush( file$+"_BK.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;left face
b=LoadBrush( file$+"_RT.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;top face
b=LoadBrush( file$+"_UP.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;bottom face
b=LoadBrush( file$+"_DN.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,100,100,100
FlipMesh m
EntityFX m,1
EntityOrder m,1
Return m
End Function



Techlord(Posted 2003) [#21]
jfk,

Heres a version of your code using my 3D camera system. I warn you, that you must have sync timer set to max, otherwise you get a great deal of flicker. You select for color combinations by pressing keys 1-4 (RED/CYN,RED/GRN,YEL/BLU,MAG/GRN) respectively.

; 3D Glasses Demo by JFK of CSP (inspred by Doggie, thx!)
; 3DCam by Frank Taylor

Graphics3D 800,600,32,1
Collisions 1,2,2,2

player=CreatePivot()
PositionEntity player,0,1,-1
EntityRadius player,.6
EntityType player,1

mycamera.camera=CameraCreate()
mycamera\mode=1 ;1=red/cyan
EntityParent(mycamera\camera,player)
CameraRange mycamera\camera,.1,100

level=LoadMesh( "test.b3d" )
EntityFX level,1
EntityType level,2

spd#=.15
ey#=EntityY(player)

sky=LoadSkyBox( "sky" )
EntityParent sky,mycamera\camera
PositionEntity mycamera\camera,0,1,0
;--------------------------

synctimer=CreateTimer(120);max fps required or serious flicker

Repeat
	WaitTimer synctimer
	Cls

	If KeyHit(17)
		wire=1-wire
		WireFrame wire
	EndIf
	
	yv#=EntityY(player)-ey
	ey=EntityY(player)
	
	If KeyHit(57) yv=.1 
	MoveEntity player,0,yv-.005,0
	If KeyDown(30) Then TranslateEntity player,0,-2,0
	If KeyDown(44) Then TranslateEntity player,0,+2,0
	
	If KeyHit(2) mycamera\mode=1;1=red/cyan 
	If KeyHit(3) mycamera\mode=2;2=red/green 
	If KeyHit(4) mycamera\mode=3;3=yellow/blue	
	If KeyHit(5) mycamera\mode=4; (Magenta/Green)
	
	mxs#=-MouseXSpeed()/4
	mys#=MouseYSpeed()/4
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
	TurnEntity mycamera\camera,mys#,0,0
	TurnEntity player,0,mxs#,0
	
	If KeyDown(203) TurnEntity player,0,2,0
	If KeyDown(205) TurnEntity player,0,-2,0
	If KeyDown(200) MoveEntity player,0,0,spd
	If KeyDown(208) MoveEntity player,0,0,-spd
	
	RotateEntity sky,0,0,0,True
	
	cameramanager()
	UpdateWorld()
	RenderWorld()
	
Flip(True)
Until KeyDown(1)

;-----------------------------------------------------------------------------------------
;skybox code stolen from castle demo!
Function LoadSkyBox( file$ )
m=CreateMesh()
;front face
b=LoadBrush( file$+"_FR.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;right face
b=LoadBrush( file$+"_LF.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;back face
b=LoadBrush( file$+"_BK.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;left face
b=LoadBrush( file$+"_RT.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;top face
b=LoadBrush( file$+"_UP.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;bottom face
b=LoadBrush( file$+"_DN.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,100,100,100
FlipMesh m
EntityFX m,1
EntityOrder m,1
Return m
End Function

;============================
;CAMERA
;3DCAM by Frank Taylor
;============================
Type camera
	Field camera
	Field lens
	Field viewportx,viewporty,viewportwidth,viewportheight	
	Field mode ; 0=Normal, 1-4=Anaglyphic, 5-Pulfrich Effect, 6=Shutter, 7=Split
	Field fov#
	Field zoom#
	Field x#;left|right x plane position from center focal point
	Field yaw# ;left|right y axis degree of angle from 0
	Field r ;red color component
	Field gb ;green|blue color component
	Field llens ;left lens color [red]
	Field rlens ;right lens color [green]
	Field lenssyncpulse ;0-red, 1-green
	Field cursor
End Type


Function cameranew.camera()
	mycamera.camera=New camera
	mycamera\viewportx=0
	mycamera\viewporty=0
	mycamera\viewportwidth=GraphicsWidth() Shr 1
	mycamera\viewportheight=GraphicsHeight() Shr 1	
	mycamera\r=255
	mycamera\gb=255
	mycamera\llens=mycamera\r
	mycamera\rlens=0
	mycamera\x#=.2
	mycamera\yaw#=.5
	mycamera\lenssyncpulse=1
	Return mycamera
End Function

Function cameradelete(mycamera.camera)
	FreeEntity mycamera\lens
	Delete mycamera
End Function

Function cameramanager()
	;2 to 1 buffering
	;takes separate snapshots of the scene in two equal/opposite angles in separate color
	For eachcamera.camera=Each camera
	
		;Anaglypic/Shutter Mode
		If eachcamera\mode
			;Shutter
		   	eachcamera\lenssyncpulse=-1*eachcamera\lenssyncpulse
		    ;left | right lens
		    TranslateEntity eachcamera\camera,eachcamera\x*eachcamera\lenssyncpulse,0,0
		    TurnEntity eachcamera\camera,0,eachcamera\yaw*eachcamera\lenssyncpulse,0
		   	eachcamera\llens=eachcamera\r-eachcamera\llens
		    eachcamera\rlens=eachcamera\gb-eachcamera\rlens
			;set lens color
			Select eachcamera\mode
				;AnaglyphicRB (Red/Cyan)
				Case 1 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\rlens
				;AnaglyphicRG (Red/Green)
				Case 2 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,0
				;AnaglyphicRB (Yellow/Blue)
				Case 3 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\rlens
				;AnaglyphicRG (Magenta/Green)
				Case 4 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\llens
				;Pulfrich
				Case 5
					Select eachcamera\lenssyncpulse
						Case 1	EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\llens
						Case -1 EntityColor eachcamera\lens,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1
					End Select
				;Split	
				Case 7
					Select eachcamera\lenssyncpulse
						Case 1	CameraViewport eachcamera\camera,eachcamera\viewportx,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
						Case -1 CameraViewport eachcamera\camera,eachcamera\viewportx+eachcamera\viewportwidth,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
					End Select				
			End Select 
				
		EndIf
		
	Next
End Function

Function cameracreate.camera()
	mycamera.camera=cameranew()
	mycamera\camera=CreateCamera()
	PositionEntity mycamera\camera,0,0,-3
	;listener
	CreateListener(mycamera\camera) 
	;lens
	mycamera\lens=CreateSprite(mycamera\camera)
	TranslateEntity mycamera\lens,0,0,1
	ScaleSprite mycamera\lens,1,1
	EntityBlend mycamera\lens,2
	Return mycamera
End Function

Function cameraadjust(mycamera.camera,translate#=0,turn#=0,r=0,gb=0)
	;translates|turns|set color in -1|+1 increments
	If translate<>0 mycamera\x=mycamera\x#+translate#
	If turn<>0 mycamera\yaw#=mycamera\yaw#+turn#
	If r<>0 mycamera\r=mycamera\r+r
	If gb<>0 mycamera\gb=mycamera\gb+gb
End Function



jfk EO-11110(Posted 2003) [#22]
Not shure if this is going to work on my Machine, I got a Responsetime of 25ms on the TFT Display. But I saved it and will try it, thanks a lot for sharing!


Madcap13(Posted 2003) [#23]
You know. I actually did this ages ago. Except I dithered two red and green pictures together, like in 2d. like
rgrgr
grgrg
rgrgr

It looked pretty wonky until you put the glasses on, then you dont notice the dithering so much.
But thats just how I did it. <shrugs>


Doggie(Posted 2003) [#24]
JFK, for some odd reason your code won't work on my computer but Frank Taylors' does???? Your version just goes into an endless load and black screen while his pops up in seconds??? Weird. I'm thinking of redoing the code in StereoSpun just for fun. If you make a commercial product out of this I'll beta test it for ya.

Doggie


jfk EO-11110(Posted 2003) [#25]
Doggie - I have no Idea, what Card are you using? Maybe it don't likes the 256-Flag at:

tex=CreateTexture(512,512,256 Or 2)

I am really surprised since it doesn't include any "risky" code. I hope I didn't delete a Line or somthing while pasting. You could also try the Version I posted in the Bug Reports Archive (which should be almost identical).


Ziltch(Posted 2003) [#26]
Check this display out.
http://www.io2technology.com/
I couldn't believe you could really do this kind of display.
I like 21st Century gadgets!


jfk EO-11110(Posted 2003) [#27]
"Wot is Helio-Display"...WOOOOOOWWW!!!
What should I say? maybe this


andy_mc(Posted 2003) [#28]
lol jfk


Doggie(Posted 2003) [#29]
OK. Now this is why I want an advanced beginner book on Blitz. I took Frank Taylors code and try as I might I could not merge it with my own to get his 3d camera to work. So, here's my code would someone mind merging his red/blue camera to work with this code so I can update my red/blue editor? (sub your own graphics and md2 file)
;     # Created By HomeSpun Gold #
;# Courtesy of Doggie at BB Forums #
;D:\blit\homespun\aaa.bb  Created  # 24 Oct 2003
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
Global camera=CreateCamera()
PositionEntity camera,7.0,15,7.0
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraClsColor camera,0,0,0
CameraRange camera,1,500
CameraFogMode camera,1
CameraFogRange camera,20,200
CameraFogColor camera, 120,120,120
AmbientLight 200,200,200
terrain1=LoadTerrain( "hmap4.bmp")
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,500,True
ScaleEntity terrain1,6,40,6
terrainTex=LoadTexture( "terrain_tex0.bmp",8)
ScaleTexture terrainTex,256,256
TextureBlend terrainTex,2
EntityTexture terrain1,terrainTex,0,1
plane=CreatePlane(10)
planeTex=LoadTexture("water03.bmp")
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EntityAlpha plane,0.50
PositionEntity plane,0,2,0
EntityType plane,2
FreeImage planetex
gplane=CreatePlane(10)
gplaneTex=LoadTexture("terrain_tex0.bmp")
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex
Global player=LoadMD2( "ss.md2")
ss_tex=LoadTexture( "ss3.pcx")
EntityTexture player,ss_tex
ScaleEntity player,.09,.09,.09
AnimateMD2 player,1,0.5,0,19
PositionEntity player,0.0,4.0,0.0
RotateEntity player,0,150,0
EntityRadius player,2
EntityType player,1
PointEntity camera,player
EntityParent camera,player
Global sphere=CreateSphere(32)
EntityParent camera,player
PositionEntity sphere,508,1,1544
light1=CreateLight (3)
PositionEntity light1,508,50,1544
RotateEntity light1,90,180,180
LightRange light1,100
LightConeAngles light1,0,90
LightColor light1,55,55,55
skytex=LoadTexture("sky.jpg",8 )
ScaleEntity sphere,250,250,250
EntityTexture sphere,skytex
EntityAlpha sphere,1
FlipMesh sphere
Collisions 1,2,2,2
party=0
Dim prx(100)
Dim pry(100)
Dim prz(100)
Dim psz(100)
Dim pscale#(100)
Dim plife#(100)
Dim pfade#(100)
Dim pgravity(100)
Dim smoker(100)
Dim pbled(100)
Global dt,Bravo#
;############ Main Loop ############
While Not KeyHit(1)
If KeyDown(200) Then
MoveEntity player,0,0,.5 
EndIf
If KeyDown(208) Then
MoveEntity player,0,0,-.5 
EndIf
If KeyDown(203) Then
TurnEntity player ,0,2,0 
EndIf
If KeyDown(205) Then
TurnEntity player ,0,-2,0 
EndIf
x#=EntityX(camera)
y#=EntityY(camera)
z#=EntityZ(camera)
x1#=EntityX(player)
y1#=EntityY(player)
z1#=EntityZ(player)
terra_y#=TerrainY(terrain1,x#,y#,z#)+5
PositionEntity camera,x#,terra_y#+15,z#
terra_y1#=TerrainY(terrain1,x1#,y1#,z1#)
If Not EntityCollided(player,2)
PositionEntity player,x1#,terra_y1#+3,z1#
End If
PositionEntity sphere,x1#,y1#,z1#
PositionEntity light1,x1#,y1#+50,z1#
wx#=(wx#+.001)Mod 1
wy#=(wy#+.001)Mod 1
sx#=(sx#+.0001)Mod 1
sy#=(sy#+.0001)Mod 1
PositionTexture planeTex,wx#,wy#
PositionTexture skytex,sx#,0
If Not KeyDown(200) Or KeyDown(208)
AnimateMD2 player,1,0.5,20,25 :UpdateWorld
EndIf
MouseLook(camera)
UpdateWorld
RenderWorld
Flip
Wend
Function MouseLook(Camera)
Pitch#=Pitch#-(MouseYSpeed()*0.25)
Pitch#=Pitch#/1.2
Yaw#=Yaw#+-(MouseXSpeed()*0.25)
Yaw#=Yaw#/1.2
MoveMouse (GraphicsWidth()/2,GraphicsHeight()/2)
MoveEntity Camera,Yaw#,Pitch#+Abs(Roll#*Yaw#)/50,ZSpeed#
Local cp#=EntityPitch(Camera,True)+Pitch#
If cp<-89 Then cp=-89
If cp>89 Then cp=89
RotateEntity Camera,cp,EntityYaw(Camera)+Yaw#,Roll#
End Function


Thanks

Doggie


jfk EO-11110(Posted 2003) [#30]
Doggie, Take your Loading Part, remove everything after the Mainloop Start (including "While not keydown(1)"), also remove the Camera Creation. Then take Franks Camera Creation stuff, also his Timer Initialisation, his Mainloop and all his Function. This should work somehow.

Then you can add the animation Controls for your MD2 in the new Mainloop.


jfk EO-11110(Posted 2003) [#31]
This Laptop has no 3D, so I cannot test it, but it would probably look like this:

;     # Created By HomeSpun Gold #
;# Courtesy of Doggie at BB Forums #
;D:\blit\homespun\aaa.bb  Created  # 24 Oct 2003
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
AmbientLight 200,200,200
terrain1=LoadTerrain( "hmap4.bmp")
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,500,True
ScaleEntity terrain1,6,40,6
terrainTex=LoadTexture( "terrain_tex0.bmp",8)
ScaleTexture terrainTex,256,256
TextureBlend terrainTex,2
EntityTexture terrain1,terrainTex,0,1
entitytype terrain1,2
plane=CreatePlane(10)
planeTex=LoadTexture("water03.bmp")
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EntityAlpha plane,0.50
PositionEntity plane,0,2,0
EntityType plane,2
FreeImage planetex
gplane=CreatePlane(10)
gplaneTex=LoadTexture("terrain_tex0.bmp")
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex
Global player=LoadMD2( "ss.md2")
ss_tex=LoadTexture( "ss3.pcx")
EntityTexture player,ss_tex
ScaleEntity player,.09,.09,.09
AnimateMD2 player,1,0.5,0,19
PositionEntity player,0.0,4.0,0.0
RotateEntity player,0,150,0
EntityRadius player,2
EntityType player,1
;___
mycamera.camera=CameraCreate()
mycamera\mode=1 ;1=red/cyan
EntityParent(mycamera\camera,player)
CameraRange mycamera\camera,.1,100
;___
PositionEntity mycamera\camera,7.0,15,7.0
CameraViewport mycamera\camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraClsColor mycamera\camera,0,0,0
CameraRange mycamera\camera,1,500
CameraFogMode mycamera\camera,1
CameraFogRange mycamera\camera,20,200
CameraFogColor mycamera\camera, 120,120,120

PointEntity mycamera\camera,player
EntityParent mycamera\camera,player
Global sphere=CreateSphere(32)
EntityParent mycamera\camera,player
PositionEntity sphere,508,1,1544
light1=CreateLight (3)
PositionEntity light1,508,50,1544
RotateEntity light1,90,180,180
LightRange light1,100
LightConeAngles light1,0,90
LightColor light1,55,55,55
skytex=LoadTexture("sky.jpg",8 )
ScaleEntity sphere,250,250,250
EntityTexture sphere,skytex
EntityAlpha sphere,1
FlipMesh sphere
Collisions 1,2,2,2
party=0
Dim prx(100)
Dim pry(100)
Dim prz(100)
Dim psz(100)
Dim pscale#(100)
Dim plife#(100)
Dim pfade#(100)
Dim pgravity(100)
Dim smoker(100)
Dim pbled(100)
Global dt,Bravo#
collisions 1,2,2,2
synctimer=CreateTimer(120);max fps required or serious flicker
;############ Main Loop ############


Repeat
WaitTimer synctimer
Cls

If KeyHit(17)
 wire=1-wire
 WireFrame wire
EndIf

yv#=EntityY(player)-ey
ey=EntityY(player)

If KeyHit(57) yv=.1 
MoveEntity player,0,yv-.005,0
If KeyDown(30) Then TranslateEntity player,0,-2,0
If KeyDown(44) Then TranslateEntity player,0,+2,0

If KeyHit(2) mycamera\mode=1;1=red/cyan 
If KeyHit(3) mycamera\mode=2;2=red/green 
If KeyHit(4) mycamera\mode=3;3=yellow/blue
If KeyHit(5) mycamera\mode=4; (Magenta/Green)

mxs#=-MouseXSpeed()/4
mys#=MouseYSpeed()/4
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
TurnEntity mycamera\camera,mys#,0,0
TurnEntity player,0,mxs#,0

if KeyDown(203) TurnEntity player,0,2,0
If KeyDown(205) TurnEntity player,0,-2,0
If KeyDown(200) MoveEntity player,0,0,spd
If KeyDown(208) MoveEntity player,0,0,-spd

If Not KeyDown(200) Or KeyDown(208)
 AnimateMD2 player,1,0.5,20,25
EndIf

cameramanager()
UpdateWorld()
RenderWorld()

Flip(True)
Until KeyDown(1)

;############ End of Main ############

;============================

;CAMERA

;3DCAM by Frank Taylor

;============================

Type camera

Field camera

Field lens

Field viewportx,viewporty,viewportwidth,viewportheight

Field mode ; 0=Normal, 1-4=Anaglyphic, 5-Pulfrich Effect, 6=Shutter, 7=Split

Field fov#

Field zoom#

Field x#;left|right x plane position from center focal point

Field yaw# ;left|right y axis degree of angle from 0

Field r ;red color component

Field gb ;green|blue color component

Field llens ;left lens color [red]

Field rlens ;right lens color [green]

Field lenssyncpulse ;0-red, 1-green

Field cursor

End Type



Function cameranew.camera()

mycamera.camera=New camera

mycamera\viewportx=0

mycamera\viewporty=0

mycamera\viewportwidth=GraphicsWidth() Shr 1

mycamera\viewportheight=GraphicsHeight() Shr 1

mycamera\r=255

mycamera\gb=255

mycamera\llens=mycamera\r

mycamera\rlens=0

mycamera\x#=.2

mycamera\yaw#=.5

mycamera\lenssyncpulse=1

Return mycamera

End Function


Function cameradelete(mycamera.camera)

FreeEntity mycamera\lens

Delete mycamera

End Function


Function cameramanager()

;2 to 1 buffering

;takes separate snapshots of the scene in two equal/opposite angles in separate color

For eachcamera.camera=Each camera



;Anaglypic/Shutter Mode

If eachcamera\mode

;Shutter

   eachcamera\lenssyncpulse=-1*eachcamera\lenssyncpulse

    ;left | right lens

    TranslateEntity eachcamera\camera,eachcamera\x*eachcamera\lenssyncpulse,0,0

    TurnEntity eachcamera\camera,0,eachcamera\yaw*eachcamera\lenssyncpulse,0

   eachcamera\llens=eachcamera\r-eachcamera\llens

    eachcamera\rlens=eachcamera\gb-eachcamera\rlens

;set lens color

Select eachcamera\mode

;AnaglyphicRB (Red/Cyan)

Case 1 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\rlens

;AnaglyphicRG (Red/Green)

Case 2 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,0

;AnaglyphicRB (Yellow/Blue)

Case 3 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\rlens

;AnaglyphicRG (Magenta/Green)

Case 4 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\llens

;Pulfrich

Case 5

Select eachcamera\lenssyncpulse

Case 1EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\llens

Case -1 EntityColor eachcamera\lens,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1

End Select

;Split

Case 7

Select eachcamera\lenssyncpulse

Case 1CameraViewport eachcamera\camera,eachcamera\viewportx,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight

Case -1 CameraViewport eachcamera\camera,eachcamera\viewportx+eachcamera\viewportwidth,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight

End Select

End Select 



EndIf



Next

End Function


Function cameracreate.camera()

mycamera.camera=cameranew()

mycamera\camera=CreateCamera()

PositionEntity mycamera\camera,0,0,-3

;listener

CreateListener(mycamera\camera) 

;lens

mycamera\lens=CreateSprite(mycamera\camera)

TranslateEntity mycamera\lens,0,0,1

ScaleSprite mycamera\lens,1,1

EntityBlend mycamera\lens,2

Return mycamera

End Function


Function cameraadjust(mycamera.camera,translate#=0,turn#=0,r=0,gb=0)

;translates|turns|set color in -1|+1 increments

If translate<>0 mycamera\x=mycamera\x#+translate#

If turn<>0 mycamera\yaw#=mycamera\yaw#+turn#

If r<>0 mycamera\r=mycamera\r+r

If gb<>0 mycamera\gb=mycamera\gb+gb

End Function


(not tested)


Doggie(Posted 2003) [#32]
That's pretty much the same as I've already tried and it doesn't work. The camera just points at the MD2 from the top and everything else falls away. I suppose it has to do with the entityparenting, but I haven't been able to fix it.
Hopefully you'll get to once you get to your desktop.
Thanks.

Doggie


jfk EO-11110(Posted 2003) [#33]
Well, I really don't love it too much to test such things
when I have to add things like MD2 and Terrains just to
make it testable.

If it's only the camera then you should really be able to
make it work by your own. I guess you want the Camera to
follow the Player, right?

The easiest way is to Parent the camera to the player, but
of course you have to move it to the right osition behind
the Player.

An other way would be to use sin/cos to position an
unparented camera mathematically behind the Player, this
would look maybe like this:

dist#=4
yaw#=entityyaw(player)+180
camx#=entitxx(player)+sin(yaw#)*dist#
camy#=entitxy(player)+3
camz#=entitxz(player)+cos(yaw#)*dist#
positionentity camera,camx#,camy#,camz#
pointentity camera,player

Next Version would be to smooth the Camera Movements, so it
will follow the Player like with a rubberband. For this you
would take the diffrence of old camx and new camx, divide
it by let's say 5 (the more the slower the Camera reaction)
and then add this result to the old camx (and do the same
with camy and camz).

Problem with such Chase Cams is when there are Object
between the Camera and the Player. Sly Cams like e have
seen them first in Tomb Raider would now come closer to the
player, until he is visible again. I wrote some pseudo code
using linepicks for such a camera, it was here:
http://www.blitzbasic.com/bbs/posts.php?topic=24975

And what do you mean with "everything else is falling
apart"?


jfk EO-11110(Posted 2003) [#34]
ok, this should work now:
;     # Created By HomeSpun Gold #

;# Courtesy of Doggie at BB Forums #

;D:\blit\homespun\aaa.bb  Created  # 24 Oct 2003

Graphics3D 800,600,32,1
SetBuffer BackBuffer()
AmbientLight 200,200,200
terrain1=LoadTerrain( "hmap4.bmp")
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,500,True
ScaleEntity terrain1,6,40,6
terrainTex=LoadTexture( "terrain_tex0.bmp",8)
ScaleTexture terrainTex,256,256
TextureBlend terrainTex,2
EntityTexture terrain1,terrainTex,0,1
EntityType terrain1,2
plane=CreatePlane(10)
planeTex=LoadTexture("water03.bmp")
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EntityAlpha plane,0.50
PositionEntity plane,0,2,0
EntityType plane,2
FreeImage planetex
gplane=CreatePlane(10)
gplaneTex=LoadTexture("terrain_tex0.bmp")
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex
Global player=LoadMD2( "ss.md2")
ss_tex=LoadTexture( "ss3.pcx")
EntityTexture player,ss_tex
ScaleEntity player,.09,.09,.09
AnimateMD2 player,1,0.5,0,19
PositionEntity player,0.0,TerrainY(terrain1,EntityX(player),0,EntityZ(player))+5,0.0
RotateEntity player,0,150,0
EntityRadius player,2
EntityType player,1
;___
mycamera.camera=CameraCreate()
mycamera\mode=1 ;1=red/cyan
EntityParent(mycamera\camera,player)
CameraRange mycamera\camera,.1,100
;___
PositionEntity mycamera\camera,-50.0,25,-50.0 ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< position it here!
CameraViewport mycamera\camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraClsColor mycamera\camera,0,0,0
CameraRange mycamera\camera,1,500
CameraFogMode mycamera\camera,1
CameraFogRange mycamera\camera,20,200
CameraFogColor mycamera\camera, 120,120,120
PointEntity mycamera\camera,player
EntityParent mycamera\camera,player
Global sphere=CreateSphere(32)
EntityParent mycamera\camera,player
PositionEntity sphere,508,1,1544
light1=CreateLight (3)
PositionEntity light1,508,50,1544
RotateEntity light1,90,180,180
LightRange light1,100
LightConeAngles light1,0,90
LightColor light1,55,55,55
skytex=LoadTexture("sky.jpg",8 )
ScaleEntity sphere,250,250,250
EntityTexture sphere,skytex
EntityAlpha sphere,1
FlipMesh sphere
Collisions 1,2,2,2
party=0
Dim prx(100)
Dim pry(100)
Dim prz(100)
Dim psz(100)
Dim pscale#(100)
Dim plife#(100)
Dim pfade#(100)
Dim pgravity(100)
Dim smoker(100)
Dim pbled(100)
Global dt,Bravo#
Collisions 1,2,2,2
synctimer=CreateTimer(120);max fps required or serious flicker
spd#=.5
ey#=EntityY(player)
;############ Main Loop ############

Repeat
WaitTimer synctimer
Cls
If KeyHit(17)
 wire=1-wire
 WireFrame wire
EndIf
yv#=EntityY(player)-ey
ey=EntityY(player)


If KeyHit(57) yv=.1 
MoveEntity player,0,yv-.005,0
If KeyDown(30) Then TranslateEntity player,0,-2,0
If KeyDown(44) Then TranslateEntity player,0,+2,0

If KeyHit(2) mycamera\mode=1;1=red/cyan 
If KeyHit(3) mycamera\mode=2;2=red/green 
If KeyHit(4) mycamera\mode=3;3=yellow/blue
If KeyHit(5) mycamera\mode=4; (Magenta/Green)

mxs#=-MouseXSpeed()/4
mys#=MouseYSpeed()/4
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
TurnEntity mycamera\camera,mys#,0,0
TurnEntity player,0,mxs#,0

if KeyDown(203) TurnEntity player,0,2,0
If KeyDown(205) TurnEntity player,0,-2,0
If KeyDown(200) MoveEntity player,0,0,spd
If KeyDown(208) MoveEntity player,0,0,-spd

If Not KeyDown(200) Or KeyDown(208)
 AnimateMD2 player,1,0.5,20,25
EndIf

cameramanager()
UpdateWorld()
RenderWorld()

Flip(True)
Until KeyDown(1)

;############ End of Main ############

;============================

;CAMERA
;3DCAM by Frank Taylor

;============================


Type camera
Field camera
Field lens
Field viewportx,viewporty,viewportwidth,viewportheight
Field mode ; 0=Normal, 1-4=Anaglyphic, 5-Pulfrich Effect, 6=Shutter, 7=Split
Field fov#
Field zoom#
Field x#;left|right x plane position from center focal point
Field yaw# ;left|right y axis degree of angle from 0
Field r ;red color component
Field gb ;green|blue color component
Field llens ;left lens color [red]
Field rlens ;right lens color [green]
Field lenssyncpulse ;0-red, 1-green
Field cursor
End Type

Function cameranew.camera()
mycamera.camera=New camera
mycamera\viewportx=0
mycamera\viewporty=0
mycamera\viewportwidth=GraphicsWidth() Shr 1
mycamera\viewportheight=GraphicsHeight() Shr 1
mycamera\r=255
mycamera\gb=255
mycamera\llens=mycamera\r
mycamera\rlens=0
mycamera\x#=.2
mycamera\yaw#=.5
mycamera\lenssyncpulse=1
Return mycamera
End Function

Function cameradelete(mycamera.camera)
FreeEntity mycamera\lens
Delete mycamera
End Function

Function cameramanager()
;2 to 1 buffering
;takes separate snapshots of the scene in two equal/opposite angles in separate color
For eachcamera.camera=Each camera
;Anaglypic/Shutter Mode
If eachcamera\mode
;Shutter
   eachcamera\lenssyncpulse=-1*eachcamera\lenssyncpulse
    ;left | right lens
    TranslateEntity eachcamera\camera,eachcamera\x*eachcamera\lenssyncpulse,0,0
    TurnEntity eachcamera\camera,0,eachcamera\yaw*eachcamera\lenssyncpulse,0
   eachcamera\llens=eachcamera\r-eachcamera\llens
    eachcamera\rlens=eachcamera\gb-eachcamera\rlens
;set lens color
Select eachcamera\mode
;AnaglyphicRB (Red/Cyan)
Case 1 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\rlens
;AnaglyphicRG (Red/Green)
Case 2 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,0
;AnaglyphicRB (Yellow/Blue)
Case 3 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\rlens
;AnaglyphicRG (Magenta/Green)
Case 4 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\llens
;Pulfrich
Case 5
Select eachcamera\lenssyncpulse
Case 1EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\llens
Case -1 EntityColor eachcamera\lens,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1
End Select
;Split
Case 7
Select eachcamera\lenssyncpulse
Case 1CameraViewport eachcamera\camera,eachcamera\viewportx,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
Case -1 CameraViewport eachcamera\camera,eachcamera\viewportx+eachcamera\viewportwidth,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
End Select
End Select 
EndIf
Next
End Function

Function cameracreate.camera()
mycamera.camera=cameranew()
mycamera\camera=CreateCamera()
PositionEntity mycamera\camera,0,0,-3
;listener
CreateListener(mycamera\camera) 
;lens
mycamera\lens=CreateSprite(mycamera\camera)
TranslateEntity mycamera\lens,0,0,1
ScaleSprite mycamera\lens,1,1
EntityBlend mycamera\lens,2
Return mycamera
End Function

Function cameraadjust(mycamera.camera,translate#=0,turn#=0,r=0,gb=0)
 ;translates|turns|set color in -1|+1 increments
 If translate<>0 mycamera\x=mycamera\x#+translate#
 If turn<>0 mycamera\yaw#=mycamera\yaw#+turn#
 If r<>0 mycamera\r=mycamera\r+r
 If gb<>0 mycamera\gb=mycamera\gb+gb
End Function

 


But this thing is flickering wildy on my Machine... and there is also some strange "diagonally cut Renders" - maybe a Problem with the Camerarange.


Doggie(Posted 2003) [#35]
That comes closer but still doesn't work.
Removing the MD2 helps but instead of
getting the red/blue I get what I can
only best describe as "glass shards" shaped
flickers of red and blue at odd angles
all over the screen. Thanks for your help
and I'll keep tweaking it. If I get it right
I'll post it.

Doggie


Techlord(Posted 2003) [#36]
jfk,

I warned you guys about that flickering:) You may have to adjust the lens distance from the camera to stop the diagonal cut.
TranslateEntity mycamera\lens,0,0,1

;Changed To

TranslateEntity mycamera\lens,0,0,.3
There are several other tweaks that may be needed to get the camera right. Unfortunately, I have yet to view the system through 3D glasses:(


jfk EO-11110(Posted 2003) [#37]
Hehe, that's like Lego in the Dark.


Doggie(Posted 2003) [#38]
OK. Tweaked and working though not outstanding 3D effect with terrains. I'll keep tweaking and you'll have to look for yourself to see what changes I made cuz I don't really remember. I just hack and slash till it more or less works.
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
AmbientLight 250,50,250
terrain1=LoadTerrain( "hmap4.bmp")
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,500,True
ScaleEntity terrain1,6,40,6
terrainTex=LoadTexture( "terrain_tex0.bmp",8)
ScaleTexture terrainTex,256,256
TextureBlend terrainTex,2
EntityTexture terrain1,terrainTex,0,1
EntityType terrain1,2
plane=CreatePlane(10)
planeTex=LoadTexture("water03.bmp")
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EntityAlpha plane,0.50
PositionEntity plane,0,2,0
EntityType plane,2
FreeImage planetex
gplane=CreatePlane(10)
gplaneTex=LoadTexture("terrain_tex0.bmp")
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex

Collisions 1,2,2,2


player=CreatePivot()
PositionEntity player,0,1,-1
EntityRadius player,.6
EntityType player,1



;___
mycamera.camera=CameraCreate()
mycamera\mode=1 ;1=red/cyan
EntityParent(mycamera\camera,player)
CameraRange mycamera\camera,.1,1000
;___
PositionEntity mycamera\camera,-50.0,25,-50.0 ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< position it here!
CameraViewport mycamera\camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraClsColor mycamera\camera,200,0,200
CameraRange mycamera\camera,1,1500
CameraFogMode mycamera\camera,0
CameraFogRange mycamera\camera,20,200
CameraFogColor mycamera\camera, 120,0,120
PointEntity mycamera\camera,player
EntityParent mycamera\camera,player
Global sphere=CreateSphere(32)
EntityParent mycamera\camera,player
PositionEntity sphere,508,1,1544
light1=CreateLight (3)
PositionEntity light1,508,50,1544
RotateEntity light1,90,180,180
LightRange light1,1000
LightConeAngles light1,0,190
LightColor light1,155,5,155
skytex=LoadTexture("sky.jpg",8 )
ScaleEntity sphere,250,250,250
EntityTexture sphere,skytex
EntityAlpha sphere,1
FlipMesh sphere
Collisions 1,2,2,2
party=0
Dim prx(100)
Dim pry(100)
Dim prz(100)
Dim psz(100)
Dim pscale#(100)
Dim plife#(100)
Dim pfade#(100)
Dim pgravity(100)
Dim smoker(100)
Dim pbled(100)
Global dt,Bravo#
Collisions 1,2,2,2
synctimer=CreateTimer(120);max fps required or serious flicker
spd#=.5
ey#=EntityY(player)
;############ Main Loop ############
Repeat
WaitTimer synctimer
Cls
If KeyHit(17)
 wire=1-wire
 WireFrame wire
EndIf
yv#=EntityY(player)-ey
ey=EntityY(player)


If KeyHit(57) yv=.1 
MoveEntity player,0,yv-.005,0
If KeyDown(30) Then TranslateEntity player,0,-2,0
If KeyDown(44) Then TranslateEntity player,0,+2,0

If KeyHit(2) mycamera\mode=1;1=red/cyan 
If KeyHit(3) mycamera\mode=2;2=red/green 
If KeyHit(4) mycamera\mode=3;3=yellow/blue
If KeyHit(5) mycamera\mode=4; (Magenta/Green)

mxs#=-MouseXSpeed()/4
mys#=MouseYSpeed()/4
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
TurnEntity mycamera\camera,mys#,0,0
TurnEntity player,0,mxs#,0

If KeyDown(203) TurnEntity player,0,2,0
If KeyDown(205) TurnEntity player,0,-2,0
If KeyDown(200) MoveEntity player,0,0,spd
If KeyDown(208) MoveEntity player,0,0,-spd
PositionEntity light1,EntityX(player),EntityY(player),EntityZ(player)
x1#=EntityX(player)
y1#=EntityY(player)
z1#=EntityZ(player)
PositionEntity sphere,x1#,y1#,z1#
wx#=(wx#+.001)Mod 1
wy#=(wy#+.001)Mod 1
sx#=(sx#+.0001)Mod 1
sy#=(sy#+.0001)Mod 1
PositionTexture planeTex,wx#,wy#
PositionTexture skytex,sx#,0



cameramanager()
UpdateWorld()
RenderWorld()
WaitTimer synctimer
UpdateWorld()
RenderWorld()

Flip(True)
Until KeyDown(1)

;############ End of Main ############

;============================

;CAMERA
;3DCAM by Frank Taylor

;============================


Type camera
Field camera
Field lens
Field viewportx,viewporty,viewportwidth,viewportheight
Field mode ; 0=Normal, 1-4=Anaglyphic, 5-Pulfrich Effect, 6=Shutter, 7=Split
Field fov#
Field zoom#
Field x#;left|right x plane position from center focal point
Field yaw# ;left|right y axis degree of angle from 0
Field r ;red color component
Field gb ;green|blue color component
Field llens ;left lens color [red]
Field rlens ;right lens color [green]
Field lenssyncpulse ;0-red, 1-green
Field cursor
End Type

Function cameranew.camera()
mycamera.camera=New camera
mycamera\viewportx=-3
mycamera\viewporty=-3
mycamera\viewportwidth=GraphicsWidth() Shr 1
mycamera\viewportheight=GraphicsHeight() Shr 1
mycamera\r=255
mycamera\gb=255
mycamera\llens=mycamera\r
mycamera\rlens=0
mycamera\x#=.2
mycamera\yaw#=.5
mycamera\lenssyncpulse=-3
Return mycamera
End Function

Function cameradelete(mycamera.camera)
FreeEntity mycamera\lens
Delete mycamera
End Function

Function cameramanager()
;2 to 1 buffering
;takes separate snapshots of the scene in two equal/opposite angles in separate color
For eachcamera.camera=Each camera
;Anaglypic/Shutter Mode
If eachcamera\mode
;Shutter
   eachcamera\lenssyncpulse=-1*eachcamera\lenssyncpulse
    ;left | right lens
    TranslateEntity eachcamera\camera,eachcamera\x*eachcamera\lenssyncpulse,0,0
    TurnEntity eachcamera\camera,0,eachcamera\yaw*eachcamera\lenssyncpulse,0
   eachcamera\llens=eachcamera\r-eachcamera\llens
    eachcamera\rlens=eachcamera\gb-eachcamera\rlens
;set lens color
Select eachcamera\mode
;AnaglyphicRB (Red/Cyan)
Case 1 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\rlens
;AnaglyphicRG (Red/Green)
Case 2 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,0
;AnaglyphicRB (Yellow/Blue)
Case 3 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\rlens
;AnaglyphicRG (Magenta/Green)
Case 4 EntityColor eachcamera\lens,eachcamera\llens,eachcamera\rlens,eachcamera\llens
;Pulfrich
Case 5
Select eachcamera\lenssyncpulse
Case 1EntityColor eachcamera\lens,eachcamera\llens,eachcamera\llens,eachcamera\llens
Case -1 EntityColor eachcamera\lens,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1,eachcamera\rlens Shr 1
End Select
;Split
Case 7
Select eachcamera\lenssyncpulse
Case 1CameraViewport eachcamera\camera,eachcamera\viewportx,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
Case -1 CameraViewport eachcamera\camera,eachcamera\viewportx+eachcamera\viewportwidth,eachcamera\viewporty,eachcamera\viewportwidth,eachcamera\viewportheight
End Select
End Select 
EndIf
Next
End Function

Function cameracreate.camera()
mycamera.camera=cameranew()
mycamera\camera=CreateCamera()
PositionEntity mycamera\camera,0,0,-3
;listener
CreateListener(mycamera\camera) 
;lens
mycamera\lens=CreateSprite(mycamera\camera)
TranslateEntity mycamera\lens,0,0,1.1
ScaleSprite mycamera\lens,1.5,1.5
EntityBlend mycamera\lens,2
Return mycamera
End Function

Function cameraadjust(mycamera.camera,translate#=0,turn#=0,r=0,gb=0)
 ;translates|turns|set color in -1|+1 increments
 If translate<>0 mycamera\x=mycamera\x#+translate#
 If turn<>0 mycamera\yaw#=mycamera\yaw#+turn#
 If r<>0 mycamera\r=mycamera\r+r
 If gb<>0 mycamera\gb=mycamera\gb+gb
End Function

Now if you happen to have a copy of HomeSpun you can create an HSP level then cut and paste all your prims,objs and loaded models in ahead of the main loop.
Thanks Frank and JFK!
Doggie