Advertisement
deseven

customSkyBox

Jun 11th, 2015
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #sbsize = 4096
  2.  
  3. Enumeration textures
  4.   #texSBFront
  5.   #texSBBack
  6.   #texSBLeft
  7.   #texSBRight
  8.   #texSBUp
  9.   #texSBDown
  10. EndEnumeration
  11.  
  12. Enumeration materials
  13.   #matSBFront
  14.   #matSBBack
  15.   #matSBLeft
  16.   #matSBRight
  17.   #matSBUp
  18.   #matSBDown
  19. EndEnumeration
  20.  
  21. Enumeration meshes
  22.   #meshSBFront
  23.   #meshSBBack
  24.   #meshSBLeft
  25.   #meshSBRight
  26.   #meshSBUp
  27.   #meshSBDown
  28. EndEnumeration
  29.  
  30. Enumeration entities
  31.   #entSBFront
  32.   #entSBBack
  33.   #entSBLeft
  34.   #entSBRight
  35.   #entSBUp
  36.   #entSBDown
  37. EndEnumeration
  38.  
  39. Enumeration nodes
  40.   #skybox
  41. EndEnumeration
  42.  
  43. Procedure customSkyBox(template.s)
  44.   Protected ratio.l,name.s,ext.s
  45.   ext = StringField(template,2,".")
  46.   name = StringField(template,1,".")
  47.  
  48.   ; cleaning
  49.   If IsNode(#skybox)
  50.     FreeNode(#skybox)
  51.     FreeEntity(#entSBFront) : FreeMaterial(#matSBFront) : FreeMesh(#meshSBFront) : FreeTexture(#texSBFront)
  52.     FreeEntity(#entSBBack) : FreeMaterial(#matSBBack) : FreeMesh(#meshSBBack) : FreeTexture(#texSBBack)
  53.     FreeEntity(#entSBLeft) : FreeMaterial(#matSBLeft) : FreeMesh(#meshSBLeft) : FreeTexture(#texSBLeft)
  54.     FreeEntity(#entSBRight) : FreeMaterial(#matSBRight) : FreeMesh(#meshSBRight) : FreeTexture(#texSBRight)
  55.     FreeEntity(#entSBUp) : FreeMaterial(#matSBUp) : FreeMesh(#meshSBUp) : FreeTexture(#texSBUp)
  56.     FreeEntity(#entSBDown) : FreeMaterial(#matSBDown) : FreeMesh(#meshSBDown) : FreeTexture(#texSBDown)
  57.   EndIf
  58.  
  59.   LoadTexture(#texSBFront,name + "_FR." + ext)
  60.   ratio = #sbsize/TextureWidth(#texSBFront)
  61.   CreateMaterial(#matSBFront,TextureID(#texSBFront))
  62.   DisableMaterialLighting(#matSBFront,#True)
  63.   CreatePlane(#meshSBFront,TextureWidth(#texSBFront),TextureHeight(#texSBFront),1,1,1,1)
  64.   CreateEntity(#entSBFront,MeshID(#meshSBFront),MaterialID(#matSBFront))
  65.   ScaleEntity(#entSBFront,ratio,1,ratio)
  66.   RotateEntity(#entSBFront,-90,0,180,#PB_Absolute)
  67.   MoveEntity(#entSBFront,0,0,-#sbsize/2)
  68.  
  69.   LoadTexture(#texSBBack,name + "_BK." + ext)
  70.   ratio = #sbsize/TextureWidth(#texSBBack)
  71.   CreateMaterial(#matSBBack,TextureID(#texSBBack))
  72.   DisableMaterialLighting(#matSBBack,#True)
  73.   CreatePlane(#meshSBBack,TextureWidth(#texSBBack),TextureHeight(#texSBBack),1,1,1,1)
  74.   CreateEntity(#entSBBack,MeshID(#meshSBBack),MaterialID(#matSBBack))
  75.   ScaleEntity(#entSBBack,ratio,1,ratio)
  76.   RotateEntity(#entSBBack,-90,0,0,#PB_Absolute)
  77.   MoveEntity(#entSBBack,0,0,#sbsize/2)
  78.  
  79.   LoadTexture(#texSBLeft,name + "_LF." + ext)
  80.   ratio = #sbsize/TextureWidth(#texSBLeft)
  81.   CreateMaterial(#matSBLeft,TextureID(#texSBLeft))
  82.   DisableMaterialLighting(#matSBLeft,#True)
  83.   CreatePlane(#meshSBLeft,TextureWidth(#texSBLeft),TextureHeight(#texSBLeft),1,1,1,1)
  84.   CreateEntity(#entSBLeft,MeshID(#meshSBLeft),MaterialID(#matSBLeft))
  85.   ScaleEntity(#entSBLeft,ratio,1,ratio)
  86.   RotateEntity(#entSBLeft,-90,0,-90,#PB_Absolute)
  87.   MoveEntity(#entSBLeft,-#sbsize/2,0,0)
  88.  
  89.   LoadTexture(#texSBRight,name + "_RT." + ext)
  90.   ratio = #sbsize/TextureWidth(#texSBRight)
  91.   CreateMaterial(#matSBRight,TextureID(#texSBRight))
  92.   DisableMaterialLighting(#matSBRight,#True)
  93.   CreatePlane(#meshSBRight,TextureWidth(#texSBRight),TextureHeight(#texSBRight),1,1,1,1)
  94.   CreateEntity(#entSBRight,MeshID(#meshSBRight),MaterialID(#matSBRight))
  95.   ScaleEntity(#entSBRight,ratio,1,ratio)
  96.   RotateEntity(#entSBRight,-90,0,90,#PB_Absolute)
  97.   MoveEntity(#entSBRight,#sbsize/2,0,0)
  98.  
  99.   LoadTexture(#texSBUp,name + "_UP." + ext)
  100.   ratio = #sbsize/TextureWidth(#texSBUp)
  101.   CreateMaterial(#matSBUp,TextureID(#texSBUp))
  102.   DisableMaterialLighting(#matSBUp,#True)
  103.   CreatePlane(#meshSBUp,TextureWidth(#texSBUp),TextureHeight(#texSBUp),1,1,1,1)
  104.   CreateEntity(#entSBUp,MeshID(#meshSBUp),MaterialID(#matSBUp))
  105.   ScaleEntity(#entSBUp,ratio,1,ratio)
  106.   RotateEntity(#entSBUp,-180,-180,0,#PB_Absolute)
  107.   MoveEntity(#entSBUp,0,#sbsize/2,0)
  108.  
  109.   LoadTexture(#texSBDown,name + "_DN." + ext)
  110.   ratio = #sbsize/TextureWidth(#texSBDown)
  111.   CreateMaterial(#matSBDown,TextureID(#texSBDown))
  112.   DisableMaterialLighting(#matSBDown,#True)
  113.   CreatePlane(#meshSBDown,TextureWidth(#texSBDown),TextureHeight(#texSBDown),1,1,1,1)
  114.   CreateEntity(#entSBDown,MeshID(#meshSBDown),MaterialID(#matSBDown))
  115.   ScaleEntity(#entSBDown,ratio,1,ratio)
  116.   RotateEntity(#entSBDown,0,-180,0,#PB_Absolute)
  117.   MoveEntity(#entSBDown,0,-#sbsize/2,0)
  118.  
  119.   CreateNode(#skybox)
  120.   AttachNodeObject(#skybox,EntityID(#entSBFront))
  121.   AttachNodeObject(#skybox,EntityID(#entSBBack))
  122.   AttachNodeObject(#skybox,EntityID(#entSBLeft))
  123.   AttachNodeObject(#skybox,EntityID(#entSBRight))
  124.   AttachNodeObject(#skybox,EntityID(#entSBUp))
  125.   AttachNodeObject(#skybox,EntityID(#entSBDown))
  126. EndProcedure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement