Guest User

Untitled

a guest
Jan 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. public LightSource(VectorInt worldPosIndex , byte radius , Color color)
  2. {
  3.     this.radius = (byte)radius;
  4.     this.color = color;
  5.        
  6.     // Clamp it might go over the edge of world position
  7.     xMin = Helper.ClampInt( worldPosIndex.X - radius , 0 , worldPosIndex.X );
  8.     xMax = Helper.ClampInt( worldPosIndex.X + radius , worldPosIndex.X , World.worldXLength );
  9.    
  10.     yMin = Helper.ClampInt( worldPosIndex.Y - radius , 0 , worldPosIndex.Y );
  11.     yMax = Helper.ClampInt( worldPosIndex.Y + radius , worldPosIndex.Y , World.worldYLength );
  12.        
  13.     zMin = Helper.ClampInt( worldPosIndex.Z - radius , 0 , worldPosIndex.Z );
  14.     zMax = Helper.ClampInt( worldPosIndex.Z + radius , worldPosIndex.Z , World.worldZLength );
  15.    
  16.     // The size of the cube array, +1 for the Light Source Position so it will be when spread >   1  2  3  4  LS   4  3  2  1
  17.     xSize = (xMax-xMin)+1;
  18.     ySize = (yMax-yMin)+1;
  19.     zSize = (zMax-zMin)+1;
  20.        
  21.     // The index of the Light Source in the cube-array, this is where the spreading/propagation starts.
  22.     xIndex = posInShipData.X-xMin;
  23.     yIndex = posInShipData.Y-yMin;
  24.     zIndex = posInShipData.Z-zMin;
  25.    
  26.     // Start Spreading. . .
  27. }
  28.  
  29. private XYZ WorldToIndex( int x , int y , int z )
  30. {  
  31.     return new XYZ( x - xMin , y - yMin , z - zMin );
  32. }
  33.  
  34. private XYZ IndexToWorld( int x , int y , int z )
  35. {
  36.     return new XYZ( xMin + x , yMin + y , zMin + z );
  37. }
Add Comment
Please, Sign In to add comment