Advertisement
Guest User

MultiplayerDemo.h

a guest
Apr 9th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.46 KB | None | 0 0
  1. // Copyright 2018 Phyronnaz
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "VoxelUtilities.h"
  7. #include "VoxelType.h"
  8. #include "VoxelMaterial.h"
  9. #include "VoxelWorldGenerator.h"
  10. #include "VoxelAsset.h"
  11. #include "FastNoise.h"
  12. #include "MultiplayerDemo.generated.h"
  13.  
  14.  
  15. class FMultiplayerDemoInstance : public FVoxelWorldGeneratorInstance
  16. {
  17. public:
  18.     struct FVoxelContext { int32 X; int32 Y; int32 Z; };
  19.     FMultiplayerDemoInstance(
  20. )
  21.     {
  22.  
  23.     }
  24.     virtual void GetValuesAndMaterialsAndVoxelTypes(float Values[], FVoxelMaterial Materials[], FVoxelType VoxelTypes[], const FIntVector& Start, const FIntVector& StartIndex, const int Step, const FIntVector& Size, const FIntVector& ArraySize) const override
  25.     {
  26.         for (int K = 0; K < Size.Z; K++)
  27.         {
  28.             const int Z = Start.Z + K * Step;
  29.             for (int J = 0; J < Size.Y; J++)
  30.             {
  31.                 const int Y = Start.Y + J * Step;
  32.                 for (int I = 0; I < Size.X; I++)
  33.                 {
  34.                     const int X = Start.X + I * Step;
  35.                     const int Index = (StartIndex.X + I) + ArraySize.X * (StartIndex.Y + J) + ArraySize.X * ArraySize.Y * (StartIndex.Z + K);
  36. float ___Value___ = 1;
  37. FVoxelMaterial ___Material___(0, 0, 0, 0);
  38. FVoxelType ___VoxelType___ = FVoxelType::UseAll();
  39. FVoxelContext ___Context___;
  40. ___Context___.X = X;
  41. ___Context___.Y = Y;
  42. ___Context___.Z = Z;
  43. float ___0___;
  44. ___0___ = ___Context___.Z;
  45. float ___1___;
  46. ___1___ = 10.0 - ___0___;
  47. float ___2___;
  48. ___2___ = ___1___ / 2.5;
  49. float ___3___;
  50. ___3___ = ___Context___.Z;
  51. float ___4___;
  52. ___4___ = 0.0;
  53. float ___5___;
  54. ___5___ = ___Context___.X;
  55. float ___6___;
  56. ___6___ = ___Context___.Y;
  57. float ___7___;
  58. ___7___ = ___Context___.Z;
  59. float ___8___;
  60. ___8___ = VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.GetSimplexFractal(___5___ / 1.0, ___6___ / 1.0, ___7___ / 1.0);
  61. float ___9___;
  62. ___9___ = 10.0;
  63. float ___10___;
  64. ___10___ = ___8___ * ___9___;
  65. float ___11___;
  66. ___11___ = FMath::Min<float>(___3___, ___4___);
  67. float ___12___;
  68. ___12___ = 1.0;
  69. float ___13___;
  70. ___13___ = ___10___ + ___11___;
  71. float ___14___;
  72. ___14___ = FMath::Clamp<float>(___2___, 0.0, 1.0);
  73. float ___15___;
  74. ___15___ = FMath::Lerp<float>(___12___, ___13___, ___14___);
  75. float ___16___;
  76. ___16___ = ___15___ / 5.0;
  77. ___Value___ = FMath::Clamp<float>(___16___, -1.f, 1.f);                 if (Values)
  78.                     {
  79.                         Values[Index] = ___Value___;
  80.                     }
  81.                     if (Materials)
  82.                     {
  83.                         Materials[Index] = ___Material___;
  84.                     }
  85.                     if (VoxelTypes)
  86.                     {
  87.                         VoxelTypes[Index] = ___VoxelType___;
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.     }
  93.    
  94.     virtual void SetVoxelWorld(const AVoxelWorld* ___VoxelWorld___) override
  95.     {
  96. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetSeed(1337);
  97. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetFrequency(0.02);
  98. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetInterp((FastNoise::Interp)2);
  99. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetFractalOctaves(3);
  100. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetFractalLacunarity(2.0);
  101. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetFractalGain(0.5);
  102. VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.SetFractalType((FastNoise::FractalType)0);
  103.     }
  104.    
  105.     virtual bool IsEmpty(const FIntVector& Start, const int Step, const FIntVector& Size) const override
  106.     {
  107.         int __IsEmptySign__ = 0;
  108.         for (int K = 0; K < Size.Z; K++)
  109.         {
  110.             const int Z = Start.Z + K * Step;
  111.             for (int J = 0; J < Size.Y; J++)
  112.             {
  113.                 const int Y = Start.Y + J * Step;
  114.                 for (int I = 0; I < Size.X; I++)
  115.                 {
  116.                     const int X = Start.X + I * Step;
  117. float ___Value___ = 1;
  118. FVoxelMaterial ___Material___(0, 0, 0, 0);
  119. FVoxelType ___VoxelType___ = FVoxelType::UseAll();
  120. FVoxelContext ___Context___;
  121. ___Context___.X = X;
  122. ___Context___.Y = Y;
  123. ___Context___.Z = Z;
  124. float ___0___;
  125. ___0___ = ___Context___.Z;
  126. float ___1___;
  127. ___1___ = 10.0 - ___0___;
  128. float ___2___;
  129. ___2___ = ___1___ / 2.5;
  130. float ___3___;
  131. ___3___ = ___Context___.Z;
  132. float ___4___;
  133. ___4___ = 0.0;
  134. float ___5___;
  135. ___5___ = ___Context___.X;
  136. float ___6___;
  137. ___6___ = ___Context___.Y;
  138. float ___7___;
  139. ___7___ = ___Context___.Z;
  140. float ___8___;
  141. ___8___ = VoxelNode_3DSimplexNoiseFractal_0___Noise___4804.GetSimplexFractal(___5___ / 1.0, ___6___ / 1.0, ___7___ / 1.0);
  142. float ___9___;
  143. ___9___ = 10.0;
  144. float ___10___;
  145. ___10___ = ___8___ * ___9___;
  146. float ___11___;
  147. ___11___ = FMath::Min<float>(___3___, ___4___);
  148. float ___12___;
  149. ___12___ = 1.0;
  150. float ___13___;
  151. ___13___ = ___10___ + ___11___;
  152. float ___14___;
  153. ___14___ = FMath::Clamp<float>(___2___, 0.0, 1.0);
  154. float ___15___;
  155. ___15___ = FMath::Lerp<float>(___12___, ___13___, ___14___);
  156. float ___16___;
  157. ___16___ = ___15___ / 5.0;
  158. ___Value___ = FMath::Clamp<float>(___16___, -1.f, 1.f);                 if (-1 + KINDA_SMALL_NUMBER < ___Value___ && ___Value___ < 1 - KINDA_SMALL_NUMBER)
  159.                     {
  160.                         return false;
  161.                     }
  162.  
  163.                     if (__IsEmptySign__ == 0)
  164.                     {
  165.                         __IsEmptySign__ = ___Value___ > 0 ? 1 : -1;
  166.                     }
  167.                     else if (__IsEmptySign__ == 1)
  168.                     {
  169.                         if (___Value___ < 0)
  170.                         {
  171.                             return false;
  172.                         }
  173.                     }
  174.                     else
  175.                     {
  176.                         check(__IsEmptySign__ == -1);
  177.                         if (___Value___ > 0)
  178.                         {
  179.                             return false;
  180.                         }
  181.                     }
  182.                 }
  183.             }
  184.         }
  185.         return true;
  186.     }
  187.    
  188. public:
  189. private:
  190.     FastNoise VoxelNode_3DSimplexNoiseFractal_0___Noise___4804;
  191.  
  192. };
  193.  
  194. UCLASS(Blueprintable)
  195. class UMultiplayerDemo : public UVoxelWorldGenerator
  196. {
  197.     GENERATED_BODY()
  198.  
  199. public:
  200.     UMultiplayerDemo()
  201.     {
  202.  
  203.     }
  204.     TSharedRef<FVoxelWorldGeneratorInstance> GetWorldGenerator() override
  205.     {
  206.         return MakeShareable(new FMultiplayerDemoInstance(
  207. ));
  208.     }
  209.  
  210. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement