Here's my first thing...94 lines. Using my newest GDK - Has Sky Sphere, Terrain, a 3d model and controls to fly around. If people want the files i'll happily post em but i think the picture will suffice for now!
Code: (Select All)
REM $INCLUDE:'UnseenGDK3\New_GDK.bi' '// GDK 3 Header File
DIM SHARED Terrain AS GDK_GL_Terrain, World~&, Viper AS GDK_GL_MODEL, Viper_Roll AS GDK_Range, Viper_RWD AS GDK_RWD, Viper_Pitch AS GDK_Range
GDK_System_Start "UnseenGDK3\World Demo\", 0, 0, 1024, 660, GDK_FALSE, "GDK Test - World Demo", GDK_GL_3D
GDK_GL_Set_Defaults '// If your using GL then you need to either set things up yourself of call this for a generic base
GDK_GL_Set_FOV 75
GDK_GL_Set_Clipping .1, 20000
Viper_Roll.Min = 315
Viper_Roll.Max = 405
Viper_Roll.Default = 360
Viper_Roll.Current = 360
Viper_Pitch.Min = -35
Viper_Pitch.Max = 35
Viper_RWD.Speed = 10
GDK_Allow_GL = GDK_TRUE
GDK_Init_GL = GDK_TRUE
DO
GDK_System_Update
IF _KEYDOWN(19200) THEN '// Left
IF Viper_Roll.Current > Viper_Roll.Min THEN Viper_Roll.Current = Viper_Roll.Current - 2
Viper_RWD.Rotation.Y = Viper_RWD.Rotation.Y + (1 / RAD_TO_DEG_RATIO)
ELSEIF _KEYDOWN(19712) THEN '// Right
IF Viper_Roll.Current < Viper_Roll.Max THEN Viper_Roll.Current = Viper_Roll.Current + 2
Viper_RWD.Rotation.Y = Viper_RWD.Rotation.Y - (1 / RAD_TO_DEG_RATIO)
ELSE
IF Viper_Roll.Current < Viper_Roll.Default THEN Viper_Roll.Current = Viper_Roll.Current + 1 ELSE IF Viper_Roll.Current > Viper_Roll.Default THEN Viper_Roll.Current = Viper_Roll.Current - 1
END IF
IF Viper_RWD.Rotation.Y < 0 THEN Viper_RWD.Rotation.Y = Viper_RWD.Rotation.Y + TWO_Pi ELSE IF Viper_RWD.Rotation.Y > TWO_Pi THEN Viper_RWD.Rotation.Y = Viper_RWD.Rotation.Y - TWO_Pi
IF _KEYDOWN(18432) THEN '// Up
IF Viper_Pitch.Current < Viper_Pitch.Max THEN Viper_Pitch.Current = Viper_Pitch.Current + 1
ELSEIF _KEYDOWN(20480) THEN '// down
IF Viper_Pitch.Current > Viper_Pitch.Min THEN Viper_Pitch.Current = Viper_Pitch.Current - 1
ELSE '// Return to default
IF Viper_Pitch.Current < Viper_Pitch.Default THEN Viper_Pitch.Current = Viper_Pitch.Current + .5 ELSE IF Viper_Pitch.Current > Viper_Pitch.Default THEN Viper_Pitch.Current = Viper_Pitch.Current - .5
END IF
Viper_RWD.Rotation.X = Viper_Pitch.Current / RAD_TO_DEG_RATIO
IF _KEYDOWN(ASC("A")) OR _KEYDOWN(ASC("a")) THEN
IF Viper_RWD.Speed < 40 THEN Viper_RWD.Speed = Viper_RWD.Speed + .2
ELSEIF _KEYDOWN(ASC("Z")) OR _KEYDOWN(ASC("z")) THEN
IF Viper_RWD.Speed > 0 THEN Viper_RWD.Speed = Viper_RWD.Speed - .5 ELSE Viper_RWD.Speed = 0
END IF
GDK_RWD_Update Viper_RWD
LOOP UNTIL INKEY$ = CHR$(27)
SUB _GL
IF GDK_System.Render_Mode = GDK_GL_2D OR GDK_System.Render_Mode = GDK_GL_3D THEN
IF GDK_Allow_GL = GDK_TRUE THEN
GDK_GL_Init
IF GDK_System.GL.Lighting = GDK_FALSE THEN GDK_GL_Enable_Lighting
IF GDK_System.GL.Culling THEN GDK_GL_Disable_Culling
IF GDK_Init_GL = GDK_TRUE THEN
World~& = GDK_GL_Make_World_List~&
GDK_GL_MODEL_LOAD Viper, "Viper\tris.md2", "viper\skin.pcx"
GDK_Init_GL = GDK_FALSE
ELSE
GDK_GL_CLS
gluLookAt 0, 165, 120, 0, 0, 0, 0, 1, 0
_GLPUSHMATRIX
_GLLOADIDENTITY
_GLROTATEF -Viper_RWD.Rotation.Y * RAD_TO_DEG_RATIO, 0, 1, 0
_GLTRANSLATEF Viper_RWD.Position.X, Viper_RWD.Position.Y, Viper_RWD.Position.Z
_GLCALLLIST World~&
_GLPOPMATRIX
_GLPUSHMATRIX
_GLLOADIDENTITY
_GLTRANSLATEF 0, -65, -150
_GLROTATEF -90, 1, 0, 0
_GLROTATEF 90, 0, 0, 1
_GLROTATEF Viper_Pitch.Current, 0, 1, 0
_GLROTATEF Viper_Roll.Current, 1, 0, 0
GDK_GL_MODEL_DRAW Viper, 0
_GLPOPMATRIX
_DISPLAY
END IF
END IF
END IF
END SUB
FUNCTION GDK_GL_Make_World_List~&
goodmap% = GDK_GL_Terrain_Load(Terrain, "Hill_HMap.png", "Hill_Texture.png", 90, 3900)
Terrain.Position.Y = -4200 ' Adjust terrain base position
TList~& = GDK_GL_Terrain_Make_List(Terrain)
SkyList~& = GDK_GL_CreateSphereList(12000, 120, 120, GDK_GL_Load_Texture("Sky.png")) '// This is so cool, dont even have to load then pass the image!
TmpList~& = _GLGENLISTS(1)
_GLNEWLIST TmpList~&, _GL_COMPILE
_GLPUSHMATRIX
_GLTRANSLATEF 0, Terrain.Position.Y, 0
_GLCALLLIST TList~&
_GLPOPMATRIX
_GLPUSHMATRIX
_GLROTATEF 180, 1, 0, 0
_GLCALLLIST SkyList~&
_GLPOPMATRIX
_GLENDLIST '// Finihsed everything so stop making the lists
GDK_GL_Make_World_List~& = TmpList~&
END FUNCTION
REM $INCLUDE:'UnseenGDK3\New_GDK.bm' '// UnseenGDK 3 Lib file // change nothing but addint the pitch functionalaity
john