GLBasic forum

Codesnippets => 3D-snippets => Topic started by: matty47 on 2023-Apr-10

Title: Location of 3d model files
Post by: matty47 on 2023-Apr-10
Just getting back into GLBasic after a long hiatus. I wrote some 3d testing code a long time ago (looks like 2007). When I recompile these programs with V15.238 it seems that the .dd models are not being found. I tried adding GetCurrentPath$ to the file name and made sure that the files were in the executable directory but no luck. I also tried loading from a media directory but still no luck.
This is the code. I recently added the GetCurrentDir$ when the original would not work.
Code (glbasic) Select
// --------------------------------- //
// Project: 3dtry
// Start: Monday, September 10, 2007
// IDE Version: 4.279


LOADSPRITE GETCURRENTDIR$()+"floor.png", 0

X_LOADOBJ GETCURRENTDIR$()+"floor1.dda", 0

cam_x =0;cam_y=0.5;cam_z=1.5 //camera postion
cam_dir=0  //camera direction
player_x=0;player_y=0;player_z=0
sz=2 //camera step size
WHILE TRUE
dtime=GETTIMER()
//IF INKEY$="Q" THEN END

X_MAKE3D 0.1,500,60
//X_CULLMODE 0
X_CAMERA cam_x,cam_y,cam_z,cam_x+COS(cam_dir)*sz,cam_y,cam_z+SIN(cam_dir)*sz
X_AMBIENT_LT 0, RGB(200,200,200)
X_SPOT_LT 0,RGB(255,255,255),0,40,0,0,-1,0,100
X_MOVEMENT player_x,player_y,Player_z
//X_SCALING 2,0.25,2
X_SETTEXTURE 0,-1
X_DRAWOBJ 0,0
X_DRAWAXES 0,0,0
X_DOT 2,0,0,10,RGB(255,0,0)
X_DOT 0,0,2,10,RGB(0,0,255)
MoveCam()
//X_3rd_Person(Player_x,Player_y,Player_z,10,1)
//player_x=player_x-0.05
X_MAKE2D
//show the frames per second
fps=((1000/dtime)+fps)/2
delay=delay+dtime
IF delay>1000
delay=0
showFPS=fps
ENDIF
PRINT "FPS: "+INTEGER(showFPS)+"  CamY= "+height,0,0
SHOWSCREEN
WEND







FUNCTION  X_3rd_Person: Player_x, Player_y, Player_z, Max_Cam_dist, Min_Cam_Dist
   IF ein_durchlauf = FALSE
      Distance = Max_Cam_dist
      my = 45
      ein_durchlauf = TRUE
   ENDIF


   X_CAMERA cam_x+Player_x, cam_y+Player_y, cam_z+Player_z,    Player_x, Player_y, Player_z



   INC Distance,MOUSEAXIS(2)*5
   IF Distance < Min_Cam_Dist THEN Distance = Min_Cam_Dist
   IF Distance > Max_Cam_dist THEN Distance = Max_Cam_dist

   mx = mx + MOUSEAXIS(0)/20
   my = my + MOUSEAXIS(1)/20

   IF my < -40 THEN my = -40
   IF my > 80 THEN my = 80

   cam_x = Distance * COS(mx)
   cam_z = Distance * SIN(mx)
   cam_y = Distance * SIN(my)
ENDFUNCTION


FUNCTION MoveCam:
mx=MOUSEAXIS(0)*dtime/5
my=0

IF KEY(200) THEN my=0.06*dtime
IF KEY(208) THEN my=-0.06*dtime
cam_x=cam_x + my*COS(cam_dir)*sz*dtime/500
cam_z=cam_z + my*SIN(cam_dir)*sz*dtime/500

height=X_COLLISIONRAY(0,0,cam_x,cam_y,cam_z,0,-1,0)
cam_y=cam_y+0.5-height
cam_dir=cam_dir+mx*dtime/600
ENDFUNCTION

Any ideas? It would have been great if the X_LoadObj returned something that indicated success or not. The help file does not indicate any return value.
Thanks for any pointers.
Title: Re: Location of 3d model files
Post by: Qedo on 2023-Apr-11
I'm not a big 3d expert but probably the object is behind the camera
try
cam_z=-1.5