I first compiled this code in DBP, worked fine of course. After the release of the GDK for C++, i successfully converted it...also worked fine. Recently i bought the DarkGDK.NET because i'm more familiar with Visual Basic and C++ was giving me headaches (Please lets not get into the old C++ is better than VB discussion again). Well for some reason, this code after I rewrote the basic parts for vb isn't working, though it's nearly identical as far as i know. The skysphere is there, the fighter even banks left and right as it should (kind of sharp though, in C++ and DBP is was more gradual.)
Problem is, up/down/left/right don't seem to be doing anything. The fighter just sits there with no movement, where it should move around the skybox and be followed by the cam as it was in C++ and DBP. It looks like i converted everything right, and i'm not getting any errors at all. I'm posting both my C++ code, and vb.net code so you can see the comparisons. I'm using VB.NET 2008 Express Edition.
VB.NET CODE
Sub Main()
REM set up display
oDBCamera.AutoCamOff()
oDBInput.HideMouse()
oDBCore.SyncOn()
oDBCore.SyncRate(60)
REM load map
oDBCamera.SetCameraRange(2.5, 50000)
oDB3D.LoadObject("cielo.x", 666)
oDB3D.SetObjectTexture(666, 2, 1)
oDB3D.SetObjectCull(666, 0)
oDB3D.YRotateObject(666, 270)
oDB3D.ScaleObject(666, 95000, 95000, 95000)
oDB3D.SetObjectCollisionOff(666)
oDBLight.SetAmbientLight(1)
oDBLight.MakeLight(1)
oDBLight.PositionLight(1, 0, 0, 0)
oDBLight.ColorLight(1, 255)
oDBLight.SetLightRange(1, 600000)
oDBLight.MakeLight(2)
oDBLight.PositionLight(2, 40000, 0, 40000)
oDBLight.ColorLight(2, 255)
oDBLight.SetLightRange(2, 300000)
oDBLight.MakeLight(3)
oDBLight.ColorLight(3, 255)
oDBLight.SetLightRange(3, 10000)
oDBLight.SetNormalizationOn()
REM set speed
Dim speed As Integer
Dim speed_max As Integer
Dim speed_min As Integer
Dim speed_chg As Integer
Dim plyr_bank As Integer
Dim plyr_turn As Integer
Dim plyr_tilt As Integer
speed = 0
speed_max = 10
speed_min = 0
speed_chg = 0.1
plyr_bank = 0
plyr_turn = 0
plyr_tilt = 0
REM create player cone
oDB3D.MakeObjectCone(10, 25)
oDB3D.PositionObject(10, 50000, 10000, 50000)
oDB3D.XRotateObject(10, 90)
oDB3D.FixObjectPivot(10)
oDB3D.HideObject(10)
REM create player
oDB3D.LoadObject("fighter1.3ds", 15)
oDBImage.LoadImage("cinfa.jpg", 15)
oDB3D.TextureObject(15, 15)
oDB3D.XRotateObject(15, -90)
oDB3D.ScaleObject(15, 400, 400, 400)
oDB3D.GlueObjectToLimb(15, 10, 0)
oDBImage.LoadImage("spheremap.jpg", 16)
oDB3D.SetSphereMappingOn(15, 16)
Dim px As Integer
Dim py As Integer
Dim pz As Integer
While oDBP.LoopGDK()
REM get position
px = oDB3D.ObjectPositionX(10)
py = oDB3D.ObjectPositionY(10)
pz = oDB3D.ObjectPositionZ(10)
REM adjust speed
If oDBInput.ShiftKey() = 1 Then speed = speed + 0.01
If oDBInput.ControlKey() = 1 Then speed = speed - 0.01
If speed > speed_max Then speed = speed_max
If speed < speed_min Then speed = speed_min
oDB3D.MoveObject(10, speed)
REM left/right
If oDBInput.LeftKey() = 1 Then plyr_turn = oDBCore.CurveValue(-2, plyr_turn, 10)
If oDBInput.RightKey() = 1 Then plyr_turn = oDBCore.CurveValue(2, plyr_turn, 10)
If oDBInput.LeftKey() = 0 And oDBInput.RightKey() = 0 Then plyr_turn = oDBCore.CurveValue(0, plyr_turn, 10)
oDB3D.YRotateObject(10, oDBCore.WrapValue(oDB3D.ObjectAngleY(10) + plyr_turn))
REM update/down
If oDBInput.UpKey() = 1 Then plyr_tilt = oDBCore.CurveValue(1, plyr_tilt, 20)
If oDBInput.DownKey() = 1 Then plyr_tilt = oDBCore.CurveValue(-1, plyr_tilt, 20)
If oDBInput.UpKey() = 0 And oDBInput.DownKey() = 0 Then plyr_tilt = oDBCore.CurveValue(0, plyr_tilt, 10)
oDB3D.XRotateObject(10, oDBCore.WrapValue(oDB3D.ObjectAngleX(10) + plyr_tilt))
REM smooth banking
If oDBInput.LeftKey() = 1 Then plyr_bank = oDBCore.CurveValue(50, plyr_bank, 25)
If oDBInput.RightKey() = 1 Then plyr_bank = oDBCore.CurveValue(-50, plyr_bank, 25)
If oDBInput.LeftKey() = 0 And oDBInput.RightKey() = 0 Then plyr_bank = oDBCore.CurveValue(0, plyr_turn, 25)
oDB3D.YRotateObject(15, plyr_bank)
REM Set camera
oDBCamera.SetCameraToObjectOrientation(10)
oDBCamera.PositionCamera(px, py + 50, pz)
oDBCamera.MoveCamera(-100)
REM positin skybox
oDB3D.PositionObject(666, oDBCamera.CameraPositionX(), oDBCamera.CameraPositionY(), oDBCamera.CameraPositionZ())
oDBCore.Sync()
End While
End Sub
C++ Code
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbAutoCamOff ();
dbHideMouse ();
dbBackdropOn ();
//setup map
dbSetCameraRange (2.5,50000);
dbLoadObject ("sky/cielo.x",666);
//dbPositionObject (666,256,30,0);
dbSetObjectTexture (666,2,1);
dbSetObjectLight (666,0);
dbSetObjectCull (666,0);
dbYRotateObject (666,270);
dbScaleObject (666,95000,95000,95000);
dbSetObjectCollisionOff (666);
dbSetAmbientLight (1);
dbMakeLight (1);
dbPositionLight (1,0,0,0);
dbColorLight (1,255,0,0);
dbSetLightRange (1,600000);
dbMakeLight (2);
dbPositionLight (2,40000,0,40000);
dbColorLight (2,255,255,255);
dbSetLightRange (2,300000);
dbMakeLight (3);
dbColorLight (3,255,255,255);
dbSetLightRange (3,10000);
dbSetNormalizationOn ();
//variables
float px = 0;//initialize to Zero - just good habit.
float py = 0;
float pz = 0;
float camx=0;
float camy=0;
float camz=0;
int speed = 0;
int speedmax = 0;
int speedmin = 0;
int speedchg = 0;
//Make Player
dbMakeObjectCone (10,25);
dbPositionObject (10,50000,10000,50000);
dbXRotateObject (10,90);
dbFixObjectPivot (10);
dbHideObject (10);
dbLoadObject ("player/fighter1.3ds",15);
dbLoadImage ("player/cinfa.jpg", 15);
//dbMakeObjectCube(15,5);
dbXRotateObject (15,-90);
dbScaleObject (15,400,400,400);
dbScaleObject (15,400,400,400);
dbGlueObjectToLimb (15, 10, 0);
dbTextureObject (15, 15);
dbLoadImage ("player/spheremap.jpg",15);
dbSetSphereMappingOn (15,15);
//test object
dbMakeObjectCube(16,10);
dbPositionObject(16,50000,10050,50000);
//setup speed
speed = 0;
speedmax = 30;
speedmin = 0;
speedchg = 1;
float plyr_bank = 0;
float plyr_turn = 0;
float plyr_tilt = 0;
int up=0;
int dbUpKey();
// our main loop
while ( LoopGDK ( ) )
{
px = dbObjectPositionX (15);
py = dbObjectPositionY (15);
pz = dbObjectPositionZ (15);
up=dbUpKey();
//control speed
if (dbControlKey( )) speed=speed-1;
if (dbShiftKey( )) speed=speed+1;
if (speed > speedmax) speed = speedmax;
if (speed < speedmin) speed = speedmin;
dbMoveObject (10, speed);
//Navigation
if (dbUpKey( )) {plyr_tilt = dbCurveValue(1, plyr_tilt, 20);}else{plyr_tilt = dbCurveValue(0, plyr_tilt, 20);}
if (dbDownKey( )) {plyr_tilt = dbCurveValue(-1, plyr_tilt, 20);}else{plyr_tilt = dbCurveValue(0, plyr_tilt, 20);}
dbXRotateObject (10,dbWrapValue(dbObjectAngleX(10)+plyr_tilt));
if (dbLeftKey( )) {plyr_turn = dbCurveValue(-2, plyr_turn, 10);}else{plyr_turn = dbCurveValue(0, plyr_turn, 10);}
if (dbRightKey( )) {plyr_turn = dbCurveValue(2, plyr_turn, 10);}else{plyr_turn = dbCurveValue(0, plyr_turn, 10);}
dbYRotateObject (10, dbWrapValue(dbObjectAngleY(10)+plyr_turn));
if (dbLeftKey( )){plyr_bank = dbCurveValue(50, plyr_bank, 25);}else{plyr_bank = dbCurveValue(0, plyr_bank, 25);}
if (dbRightKey( )){plyr_bank = dbCurveValue(-50, plyr_bank, 25);}else{plyr_bank = dbCurveValue(0, plyr_bank, 25);}
dbYRotateObject (15,plyr_bank);
//set camera
camx=dbCameraPositionX();
camy=dbCameraPositionY();
camz=dbCameraPositionZ();
dbSetCameraToObjectOrientation (10);
dbPositionCamera (px, py+50, pz);
dbMoveCamera (-100);
//skybox position
dbPositionObject (666,camx, camy, camz);
dbSync ( );
}
return;
}