dolphin.bb 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ;Blend Meshes
  2. ;Concept and models from directX7 SDK.
  3. ;Converted to Blitz3D by
  4. ;David Bird
  5. ;[email protected]
  6. Graphics3D 640,480
  7. SetBuffer BackBuffer()
  8. lit=CreateLight()
  9. LightColor lit,50,50,170
  10. AmbientLight 51,51,51
  11. piv=CreatePivot()
  12. cam=CreateCamera()
  13. CameraRange cam,1,2000
  14. CameraClsColor cam,0,102,136
  15. CameraFogColor cam,0,102,136
  16. CameraFogMode cam,1
  17. CameraFogRange cam,1,50
  18. PositionEntity cam,0,4,-30
  19. ; LOAD DOLPHIN INFORMATION HERE
  20. ; All triangles and vertices MUST be the same
  21. ; for this to work.
  22. upmesh=LoadMesh("dup.x"):HideEntity upmesh ;load mesh back fin uppermost
  23. md=LoadMesh("dolphin.x"):HideEntity md;load mesh for middle
  24. dnmesh=LoadMesh("ddown.x"):HideEntity dnmesh ;load mesh back fin lowermost
  25. final=LoadMesh("dolphin.x")
  26. ScaleMesh upmesh,.01,.01,.01
  27. ScaleMesh md,.01,.01,.01
  28. ScaleMesh dnmesh,.01,.01,.01
  29. seafloor=LoadMesh("seafloor.x")
  30. While Not KeyDown(1)
  31. TurnEntity final,0,1,0:MoveEntity final,-.2,0,0
  32. PointEntity cam,final
  33. If KeyDown(203) TurnEntity cam,0,+1,0
  34. If KeyDown(205) TurnEntity cam,0,-1,0
  35. If KeyDown(200) TurnEntity cam,+1,0,0
  36. If KeyDown(208) TurnEntity cam,-1,0,0
  37. If KeyDown(44) MoveEntity cam,0,0,-10
  38. If KeyDown(30) MoveEntity cam,0,0,10
  39. q#=Sin(p)
  40. p=(p+4) Mod 360
  41. If q<0 Then
  42. Blend_meshes(final,dnmesh,md,-q#)
  43. Else
  44. Blend_meshes(final,upmesh,md,q#)
  45. End If
  46. TranslateEntity final,0,Sin(-q),0
  47. UpdateWorld
  48. RenderWorld
  49. Flip
  50. Wend
  51. FreeEntity upmesh
  52. FreeEntity dnmesh
  53. FreeEntity final
  54. FreeEntity lit
  55. FreeEntity piv
  56. FreeEntity cam
  57. EndGraphics
  58. End
  59. Function Blend_Meshes(dst,sc1,sc2,w#)
  60. iw#=1-w
  61. sc1s=GetSurface(sc1,CountSurfaces(sc1))
  62. sc2s=GetSurface(sc2,CountSurfaces(sc2))
  63. dsts=GetSurface(dst,CountSurfaces(dst))
  64. For a=0 To CountVertices(sc1s)-1
  65. x# = w*VertexX(sc1s,a) + iw*VertexX(sc2s,a)
  66. y# = w*VertexY(sc1s,a) + iw*VertexY(sc2s,a)
  67. z# = w*VertexZ(sc1s,a) + iw*VertexZ(sc2s,a)
  68. nx# = w*VertexNX(sc1s,a) + iw*VertexNX(sc2s,a)
  69. nx# = w*VertexNY(sc1s,a) + iw*VertexNY(sc2s,a)
  70. nx# = w*VertexNZ(sc1s,a) + iw*VertexNZ(sc2s,a)
  71. VertexCoords dsts,a,x,y,z
  72. VertexNormal dsts,a,nx,ny,nz
  73. Next
  74. End Function