Ooops
November 25, 2020, 05:41:41 AM

Author Topic: [bb] Cube mapping made 6x faster and easier by Damien Sturdy [ 1+ years ago ]  (Read 568 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Cube mapping made 6x faster and easier
Author : Damien Sturdy
Posted : 1+ years ago

Description : May 03 2005; MultiTexturing problem spotted by SnarkBait fixed.
-----------------------------------------------------------
Okay, today, i decided to look at cubemapping- something ive not played with before.

I got the demo from blitz to work, and fixed a couple of its bugs (not hiding the camera) so some of the credit goes to the author of that demo.

This system allows you to turn any loaded mesh into a "cubemapped" mesh- by calling one command. the system keeps track of cameras and textures on its own.

Usage:

To make an object cubemapped:

addcubemapobject(mesh,texturesize,texturelayer)
                            turns "mesh" into a cubemapped entity

Updatecubemaps()            Goes through all cubemap objects and updates their textures

Deletecubemapobject(mesh)   Deletes the cubemap resources from "mesh"

Deleteallcubemapobjects()   Frees all cubemapping resources

All thats required to get this to work:

Addcubemapobject(mesh,256)
and
updatecubemaps()

[edit]
Just added a new command:
cubemeshCameraRange(mesh,CameraRangemin#,CameraRangemax#)

This sets how far the camera that renderes the reflection can "see" :D
[New version]

Okay, so i didnt need several cameras for several objects, so i overhauled the camera management...

The usage is exactly the same as before, except if you change graphics modes without clearing all the objects, youl get a Memory Access Violation.
Make sure you use Deleteallcubemapobjects() before changing graphics mode :)
New commands on 03/10/04:

BIG UPDATE!
Setcubemapupdatefrequency (okay so this may need changing)

Setcubemapupdatefrequency(mesh,frames,faceperrender) Sets how many "updatecubemaps" should be executed before this cubemapped entity gets cubemapped. If faceperrender=1 then it only updates 1 face of each cubemap every update, which is efficient but can cause glitches depending on the scenery. this means much faster "realtime" cubemapping though!
UpdateNextCubemap()  ;Iterates to the next cubemap and updates it. call this instead of updatecubemaps each frame for a higher framerate. this command disregards the above commands "frames" property..


Code :
Code: BlitzBasic
  1. Global scx=640,scy=480
  2. Graphics3D scx,scy,16,2
  3.  
  4. light=CreateLight()
  5. plane=CreatePlane()
  6.  
  7.  
  8. gld=CreateTexture(255,255)
  9. SetBuffer TextureBuffer(gld)
  10. For x=0 To 128
  11. Color x,x*2,x*3
  12. Rect x,x,255-x/2,255-x/2,0
  13. Next
  14. SetBuffer BackBuffer()
  15.  
  16. ScaleTexture gld,100,100
  17. EntityTexture plane,gld
  18.  
  19. camera=CreateCamera()
  20. CameraClsColor camera,10,20,250
  21. Pivot=CreatePivot()
  22. EntityParent camera,Pivot
  23.  
  24.  
  25. PositionEntity camera,0,20,-30
  26.  
  27.  
  28. ;Create some entities to cubemap
  29. sphere=CreateSphere(20)
  30. PositionEntity sphere,0,20,10
  31. ScaleEntity sphere,10,10,10
  32. cube=CreateCube()
  33. PositionEntity cube,0,20,-10
  34. ScaleEntity cube,5,5,5
  35.  
  36. ;Cubemap them!
  37. addcubemapobject(cube,256,0)
  38. addcubemapobject(sphere,128,0)
  39.  
  40.  
  41. ;You dont need to do the next couple of lines, but its good for efficiency:
  42. setcubemapupdatefrequency(cube,2,1)             ;Update cube every 15 frames, and enable "face per render" (update only a part of the cubemap every update)
  43. setcubemapupdatefrequency(sphere,2,1)           ;Update sphere every 15 frames, and enable "face per render" (update only a part of the cubemap every update)
  44.  
  45.  
  46.  
  47.  
  48. ;change the camera range of these two to speed things up
  49. cubemeshCameraRange(cube,10,250)
  50. cubemeshCameraRange(sphere,10,250)
  51.  
  52.  
  53.  
  54. ;do a render loop
  55. Repeat
  56. mlt#=1
  57. If KeyDown(57) Then mlt#=10
  58. TurnEntity Pivot,0,.1*mlt#,0
  59. TurnEntity cube,.1*mlt#,0,0
  60. updatecubemaps()   ;Update all cubemaps!
  61.  
  62. ;or you can use : updatenextcubemap()   ;Update NEXT cubemap!
  63.  
  64.  
  65. RenderWorld
  66. Flip
  67. Until KeyDown(1)
  68. Deletecubemapobject(cube)       ;Delete the cubemap stuff from "cube"
  69. Deletecubemapobject(sphere)     ;Delete the cubemap stuff from "sphere"
  70.  
  71. Deleteallcubemapobjects()               ;Alternatively, call this at the end to wipe all cubemap stuff
  72.  
  73. End
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Cubemap System;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  86. Type cubemapobject
  87. Field entity
  88. Field Texture
  89. Field detail
  90. Field cammin#,cammax#
  91. Field Lastupdate,updatefrequency
  92. Field Lastcamupdate
  93. Field faceperrender
  94. Field Lastface=1
  95. End Type
  96.  
  97. Global cubemapcameraent=0
  98. Global Lastcubemapcount,cubemapcount
  99.  
  100. Function clearcubemapsystem()
  101. Deleteallcubemapobjects()
  102. If cubemapcameraent<>0 Then FreeEntity cubemapcameraent:cubemapcameraent=0
  103. End Function
  104.  
  105. Function addcubemapobject(mesh,detail,Texturelayer=0,blendmode=2)
  106. Local t.cubemapobject=New cubemapobject
  107. tentity=mesh
  108. Tx=CreateTexture(detail,detail,1+128+256)
  109. EntityTexture mesh,tx,0,Texturelayer
  110. TextureBlend tx,blendmode
  111. tTexture=tx
  112. tdetail=detail
  113. If cubemapcameraent=0 Then cubemapcameraent=CreateCamera():CameraProjMode cubemapcameraent,0
  114. tupdatefrequency=1
  115. tLastupdate=Lastcubemapcount
  116. CameraProjMode cubemapcameraent,0
  117. tcammin=1
  118. tcammax=1000
  119. CameraRange cubemapcameraent,tcammin,tcammax
  120. updatecubemap(tTexture,cubemapcameraent,tentity)
  121. Lastcubemapcount=Lastcubemapcount+1;MilliSecs()
  122. End Function
  123.  
  124.  
  125. Function cubemeshCameraRange(mesh,CameraRangemin#,CameraRangemax#)  ;sets how a cubemaped texture is rendered.
  126. Local n.cubemapobject
  127. For n=Each cubemapobject
  128. If nentity=mesh Then
  129. ncammin=CameraRangemin
  130. ncammax=CameraRangemax
  131. EndIf
  132. Next
  133. End Function
  134.  
  135.  
  136. Function Deleteallcubemapobjects()
  137. Local n.cubemapobject
  138. For n=Each cubemapobject
  139. Deletecubemapobject nentity
  140. Next
  141. If cubemapcameraent<>0 Then FreeEntity cubemapcameraent:cubemapcameraent=0
  142. End Function
  143.  
  144.  
  145. Function Deletecubemapobject(mesh)
  146. Local n.cubemapobject
  147. For n=Each cubemapobject
  148. If nentity=mesh Then
  149. If nTexture<>0 Then FreeTexture nTexture
  150. Delete n
  151. EndIf
  152. Next
  153. checkifanycubemapsleft()
  154. End Function
  155.  
  156. Function checkifanycubemapsleft()
  157. Local cnt=0,n.cubemapobject
  158. For n=Each cubemapobject
  159. cnt=cnt+1
  160. Next
  161. If cnt=0 Then clearcubemapsystem()
  162. End Function
  163.  
  164. Function updatecubemaps()
  165. Local o.cubemapobject
  166. For o.cubemapobject=Each cubemapobject
  167. If (cubemapcount-oLastupdate)>oupdatefrequency Then
  168. CameraProjMode cubemapcameraent,0
  169. CameraRange cubemapcameraent,ocammin,ocammax
  170. updatecubemap(oTexture,cubemapcameraent,oentity,oLastface*ofaceperrender):oLastface=(oLastface Mod 6)+1
  171. oLastupdate=cubemapcount
  172. EndIf
  173. Next
  174. cubemapcount=cubemapcount+1
  175. End Function
  176.  
  177.  
  178. Function updatenextcubemap()
  179. Local o.cubemapobject
  180. Local cnt=0,cnt2=0
  181.  
  182. For o.cubemapobject=Each cubemapobject
  183. cnt2=cnt2+1
  184. Next
  185.  
  186. For o.cubemapobject=Each cubemapobject
  187. cnt=cnt+1
  188. If cubemapcount Mod (cnt2+1)=cnt Then;If (cubemapcount-oLastupdate)>oupdatefrequency Then
  189. CameraProjMode cubemapcameraent,0
  190. CameraRange cubemapcameraent,ocammin,ocammax
  191. updatecubemap(oTexture,cubemapcameraent,oentity,oLastface*ofaceperrender):oLastface=(oLastface Mod 6)+1
  192. oLastupdate=cubemapcount
  193. EndIf
  194. Next
  195. cubemapcount=cubemapcount+1
  196. End Function
  197.  
  198. Function setcubemapupdatefrequency(mesh,updaterate,faceperrender=0)
  199. Local o.cubemapobject
  200. For o.cubemapobject=Each cubemapobject
  201. If oentity=mesh Then oupdatefrequency=updaterate:ofaceperrender=faceperrender
  202. Next
  203. End Function
  204.  
  205. Function UpdateCubemap(tex,camera,entity,side=0)   ;the bit ripped from the Blitz demo
  206.  
  207.  
  208.         tex_sz=TextureWidth(tex)
  209.  
  210.         ; Show the camera we have specifically created for updating the cubemap
  211.         CameraProjMode camera,1
  212.         ; Hide entity that will have cubemap applied to it. This is so we can get cubemap from its position, without it blocking the view
  213.         HideEntity entity
  214.  
  215.         ; Position camera where the entity is - this is where we will be rendering views from for cubemap
  216.         PositionEntity camera,EntityX#(entity,1),EntityY#(entity,1),EntityZ#(entity,1)
  217.  
  218.         CameraClsMode camera,False,True
  219.        
  220.         ; Set the camera's viewport so it is the same size as our texture - so we can fit entire screen contents into texture
  221.         CameraViewport camera,0,0,tex_sz,tex_sz
  222.  
  223.         ; Update cubemap
  224. If side=0 Or side=1 Then
  225.         ; do left view 
  226.         SetCubeFace tex,0
  227.         RotateEntity camera,0,90,0
  228.         RenderWorld
  229.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  230. EndIf
  231. If side=0 Or side=2 Then
  232.         ; do forward view
  233.         SetCubeFace tex,1
  234.         RotateEntity camera,0,0,0
  235.         RenderWorld
  236.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  237.  
  238. EndIf
  239. If side=0 Or side=3 Then
  240.  
  241.         ; do right view
  242.         SetCubeFace tex,2
  243.         RotateEntity camera,0,-90,0
  244.         RenderWorld
  245.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  246.        
  247. EndIf
  248. If side=0 Or side=4 Then
  249.         ; do backward view
  250.         SetCubeFace tex,3
  251.         RotateEntity camera,0,180,0
  252.         RenderWorld
  253.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  254.        
  255. EndIf
  256. If side=0 Or side=5 Then
  257.  
  258.         ; do up view
  259.         SetCubeFace tex,4
  260.         RotateEntity camera,-90,0,0
  261.         RenderWorld
  262.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  263.        
  264. EndIf
  265. If side=0 Or side=6 Then
  266.  
  267.         ; do down view
  268.         SetCubeFace tex,5
  269.         RotateEntity camera,90,0,0
  270.         RenderWorld
  271.         CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
  272.        
  273. EndIf
  274.         ; Show entity again
  275.         ShowEntity entity
  276.        
  277.         ; Hide the cubemap camera
  278.         CameraProjMode camera,0
  279.        
  280. End Function
  281. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Comments :


xmlspy(Posted 1+ years ago)

 I get an Entity does not exist.  Remove the # from cubemapcameraent# .


BlitzSupport(Posted 1+ years ago)

 Yeah, handy stuff, but like xml says, don't ever use floats for entity handles! (Or images, sounds, etc.)


Damien Sturdy(Posted 1+ years ago)

 Forgot to post... i fixed the # which was there from an earlier typo.Also fixed a problem with parented meshes where the camera would always be put at 0,0,0.


Snarkbait(Posted 1+ years ago)

 I had to fix this to get multitexturing to work:EntityTexture mesh,tx,0,Texturelayer <== added the '0' in the 'frame' spot, and added blendmode and textureblend to the function.
Code: [Select]
Function addcubemapobject(mesh,detail,Texturelayer=0,blendmode=2)
Local t.cubemapobject=New cubemapobject
tentity=mesh
Tx=CreateTexture(detail,detail,1+128+256)
EntityTexture mesh,tx,0,Texturelayer
TextureBlend tx,blendmode
tTexture=tx
tdetail=detail
If cubemapcameraent=0 Then cubemapcameraent=CreateCamera():CameraProjMode cubemapcameraent,0
tupdatefrequency=1
tLastupdate=Lastcubemapcount
CameraProjMode cubemapcameraent,0
tcammin=1
tcammax=1000
CameraRange cubemapcameraent,tcammin,tcammax
updatecubemap(tTexture,cubemapcameraent,tentity)
Lastcubemapcount=Lastcubemapcount+1;MilliSecs()
End Function



Damien Sturdy(Posted 1+ years ago)

 Cheers for that. I have not had an issue though i did occasionally momentarily see some wierd artifacts. Thats a silly mistake (number 2 I suppose!)I'll update the entry now.


Trader3564(Posted 1+ years ago)

 awesome, i almost feel the colthmetal cool my skin when i watch this demo. well done.


plash(Posted 1+ years ago)

 Too tired to continue working on this, but maybe someone will find it useful! (much confusion, as minib3d does not have createplane function)Blitzmax superstrict (currently not working)
Code: [Select]
SuperStrict

Import sidesign.minib3d

Global scx:Int = 640, scy:Int = 480
Graphics3D scx, scy, 16, 2

Local Light:TLight = createLight()
Local PLANE:TMesh = createCube()  'substitute for createplane - as it does not exist in klepto's or simons version
ScaleEntity PLANE, 5, 0, 5
PositionEntity PLANE, - 6, - 6, 0

Local gld:TTexture = CreateTexture(255, 255)
For Local X:Int = 0 To 128
SetColor X, X * 2, X * 3
DrawRect X, X, 255 - X / 2, 255 - X / 2
Next
Flip
BackBufferToTex(gld)
Cls

scaleTexture gld, 100, 100
EntityTexture PLANE, gld

Local CAMERA:TCamera = createCamera()
CameraClsColor CAMERA, 10, 20, 250

Local PIVOT:TPivot = createPivot()
EntityParent CAMERA, PIVOT

PositionEntity CAMERA, 0, 20, - 30

'Create some entities To cubemap
Local sphere:TMesh = createSphere(20)
PositionEntity sphere, 0, 20, 10
ScaleEntity sphere, 10, 10, 10

Local cube:TMesh = createCube()
PositionEntity cube, 0, 20, - 10
ScaleEntity cube, 5, 5, 5

'Cubemap them!
addcubemapobject(cube, 256, 0)
addcubemapobject(sphere, 128, 0)

'You dont need To do the Next couple of lines, but its good For efficiency;
setcubemapupdatefrequency(cube, 2, 1)   'Update cube every 15 frames, And enable "face per render" (update only a part of the cubemap every update)
setcubemapupdatefrequency(sphere, 2, 1)   'Update sphere every 15 frames, And enable "face per render" (update only a part of the cubemap every update)

'change the camera range of these two To speed things up
cubemeshCameraRange(cube, 10, 250)
cubemeshCameraRange(sphere, 10, 250)


'do a render loop
Local mlt:Float = 1.0
Repeat

If KeyDown(57) Then mlt = 10
TurnEntity PIVOT, 0, .1 * mlt, 0
TurnEntity cube, .1 * mlt, 0, 0
updatecubemaps()    'Update all cubemaps!

'Or you can use ; updatenextcubemap()   'Update Next cubemap!


RenderWorld
Flip
Until KeyHit(KEY_ESCAPE)

Deletecubemapobject(cube)   'Delete the cubemap stuff from "cube"
Deletecubemapobject(sphere) 'Delete the cubemap stuff from "sphere"

Deleteallcubemapobjects() 'Alternatively, call this at the End To wipe all cubemap stuff

End


Type cubemapobject
  Global _list:TList = New TList
 
Field entity:TEntity
Field TEXTURE:TTexture
Field detail:Int
Field cammin:Float, cammax:Float
Field Lastupdate:Int, updatefrequency:Int
Field Lastcamupdate:Int
Field faceperrender:Int
Field Lastface:Int = 1

Method New()
  _list.AddLast(Self)

End Method

Method remove()
entity.FreeEntity() ; entity = Null
TEXTURE = Null
detail = Null
cammin = Null ; cammax = Null
lastupdate = Null ; updatefrequency = Null
lastcamupdate = Null ; faceperrender = Null
lastface = Null

  _list.remove(Self)
 
End Method

End Type

Global cubemapcameraent:TCamera = Null
Global Lastcubemapcount:Int, cubemapcount:Int

Function clearcubemapsystem()
Deleteallcubemapobjects()

   If cubemapcameraent <> Null Then FreeEntity cubemapcameraent ; cubemapcameraent = Null

End Function

Function addcubemapobject(MESH:TMesh, detail:Int, Texturelayer:Int = 0, blendmode:Int = 2)
  Local t:cubemapobject = New cubemapobject, Tx:TTexture

t.entity = MESH
Tx = CreateTexture(detail, detail, 1 + 128 + 256)
EntityTexture MESH, tx, 0, Texturelayer
TextureBlend tx, blendmode

t.TEXTURE = tx
t.detail = detail

If cubemapcameraent = Null Then cubemapcameraent = createCamera() ; CameraProjMode cubemapcameraent, 0

t.updatefrequency = 1
t.Lastupdate = Lastcubemapcount
CameraProjMode cubemapcameraent, 0
t.cammin = 1
t.cammax = 1000
CameraRange cubemapcameraent, t.cammin, t.cammax
_UpdateCubemap(t.TEXTURE, cubemapcameraent, t.entity)

Lastcubemapcount = Lastcubemapcount + 1

End Function


Function cubemeshCameraRange(MESH:TEntity, CameraRangemin:Float, CameraRangemax:Float)   'sets how a cubemaped texture is rendered.
  Local n:cubemapobject

For n = EachIn cubemapobject._list

If n.entity = MESH Then
n.cammin = CameraRangemin
n.cammax = CameraRangemax

EndIf

Next

End Function


Function Deleteallcubemapobjects()
  Local n:cubemapobject

For n = EachIn cubemapobject._list

Deletecubemapobject n.entity

Next

   If cubemapcameraent <> Null Then FreeEntity cubemapcameraent ; cubemapcameraent = Null

End Function


Function Deletecubemapobject(MESH:TEntity)
  Local n:cubemapobject

For n = EachIn cubemapobject._list
If n.entity = MESH Then
  If n.TEXTURE <> Null Then FreeTexture n.TEXTURE
n.remove()

EndIf
Next

   'checkifanycubemapsleft()
   If cubemapobject._list.count() = 0 Then cubemapobject._list.clear()
   
End Function

rem
Function checkifanycubemapsleft()
  Local cnt:Int = 0, n:cubemapobject

For n = EachIn cubemapobject._list

cnt = cnt + 1

Next

   If cnt = 0 Then clearcubemapsystem()
 
End Function
endrem

Function updatecubemaps()
  Local o:cubemapobject

For o = EachIn cubemapobject._list

If (cubemapcount - o.Lastupdate) > o.updatefrequency Then
CameraProjMode cubemapcameraent, 0
CameraRange cubemapcameraent, o.cammin, o.cammax
_UpdateCubemap(o.TEXTURE, cubemapcameraent, o.entity, o.Lastface * o.faceperrender) ; o.Lastface = (o.Lastface Mod 6) + 1
  o.Lastupdate = cubemapcount
EndIf

Next

   cubemapcount = cubemapcount + 1
   
End Function


Function updatenextcubemap()
  Local o:cubemapobject
  Local cnt:Int = 0, cnt2:Int = 0

For o = EachIn cubemapobject._list

cnt2 = cnt2 + 1

Next

For o = EachIn cubemapobject._list
  cnt = cnt + 1
If cubemapcount Mod (cnt2 + 1) = cnt Then'If (cubemapcount-oLastupdate)>oupdatefrequency Then
CameraProjMode cubemapcameraent, 0
CameraRange cubemapcameraent, o.cammin, o.cammax
_UpdateCubemap(o.TEXTURE, cubemapcameraent, o.entity, o.Lastface * o.faceperrender) ; o.Lastface = (o.Lastface Mod 6) + 1
  o.Lastupdate = cubemapcount
EndIf
Next

   cubemapcount = cubemapcount + 1
   
End Function

Function setcubemapupdatefrequency(MESH:TEntity, updaterate:Int, faceperrender:Int = 0)
  Local o:cubemapobject

For o = EachIn cubemapobject._list

If o.entity = MESH Then o.updatefrequency = updaterate ; o.faceperrender = faceperrender

Next

End Function

Function _UpdateCubemap(tex:TTexture, CAMERA:TCamera, entity:TEntity, side:Int = 0)        'the bit ripped from the Blitz demo
  Local tex_sz:Int = TextureWidth(tex)

' Show the camera we have specifically created For updating the cubemap
CameraProjMode CAMERA, 1
' Hide entity that will have cubemap applied To it. This is so we can get cubemap from its position, without it blocking the view
HideEntity entity

' Position camera where the entity is - this is where we will be rendering views from For cubemap
PositionEntity CAMERA, EntityX(entity, 1), EntityY(entity, 1), EntityZ(entity, 1)

CameraClsMode CAMERA, False, True

' Set the camera's viewport so it is the same size as our texture - so we can fit entire screen contents into texture
CameraViewport CAMERA, 0, 0, tex_sz, tex_sz

' Update cubemap
If side = 0 Or side = 1 Then
' do Left view
SetCubeFace tex, 0
RotateEntity CAMERA, 0, 90, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

If side = 0 Or side = 2 Then
' do forward view
SetCubeFace tex, 1
RotateEntity CAMERA, 0, 0, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

If side = 0 Or side = 3 Then
' do Right view
SetCubeFace tex, 2
RotateEntity CAMERA, 0, - 90, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

If side = 0 Or side = 4 Then
' do backward view
SetCubeFace tex, 3
RotateEntity CAMERA, 0, 180, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

If side = 0 Or side = 5 Then
' do up view
SetCubeFace tex, 4
RotateEntity CAMERA, - 90, 0, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

If side = 0 Or side = 6 Then
' do down view
SetCubeFace tex, 5
RotateEntity CAMERA, 90, 0, 0
RenderWorld
'CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex)
BackBufferToTex(tex)

EndIf

' Show entity again
ShowEntity entity

' Hide the cubemap camera
CameraProjMode CAMERA, 0

End Function



DareDevil(Posted 1+ years ago)

 Very good procedure, add all for my code;) [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal