Can't load objects
Blitz3D Forums/Blitz3D Programming/Can't load objects
| ||
Hi people. I am having a major problem here in getting my file requester to work. When I run the code and press L to load an object I get the error "Variable must be a type" for some reason. It highlights the code: If KeyDown(200) Then MoveEntity m\entity,0,0,.1 As being the offending code. For some reason though. I can't figure this one out its driving me insane :( So the thing is, it shouldn't be flagging me an error to begin with as I haven't even had the chance to load a file for it to check in the first place :( Here is my code. I would be very grateful if someone can help me out here. Graphics3D 800,600 SetBuffer BackBuffer() ;file requester code Include "bin\file_request.bb" Global file_path$="C:\" ;file$ = getopenfile$("Select file...",file_path$,"3DS file"+Chr(0)+"*.3ds"+Chr(0)+"Blitz 3D file"+Chr(0)+"*.b3d"+Chr(0)) Global L_KEY = 38 Global M_KEY = 50 Global W_KEY = 17 Global FULL_SCREEN_KEY = 33 Global view_x = 0;150 Global view_y = 0;100 Global view_width = 500 Global view_height = 300 Global FULL_SCREEN = 0 ;Used to resize the window Global MOVE = 0 ;Used to control the movement of objects Global WIRE = 0 ;Used to toggle wireframe mode on/off Global cam = CreateCamera() PositionEntity cam,0,2,-4 AmbientLight 175,175,175 Global light = CreateLight(1) Global plane = CreatePlane() ;file$= getopenfile$("Please select a texture for the grid..","file_path$","Bitmap"+Chr(0)+"*.bmp"+Chr(0)+"Jpeg"+Chr(0)+"*.jpg"+Chr(0)+"PNG"+Chr(0)+"*.png"+Chr(0)+"All"+Chr(0)+"*"+Chr(0)) plane_tex = LoadTexture("textures/plane_tex.png") EntityTexture plane,plane_tex ;Global ball = CreateSphere() ;PositionEntity ball,0,MeshHeight(ball)/2,0 Global bg = LoadImage("img\bg.png") Global font = LoadFont("georgia.tff",18,1) SetFont font ;Types Type mesh Field entity Field x# Field y# Field z# End Type ClsColor 150,180,255 While Not KeyHit(1) Cls DrawImage bg,0,0 WireFrame WIRE ;TurnEntity cam,0,.2,0 If KeyHit(L_KEY) Then load_object If KeyHit(M_KEY) Then MOVE = 1-MOVE If KeyHit(W_KEY) Then WIRE = 1-WIRE If KeyHit(FULL_SCREEN_KEY) Then FULL_SCREEN = 1-FULL_SCREEN check_move UpdateWorld RenderWorld Rect view_x,view_y,view_width,view_height,0 resize_view Flip Wend End Function trim_file_path(file$) For loop = Len(file$) To 1 Step - 1 If Mid$(file$,loop,1) = "\" And flag = 0 Then flag = 1 length = loop End If Next If flag = 1 Then file_path = Mid$(file,1,length) End If Return file End Function Function load_object() file$ = getopenfile$("Select file...",file_path$,"3DS file"+Chr(0)+"*.3ds"+Chr(0)+"Blitz 3D file"+Chr(0)+"*.b3d"+Chr(0)) If file$<>0 m.mesh = New mesh m\entity = LoadMesh(file$) m\x = 0 m\y = 0 m\z = 0 FitMesh m\entity,m\x,m\y,m\z,0.9,0.9,0.9 PositionEntity m\entity,m\x,m\y,m\z EndIf End Function Function resize_view() If FULL_SCREEN = 1 view_x = 0 view_y = 15 view_width = 800 view_height = 550 Text view_x+1,view_y+1,"Kitchen Designer" Text 0,565,"L - Load Object" Text 0,585,"F - Normal Screen" If MOVE<>0 Color 0,255,50 Else Color 255,255,255 EndIf Text 200,565,"M - Move Mode" Color 255,255,255 If WIRE<>0 Color 255,50,0 Else Color 255,255,255 EndIf Text 200,585,"W - Wireframe On/Off" Color 255,255,255 Text 400,565,"ESC - Exit" ElseIf FULL_SCREEN = 0 view_x = 0;150 view_y = 0;100 view_width = 500 view_height = 300 Text view_x+1,view_y+1,"Kitchen Designer" Text view_x,view_y+305,"L - Load Object" Text view_x,view_y+325,"F - Full Screen" If MOVE<>0 Color 0,255,50 Else Color 255,255,255 EndIf Text view_x,view_y+345,"M - Move Mode" Color 255,255,255 If WIRE<>0 Color 255,50,0 Else Color 255,255,255 EndIf Text view_x,view_y+365,"W - Wireframe On/Off" Color 255,255,255 Text view_x,view_y+385,"ESC - Exit" EndIf CameraViewport cam,view_x,view_y,view_width,view_height End Function Function check_move() If MOVE <> 0 If KeyDown(200) Then MoveEntity m\entity,0,0,.1 If KeyDown(208) Then MoveEntity m\entity,0,0,-.1 If KeyDown(205) Then MoveEntity m\entity,.1,0,0 If KeyDown(203) Then MoveEntity m\entity,-.1,0,0 EndIf End Function Thanks for any help guys :) Ash |
| ||
In your check_move() function the 'm' does not exist yet. You have to pass the type directly to the function like this "function check_move(m.mesh)", alternatively you have to make the type instance holding your entity global. |
| ||
Hi Matty :) Thanks a million. That sorted out the problem :) Now i'm presented with a new problem. When I press L to load an object, I get the error message, "Entity does not exist" and it highlights: FitMesh m\entity,m\x,m\y,m\z,0.9,0.9,0.9 As being the offending code. Any ideas? Thanks again for your help. Very much appriciated :) Ash |
| ||
Hmmm. Actually, its quite difficult to fully explain my problem so I have included a link to a zip file below. This contains everything for the code to run. Just make sure to have either a 3ds or B3d object to test it out :) Here is the file: EDIT: Sorry I am having a problem with getting a link to my file :( I have this code enclosed in the [a] and [/a] but the link doesn't seem to work even though I know the location to the file is correct :( I'll see if I can fix it somehow. The code in [a] and [/a] http://www.ashleymoore.streamlinenettrial.co.uk/htdocs/zips/kitchen.rar Ash |
| ||
Page not found. |