Hi all,
I follow the 3d tutorial -Tutorial 3- battle003. (The following media files also come from that tutorial)
My test files could be downloaded here!
Questions:
-------------
1. When I run the program, I STILL could pass through wall of house, even I have set the collisons command.
(Collisions PLAYER, PROPS, 2,1). Why? (I tried to run the sample program provided and still could pass through wall!!!)
2. According to the tutorial,
terra_y# = TerrainY(terrain,x#,y#,z#)+1.6
PositionEntity camera_pivot,x#,terra_y#,z#
MUST be after "UpdateWorld" command.
However, according to B3d Manual, "UpdateWorld" is used for collision checking.
So, I tried to move these 2 statements before "UpdateWorld" command as follows:
Ok. I could be blocked by the wall of house this time!! However, my starting position was changed too! Why?
(New position: x= 0, y=6.5, z=2.38.
It should have been: x= 10, y=5.6, z=120
because "PositionEntity camera_pivot,10,5.6,120")
I am using update v.191. Any ideas?
Thanks in advance
Sammy
:)
I follow the 3d tutorial -Tutorial 3- battle003. (The following media files also come from that tutorial)
My test files could be downloaded here!
;graphics Graphics3D 800,600 SetBuffer BackBuffer() ;globals Global floor1, nacar Global x#,y#,z#,terra_y# Global kit, ttShoppe ;collision groups Global SCENERY = 1 Global PLAYER = 2 Global PROPS = 4 Global CARPET = 5 ;light Global light = CreateLight() RotateEntity light,90,0,90 ;camera pivot camera_pivot = CreatePivot() EntityRadius camera_pivot,1.4 EntityType camera_pivot, PLAYER ;camera Global camera = CreateCamera(camera_pivot) CameraRange camera,1,10000 CameraFogMode camera,1 CameraFogRange camera,60,200 ;sky Global sky = CreateSphere(16,camera_pivot) FlipMesh sky ScaleEntity sky,100,100,100 PositionEntity sky,0,50,0 sky_tex = LoadTexture("sky.bmp") EntityTexture sky,sky_tex ;terrain Global terrain = LoadTerrain("height2.jpg") TerrainDetail terrain,2500,True ScaleEntity terrain,3,15,3 PositionEntity terrain,-1000,0,-530 ter_tex = LoadTexture("mossyground.bmp") EntityTexture terrain, ter_tex EntityRadius terrain,0.2 EntityType terrain, SCENERY ; Weapon Global weapon2 = LoadMesh("gloc.3ds",camera_pivot) weapon_tex2 = LoadTexture("glocmap.jpg") EntityTexture weapon2,weapon_tex2 RotateEntity weapon2,12,170,14 ScaleEntity weapon2,0.01,0.01,0.01 PositionEntity weapon2,0.01,0.01,0.01 PositionEntity weapon2,1,-1,1.5 EntityOrder weapon2,-1 ; a floor cube_tile = LoadTexture("Floor.jpg") floor1 = CreateCube() ScaleEntity floor1,8,0.06,13 ScaleTexture cube_tile,.5,.5 EntityTexture floor1,cube_tile EntityType floor1,CARPET EntityRadius floor1,.4 PositionEntity floor1,10,6,120 ; More floors floor2 = CopyEntity(floor1) floor3 = CopyEntity(floor1) floor4 = CopyEntity(floor1) PositionEntity floor2,-100,6,120 PositionEntity floor3,100,6,120 PositionEntity floor4,0,6,0 ; kitchen kit = LoadMesh("weapshop.3ds") kit_tex = LoadTexture("kitchen.jpg") EntityTexture kit,kit_tex EntityType kit,PROPS EntityRadius kit,1.10 PositionEntity kit,10,6.5,128 ScaleEntity kit,0.08,0.08,0.08 ; other stuff ttShoppe = LoadMesh("shop.3ds") PositionEntity ttShoppe, 10,6.5,112 RotateEntity ttShoppe, 0,180,0 ScaleEntity ttShoppe, 0.08,0.08,0.08 ttShoppe_tex = LoadTexture("ttshop.jpg") EntityTexture ttShoppe, ttshoppe_tex EntityType ttShoppe,PROPS EntityRadius ttShoppe,1.10 nacar = LoadMesh("pearlank.b3d") nacar_tex = LoadTexture("eggo2.jpg",67) EntityTexture nacar,nacar_tex PositionEntity nacar ,10,6.4,120 ScaleEntity nacar,0.005,0.005,0.005 EntityType nacar,PROPS EntityRadius nacar,1 ;position the cammera PositionEntity camera_pivot,10,5.6,120 ;collision handling Collisions CARPET, SCENERY,2,1 Collisions PLAYER, PROPS, 2,1 ;main loop While Not KeyHit(1) If KeyDown(200) MoveEntity camera_pivot, 0,0,0.2 If KeyDown(208) MoveEntity camera_pivot, 0,0,-.2 If KeyDown(203) TurnEntity camera_pivot, 0,2,0 If KeyDown(205) TurnEntity camera_pivot, 0,-2,0 x# = EntityX(camera_pivot) y# = EntityY(camera_pivot) z# = EntityZ(camera_pivot) touchGround(floor1) touchGround(floor2) touchGround(floor3) touchGround(floor4) TurnEntity nacar,0.5,0.5,0 UpdateWorld terra_y# = TerrainY(terrain,x#,y#,z#)+1.6 PositionEntity camera_pivot,x#,terra_y#,z# RenderWorld Text 10,10, "X= "+x# Text 10,25, "Y= "+y# Text 10,40, "Z= "+z# Flip Wend Function touchGround(n$) If Not EntityCollided(n$,SCENERY) PositionEntity(n$, EntityX(n$), EntityY(n$) -0.01, EntityZ(n$)) EndIf End Function End
Questions:
-------------
1. When I run the program, I STILL could pass through wall of house, even I have set the collisons command.
(Collisions PLAYER, PROPS, 2,1). Why? (I tried to run the sample program provided and still could pass through wall!!!)
2. According to the tutorial,
terra_y# = TerrainY(terrain,x#,y#,z#)+1.6
PositionEntity camera_pivot,x#,terra_y#,z#
MUST be after "UpdateWorld" command.
However, according to B3d Manual, "UpdateWorld" is used for collision checking.
So, I tried to move these 2 statements before "UpdateWorld" command as follows:
;graphics Graphics3D 800,600 SetBuffer BackBuffer() ;globals Global floor1, nacar Global x#,y#,z#,terra_y# Global kit, ttShoppe ;collision groups Global SCENERY = 1 Global PLAYER = 2 Global PROPS = 4 Global CARPET = 5 ;light Global light = CreateLight() RotateEntity light,90,0,90 ;camera pivot camera_pivot = CreatePivot() EntityRadius camera_pivot,1.4 EntityType camera_pivot, PLAYER ;camera Global camera = CreateCamera(camera_pivot) CameraRange camera,1,10000 CameraFogMode camera,1 CameraFogRange camera,60,200 ;sky Global sky = CreateSphere(16,camera_pivot) FlipMesh sky ScaleEntity sky,100,100,100 PositionEntity sky,0,50,0 sky_tex = LoadTexture("sky.bmp") EntityTexture sky,sky_tex ;terrain Global terrain = LoadTerrain("height2.jpg") TerrainDetail terrain,2500,True ScaleEntity terrain,3,15,3 PositionEntity terrain,-1000,0,-530 ter_tex = LoadTexture("mossyground.bmp") EntityTexture terrain, ter_tex EntityRadius terrain,0.2 EntityType terrain, SCENERY ; Weapon Global weapon2 = LoadMesh("gloc.3ds",camera_pivot) weapon_tex2 = LoadTexture("glocmap.jpg") EntityTexture weapon2,weapon_tex2 RotateEntity weapon2,12,170,14 ScaleEntity weapon2,0.01,0.01,0.01 PositionEntity weapon2,0.01,0.01,0.01 PositionEntity weapon2,1,-1,1.5 EntityOrder weapon2,-1 ; a floor cube_tile = LoadTexture("Floor.jpg") floor1 = CreateCube() ScaleEntity floor1,8,0.06,13 ScaleTexture cube_tile,.5,.5 EntityTexture floor1,cube_tile EntityType floor1,CARPET EntityRadius floor1,.4 PositionEntity floor1,10,6,120 ; More floors floor2 = CopyEntity(floor1) floor3 = CopyEntity(floor1) floor4 = CopyEntity(floor1) PositionEntity floor2,-100,6,120 PositionEntity floor3,100,6,120 PositionEntity floor4,0,6,0 ; kitchen kit = LoadMesh("weapshop.3ds") kit_tex = LoadTexture("kitchen.jpg") EntityTexture kit,kit_tex EntityType kit,PROPS EntityRadius kit,1.10 PositionEntity kit,10,6.5,128 ScaleEntity kit,0.08,0.08,0.08 ; other stuff ttShoppe = LoadMesh("shop.3ds") PositionEntity ttShoppe, 10,6.5,112 RotateEntity ttShoppe, 0,180,0 ScaleEntity ttShoppe, 0.08,0.08,0.08 ttShoppe_tex = LoadTexture("ttshop.jpg") EntityTexture ttShoppe, ttshoppe_tex EntityType ttShoppe,PROPS EntityRadius ttShoppe,1.10 nacar = LoadMesh("pearlank.b3d") nacar_tex = LoadTexture("eggo2.jpg",67) EntityTexture nacar,nacar_tex PositionEntity nacar ,10,6.4,120 ScaleEntity nacar,0.005,0.005,0.005 EntityType nacar,PROPS EntityRadius nacar,1 ;position the cammera PositionEntity camera_pivot,10,5.6,120 ;collision handling Collisions CARPET, SCENERY,2,1 Collisions PLAYER, PROPS, 2,1 ;main loop While Not KeyHit(1) If KeyDown(200) MoveEntity camera_pivot, 0,0,0.2 If KeyDown(208) MoveEntity camera_pivot, 0,0,-.2 If KeyDown(203) TurnEntity camera_pivot, 0,2,0 If KeyDown(205) TurnEntity camera_pivot, 0,-2,0 x# = EntityX(camera_pivot) y# = EntityY(camera_pivot) z# = EntityZ(camera_pivot) terra_y# = TerrainY(terrain,x#,y#,z#)+1.6 PositionEntity camera_pivot,x#,terra_y#,z# touchGround(floor1) touchGround(floor2) touchGround(floor3) touchGround(floor4) TurnEntity nacar,0.5,0.5,0 UpdateWorld RenderWorld Text 10,10, "X= "+x# Text 10,25, "Y= "+y# Text 10,40, "Z= "+z# Flip Wend Function touchGround(n$) If Not EntityCollided(n$,SCENERY) PositionEntity(n$, EntityX(n$), EntityY(n$) -0.01, EntityZ(n$)) EndIf End Function End
Ok. I could be blocked by the wall of house this time!! However, my starting position was changed too! Why?
(New position: x= 0, y=6.5, z=2.38.
It should have been: x= 10, y=5.6, z=120
because "PositionEntity camera_pivot,10,5.6,120")
I am using update v.191. Any ideas?
Thanks in advance
Sammy
:)