Tokamak space ship

Miscellaneous Forums/Blitz Showcase/Tokamak space ship

I dug this up, and I realized that somebody may find it handy.

This is a test that I did a long time ago using the Tokamak physics engine and a lot of help from people on these forums (who taught me all about the TForm commands).
This application used to work quite poorly and had very rough collision detection... which is why it inspired me to write APE -- Which I have just used, about 15 minutes ago, to fix up the Rigid Body objects. It now works perfectly :D
You may notice a bit of imperfection around the @#!*pit, because its RB object is just a big cube. (uhm... the FRONT of the ship. I hope this censor doesn't censor code... because there's lots of naughty words ending up in some of those Windows API things. InitCommonControlsEx springs to mind)

I did a bit of cheating with regards to realism... For the ship to be able to stop, I just added air friction. I could have had thrusters on the ship and a little 'on-board' program to handle this (would have been in the game, if it ever succeeded in becoming a game, which it obviously, sadly, did not... but may eventually). In order to make this air friction seem moderately possible, I dumped the scene inside of Klass's excellent fog system. (Thus, it is all in some kind of weird cloud of gas).
The controls are as follows: Arrow keys turn, W and E rotate. Numpad + and - change speed. Backspace jumps to full speed, and 0 jumps to full stop.
Sorry about the very limited camera controls.

Anyway, have fun :D
What do you think of it?

Download: http://crumbsoftware.f2o.org/files/TokSpaceTest.zip

This screenie is not intended to look nice... it's just so that nobody will complain about how this would otherwise lack one:


Also needs the latest version of Sweeney's Tokamak wrapper, and a recent version of the Tokamak Physics Library.
Includes source. Thankfully, it is commented... for once.

looks cool..

User lib not found
got that error tho

That ALWAYS happens to me!
I'll fix the archive. Give me 30 seconds to upload.
Now contains both required DLLs and Decls files. I did not create Tokamak.decls... credit for that goes to Sweeney. (Though hopefully everyone already knows this)

Apart from a few stats in the top left-hand corner, that's the stealthiest ship I think I've ever (not) seen.

Hehe, yah... it doesn't work well on CRT monitors.
Just go into the source and play around with the setting in line 86. Doing Global weather_nearfade = 100 should work fine.
You may also want to change CameraFogRange in line 53.

Uhm... Sorry, my FPS counter appears to have been attached the the fog effect, so don't trust it.

As I said, this was done a long time ago...

Sorry - I should have been more specific while I was being facetious: the screenshot is as black as the ace of spades.

I will however check out the code just so I can see what I'm not seeing. :o) I dun wanna miss out.

[edit] Okay... now I'm more perplexed. It's an interesting effect, and the collisions look as cool as collisions do when they look cool... but is 'silhouette at night in dark fog' the look you're going for... nice that it is?[/edit]

Actually, I wasn't looking for a look.
Because of that, now that ou mention it, I think I'll tone down the fog... Above post changed.

Thanks for the advice and comments :)


Don't worry, no offence taken! Your response was helpful advice. Yah, no textures... It's just a physics demo. I do have textures for that model, but they look horrible.
|
|
\/

Sorry - I didn't mean it to sound like criticism. I thought it might have been missing a texture or something...

^
|
|
|
Okay then! :o) I'll twiddle with the settings as you suggested. It still provides a cool "flying at high speed with wingman" sorta feel nonetheless.

Oh, so this kind of thing IS possible with blitz? Wow i had nooo idea. This is really cool. Too bad i got rid of any physics-dependant ideas from the outset. I mean i have no clue how Tokamak works and what it can do, i thought it can only do collisions between primitives. Maybe this is also only collisions between primitives but it feels more complex anyway.

This scene contains two rigid body objects. The objects's physics collision data are each assembled out of 4 boxes, two cylinders, and two convex hulls. (Convex hulls are about as close to pixel-perfect as you can get.).

The front of the ship should really be a convex hull, but I was too lazy to redo that model (even though it would only take a minute :D). The original model was done for a more basic, far-off perspective simulation, so perfection didn't matter.

So, real-time physics (in any language, actually) are still carried out using Primitives, but they are all cleverly assembled into one object to make a rather complex physics object. Of course, you will have to come up with positions of the primitives on your own. (Which, of course, is where my editor, and others like it but not as fantastically amazing, comes in ;) )

I played around with turbulence today, and the results are actually surprisingly nice.
I also added a basic chase camera from the code archives. (SuperCam, by PsychicParrot).
It doesn't work perfectly for this program, but it doesn't really matter since it's just a horribly coded test.

;3d space flight engine v 3
;now that I have proper physics, I think it may work out
;I'm aiming to fix the problem involving it just not 'feeling' right, which is very hard to fix with conventional control systems

;includes
;the dust clouds effect
Include "dustclouds.bb"

Const TurbulencePower=2 ;You can change this

;the fog type
Type snow
	Field entity
	Field x#,y#,z#
	Field vx#,vy#,vz#
End Type

;the type instance for the centrepoint() function
Type point
   Field x#,y#,z# 
   Field lx#,ly#,lz#
   Field rx#,ry#,rz#
End Type

;set up graphics
Graphics3D 1024,768,0,2

;double buffering
SetBuffer BackBuffer()

SeedRnd MilliSecs()


;set up tokamak simulator

TOKSIM_SetRigidBodiesCount 2
TOKSIM_SetAnimatedBodiesCount 0
TOKSIM_SetRigidParticleCount 0
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount 16
TOKSIM_SetOverlappedPairsCount 16

TOKSIM_CreateSimulator(0,0,0)

;the camera
;Global cam1 = CreateCamera()

Global campivot=CreatePivot() ; create pivot for camera
Global cam1=CreateCamera()  ; create camera (!!!)
CameraViewport cam1,0,0,GraphicsWidth(),GraphicsHeight()
PositionEntity cam1,0,0,-10

;load the ship(s)
;NOTE: CHANGE THIS TO AN ARRAY OR SOMETHING!!
Global Ship01=LoadMesh("media\models\ship01\Fighter1.3ds")
MoveEntity ship01,-0.65,0.6,0.35
Global CamTarget=CreatePivot(ship01)
Global Ship01_2=CopyEntity(ship01)
MoveEntity ship01_2,-0.65,0.6,0.35

;playing with klaas's fog effect
CameraClsColor cam1,5,5,35
CameraFogColor cam1,5,5,35
CameraFogMode cam1,1
CameraFogRange cam1,-10,200

;cameracone for the topview
cone = CreateCone(12,1,cam1)
EntityColor(cone,255,0,0)
TurnEntity cone,-90,0,0

Global x_speed#,y_speed#,z_speed#

;------ load the snowflake
extractdata("snow.jpg")
Global snow = LoadSprite("snow.jpg",2)
ScaleSprite(snow,0.4,0.4)
ScaleSprite(snow,16,16)
EntityColor(snow,10,10,10)
EntityAlpha snow,0.2
DeleteFile("snow.jpg")
HideEntity(snow)
SpriteViewMode(snow,4)

;topview camera
topview = CreateCamera(ml_cam_pivot)
CameraViewport topview,10,10,320,240
CameraProjMode(topview,2)
CameraZoom(topview,0.01)
MoveEntity(topview,0,10,10)
TurnEntity(topview,90,0,0)
HideEntity topview

;----- the dimension of the weather box
Global weather_x# = 40
Global weather_y# = 35
Global weather_z# = 50
Global weather_nearfade = 30
createSnow(40)

;the lights
AmbientLight 100,100,100

;render tweening timer / constants / initial variables
Const FPS=60
period=1000/FPS
time=MilliSecs()-period


;APOE Physics Editor 0.1; output for Fighter1.3ds
ship01rb=TOKRB_Create()
TOKRB_SetPosition ship01rb,0,5,0 ;For this version of APOE, you must set positions manually
TOKRB_SetRotation ship01rb,0,0,0 ;For this version of APOE, you must set positions manually
TOKRB_SetLinearDamping ship01rb,0.05
TOKRB_SetAngularDamping ship01rb,0.07
TOKRB_CollideConnected ship01rb,0
TOKRB_SetMass ship01rb,10.0
TOKRB_SetBoxInertiaTensor ship01rb,5.0,5.0,5.0,10.0

Geom_4=TOKRB_AddBox(ship01rb,0.346159,2.11598,3.468)
TOKGEOM_SetPositionAndRotation Geom_4,6.14357,0.0191566,-2.392,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_4,3
Geom_6=TOKRB_AddCylinder(ship01rb,0.430949,5.25123)
TOKGEOM_SetPositionAndRotation Geom_6,6.10232,0.0140017,-1.35361,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_6,2
Geom_3=TOKRB_AddBox(ship01rb,3.41733,3.28844,6.02556)
TOKGEOM_SetPositionAndRotation Geom_3,-0.0511686,0.0645195,-1.793,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_3,3
Geom_5=TOKRB_AddBox(ship01rb,0.346159,2.11598,3.468)
TOKGEOM_SetPositionAndRotation Geom_5,-6.22443,0.0194947,-2.392,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_5,3
Geom_7=TOKRB_AddCylinder(ship01rb,0.448,5.25123)
TOKGEOM_SetPositionAndRotation Geom_7,-6.25,0.0140017,-1.35361,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_7,2
cHull = LoadConvex("media\models\ship01\RB_CHull_1.bin")
Geom_2=TOKRB_AddConvex(ship01rb,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_2,-3.95875,0.0196976,-2.448,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_2,3
Geom_8=TOKRB_AddBox(ship01rb,3.06407,2.98516,7.30887)
TOKGEOM_SetPositionAndRotation Geom_8,0.0137982,0.667202,4.72569,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_8,1
cHull = LoadConvex("media\models\ship01\RB_CHull_0.bin")
Geom_1=TOKRB_AddConvex(ship01rb,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_1,3.8196,0.0196976,-2.448,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_1,3

TOKRB_SetCollisionID ship01rb,1
TOKRB_UpdateBoundingInfo ship01rb

;a ship to smash into.... Lazy me....
ship01_2rb=TOKRB_Create()
	TOKRB_SetPosition ship01_2rb,10.0,8.0,10.0
	TOKRB_SetRotation ship01_2rb,10.0,5.0,40.0
	TOKRB_SetLinearDamping ship01_2rb,0.05
	TOKRB_SetAngularDamping ship01_2rb,0.07
	TOKRB_CollideConnected ship01_2rb,0
	TOKRB_SetMass ship01_2rb,10.0
	TOKRB_SetBoxInertiaTensor ship01_2rb,5.0,5.0,5.0,10.0

Geom_4=TOKRB_AddBox(ship01_2rb,0.346159,2.11598,3.468)
TOKGEOM_SetPositionAndRotation Geom_4,6.14357,0.0191566,-2.392,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_4,3
Geom_6=TOKRB_AddCylinder(ship01_2rb,0.430949,5.25123)
TOKGEOM_SetPositionAndRotation Geom_6,6.10232,0.0140017,-1.35361,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_6,2
Geom_3=TOKRB_AddBox(ship01_2rb,3.41733,3.28844,6.02556)
TOKGEOM_SetPositionAndRotation Geom_3,-0.0511686,0.0645195,-1.793,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_3,3
Geom_5=TOKRB_AddBox(ship01_2rb,0.346159,2.11598,3.468)
TOKGEOM_SetPositionAndRotation Geom_5,-6.22443,0.0194947,-2.392,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_5,3
Geom_7=TOKRB_AddCylinder(ship01_2rb,0.448,5.25123)
TOKGEOM_SetPositionAndRotation Geom_7,-6.25,0.0140017,-1.35361,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_7,2
cHull = LoadConvex("media\models\ship01\RB_CHull_1.bin")
Geom_2=TOKRB_AddConvex(ship01_2rb,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_2,-3.95875,0.0196976,-2.448,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_2,3
Geom_8=TOKRB_AddBox(ship01_2rb,3.06407,2.98516,7.30887)
TOKGEOM_SetPositionAndRotation Geom_8,0.0137982,0.667202,4.72569,0.0,0.0,0.0
;TOKGEOM_SetMaterialIndex Geom_8,1
cHull = LoadConvex("media\models\ship01\RB_CHull_0.bin")
Geom_1=TOKRB_AddConvex(ship01_2rb,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_1,3.8196,0.0196976,-2.448,0.0,0.0,0.0				

TOKRB_SetCollisionID ship01_2rb,1
TOKRB_UpdateBoundingInfo ship01_2rb

;collision reponse for the player's ship with the dummy ship
;TOKSIM_SetCollisionResponse 1,1,3

;um, let's hope I just set up the scaling wrong here...
;TO DO: I THINK THE FRONT OF THE SHIP'S RIGID BODY SETUP IS WRONG
;TRY USING A DIFFERENT COLLISION SYSTEM ALONG WITH TOKRB_ApplyImpulse2
			
;the acceleration variables
;NOTE: PUT THRUST INTO THE SHIP01 ARRAY/Type
thrust = 0

;arrays for engine's positions (see top of "rotation stuff" section)
;the port wing engine
Dim PortEngine#(2)

;the starboard wing engine
Dim StarboardEngine#(2)

;the top back engine
Dim BackTopEngine#(2)

;the bottom back engine
Dim BackBottomEngine#(2)

;main loop
While Not KeyDown(1)

	;temporary fps counter
	Start = MilliSecs()

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed
	ticks=elapsed/period	;how many 'frames' have elapsed	
	tween#=Float(elapsed Mod period)/Float(period)	;fractional remainder
	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		;;;;;;;;;;;;;;CONTENT HERE;;;;;;;;;;;;;;;;;;;;
		
		;;;;;;;;;;;;;;MOVEMENT RELATED STUFF STILL TO DO;;;;;;;;;;;;;;;;
		;shaking the ship at random
		;ability to cut flow from certain engines
				
		;;;acceleration stuff;;;

		; if the + key is pressed
	
		If KeyDown(78)
	
		;if not exeeding max speed  NOTE: WHEN YOU SET UP AN ARRAY/TYPE INSTANCE FOR THE SHIP, MAKE MAX SPEED A VARIABLE
			If thrust<1000
		
			;speed up		
			thrust = thrust + 2
		
			EndIf
		EndIf
	
		;if the - key is pressed
	
		If KeyDown(74)
	
			If thrust>-800 ; max speed check
		
				;slow down
				thrust = thrust - 2
			EndIf	
		EndIf
	
		;if the "0" key on the number line (not num pad) is pressed
		If KeyDown(11)
			thrust = 0 ;stop engines
		EndIf
		
		;if the backspace key is pressed
		If KeyDown(14)
			thrust = 1000 ;imediately go to maximum speed
		EndIf
	
		;actually move	
		
		;first TformVector on the ship entity to get the right movement direction
			TFormVector 0,0,Thrust,ship01,0
			TOKRB_SetForce ship01rb,TFormedX#(),TFormedY#(),TFormedZ#()
		
		;end acceleration stuff
		
		;;;;;;;rotation stuff;;;;;;;
		
		;creating the variables to store postitions of the engines on the ship
		;try to reduce the number of thrusters on this ship; it will increase speed a lot.
		;I may have mucked up my left and right orientation at some point
		;so this would be a good place to look for the problem		
		TFormPoint 3.8,0,0,ship01,0 ;port engine
			PortEngine#(0)=TFormedX#() ;storing the x position
			PortEngine#(1)=TFormedY#() ;storing the y position
			PortEngine#(2)=TFormedZ#() ;storing the z position
		
		TFormPoint -3.8,0,0,ship01,0 ;starboard engine
			StarboardEngine#(0)=TFormedX#() ;storing the x position
			StarboardEngine#(1)=TFormedY#() ;storing the y position
			StarboardEngine#(2)=TFormedZ#() ;storing the z position
		

		TFormPoint 0,2,0,ship01,0 ;top back engine
			BackTopEngine#(0)=TFormedX#()
			BackTopEngine#(1)=TFormedY#()
			BackTopEngine#(2)=TFormedZ#()
		
		TFormPoint 0,-2,0,ship01,0 ;bottom back engine
			BackBottomEngine#(0)=TFormedX#()
			BackBottomEngine#(1)=TFormedY#()
			BackBottomEngine#(2)=TFormedZ#()
		
		
		;yaw control
			
		;left turn with left arrow
		If KeyDown(203)
				
			;apply reverse force to engine on port wing
			TFormVector 0,0,1,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),PortEngine#(0),PortEngine#(1),PortEngine#(2))
						
			;apply forward force to engine on starboard wing
			TFormVector 0,0,-1,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),StarboardEngine#(0),StarboardEngine#(1),StarboardEngine#(2))			
						
		EndIf
	
		;right turn with right arrow
		If KeyDown(205)		
			;forward force to left wing	
			TFormVector 0,0,-1,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),PortEngine#(0),PortEngine#(1),PortEngine#(2))
						
			;apply reverse force to engine on starboard wing
			TFormVector 0,0,1,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),StarboardEngine#(0),StarboardEngine#(1),StarboardEngine#(2))			
		
		EndIf
		
		;pitch control
		
		;downwards with up arrow
		If KeyDown(200)
			;forward force to top back engine			
			TFormVector 0,0,1,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),BackTopEngine#(0),BackTopEngine#(1),BackTopEngine#(2))
			;reverse force to bottom back engine						
			TFormVector 0,0,-1,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),BackBottomEngine#(0),BackBottomEngine#(1),BackBottomEngine#(2))
		EndIf
		
		;upwards with down arrow
		If KeyDown(208)
			;reverse force to top back engine		
			TFormVector 0,0,-1,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),BackTopEngine#(0),BackTopEngine#(1),BackTopEngine#(2))
			;forward force to bottom back engine						
			TFormVector 0,0,1,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),BackBottomEngine#(0),BackBottomEngine#(1),BackBottomEngine#(2))
		EndIf
		
		;rotate counterclockwise with "w" key
		If KeyDown(17)
			;downwards force to port engine
			TFormVector 0,1,0,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),PortEngine#(0),PortEngine#(1),PortEngine#(2))			
			;upwards force to starboard engine
			TFormVector 0,-1,0,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),StarboardEngine#(0),StarboardEngine#(1),StarboardEngine#(2))		
		EndIf
		
		;rotate clockwise with "e" key
		If KeyDown(18)
			;upwards force to port engine
			TFormVector 0,-1,0,ship01,0	
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),PortEngine#(0),PortEngine#(1),PortEngine#(2))			
			;downwards force to starboard engine
			TFormVector 0,1,0,ship01,0
			TOKRB_ApplyImpulse2(ship01rb,TFormedX#(),TFormedY#(),TFormedZ#(),StarboardEngine#(0),StarboardEngine#(1),StarboardEngine#(2))		
		EndIf
		
		;Turbulence... an interesting effect
		TFormPoint Rnd(-MeshWidth(ship01)/2,MeshWidth(ship01)/2),Rnd(-MeshHeight(ship01)/2,MeshHeight(ship01)/2),Rnd(-MeshDepth(ship01)/2,MeshDepth(ship01)/2),ship01,0
			BlastX#=TFormedX() : BlastY#=TFormedY() : BlastZ#=TFormedZ()
		TOKRB_ApplyImpulse2 ship01rb,Rnd(-TurbulencePower,TurbulencePower),Rnd(-TurbulencePower,TurbulencePower),Rnd(-TurbulencePower,TurbulencePower),BlastX,BlastY,BlastZ


		;Camera Movement
		
		;Chase
		SuperCam(cam1,Ship01,0.5,8,3,3,0)


		doSnow()
		
		
		;;;;;;;;;;;;;;;;END CONTENT;;;;;;;;;;;;;;;;;;;;
	
		;update the simulator
			TOKSIM_Advance(1.5/FPS,1)
		
		;matching objects to their rigid bodies
		;match ship01 to the tokamak rigid body
		PositionEntity ship01,TOKRB_GetX#(ship01rb),TOKRB_GetY#(ship01rb),TOKRB_GetZ#(ship01rb)
		RotateEntity ship01,TOKRB_GetPitch#(ship01rb),TOKRB_GetYaw#(ship01rb),TOKRB_GetRoll#(ship01rb),False
		
		;match the dummy ship to it's tokamak rigid body
		PositionEntity ship01_2,TOKRB_GetX#(ship01_2rb),TOKRB_GetY#(ship01_2rb),TOKRB_GetZ#(ship01_2rb)
		RotateEntity ship01_2,TOKRB_GetPitch#(ship01_2rb),TOKRB_GetYaw#(ship01_2rb),TOKRB_GetRoll#(ship01_2rb),False		


			
		;finish render tweening
			UpdateWorld
		Next
	
	RenderWorld tween#
	
	;another part of the very temporary fps counter
	CurFPS# = 1000.0 / (MilliSecs() - Start)
	
	;the temporary HUD
	;by the way, this seems to be the best place to put one
	
	Text 0,10,"Thrust: " + thrust/10 ; display thrust
	
	;TODO: A SHIP SPEED CHECKER	

	Text 0,30,"Physics Time:"+TOKSIM_GetPhysicsTime()*1000.0+ " milliseconds" ;physics time

	Text 0,50,"Render Time:"+Str(elapsed)+ " milliseconds" ;render time
	
	;Text 0,70,"Fps: " + CurFps# ;display fps ;Removed FPS counter
	
	;Text 0,90,collision$ ;display if the ships are collided or not
		
	;more double buffering
	Flip
	
Wend

TOKSIM_DestroySimulator()
End

;;;;;;;;;The functions;;;;;;;;;;;

;the function to update cube maps

Function UpdateCubeMap( tex,camera ) 

tex_sz=TextureWidth(tex) 

;do left view 
SetCubeFace tex,0 

; copy contents of backbuffer to cube map 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do forward view 
SetCubeFace tex,1 
RotateEntity camera,0,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do right view 
SetCubeFace tex,2 
RotateEntity camera,0,-90,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do backward view 
SetCubeFace tex,3 
RotateEntity camera,0,180,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do up view 
SetCubeFace tex,4 
RotateEntity camera,-90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do down view 
SetCubeFace tex,5 
RotateEntity camera,90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
End Function

Function LoadConvex(file$)
 Convex = CreateBank(FileSize(file$))
 filein = ReadFile(file$)
 For i=0 To FileSize(file$)-1
  PokeByte Convex,i,ReadByte(filein)
 Next
 CloseFile filein
 Return Convex
End Function


; SuperCam!
;
; by PsychicParrot 2003
;
; 
; Usage : SuperCam(cam,ent,cspeed#,dist#,hite#,xrot#,tilt#)
; 
;

Function SuperCam(cam,ent,cspeed#,dist#,hite#,xrot#,tilt#)
	TFormPoint 0,hite#,-dist#,ent,0

	cx#=(TFormedX()-EntityX(cam))*cspeed#
	cy#=(TFormedY()-EntityY(cam))*cspeed#
	cz#=(TFormedZ()-EntityZ(cam))*cspeed#

	TranslateEntity cam,cx,cy,cz
	PointEntity cam,ent
	RotateEntity cam,xrot#,EntityYaw(cam),tilt
End Function



(Oh and this thread should probably be moved to the B3d section...)