Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. local kbVec3 = require 'vec3'
  2. local kbAnim = require 'anim'
  3.  
  4. local kbModel = require 'widget.model'
  5. local kbSkybox = require 'widget.skybox'
  6. local kbWidget = require 'widget'
  7. local kbCamera = require 'widget.camera'
  8. local kbScreen = require 'screen'
  9. local kbEvent = require 'event'
  10. local kbAnim = require 'anim'
  11.  
  12. local wStartingCamera = nil --widget.camera#camera
  13.  
  14. -- Set an Optional Starting Camera Position
  15. local wStartingCameraPosition = kbVec3(0, 0, -0.808414)
  16. local wStartingCameraRotation = kbVec3(0, 0, 0.00)
  17.  
  18. local wModelFilenames =
  19. {
  20. 'models/test_mock/left-sidebar.iqm'
  21. -- ,'models/jeep_grand_cherokee/jeep-low.iqm'
  22. } --#list<string>
  23.  
  24. local wModelScales =
  25. {
  26. kbVec3(1, 1, 1)
  27. -- ,kbVec3(0.1, 0.1, 0.1)
  28. } --#list<vec3#vec3>
  29.  
  30. local wModelRotations =
  31. {
  32. kbVec3(0, 0, 0)
  33. -- ,kbVec3(0, 180, 0)
  34. } --#list<vec3#vec3>
  35.  
  36. local wModelPositions =
  37. {
  38. kbVec3(0.0, 0.0, 0.0)
  39. -- ,kbVec3( 0.0, 0.0, 0.0 )
  40. } --#list<vec3#vec3>
  41.  
  42. local wModels = {} --#list<widget.model#model>
  43. wModels.model = nil --widget.model#model
  44. wModels.model_animation_count = nil --#number
  45.  
  46. local function PlayAnimation(nIndex, bLoop)
  47. -- Get Animation Name
  48. local strAnimationName = wModels.model:get_animation_name(nIndex)
  49. -- Play Animation
  50. wModels.model:set_animation(strAnimationName, bLoop)
  51. end
  52.  
  53. local function Main()
  54. -- all widgets have three arguments (scale, rotation, position) defined
  55. -- as vec3's. Here we just put the model in the origin with a scale of
  56. -- one.
  57.  
  58. for nPos = 1, #wModelFilenames do
  59. wModels[nPos] = kbModel( wModelScales[nPos], wModelRotations[nPos], wModelPositions[nPos])
  60. wModels[nPos]:set_model( wModelFilenames[nPos] )
  61. end
  62.  
  63. kbEvent.create(function() PlayAnimation(8) end, kbEvent.owners.key, kbEvent.types.released, kbEvent.scancodes.KB_1)
  64. kbEvent.create(function() PlayAnimation(9) end, kbEvent.owners.key, kbEvent.types.released, kbEvent.scancodes.KB_2)
  65.  
  66. -- Camera Starting Position
  67. wStartingCamera = kbCamera( kbVec3.one(), wStartingCameraRotation, wStartingCameraPosition)
  68. kbScreen.set_camera(wStartingCamera)
  69.  
  70. -- a skybox
  71. local skybox = kbSkybox(kbVec3.one(), kbVec3.zero(), kbVec3.zero())
  72. skybox:set_cubemap('night.sky')
  73.  
  74. -- for environment reflections
  75. kbScreen.set_environment_cubemap('night.sky')
  76. end
  77.  
  78. return
  79. {
  80. main = Main
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement