Any ideas on this code??
Blitz3D Forums/Blitz3D Programming/Any ideas on this code??
| ||
Hi, I have bought the package WorldSpin to create terrains etc, I have done a test terrain and exported it to BLitz but when I run it on my 30 day trial version of Blitz I get an error message saying illegal memory address?? Any ideas? Heres the code: ; ****************************** ; Sourcecode created with WorldSpin ; Last Change: 11 Mar 2004 00:51:45 ; ****************************** Graphics3D 800,600,16,1 ; ScreenResolution and ColorDepth SetBuffer BackBuffer() HidePointer Global Cam,dt#,DeltaT#,Terrain,Waterplane, Waterplane2,WaterMove,Cloudplane,Cloudplane2 Const CAM_TYPE=1 Type Entity ;Type to hold your objects/lights/sprites Field Entity_ID Field Entity_Name$ Field Entity_Type Field Spriteplane End Type Type Sprite ;Type to hold your spriteimages Field Holder End Type ; setup camera and fog Cam=CreateCamera() CameraRange Cam,1,4000 CameraFogMode Cam,1 CameraFogRange Cam,1000,3000 CameraClsColor Cam,0,144,211 CameraFogColor Cam,0,144,211 EntityType Cam,CAM_TYPE EntityRadius Cam,1.8 PositionEntity Cam,2304,312,1223 AmbientLight 255,255,255 CreateTerrainscape() CreateWaterplane() CreateCloudplane() ; ####### Main Loop ####### Repeat ;coding on time for equal FPS If dt=0 Then dt=MilliSecs() ;multiply all movements with DeltaT DeltaT=(MilliSecs()-dt)/1000 dt=MilliSecs() ;basicmovement If KeyDown(200)=True Then MoveEntity Cam,0,0,300*DeltaT ; Up If KeyDown(208)=True Then MoveEntity Cam,0,0,-300*DeltaT ; Down If KeyDown(205)=True Then MoveEntity Cam,300*DeltaT,0,0 ; Right (Sidestep) If KeyDown(203)=True Then MoveEntity Cam,-300*DeltaT,0,0 ; Left (Sidestep) If KeyDown(76)=True Then TurnEntity Cam,-EntityPitch#(Cam),0,-EntityRoll#(Cam) ; center look ; mouse look if right mousebutton is down If MouseDown(2)=True Mx#=Mx#*.9+MouseXSpeed() My#=My#*.9+MouseYSpeed() If Pressed=0 If Mx#>20 Then Mx#=20 If My#>20 Then My#=20 Pressed=1 EndIf MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 TurnEntity Cam,+(My#*2)*DeltaT,-(Mx#*2)*DeltaT,0 Roll#=EntityRoll#(Cam) If Roll#<>0 Then TurnEntity Cam,0,0,-Roll# ; Restriction looking up Pitch#=EntityPitch#(Cam) If Pitch#>50 Pitch#=Pitch#-50 TurnEntity Cam,-Pitch#*DeltaT,0,0 EndIf ; Restriction looking down If Pitch#<-75 Pitch#=Pitch#+75 TurnEntity Cam,-Pitch#*DeltaT,0,0 EndIf FlushMouse End If ; collision with the terrain X#=EntityX#(Cam) Y#=EntityY#(Cam) Z#=EntityZ#(Cam) Terra_Y#=TerrainY#(Terrain,X#,Y#,Z#)+40 PositionEntity Cam,X#,Terra_Y#,Z# ;Watermovement (basic circle movement) WaterMove=WaterMove+1 If WaterMove>=360 Then WaterMove=0 PositionEntity Waterplane,Sin(WaterMove)*40,150,Cos(WaterMove)*40 PositionEntity Waterplane2,Sin(Watermove)*40,150,Cos(WaterMove)*40 ; Cloudplanemovement MoveEntity Cloudplane,50*DeltaT,0,50*DeltaT MoveEntity Cloudplane2,100*DeltaT,0,100*DeltaT UpdateWorld() RenderWorld() ; insert any 2Dactions here Flip Until KeyHit(1)=True End Function CreateTerrainscape() ; setup terrain Terrain=LoadTerrain("C:\Program Files\Guildhall Leisure\Worldspin\Heightmaps\heightmap_256.bmp") ScaleEntity Terrain,20,400,20 TerrainDetail Terrain,2000,0 ; texture terrain Tmap=LoadTexture("C:\Program Files\Guildhall Leisure\Worldspin\Textures\dirt.jpg",9) ScaleTexture Tmap,20,20 TextureBlend Tmap,2 EntityTexture Terrain,Tmap,0,1 FreeTexture Tmap End Function Function CreateWaterplane() Wmap=LoadTexture("Textures\WATER.jpg",11) ScaleTexture Wmap,100,100 Waterplane=CreatePlane() EntityTexture Waterplane,Wmap EntityBlend Waterplane,1 EntityAlpha Waterplane,1.000000 PositionEntity Waterplane,0,150,0 Waterplane2=CopyEntity(Waterplane) PositionEntity Waterplane2,0,150,0 RotateEntity Waterplane2,0,0,180 FreeTexture Wmap End Function Function CreateCloudplane() Cmap=LoadTexture("C:\Program Files\Guildhall Leisure\Worldspin\Textures\cloud.bmp",3) ScaleTexture Cmap,2000,2000 Cloudplane=CreatePlane() EntityTexture Cloudplane,Cmap RotateEntity Cloudplane,0,0,180 EntityAlpha Cloudplane,0.900000 PositionEntity Cloudplane,0,1100,0 Cloudplane2=CreatePlane() EntityTexture Cloudplane2,Cmap RotateEntity Cloudplane2,0,0,180 EntityAlpha Cloudplane2,0.900000+0.2 PositionEntity Cloudplane2,1000,1100-90,500 FreeTexture Cmap End Function |
| ||
Can't see anything thats obviously wrong, other than you're using absolute paths to load textures and stuff. You really should use relative paths only, eg, put all your textures into the same folder as your .bb source, and just do stuff like:Cmap=LoadTexture("cloud.bmp",3) |
| ||
The program Worldspin creates this sorce code for you. Just wanted to see it demo so left the textures where they are for now but still doesnt work :( |
| ||
In that case, switch Debug on, and run it again. You'll likely get an error telling you that an image or texture or something doesn't exist... |
| ||
I just tried it - the code works - are you sure you are correctly pathing to the external files? |
| ||
oooops! Worldspin made an error for the texture waterplan!! :) Sorted thanks :)) |
| ||
I notice there's a few JPEG image files being called in that code. Last time I used the Blitz3D demo I think it only supported '.bmp' image files. You are probably using a more up to date version of the demo but, if not, then that would cause the problem you're describing. |
| ||
I used WorldSpin before moving on to Quill 3D, which is a much better world editor. If you 'export as code' in WorldSpin, you will find errors in the syntax. I always found errors in the .DATA statements. The bottom line is that it's not Blitz3D, it's the code generated by Worldspin. Regards, Rogue Vector |