This commit is contained in:
yulong 2023-10-20 13:51:32 +08:00
parent a03f19f39e
commit 6c97e51aab
2780 changed files with 777831 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
/Assembly-CSharp.csproj
/Assembly-CSharp-Editor.csproj
/Assembly-CSharp-Editor-firstpass.csproj
/Assembly-CSharp-firstpass.csproj
/NewN_UAVPlane.sln
/README.md
/.vs
/Library
/obj
/Temp

8
Assets/3rdParty.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 87bebcb1c9e35eb498afc8a1ad9ec6ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b534caf804deec4198d3c05ecc45386
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 216f7c2c5a40a044e89db02f0346d9f3
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,89 @@
using UnityEngine;
using UnityEditor;
using System.IO;
namespace CloudSkybox
{
[CustomEditor(typeof(NoiseVolume))]
public class NoiseVolumeEditor : Editor
{
SerializedProperty _noiseType;
SerializedProperty _frequency;
SerializedProperty _fractalLevel;
SerializedProperty _seed;
void OnEnable()
{
_noiseType = serializedObject.FindProperty("_noiseType");
_frequency = serializedObject.FindProperty("_frequency");
_fractalLevel = serializedObject.FindProperty("_fractalLevel");
_seed = serializedObject.FindProperty("_seed");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_noiseType);
EditorGUILayout.PropertyField(_frequency);
EditorGUILayout.PropertyField(_fractalLevel);
EditorGUILayout.PropertyField(_seed);
var shouldRebuild = EditorGUI.EndChangeCheck();
serializedObject.ApplyModifiedProperties();
if (shouldRebuild)
foreach (var t in targets)
((NoiseVolume)t).RebuildTexture();
}
static void CreateAsset(int resolution)
{
// Make a proper path from the current selection.
var path = AssetDatabase.GetAssetPath(Selection.activeObject);
if (string.IsNullOrEmpty(path))
path = "Assets";
else if (Path.GetExtension(path) != "")
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
var assetPathName = AssetDatabase.GenerateUniqueAssetPath(path + "/NewNoiseVolume.asset");
// Create an asset.
var asset = ScriptableObject.CreateInstance<NoiseVolume>();
asset.ChangeResolution(resolution);
AssetDatabase.CreateAsset(asset, assetPathName);
AssetDatabase.AddObjectToAsset(asset.texture, asset);
// Build an initial volume for the asset.
asset.RebuildTexture();
// Save the generated mesh asset.
AssetDatabase.SaveAssets();
// Tweak the selection.
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}
[UnityEditor.MenuItem("Assets/Create/NoiseVolume/32")]
public static void CreateNoiseVolume32()
{
CreateAsset(32);
}
[UnityEditor.MenuItem("Assets/Create/NoiseVolume/64")]
public static void CreateNoiseVolume64()
{
CreateAsset(64);
}
[UnityEditor.MenuItem("Assets/Create/NoiseVolume/128")]
public static void CreateNoiseVolume128()
{
CreateAsset(128);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 990d746f448d34ede87401bb1421a0b6
timeCreated: 1462893327
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a2e44bfbb32716b439609ff937b34ad2
timeCreated: 1461632467
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 477c737a4683ce549ad3142cbd165767
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6a84f708d0201c945a669c7d57b0c2a6
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: mat_fx_fog
m_Shader: {fileID: 4800000, guid: f21713de5ca30894ea6bb7c51ae7d47b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 049e1c7514867f4439d54455571bb143, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _InvFade: 0.06
- _LightFac: 1
- _LightningFac: 0.085
- _NightFac: 0.107
- _OverBright: 1
- _ShadowBoost: 1
- _ShadowRange: 0.628
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _TintColor: {r: 0.9044, g: 0.9044, b: 0.9044, a: 0}

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 86048402a6952f64f84ba9c5bdd2bf13
NativeFormatImporter:
userData:

View File

@ -0,0 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: mat_fx_rain
m_Shader: {fileID: 4800000, guid: f21713de5ca30894ea6bb7c51ae7d47b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: dcda72e15b795574c98b8e802037d80a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _InvFade: 1
- _LightFac: 0.183
- _LightningFac: 1
- _NightFac: 0.1
- _OverBright: 3
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _TintColor: {r: 0.6188, g: 0.714, b: 0.714, a: 0.12}

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 11ff248363d5dd04d84295569f93944b
NativeFormatImporter:
userData:

View File

@ -0,0 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: mat_fx_rainFog
m_Shader: {fileID: 4800000, guid: f21713de5ca30894ea6bb7c51ae7d47b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 049e1c7514867f4439d54455571bb143, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _InvFade: 1
- _LightFac: 1
- _LightningFac: 0.3
- _NightFac: 0.1
- _OverBright: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _TintColor: {r: 0.952, g: 0.952, b: 0.952, a: 0.004}

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: eb225d6dba5b8114ea482438f810a3ec
NativeFormatImporter:
userData:

View File

@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: mat_fx_rainSplash
m_Shader: {fileID: 4800000, guid: f21713de5ca30894ea6bb7c51ae7d47b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 3aaa6c36f31e2b54aae2b4fd2831c3a5, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _screenMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _InvFade: 3
- _LightFac: 0.5
- _LightningFac: 1
- _NightFac: 0.1
- _OverBright: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _TintColor: {r: 0.952, g: 0.952, b: 0.952, a: 0.65}

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 70379c24f2abeee43bcde68f4cede7de
NativeFormatImporter:
userData:

View File

@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: mat_fx_snow
m_Shader: {fileID: 4800000, guid: f21713de5ca30894ea6bb7c51ae7d47b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: dc2b86b75f92c7142a85a369dd553acb, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _InvFade: 2.78
- _LightFac: 0
- _LightningFac: 0.75
- _NightFac: 0.063
- _OverBright: 2
- _ShadowBoost: 1.32
- _ShadowRange: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _TintColor: {r: 0.80920005, g: 0.80920005, b: 0.80920005, a: 0.45}

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: d3a18964e01c3434e805da3dd46a7fef
NativeFormatImporter:
userData:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: dcda72e15b795574c98b8e802037d80a
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 3aaa6c36f31e2b54aae2b4fd2831c3a5
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: dc2b86b75f92c7142a85a369dd553acb
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 049e1c7514867f4439d54455571bb143
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 5fbce30555884d047a557b8330f9f5d6
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: cc72da48d05e01a4f8feecbed77fc0fa
NativeFormatImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 9b91a2faa654f2b4884c2469e12e5006
NativeFormatImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57d9e847574d8eb4189d50a65e47e1de
timeCreated: 1472000418
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: b719fcd461406c843add3d35f247cf5b
NativeFormatImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 62a0ba30e8ecc6f4c9ad497430b9f8e2
NativeFormatImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cc416020c0c84ff4daab581666ec99a4
timeCreated: 1471992248
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: ab51236a129e8fb4b95d7d6cfbabbec9
NativeFormatImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: d23e69be23faab34cabd2c77f47f93cc
NativeFormatImporter:
userData:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 04dbff2622158404894a3fdf58d7b17d
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 797d24fd18afe2f4aa6e5693ee99595c
NativeFormatImporter:
userData:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5d8cf301f5ff09f45b837ee8db76ed3b
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: a6cab5a47c3559c49b67733e646c3949
TextScriptImporter:
userData:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 27a51dd1b7a005a4ab6f753bf6d67782
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,121 @@
fileFormatVersion: 2
guid: c0a11b59e01c2704190adf8e2bed3aa9
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 1
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 1
pSDShowRemoveMatteOption: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
fileFormatVersion: 2
guid: 4155a4c1bceff4148ab76393e4b738b7
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 512
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: 1241a4e30e423cf4aaa75928ee5b6fa2
timeCreated: 1428441291
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 512
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 41cb06fe8a991374e80546ca63fab097
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: ce83f3ff10b792d4ca319e985ef3f712
timeCreated: 1428441611
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 512
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,53 @@
fileFormatVersion: 2
guid: 233ad955106ad0e4a843c30bcddb55d4
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 512
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: 617d1c6f1ad53d54c8a9e3327bf2855d
timeCreated: 1428441291
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 512
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: f67c814b5e4f2e042a8c81fd5b507a37
timeCreated: 1448136784
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 1
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: 1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e16c5ff7a45e58f45a019225778f0a3a
folderAsset: yes
timeCreated: 1436372897
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1cc41e3c004f87249b36bc2d76e5dfd2
folderAsset: yes
timeCreated: 1477325212
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
using UnityEngine;
namespace NoiseTools
{
public abstract class NoiseGeneratorBase
{
#region Public members
public NoiseGeneratorBase(int frequency, int repeat, int seed = 0)
{
_freq = frequency;
_repeat = repeat * frequency;
_seed = seed;
}
public float GetAt(float x, float y)
{
return Calculate2D(new Vector2(x, y));
}
public float GetAt(Vector2 point)
{
return Calculate2D(point);
}
public float GetAt(float x, float y, float z)
{
return Calculate3D(new Vector3(x, y, z));
}
public float GetAt(Vector3 point)
{
return Calculate3D(point);
}
public float GetFractal(float x, float y, int level)
{
return Calculate2DFractal(new Vector2(x, y), level);
}
public float GetFractal(Vector2 point, int level)
{
return Calculate2DFractal(point, level);
}
public float GetFractal(float x, float y, float z, int level)
{
return Calculate3DFractal(new Vector3(x, y, z), level);
}
public float GetFractal(Vector3 point, int level)
{
return Calculate3DFractal(point, level);
}
#endregion
#region Protected members
int _freq;
int _repeat;
int _seed;
protected float Frequency { get { return _freq; } }
protected int Repeat(int i)
{
i %= _repeat;
if (i < 0) i += _repeat;
return i;
}
protected int Hash(int id)
{
return (int)XXHash.GetHash(id, _seed);
}
protected float Hash01(int id)
{
return XXHash.GetHash(id, _seed) / (float)uint.MaxValue;
}
protected int CellID(int cx, int cy)
{
return Repeat(cy) * _repeat + Repeat(cx);
}
protected int CellID(int cx, int cy, int cz)
{
return (Repeat(cz) * _repeat + Repeat(cy)) * _repeat + Repeat(cx);
}
#endregion
#region Noise functions
protected abstract float Calculate2D(Vector2 point);
protected abstract float Calculate3D(Vector3 point);
float Calculate2DFractal(Vector2 point, int level)
{
var originalFreq = _freq;
var originalRepeat = _repeat;
var sum = 0.0f;
var w = 0.5f;
for (var i = 0; i < level; i++)
{
sum += Calculate2D(point) * w;
_freq *= 2;
_repeat *= 2;
w *= 0.5f;
}
_freq = originalFreq;
_repeat = originalRepeat;
return sum;
}
float Calculate3DFractal(Vector3 point, int level)
{
var originalFreq = _freq;
var originalRepeat = _repeat;
var sum = 0.0f;
var w = 0.5f;
for (var i = 0; i < level; i++)
{
sum += Calculate3D(point) * w;
_freq *= 2;
_repeat *= 2;
w *= 0.5f;
}
_freq = originalFreq;
_repeat = originalRepeat;
return sum;
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3ecf91b8b971d4d08b0c1a27c74b08e8
timeCreated: 1463064353
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
using UnityEngine;
namespace CloudSkybox
{
public class NoiseVolume : ScriptableObject
{
#region Asset creation
enum NoiseType { Perlin, Worley }
[SerializeField]
NoiseType _noiseType = NoiseType.Perlin;
[SerializeField]
int _frequency = 1;
[SerializeField]
int _fractalLevel = 0;
[SerializeField]
int _seed;
[SerializeField, HideInInspector]
Texture3D _texture;
const int kDefaultResolution = 32;
public Texture3D texture {
get { return _texture; }
}
void OnEnable()
{
if (_texture == null)
{
_texture = new Texture3D(
kDefaultResolution,
kDefaultResolution,
kDefaultResolution,
TextureFormat.Alpha8, false
);
_texture.name = "Texture3D";
}
}
public void ChangeResolution(int newResolution)
{
DestroyImmediate(_texture);
_texture = new Texture3D(
newResolution,
newResolution,
newResolution,
TextureFormat.Alpha8, false
);
_texture.name = "Texture3D";
}
public void RebuildTexture()
{
if (_texture == null)
{
Debug.LogError("Texture3D asset is missing.");
return;
}
var size = _texture.width;
var scale = 1.0f / size;
NoiseTools.NoiseGeneratorBase noise;
if (_noiseType == NoiseType.Perlin)
noise = new NoiseTools.PerlinNoise(_frequency, 1, _seed);
else
noise = new NoiseTools.WorleyNoise(_frequency, 1, _seed);
var buffer = new Color[size * size * size];
var index = 0;
for (var ix = 0; ix < size; ix++)
{
var x = scale * ix;
for (var iy = 0; iy < size; iy++)
{
var y = scale * iy;
for (var iz = 0; iz < size; iz++)
{
var z = scale * iz;
var c = _fractalLevel > 1 ?
noise.GetFractal(x, y, z, _fractalLevel) :
noise.GetAt(x, y, z);
buffer[index++] = new Color(c, c, c, c);
}
}
}
_texture.SetPixels(buffer);
_texture.Apply();
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9c5b4c2d28454448492bca562d7bc15f
timeCreated: 1462893311
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,110 @@
using UnityEngine;
namespace NoiseTools
{
public class PerlinNoise : NoiseGeneratorBase
{
#region Constructor
public PerlinNoise(int frequency, int repeat, int seed = 0)
: base(frequency, repeat, seed)
{
}
#endregion
#region Private members
static float Fade(float t)
{
return t * t * t * (t * (t * 6 - 15) + 10);
}
static float Lerp(float t, float a, float b)
{
return a + t * (b - a);
}
static float Grad(int hash, float x, float y)
{
return ((hash & 1) == 0 ? x : -x) + ((hash & 2) == 0 ? y : -y);
}
static float Grad(int hash, float x, float y, float z)
{
var h = hash & 15;
var u = h < 8 ? x : y;
var v = h < 4 ? y : (h == 12 || h == 14 ? x : z);
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
}
#endregion
#region 2D noise
protected override float Calculate2D(Vector2 point)
{
var x = point.x * Frequency;
var y = point.y * Frequency;
var cx = Mathf.FloorToInt(x);
var cy = Mathf.FloorToInt(y);
x -= cx;
y -= cy;
var u = Fade(x);
var v = Fade(y);
var h00 = Hash(CellID(cx , cy ));
var h01 = Hash(CellID(cx + 1, cy ));
var h10 = Hash(CellID(cx , cy + 1));
var h11 = Hash(CellID(cx + 1, cy + 1));
var n = Lerp(v, Lerp(u, Grad(h00, x, y ), Grad(h01, x-1, y )),
Lerp(u, Grad(h10, x, y-1), Grad(h11, x-1, y-1)));
return n * 0.5f + 0.5f;
}
#endregion
#region 3D noise
protected override float Calculate3D(Vector3 point)
{
var x = point.x * Frequency;
var y = point.y * Frequency;
var z = point.z * Frequency;
var cx = Mathf.FloorToInt(x);
var cy = Mathf.FloorToInt(y);
var cz = Mathf.FloorToInt(z);
x -= cx;
y -= cy;
z -= cz;
var u = Fade(x);
var v = Fade(y);
var w = Fade(z);
var h000 = Hash(CellID(cx , cy , cz ));
var h001 = Hash(CellID(cx + 1, cy , cz ));
var h010 = Hash(CellID(cx , cy + 1, cz ));
var h011 = Hash(CellID(cx + 1, cy + 1, cz ));
var h100 = Hash(CellID(cx , cy , cz + 1));
var h101 = Hash(CellID(cx + 1, cy , cz + 1));
var h110 = Hash(CellID(cx , cy + 1, cz + 1));
var h111 = Hash(CellID(cx + 1, cy + 1, cz + 1));
var n = Lerp(w, Lerp(v, Lerp(u, Grad(h000, x, y , z ), Grad(h001, x-1, y , z )),
Lerp(u, Grad(h010, x, y-1, z ), Grad(h011, x-1, y-1, z ))),
Lerp(v, Lerp(u, Grad(h100, x, y , z-1), Grad(h101, x-1, y , z-1)),
Lerp(u, Grad(h110, x, y-1, z-1), Grad(h111, x-1, y-1, z-1))));
return n * 0.5f + 0.5f;
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dca3a013dc69b4601864de1590fd5f10
timeCreated: 1463063332
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,127 @@
using UnityEngine;
namespace NoiseTools
{
public class WorleyNoise : NoiseGeneratorBase
{
#region Constructor
public WorleyNoise(int frequency, int repeat, int seed = 0)
: base(frequency, repeat, seed)
{
}
#endregion
#region 2D noise
const int kIDOffs1 = 100000;
const int kIDOffs2 = 200000;
Vector2 Feature(int cx, int cy)
{
var id = CellID(cx, cy);
return new Vector2(
Hash01(id ) + cx,
Hash01(id + kIDOffs1) + cy
);
}
float DistanceToFeature(Vector2 p, int cx, int cy)
{
return Vector2.Distance(p, Feature(cx, cy));
}
protected override float Calculate2D(Vector2 point)
{
point *= Frequency;
var cx = Mathf.FloorToInt(point.x);
var cy = Mathf.FloorToInt(point.y);
var d = DistanceToFeature(point, cx, cy);
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy ));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy ));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1));
return d;
}
#endregion
#region 3D noise
Vector3 Feature(int cx, int cy, int cz)
{
var id = CellID(cx, cy, cz);
return new Vector3(
Hash01(id ) + cx,
Hash01(id + kIDOffs1) + cy,
Hash01(id + kIDOffs2) + cz
);
}
float DistanceToFeature(Vector3 p, int cx, int cy, int cz)
{
return Vector3.Distance(p, Feature(cx, cy, cz));
}
protected override float Calculate3D(Vector3 point)
{
point *= Frequency;
var cx = Mathf.FloorToInt(point.x);
var cy = Mathf.FloorToInt(point.y);
var cz = Mathf.FloorToInt(point.z);
var d = DistanceToFeature(point, cx, cy, cz);
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy , cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz - 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy , cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz + 1));
d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz + 1));
return d;
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: db44ee3b32a9440d3b957f8fb540ad3e
timeCreated: 1463046835
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@
namespace NoiseTools
{
public struct XXHash
{
#region Private Members
const uint PRIME32_1 = 2654435761U;
const uint PRIME32_2 = 2246822519U;
const uint PRIME32_3 = 3266489917U;
const uint PRIME32_4 = 668265263U;
const uint PRIME32_5 = 374761393U;
static uint rotl32(uint x, int r)
{
return (x << r) | (x >> 32 - r);
}
#endregion
#region Static Functions
public static uint GetHash(int data, int seed)
{
uint h32 = (uint)seed + PRIME32_5;
h32 += 4U;
h32 += (uint)data * PRIME32_3;
h32 = rotl32(h32, 17) * PRIME32_4;
h32 ^= h32 >> 15;
h32 *= PRIME32_2;
h32 ^= h32 >> 13;
h32 *= PRIME32_3;
h32 ^= h32 >> 16;
return h32;
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fa7ace50a3c53473f930fe2f09f4152c
timeCreated: 1463059863
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,133 @@
using System;
using UnityEngine;
namespace Tenkoku.Core
{
public class ParticlePlanetHandler : MonoBehaviour
{
//PUBLIC VARIABLES
public bool planetReset = false;
public String planetName = "mars";
public float planetVis = 1.0f;
public Color planetColor = Color.white;
public float planetSize = 0.02f;
public Vector3 planetOffset = new Vector3(0f,0f,0f);
//PRIVATE VARIABLES
private int numParticles = 1;
private bool hasStarted = false;
private ParticleSystem PlanetSystem;
private Renderer planetRenderer;
private ParticleSystem.Particle[] PlanetParticles;
private Vector4[] planetPOS;
private String[] planetDataArray;
private String planetDataString;
private float currPlanetVis = -1.0f;
private int px = 0;
private Color useColor = new Color(0f,0f,0f,0f);
private Color visColor = new Color(0.5f,0.5f,0.5f,1.0f);
private Vector3 particlePosition = Vector3.zero;
void Start () {
hasStarted = false;
PlanetSystem = this.GetComponent<ParticleSystem>();
PlanetSystem.Emit(numParticles);
planetRenderer = this.GetComponent<Renderer>();
PlanetParticles = new ParticleSystem.Particle[8];
}
void LateUpdate(){
if (currPlanetVis != planetVis){
currPlanetVis = planetVis;
if (planetRenderer != null){
visColor.a = planetVis;
if (Application.isPlaying){
visColor = planetRenderer.material.GetColor("_TintColor");
planetRenderer.material.SetColor("_TintColor", visColor);
} else {
visColor = planetRenderer.sharedMaterial.GetColor("_TintColor");
planetRenderer.sharedMaterial.SetColor("_TintColor", visColor);
}
}
}
if (!hasStarted){
hasStarted = true;
planetReset = true;
}
if (planetReset){
PlSystemUpdate();
}
}
void PlSystemUpdate () {
//reset planet system
if (planetReset){
planetReset = false;
PlanetSystem.GetParticles(PlanetParticles);
for (px = 0; px < 8; px++){
//default position
//if (px < PlanetSystem.particleCount && PlanetParticles[px] != null){
if (px < PlanetSystem.particleCount){
particlePosition.x = -25.0f + planetOffset.x;
particlePosition.y = planetOffset.y;
particlePosition.z = planetOffset.z;
PlanetParticles[px].position = particlePosition;
// set planet size
#if UNITY_5_3_OR_NEWER
PlanetParticles[px].startSize = planetSize;
#else
PlanetParticles[px].size = planetSize;
#endif
// set planet color
useColor = planetColor;
#if UNITY_5_3_OR_NEWER
PlanetParticles[px].startColor = useColor;
#else
PlanetParticles[px].color = useColor;
#endif
} else {
break;
}
px++;
}
PlanetSystem.SetParticles(PlanetParticles,PlanetParticles.Length);
PlanetSystem.Emit(PlanetParticles.Length);
PlanetSystem.Play();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5914b641c94392c48895c47cdfdd689c
timeCreated: 1461158441
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,558 @@
using System;
using System.IO;
using UnityEngine;
namespace Tenkoku.Core
{
public class ParticleStarfieldHandler : MonoBehaviour
{
//PUBLIC VARIABLES
public bool starReset = false;
public int numParticles = 9110;
public float baseSize = 0.02f;
public float setSize = 0.02f;
public float constellationSize = 0.025f;
public Color starBrightness = Color.white;
public Vector3 offset = new Vector3(0f,0f,0f);
public TextAsset starFile;
public float starDistance = 1300f;
//PRIVATE VARIABLES
private bool hasStarted = false;
private ParticleSystem StarSystem;
private ParticleSystem.Particle[] StarParticles;
private Vector4[] starPOS;
private String[] starDataArray;
private String starDataString;
private Vector3 offsetC = new Vector3(0f,0f,0f);
private float baseSizeC = 0.02f;
private float constellationSizeC = 0.025f;
private Color currStarBrightness = new Color(1f,1f,1f,1f);
private Renderer rendererComponent;
//Collect for GC
private float starDeclination = 0.0f;
private float starAscension = 0.0f;
private String workData;
private String mod;
private float h;
private float m;
private float s;
private Color starColO = new Color(0.41f,0.66f,1.0f,0.5f);
private Color starColB = new Color(0.76f,0.86f,1.0f,0.5f);
private Color starColA = new Color(1.0f,1.0f,1.0f,0.5f);
private Color starColF = new Color(0.99f,1.0f,0.94f,0.5f);
private Color starColG = new Color(1.0f,0.99f,0.55f,0.5f);
private Color starColK = new Color(1.0f,0.72f,0.36f,0.5f);
private Color starColM = new Color(1.0f,0.07f,0.07f,0.5f);
private Color setColor = new Color(1.0f,1.0f,1.0f,1.0f);
private String starColor = "";
private float starFactor = 0.0f;
private float starMagnitude = 0.0f;
private String starHDnum = "";
private bool ConstellationStar = false;
private int px = 0;
private int sx = 0;
private Vector3 setpos;
private float useSize;
private Vector3 particlePosition = Vector3.zero;
private Color baseLerpColor = new Color(0.5f,0.6f,1.0f,1.0f);
void Start () {
hasStarted = false;
StarSystem = this.GetComponent<ParticleSystem>();
rendererComponent = this.GetComponent<Renderer>();
numParticles = 9110;
StarSystem.Emit(numParticles);
}
void LateUpdate(){
if (offset != offsetC){
offsetC = offset;
starReset = true;
}
if (setSize != baseSizeC){
baseSizeC = setSize;
starReset = true;
}
if (constellationSize != constellationSizeC){
constellationSizeC = constellationSize;
starReset = true;
}
//set overall material color
if (currStarBrightness != starBrightness){
currStarBrightness = starBrightness;
if (Application.isPlaying){
rendererComponent.material.SetColor("_TintColor", starBrightness);
} else {
rendererComponent.sharedMaterial.SetColor("_TintColor", starBrightness);
}
}
if (!hasStarted){
hasStarted = true;
starReset = true;
}
if (starReset){
StSystemUpdate();
}
}
void StSystemUpdate () {
//reset star system
starReset = false;
//get Star Data and parse
PopulateStarDataString();
StarParticles = new ParticleSystem.Particle[starDataArray.Length];
StarSystem.GetParticles(StarParticles);
for (px = 0; px < StarParticles.Length; px++){
//for (var sx = 0; sx < (starPOS.length); sx++){
for (sx = 0; sx < (starDataArray.Length); sx++){
//calculate Right Ascension
workData = starDataArray[sx].Substring(6,11);
h = float.Parse(workData.Substring(0,2));
m = float.Parse(workData.Substring(3,2));
s = float.Parse(workData.Substring(6,2));
starAscension = ((s/60.0f)*0.1f)+(m/60.0f)+(h);
//calculate Declination
workData = starDataArray[sx].Substring(18,12);
mod = workData.Substring(0,1);
h = float.Parse(workData.Substring(1,2));
m = float.Parse(workData.Substring(4,2));
s = float.Parse(workData.Substring(7,5));
starDeclination = ((s/60.0f)*0.1f)+(m/60.0f)+(h);
if (mod=="-") starDeclination = 0.0f-starDeclination;
//set particle positions
particlePosition.x = 0f;
particlePosition.y = 0f;
particlePosition.z = starDistance;
setpos = particlePosition;
//setpos = Quaternion.AngleAxis((90.0-starDeclination),-Vector3.right) * setpos;
setpos = Quaternion.AngleAxis((90.0f-starDeclination),-Vector3.left) * setpos;
StarParticles[px].position = setpos;
//setpos = Quaternion.AngleAxis(((starAscension*30.0)),Vector3.forward) * setpos;
setpos = Quaternion.AngleAxis(((starAscension*15.0f)),Vector3.forward) * setpos;
setpos.x = -setpos.x;
setpos.y = -setpos.y;
setpos.z = -setpos.z + 4.5f;
StarParticles[px].position = setpos;
//set star colors
workData = starDataArray[sx].Substring(67,8);
starColor = workData.Substring(1,1);
starFactor = float.Parse(workData.Substring(2,1));
if (starFactor > 0.0f) starFactor=starFactor/9.0f;
if (starColor == "O") setColor = Color.Lerp(starColO,starColB,starFactor);
if (starColor == "B") setColor = Color.Lerp(starColB,starColA,starFactor);
if (starColor == "A") setColor = Color.Lerp(starColA,starColF,starFactor);
if (starColor == "F") setColor = Color.Lerp(starColF,starColG,starFactor);
if (starColor == "G") setColor = Color.Lerp(starColG,starColK,starFactor);
if (starColor == "K") setColor = Color.Lerp(starColK,starColM,starFactor);
if (starColor == "M") setColor = Color.Lerp(starColM,starColM,starFactor);
setColor = Color.Lerp(setColor,baseLerpColor,0.5f);
//calculate magnitude
workData = starDataArray[sx].Substring(53,4);
starMagnitude = float.Parse(workData);
setColor.a = 1.0f;
if (starMagnitude >= 2.0f) setColor.a = Mathf.Lerp(1.0f,0.0f,(starMagnitude/9.0f));
if (starMagnitude < 2.0f) setColor *= 2.0f;
setColor.a = Mathf.Lerp(1.0f,0.0f,(starMagnitude/8.0f));
//check for constellations
starHDnum = starDataArray[sx].Substring(58,6);
ConstellationStar = CheckConstellationStars(starHDnum);
//temp
setColor.a = Mathf.Lerp(1.0f,0.075f,(starMagnitude/8.0f));
if (setColor.a < 0.6f) setColor.a *= 0.1f;
//set star sizes
useSize = Mathf.Lerp(setSize*1.4f,setSize,(starMagnitude/8.0f));
if (ConstellationStar && useSize < constellationSize) useSize = constellationSize;
workData = starDataArray[sx].Substring(67,8);
if (workData.Contains("IV")){
setColor.a *= 1.2f;
} else if (workData.Contains("V")){
setColor.a *= 1.0f;
} else if (workData.Contains("III")){
setColor.a *= 1.4f;
} else if (workData.Contains("II")){
useSize = useSize*1.1f;
setColor.a *= 1.6f;
} else if (workData.Contains("I")){
useSize = useSize*1.2f;
setColor.a *= 4.0f;
}
//polaris star
if (starHDnum == " 8890") useSize *= 1.25f;
//leo
/*
if (starHDnum == " 87901") useSize *= 2.0f; //regulus
if (starHDnum == " 87737") useSize *= 2.0f; //
if (starHDnum == " 89484") useSize *= 2.0f; //algieba
if (starHDnum == " 89025") useSize *= 2.0f; //
if (starHDnum == " 85503") useSize *= 2.0f; //
if (starHDnum == " 84441") useSize *= 2.0f; //
if (starHDnum == " 97603") useSize *= 2.0f; //
if (starHDnum == "102647") useSize *= 2.0f; //
if (starHDnum == " 97633") useSize *= 2.0f; //
//orion
if (starHDnum == " 39801") useSize *= 5.0f; //betelgeuse
if (starHDnum == " 36861") useSize *= 5.0f; //meissa
if (starHDnum == " 35468") useSize *= 5.0f; //bellatrix
if (starHDnum == " 34085") useSize *= 5.0f; //rigel
if (starHDnum == " 38771") useSize *= 5.0f; //saiph
if (starHDnum == " 36486") useSize *= 5.0f; //mintaka
if (starHDnum == " 37742") useSize *= 5.0f; //alnitak
if (starHDnum == " 37128") useSize *= 5.0f; //alnilam
//little dipper
if (starHDnum == " 8890") useSize *= 5.0f; //polaris
if (starHDnum == "153751") useSize *= 3.0f; //urodelus
if (starHDnum == "131873") useSize *= 3.0f; //kochab
if (starHDnum == "137422") useSize *= 3.0f; //pherkad
if (starHDnum == "166205") useSize *= 3.0f; //yildun
if (starHDnum == "142105") useSize *= 3.0f; //zeta ursae minoris
if (starHDnum == "148048") useSize *= 3.0f; //eta ursae minoris
*/
//set particle size
#if UNITY_5_3_OR_NEWER
StarParticles[px].startSize = useSize;
#else
StarParticles[px].size = useSize;
#endif
//set particle color
#if UNITY_5_3_OR_NEWER
StarParticles[px].startColor = setColor;
#else
StarParticles[px].color = setColor;
#endif
px++;
}
}
StarSystem.SetParticles(StarParticles,StarParticles.Length);
StarSystem.Emit(StarParticles.Length);
StarSystem.Play();
}
void PopulateStarDataString(){
starDataString = starFile.text;
starDataArray = starDataString.Split("\n"[0]);
}
public bool CheckConstellationStars(String starHDnum){
bool isConstellationStar = false;
//little dipper
if (starHDnum == " 8890") isConstellationStar = true; //polaris
if (starHDnum == "153751") isConstellationStar = true; //urodelus
if (starHDnum == "131873") isConstellationStar = true; //kochab
if (starHDnum == "137422") isConstellationStar = true; //pherkad
if (starHDnum == "166205") isConstellationStar = true; //yildun
if (starHDnum == "142105") isConstellationStar = true; //zeta ursae minoris
if (starHDnum == "148048") isConstellationStar = true; //eta ursae minoris
//big dipper
if (starHDnum == "103287") isConstellationStar = true; //phekda
if (starHDnum == "120315") isConstellationStar = true; //elkeid
if (starHDnum == "116842") isConstellationStar = true; //alcor
if (starHDnum == "106591") isConstellationStar = true; //megrez
if (starHDnum == " 95418") isConstellationStar = true; //merak
if (starHDnum == " 95689") isConstellationStar = true; //dubhe
if (starHDnum == "112185") isConstellationStar = true; //alioth
// orion
if (starHDnum == " 39801") isConstellationStar = true; //betelgeuse
if (starHDnum == " 36861") isConstellationStar = true; //meissa
if (starHDnum == " 35468") isConstellationStar = true; //bellatrix
if (starHDnum == " 34085") isConstellationStar = true; //rigel
if (starHDnum == " 38771") isConstellationStar = true; //saiph
if (starHDnum == " 36486") isConstellationStar = true; //mintaka
if (starHDnum == " 37742") isConstellationStar = true; //alnitak
if (starHDnum == " 37128") isConstellationStar = true; //alnilam
//taurus
if (starHDnum == " 35497") isConstellationStar = true; //elnath
if (starHDnum == " 29139") isConstellationStar = true; //aldebaran
if (starHDnum == " 28305") isConstellationStar = true; //e taur
if (starHDnum == " 28319") isConstellationStar = true; //
if (starHDnum == " 27371") isConstellationStar = true; //
if (starHDnum == " 25204") isConstellationStar = true; //
if (starHDnum == " 21120") isConstellationStar = true; //
if (starHDnum == " 37202") isConstellationStar = true; //
//scorpius
if (starHDnum == "148478") isConstellationStar = true; //
if (starHDnum == "158926") isConstellationStar = true; //
if (starHDnum == "159532") isConstellationStar = true; //
if (starHDnum == "143275") isConstellationStar = true; //
if (starHDnum == "151680") isConstellationStar = true; //
if (starHDnum == "160578") isConstellationStar = true; //
if (starHDnum == "144217") isConstellationStar = true; //
if (starHDnum == "158408") isConstellationStar = true; //
if (starHDnum == "149438") isConstellationStar = true; //
if (starHDnum == "143018") isConstellationStar = true; //
if (starHDnum == "147165") isConstellationStar = true; //
if (starHDnum == "161471") isConstellationStar = true; //
if (starHDnum == "151890") isConstellationStar = true; //
if (starHDnum == "161892") isConstellationStar = true; //
if (starHDnum == "155203") isConstellationStar = true; //
if (starHDnum == "151985") isConstellationStar = true; //
if (starHDnum == "152334") isConstellationStar = true; //
//pegasus
if (starHDnum == "206778") isConstellationStar = true; //
if (starHDnum == "217906") isConstellationStar = true; //
if (starHDnum == "218045") isConstellationStar = true; //
if (starHDnum == " 886") isConstellationStar = true; //
if (starHDnum == "215182") isConstellationStar = true; //
if (starHDnum == "214923") isConstellationStar = true; //
if (starHDnum == "216131") isConstellationStar = true; //
if (starHDnum == "210418") isConstellationStar = true; //
if (starHDnum == "210027") isConstellationStar = true; //
if (starHDnum == "215665") isConstellationStar = true; //
if (starHDnum == "206901") isConstellationStar = true; //
if (starHDnum == "215648") isConstellationStar = true; //
if (starHDnum == "210459") isConstellationStar = true; //
if (starHDnum == "224427") isConstellationStar = true; //
//cassiopeia
if (starHDnum == " 5394") isConstellationStar = true; //
if (starHDnum == " 3712") isConstellationStar = true; //
if (starHDnum == " 432") isConstellationStar = true; //
if (starHDnum == " 8538") isConstellationStar = true; //
if (starHDnum == " 11415") isConstellationStar = true; //
if (starHDnum == " 4514") isConstellationStar = true; //
if (starHDnum == " 4614") isConstellationStar = true; //
if (starHDnum == " 3360") isConstellationStar = true; //
//pisces
if (starHDnum == "219615") isConstellationStar = true; //
if (starHDnum == "220954") isConstellationStar = true; //
if (starHDnum == " 9270") isConstellationStar = true; //
if (starHDnum == "224617") isConstellationStar = true; //
if (starHDnum == "222368") isConstellationStar = true; //
if (starHDnum == " 10761") isConstellationStar = true; //
if (starHDnum == " 12446") isConstellationStar = true; //
if (starHDnum == " 6186") isConstellationStar = true; //
if (starHDnum == "220954") isConstellationStar = true; //
if (starHDnum == "224935") isConstellationStar = true; //
if (starHDnum == " 4656") isConstellationStar = true; //
if (starHDnum == " 10380") isConstellationStar = true; //
if (starHDnum == "217891") isConstellationStar = true; //
if (starHDnum == "222603") isConstellationStar = true; //
if (starHDnum == " 7106") isConstellationStar = true; //
if (starHDnum == " 28") isConstellationStar = true; //
if (starHDnum == " 11559") isConstellationStar = true; //
if (starHDnum == " 7087") isConstellationStar = true; //
if (starHDnum == " 7318") isConstellationStar = true; //
if (starHDnum == " 7964") isConstellationStar = true; //
if (starHDnum == " 9138") isConstellationStar = true; //
if (starHDnum == "224533") isConstellationStar = true; //
//aquarius
if (starHDnum == "204867") isConstellationStar = true; //
if (starHDnum == "209750") isConstellationStar = true; //
if (starHDnum == "216627") isConstellationStar = true; //
if (starHDnum == "213051") isConstellationStar = true; //
if (starHDnum == "218594") isConstellationStar = true; //
if (starHDnum == "216386") isConstellationStar = true; //
if (starHDnum == "198001") isConstellationStar = true; //
if (starHDnum == "212061") isConstellationStar = true; //
if (starHDnum == "220321") isConstellationStar = true; //
if (starHDnum == "213998") isConstellationStar = true; //
if (starHDnum == "216032") isConstellationStar = true; //
if (starHDnum == "211391") isConstellationStar = true; //
if (starHDnum == "219215") isConstellationStar = true; //
if (starHDnum == "219449") isConstellationStar = true; //
if (starHDnum == "209819") isConstellationStar = true; //
if (starHDnum == "219688") isConstellationStar = true; //
//capricornus
if (starHDnum == "192876") isConstellationStar = true; //
if (starHDnum == "192947") isConstellationStar = true; //
if (starHDnum == "193495") isConstellationStar = true; //
if (starHDnum == "194943") isConstellationStar = true; //
if (starHDnum == "197692") isConstellationStar = true; //
if (starHDnum == "198542") isConstellationStar = true; //
if (starHDnum == "204075") isConstellationStar = true; //
if (starHDnum == "205637") isConstellationStar = true; //
if (starHDnum == "206453") isConstellationStar = true; //
if (starHDnum == "207098") isConstellationStar = true; //
if (starHDnum == "206088") isConstellationStar = true; //
if (starHDnum == "203387") isConstellationStar = true; //
if (starHDnum == "200761") isConstellationStar = true; //
if (starHDnum == "196662") isConstellationStar = true; //
if (starHDnum == "195094") isConstellationStar = true; //
//sagittarius
if (starHDnum == "169022") isConstellationStar = true; //
if (starHDnum == "175191") isConstellationStar = true; //
if (starHDnum == "176687") isConstellationStar = true; //
if (starHDnum == "168454") isConstellationStar = true; //
if (starHDnum == "169916") isConstellationStar = true; //
if (starHDnum == "178524") isConstellationStar = true; //
if (starHDnum == "165135") isConstellationStar = true; //
if (starHDnum == "167618") isConstellationStar = true; //
if (starHDnum == "173300") isConstellationStar = true; //
if (starHDnum == "177716") isConstellationStar = true; //
if (starHDnum == "175775") isConstellationStar = true; //
if (starHDnum == "177241") isConstellationStar = true; //
if (starHDnum == "166937") isConstellationStar = true; //
if (starHDnum == "181577") isConstellationStar = true; //
if (starHDnum == "181454") isConstellationStar = true; //
if (starHDnum == "181869") isConstellationStar = true; //
if (starHDnum == "188114") isConstellationStar = true; //
if (starHDnum == "181623") isConstellationStar = true; //
if (starHDnum == "189103") isConstellationStar = true; //
if (starHDnum == "189763") isConstellationStar = true; //
if (starHDnum == "181615") isConstellationStar = true; //
if (starHDnum == "161592") isConstellationStar = true; //
//libra
if (starHDnum == "135742") isConstellationStar = true; //
if (starHDnum == "130841") isConstellationStar = true; //
if (starHDnum == "133216") isConstellationStar = true; //
if (starHDnum == "139063") isConstellationStar = true; //
if (starHDnum == "139365") isConstellationStar = true; //
if (starHDnum == "138905") isConstellationStar = true; //
//virgo
if (starHDnum == "116658") isConstellationStar = true; //
if (starHDnum == "114330") isConstellationStar = true; //
if (starHDnum == "110379") isConstellationStar = true; //
if (starHDnum == "107259") isConstellationStar = true; //
if (starHDnum == "102870") isConstellationStar = true; //
if (starHDnum == "102212") isConstellationStar = true; //
if (starHDnum == "104979") isConstellationStar = true; //
if (starHDnum == "112300") isConstellationStar = true; //
if (starHDnum == "113226") isConstellationStar = true; //
if (starHDnum == "118098") isConstellationStar = true; //
if (starHDnum == "122408") isConstellationStar = true; //
if (starHDnum == "124850") isConstellationStar = true; //
if (starHDnum == "129502") isConstellationStar = true; //
//leo
if (starHDnum == " 87901") isConstellationStar = true; //regulus
if (starHDnum == " 87737") isConstellationStar = true; //
if (starHDnum == " 89484") isConstellationStar = true; //algieba
if (starHDnum == " 89025") isConstellationStar = true; //
if (starHDnum == " 85503") isConstellationStar = true; //
if (starHDnum == " 84441") isConstellationStar = true; //
if (starHDnum == " 97603") isConstellationStar = true; //
if (starHDnum == "102647") isConstellationStar = true; //
if (starHDnum == " 97633") isConstellationStar = true; //
//leo minor
if (starHDnum == " 94264") isConstellationStar = true; //
if (starHDnum == " 90537") isConstellationStar = true; //
if (starHDnum == " 87696") isConstellationStar = true; //
if (starHDnum == " 82635") isConstellationStar = true; //
if (starHDnum == " 92125") isConstellationStar = true; //
if (starHDnum == " 90277") isConstellationStar = true; //
//cancer
if (starHDnum == " 69267") isConstellationStar = true; //
if (starHDnum == " 42911") isConstellationStar = true; //
if (starHDnum == " 74198") isConstellationStar = true; //
if (starHDnum == " 74739") isConstellationStar = true; //
if (starHDnum == " 76756") isConstellationStar = true; //
//gemini
if (starHDnum == " 62509") isConstellationStar = true; //
if (starHDnum == " 60179") isConstellationStar = true; //
if (starHDnum == " 62345") isConstellationStar = true; //
if (starHDnum == " 45542") isConstellationStar = true; //
if (starHDnum == " 58207") isConstellationStar = true; //
if (starHDnum == " 56986") isConstellationStar = true; //
if (starHDnum == " 56537") isConstellationStar = true; //
if (starHDnum == " 52973") isConstellationStar = true; //
if (starHDnum == " 31681") isConstellationStar = true; //
if (starHDnum == " 48737") isConstellationStar = true; //
if (starHDnum == " 54719") isConstellationStar = true; //
if (starHDnum == " 50019") isConstellationStar = true; //
if (starHDnum == " 48329") isConstellationStar = true; //
if (starHDnum == "257937") isConstellationStar = true; //
if (starHDnum == " 44478") isConstellationStar = true; //
//draco
if (starHDnum == "164058") isConstellationStar = true; //
if (starHDnum == "159181") isConstellationStar = true; //
if (starHDnum == "163588") isConstellationStar = true; //
if (starHDnum == "182564") isConstellationStar = true; //
if (starHDnum == "188119") isConstellationStar = true; //
if (starHDnum == "175306") isConstellationStar = true; //
if (starHDnum == "170153") isConstellationStar = true; //
if (starHDnum == "160922") isConstellationStar = true; //
if (starHDnum == "155763") isConstellationStar = true; //
if (starHDnum == "148387") isConstellationStar = true; //
if (starHDnum == "144284") isConstellationStar = true; //
if (starHDnum == "137759") isConstellationStar = true; //
if (starHDnum == "123299") isConstellationStar = true; //
if (starHDnum == "109387") isConstellationStar = true; //
if (starHDnum == "100029") isConstellationStar = true; //
if (starHDnum == " 85819") isConstellationStar = true; //
//----
if (starHDnum == " 4128") isConstellationStar = true; //deneb kaitos
if (starHDnum == " 14386") isConstellationStar = true; //mira
if (starHDnum == " 18884") isConstellationStar = true; //menkar
if (starHDnum == " 12929") isConstellationStar = true; //hamal
return isConstellationStar;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c5d68d87ba1c02a40842d396bcde1aa2
timeCreated: 1461160765
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,159 @@
using UnityEngine;
using System.Collections;
namespace Tenkoku.Core
{
/// <summary>
/// Simple and fast random number generator which can reset to a specific iteration
/// </summary>
public class Random
{
//Initialiser magic values
private const ulong m_A_Init = 181353;
private const ulong m_B_Init = 7;
//Seed
public int m_seed;
//State
public ulong m_stateA, m_stateB;
/// <summary>
/// Contruct and initialise the RNG
/// </summary>
/// <param name="seed"></param>
public Random(int seed = 1)
{
m_seed = seed;
if (m_seed == 0)
{
m_seed = 1;
}
Reset();
}
/// <summary>
/// Reset it to its initial state with the existing seed
/// </summary>
public void Reset()
{
m_stateA = m_A_Init * (uint)m_seed;
m_stateB = m_B_Init * (uint)m_seed;
}
/// <summary>
/// Restet it to a new state with a new seed
/// </summary>
/// <param name="seed">New seed</param>
public void Reset(int seed)
{
m_seed = seed;
if (m_seed == 0)
{
m_seed = 1;
}
Reset();
}
/// <summary>
/// Reset it to the stade defined by the state variables passed in
/// </summary>
public void Reset(ulong stateA, ulong stateB)
{
Debug.Log("Resetting RNG State " + stateA + " " + stateB);
m_stateA = stateA;
m_stateB = stateB;
}
/// <summary>
/// Return the current state for serialisation
/// </summary>
/// <param name="seed">Seed</param>
/// <param name="stateA">State A</param>
/// <param name="stateB">State B</param>
public void GetState(out int seed, out ulong stateA, out ulong stateB)
{
seed = m_seed;
stateA = m_stateA;
stateB = m_stateB;
}
//Check here for wrapper functions
//https://github.com/tucano/UnityRandom/blob/master/lib/MersenneTwister.cs
/// <summary>
/// Get the next value
/// </summary>
/// <returns>A value between zero and one inclusive</returns>
public float Next()
{
ulong x = m_stateA;
ulong y = m_stateB;
m_stateA = y;
x ^= x << 23;
x ^= x >> 17;
x ^= y ^ (y >> 26);
m_stateB = x;
return (float)(x + y) / (float)ulong.MaxValue;
}
/// <summary>
/// Return the next int
/// </summary>
/// <returns></returns>
public int NextInt()
{
return (int)(Next() * int.MaxValue);
}
/// <summary>
/// Get the next value and scale it between the min and max values supplied inclusive
/// </summary>
/// <param name="min">Minimum value</param>
/// <param name="max">Maximum value</param>
/// <returns>Next value scaled beteen the range supplied</returns>
public float Next(float min, float max)
{
//float xx = min + (Next() * (max - min));
//Debug.Log(string.Format("{0:0.0000}", xx));
//return xx;
return min + (Next() * (max - min));
}
/// <summary>
/// Get the next value and scale it between the min and max values supplied inclusive
/// </summary>
/// <param name="min">Minimum value</param>
/// <param name="max">Maximum value</param>
/// <returns>Next value scaled beteen the range supplied</returns>
public int Next(int min, int max)
{
if (min == max)
{
return min;
}
return (int)Next((float)min, (float)max+0.999f);
}
/// <summary>
/// Get the next value as a vector
/// </summary>
/// <returns>Next value as a vector in ranges 0..1</returns>
public Vector3 NextVector()
{
return new Vector3(Next(), Next(), Next());
}
/// <summary>
/// Get the next value as a vector
/// </summary>
/// <param name="min">Minimum value</param>
/// <param name="max">Maximum value</param>
/// <returns></returns>
public Vector3 NextVector(float min, float max)
{
return new Vector3(Next(min, max), Next(min, max), Next(min, max));
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 085bcf3f6a9e300438b6fb39713d9984
timeCreated: 1461636898
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,898 @@
using System;
using UnityEngine;
using System.Collections;
namespace Tenkoku.Core
{
[ExecuteInEditMode]
public class TenkokuCalculations : MonoBehaviour
{
// NOTE: All these calculations are based off of forumlas published by
// Paul Schylter, in his paper 'computing planetary positions' which can
// be viewed here: http://www.stjarnhimlen.se/comp/ppcomp.html
// I've taken liberties with his procedure where I thought appropriate
// or where I found it best suits the greater Tenkoku system.
//PUBLIC VARIABLES
[HideInInspector]
public int dstOffset = 0;
[HideInInspector]
public int tzOffset = 0;
[HideInInspector]
public int yamt = 0;
[HideInInspector]
public float eclipticoffset = 0.0f;
[HideInInspector]
public float day = 0.0f; //day number
[HideInInspector]
public int y = 2000; //year
[HideInInspector]
public int m = 1; //month
[HideInInspector]
public int D = 1; //date?
[HideInInspector]
public float UT = 1.0f; //Universal Time
[HideInInspector]
public float LT = 1.0f; //Universal Time
[HideInInspector]
public float local_latitude;
[HideInInspector]
public float local_longitude;
[HideInInspector]
public float Epoch = 2000.0f;
[HideInInspector]
public int iteration = 1000;
[HideInInspector]
public float moonPos;
[HideInInspector]
public float azimuth;
[HideInInspector]
public float altitude;
[HideInInspector]
public float moonApogee = 1.0f;
[HideInInspector]
public float ecl;
//PRIVATE VARIABLES
private static float pi = 3.14159265359f;
//private static float half_pi = 1.57079632679f;
private static float _pi180 = (pi/180.0f);
private static float _180pi = (180.0f/pi);
private static float RADEG = (180.0f/pi);
private static float DEGRAD = (pi/180.0f);
private float useUT = 1.0f;
private float use_latitude;
private float use_longitude;
private float N;
private float i;
private float w;
private float a;
private float e;
private float M;
private float v;
private float E;
private float xr;
private float yr;
private float zr;
private float xhor;
private float yhor;
private float zhor;
private float r;
private float rs;
private float lonsun;
private float lonsunM;
private float xs;
private float ys;
private float xe;
private float ye;
private float ze;
private float RA;
private float Dec;
//private float rg;
private float GMST0;
private float Ls;
private float LST;
private float E0;
private float E1;
private float xg;
private float yg;
private float zg;
private float xh;
private float yh;
private float zh;
private float lonecl;
private float latecl;
private float lon_corr;
private float Mj;
private float Mo;
private float Mu;
private float Ms;
private float Mm;
private float Nm;
//private float ws;
private float wm;
private float Lm;
private float Dm;
private float F;
private float LHA;
private float lN;
private float li;
private float lw;
private float la;
private float le;
private float lM;
private float xv;
private float yv;
private int eL;
private float ur;
private int mA;
//private float returnValue = 0f;
public float GetElementData( int checkElement, int returnElement){
//##### CALCULATE ORBITAL ELEMENTS #####
//checkElements are decoded as:
//sunstatic = 1
//sun = 2
//moon = 3
//mercury = 4
//venus = 5
//mars = 6
//jupiter = 7
//saturn = 8
//uranus = 9
//neptune = 10
//The primary orbital elements are here denoted as:
//N = 1. longitude of the ascending node
//i = 2. inclination to the ecliptic (plane of the Earth's orbit)
//w = 3. argument of perihelion
//a = 4. semi-major axis, or mean distance from Sun
//e = 5. eccentricity (0=circle, 0-1=ellipse, 1=parabola)
//M = 6. mean anomaly (0 at perihelion; increases uniformly with time)
//Related orbital elements are:
//w1 = N + w = longitude of perihelion
//L = M + w1 = mean longitude
//q = a*(1-e) = perihelion distance
//Q = a*(1+e) = aphelion distance
//P = a ^ 1.5 = orbital period (years if a is in AU, astronomical units)
//T = Epoch_of_M - (M(deg)/360_deg) / P = time of perihelion
//v = true anomaly (angle between position and perihelion)
//E = eccentric anomaly
//Orbital elements of the Sun:
if (checkElement == 1){
lN = 0.0f;
li = 0.0f;
lw = 282.9404f + 4.70935E-5f * day;
la = 1.000000f; //(AU)
le = 0.016709f - 1.151E-9f * day;
lM = 356.0470f + 0.9856f * day;
}
if (checkElement == 2){
lN = 0.0f;
li = 0.0f;
lw = 282.9404f + 4.70935E-5f * day;
la = 1.000000f; //(AU)
le = 0.016709f - 1.151E-9f * day;
lM = 356.0470f + 0.9856f * day;
}
//Orbital elements of the Moon:
if (checkElement == 3){
if (moonPos >= 0){
day = 5574f + ((m-4)*30f) - (27.31f*(moonPos/360));
}
lN = 125.1228f - 0.0529538083f * day;
li = 5.1454f;
lw = 318.0634f + 0.1643573223f * day;
la = 60.2666f; //(Earth radii)
le = 0.054900f;
lM = 115.3654f + 13.0649929509f * day;
}
//Orbital elements of Mercury:
if (checkElement == 4){
lN = 48.3313f + 3.24587E-5f * day;
li = 7.0047f + 5.00E-8f * day;
lw = 29.1241f + 1.01444E-5f * day;
la = 0.387098f; //(AU)
le = 0.205635f + 5.59E-10f * day;
lM = 168.6562f + 4.0923344368f * day;
}
//Orbital elements of Venus:
if (checkElement == 5){
lN = 76.6799f + 2.46590E-5f * day;
li = 3.3946f + 2.75E-8f * day;
lw = 54.8910f + 1.38374E-5f * day;
la = 0.723330f; //(AU)
le = 0.006773f - 1.302E-9f * day;
lM = 48.0052f + 1.6021302244f * day;
}
//Orbital elements of Mars:
if (checkElement == 6){
lN = 49.5574f + 2.11081E-5f * day;
li = 1.8497f - 1.78E-8f * day;
lw = 286.5016f + 2.92961E-5f * day;
la = 1.523688f; //(AU)
le = 0.093405f + 2.516E-9f * day;
lM = 18.6021f + 0.5240207766f * day;
}
//Orbital elements of Jupiter:
if (checkElement == 7){
lN = 100.4542f + 2.76854E-5f * day;
li = 1.3030f - 1.557E-7f * day;
lw = 273.8777f + 1.64505E-5f * day;
la = 5.20256f; //(AU)
le = 0.048498f + 4.469E-9f * day;
lM = 19.8950f + 0.0830853001f * day;
}
//Orbital elements of Saturn:
if (checkElement == 8){
lN = 113.6634f + 2.38980E-5f * day;
li = 2.4886f - 1.081E-7f * day;
lw = 339.3939f + 2.97661E-5f * day;
la = 9.55475f; //(AU)
le = 0.055546f - 9.499E-9f * day;
lM = 316.9670f + 0.0334442282f * day;
}
//Orbital elements of Uranus:
if (checkElement == 9){
lN = 74.0005f + 1.3978E-5f * day;
li = 0.7733f + 1.9E-8f * day;
lw = 96.6612f + 3.0565E-5f * day;
la = 19.18171f - 1.55E-8f * day; //(AU)
le = 0.047318f + 7.45E-9f * day;
lM = 142.5905f + 0.011725806f * day;
}
//Orbital elements of Neptune:
if (checkElement == 10){
lN = 131.7806f + 3.0173E-5f * day;
li = 1.7700f - 2.55E-7f * day;
lw = 272.8461f - 6.027E-6f * day;
la = 30.05826f + 3.313E-8f * day; //(AU)
le = 0.008606f + 2.15E-9f * day;
lM = 260.2471f + 0.005995147f * day;
}
float returnValue = 0f;
if (returnElement == 1) returnValue = lN;
if (returnElement == 2) returnValue = li;
if (returnElement == 3) returnValue = lw;
if (returnElement == 4) returnValue = la;
if (returnElement == 5) returnValue = le;
if (returnElement == 6) returnValue = lM;
return returnValue;
}
//function CalculateNode(checkElement : String) : String {
public void CalculateNode(int checkElement){
//##### CALCULATE TIME SCALE #####
// d = day number
// y = year
// m = month
// D = date
// UT = UT in hours+decimals
useUT = UT - tzOffset + dstOffset;
use_latitude = local_latitude;
use_longitude = local_longitude;
day = 367 * y - 7 * (y+(m+9)/12) / 4 + 275 * m / 9 + D - 730530;
day += useUT/24.0f;
ecl = 23.4393f - 3.563E-7f * day;
N = GetElementData(checkElement, 1);
i = GetElementData(checkElement, 2);
w = GetElementData(checkElement, 3);
a = GetElementData(checkElement, 4);
e = GetElementData(checkElement, 5);
M = GetElementData(checkElement, 6);
//solve M
M = Rev(M);
//##### CALCULATE SUN POSITION #####
if (checkElement == 2 || checkElement == 1){
//M -= 0.0006; //fudge!
// First, compute the eccentric anomaly E from the mean anomaly M and from
// the eccentricity e (E and M in degrees):
E = M + e*_180pi * Sind(M) * ( 1 + e * Cosd(M) );
// Then compute the Sun's distance r and its true anomaly v from:
xv = Cosd(E) - e;
yv = (Mathf.Sqrt(1 - (e*e)) * Sind(E));
r = Mathf.Sqrt( xv*xv + yv*yv );
v = (Mathf.Atan2(yv,xv)*_180pi);
rs = r;
// compute the Sun's true longitude:
lonsun = (v + w);
// compute the Sun's mean longitude:
lonsunM = (w + M);
lonsun = Rev(lonsun);
lonsunM = Rev(lonsunM);
// Convert lonsun,r to ecliptic rectangular geocentric coordinates xs,ys:
xs = r * Cosd(lonsun);
ys = r * Sind(lonsun);
// (since the Sun always is in the ecliptic plane, zs is of course zero).
// xs,ys is the Sun's position in a coordinate system in the plane of the ecliptic.
// To convert this to equatorial, rectangular, geocentric coordinates, compute:
xe = xs;
ye = ys * Cosd(ecl);
ze = ys * Sind(ecl);
// Finally, compute the Sun's Right Ascension (RA) and Declination (Dec):
RA = Mathf.Atan2(ye,xe);
Dec = Mathf.Atan2(ze,Mathf.Sqrt(xe*xe+ye*ye));
//##### SIDEREAL TIME #####
//We need the Sun's mean longitude, Ls, which can be computed from the Sun's v and w as follows:
//Ls = (v + w);
// this is lonsun as calculated above
// The GMST0 is easily computed from Ls (divide by 15 if you want GMST0 in hours rather
// than degrees), GMST is then computed by adding the UT, and finally the LST is computed
// by adding your local longitude (east longitude is positive, west negative).
// Note that "time" is given in hours while "angle" is given in degrees. The two are related
// to one another due to the Earth's rotation: one hour is here the same as 15 degrees.
// Before adding or subtracting a "time" and an "angle", be sure to convert them to the same
// unit, e.g. degrees by multiplying the hours by 15 before adding/subtracting:
GMST0 = (lonsunM/15.0f)+12.0f;
LST = GMST0 + useUT + (use_longitude/15.0f);
if (LST > 24){
LST -= 24;
} else if (LST < 0){
LST += 24;
}
LT = LST;
// The formulae above are written as if times are expressed in degrees. If we instead
// assume times are given in hours and angles in degrees, and if we explicitly write
// out the conversion factor of 15, we get:
//GMST0 = 15 * (Ls + 180.0);
//GMST = GMST0 + UT;
//LST = GMST + (local_longitude/15);
//##### COMPUTE SUN'S HOUR ANGLE #####
LHA = LST - ((RA*RADEG)/15.0f);
// Convert to Rectangular Coordinates
xr = Cosd(LHA*15.0f) * Mathf.Cos(Dec);
yr = Sind(LHA*15.0f) * Mathf.Cos(Dec);
zr = Mathf.Sin(Dec);
// Rotate Coordinates
xhor = xr * Sind(use_latitude) - zr * Cosd(use_latitude);
yhor = yr;
zhor = xr * Cosd(use_latitude) + zr * Sind(use_latitude);
//Compute azimuth and altitude
azimuth = Mathf.Atan2(yhor,xhor)*RADEG + 180.0f;
altitude = Asind(zhor);
} else {
//Solve N
N = Rev(N);
//##### POSITION OF THE MOON AND PLANETS #####
// First, compute the eccentric anomaly, E, from M, the mean anomaly, and e, the eccentricity.
// As a first approximation, do (E and M in degrees):
E = M + e*_180pi * Sind(M) * ( 1 + e * Cosd(M) );
// If e, the eccentricity, is less than about 0.05-0.06, this approximation is sufficiently accurate.
// If the eccentricity is larger, set E0=E and then use this iteration formula (E and M in degrees):
//if (e > 0.05){
E0 = E;
// For each new iteration, replace E0 with E1. Iterate until E0 and E1 are sufficiently close together
// (about 0.001 degrees). For comet orbits with eccentricites close to one, a difference of less than
// 1E-4 or 1E-5 degrees should be required.
// If this iteration formula won't converge, the eccentricity is probably too close to one. Then you
// should instead use the formulae for near-parabolic or parabolic orbits.
for (eL = 0; eL < iteration; eL++){
E1 = E0 - (E0 - _180pi * e * Sind(E0) - M) / ( 1.0f - e * Cosd(E0));
//if (Mathf.Approximately(E0,E1)){
if (Mathf.Abs(E1)-Mathf.Abs(E0) < 0.005f){
break;
} else {
E0 = E1;
}
}
E = E1;
//}
// Now compute the planet's distance and true anomaly:
xv = a * (Cosd(E) - e);
yv = a * (Mathf.Sqrt(1.0f - e*e) * Sind(E));
r = Mathf.Sqrt(xv*xv+yv*yv);
v = Atan2(yv,xv)*RADEG;
v = Rev(v);
//##### THE POSITION IN SPACE #####
//Compute the planet's position in 3-dimensional space:
xh = r * (Cosd(N) * Cosd(v+w) - Sind(N) * Sind(v+w) * Cosd(i));
yh = r * (Sind(N) * Cosd(v+w) + Cosd(N) * Sind(v+w) * Cosd(i));
zh = r * (Sind(v+w) * Sind(i));
// For the Moon, this is the geocentric (Earth-centered) position in the ecliptic
// coordinate system. For the planets, this is the heliocentric (Sun-centered) position,
// also in the ecliptic coordinate system. If one wishes, one can compute the ecliptic
// longitude and latitude (this must be done if one wishes to correct for perturbations,
// or if one wants to precess the position to a standard epoch):
lonecl = Atan2(yh,xh)*RADEG;
latecl = Atan2(zh,Mathf.Sqrt(xh*xh+yh*yh))*RADEG;
// As a check one can compute sqrt(xh*xh+yh*yh+zh*zh), which of course should equal r
// (except for small round-off errors).
//##### PRECESSION #####
// If one wishes to compute the planet's position for some standard epoch, such as
// 1950.0 or 2000.0 (e.g. to be able to plot the position on a star atlas), one must add
// the correction below to lonecl. If a planet's and not the Moon's position is computed,
// one must also add the same correction to lonsun, the Sun's longitude. The desired Epoch
// is expressed as the year, possibly with a fraction.
//Epoch = y;
lon_corr = 3.82394E-5f * (365.2422f * (Epoch - 2000.0f) - day);
lonecl = Rev(lonecl);
// If one wishes the position for today's epoch (useful when computing rising/setting times
// and the like), no corrections need to be done.
//##### PERTURBATIONS OF THE MOON #####
if (checkElement == 3){
// If the position of the Moon is computed, and one wishes a better accuracy than about 2 degrees,
// the most important perturbations has to be taken into account. If one wishes 2 arc minute accuracy,
// all the following terms should be accounted for. If less accuracy is needed, some of the smaller
// terms can be omitted.
//First compute data:
Ms = Rev(GetElementData(2, 6)); // Mean Anomaly of the Sun
Mm = Rev(GetElementData(3, 6)); // Mean Anomaly of the Moon
Nm = Rev(GetElementData(3, 1)); // Longitude of the Moon's node
//ws = Rev(GetElementData(2, 3)); // Argument of perihelion for the Sun
wm = Rev(GetElementData(3, 3)); // Argument of perihelion for the Moon
Ls = lonsunM; // Mean Longitude of the Sun (Ns=0)
Lm = Rev(Mm + wm + Nm); // Mean longitude of the Moon
Dm = Rev(Lm - Ls); // Mean elongation of the Moon
F = Rev(Lm - Nm); // Argument of latitude for the Moon
//Add these terms to the Moon's longitude (degrees):
lonecl -= 1.274f * Sind(Mm - (2.0f*Dm)); // (the Evection)
lonecl += 0.658f * Sind(2.0f*Dm); // (the Variation)
lonecl -= 0.186f * Sind(Ms); // (the Yearly Equation)
lonecl -= 0.059f * Sind((2.0f*Mm) - (2.0f*Dm));
lonecl -= 0.057f * Sind(Mm - (2.0f*Dm) + Ms);
lonecl += 0.053f * Sind(Mm + (2.0f*Dm));
lonecl += 0.046f * Sind((2.0f*Dm) - Ms);
lonecl += 0.041f * Sind(Mm - Ms);
lonecl -= 0.035f * Sind(Dm); // (the Parallactic Equation)
lonecl -= 0.031f * Sind(Mm + Ms);
lonecl -= 0.015f * Sind((2.0f*F) - (2.0f*Dm));
lonecl += 0.011f * Sind(Mm - (4.0f*Dm));
//Add these terms to the Moon's latitude (degrees):
latecl -= 0.173f * Sind(F - (2.0f*Dm));
latecl -= 0.055f * Sind((Mm) - F - (2.0f*Dm));
latecl -= 0.046f * Sind((Mm) + F - (2.0f*Dm));
latecl += 0.033f * Sind(F + (2.0f*Dm));
latecl += 0.017f * Sind((2.0f*Mm) + F);
// All perturbation terms that are smaller than 0.01 degrees in longitude or latitude and
// smaller than 0.1 Earth radii in distance have been omitted here. A few of the largest
// perturbation terms even have their own names! The Evection (the largest perturbation) was
// discovered already by Ptolemy a few thousand years ago (the Evection was one of Ptolemy's epicycles).
// The Variation and the Yearly Equation were both discovered by Tycho Brahe in the 16'th century.
// The computations can be simplified by omitting the smaller perturbation terms. The error introduced
// by this seldom exceeds the sum of the amplitudes of the 4-5 largest omitted terms. If one only
// computes the three largest perturbation terms in longitude and the largest term in latitude, the
// error in longitude will rarley exceed 0.25 degrees, and in latitude 0.15 degrees.
}
//##### PERTURBATIONS OF JUPITER, SATURN, and URANUS #####
if (checkElement == 7 || checkElement == 8 || checkElement == 9){
// The only planets having perturbations larger than 0.01 degrees are Jupiter, Saturn and Uranus.
// First compute:
// Mj Mean anomaly of Jupiter
// Mo Mean anomaly of Saturn
// Mu Mean anomaly of Uranus (needed for Uranus only)
Mj = GetElementData(7, 6);
Mo = GetElementData(8, 6);
Mu = GetElementData(9, 6);
//Perturbations for Jupiter. Add these terms to the longitude:
if (checkElement == 7){
lonecl -= 0.332f * Mathf.Sin(2*Mj - 5*Mo - 67.6f);
lonecl -= 0.056f * Mathf.Sin(2*Mj - 2*Mo + 21.0f);
lonecl += 0.042f * Mathf.Sin(3*Mj - 5*Mo + 21.0f);
lonecl -= 0.036f * Mathf.Sin(Mj - 2*Mo);
lonecl += 0.022f * Mathf.Cos(Mj - Mo);
lonecl += 0.023f * Mathf.Sin(2*Mj - 3*Mo + 52.0f);
lonecl -= 0.016f * Mathf.Sin(Mj - 5*Mo - 69.0f);
}
//Perturbations for Saturn. Add these terms to the longitude:
if (checkElement == 8){
lonecl += 0.812f * Mathf.Sin(2*Mj - 5*Mo - 67.6f);
lonecl -= 0.229f * Mathf.Cos(2*Mj - 4*Mo - 2.0f);
lonecl += 0.119f * Mathf.Sin(Mj - 2*Mo - 3.0f);
lonecl += 0.046f * Mathf.Sin(2*Mj - 6*Mo - 69.0f);
lonecl += 0.014f * Mathf.Sin(Mj - 3*Mo + 32.0f);
//For Saturn: also add these terms to the latitude:
latecl -= 0.020f * Mathf.Cos(2*Mj - 4*Mo - 2.0f);
latecl += 0.018f * Mathf.Sin(2*Mj - 6*Mo - 49.0f);
}
//Perturbations for Uranus: Add these terms to the longitude:
if (checkElement == 9){
lonecl += 0.040f * Mathf.Sin(Mo - 2*Mu + 6.0f);
lonecl += 0.035f * Mathf.Sin(Mo - 3*Mu + 33.0f);
lonecl -= 0.015f * Mathf.Sin(Mj - Mu + 20.0f);
}
// The "great Jupiter-Saturn term" is the largest perturbation for both Jupiter and Saturn.
// Its period is 918 years, and its amplitude is 0.332 degrees for Jupiter and 0.812 degrees
// for Saturn. These is also a "great Saturn-Uranus term", period 560 years, amplitude 0.035
// degrees for Uranus, less than 0.01 degrees for Saturn (and therefore omitted). The other
// perturbations have periods between 14 and 100 years. One should also mention the
// "great Uranus-Neptune term", which has a period of 4220 years and an amplitude of about
// one degree. It is not included here, instead it is included in the orbital elements of
// Uranus and Neptune.
// For Mercury, Venus and Mars we can ignore all perturbations. For Neptune the only significant
// perturbation is already included in the orbital elements, as mentioned above, and therefore no
// further perturbation terms need to be accounted for.
}
//##### GEOCENTRIC (EARTH-CENTERED) COORDINATES #####
// Now we have computed the heliocentric (Sun-centered) coordinate of the planet, and we have
// included the most important perturbations. We want to compute the geocentric (Earth-centerd)
// position. We should convert the perturbed lonecl, latecl, r to (perturbed) xh, yh, zh:
lonecl += lon_corr;
lonsun += lon_corr;
ur = r;
if (checkElement == 3) ur = 1.0f;
xh = ur * Cosd(lonecl) * Cosd(latecl);
yh = ur * Sind(lonecl) * Cosd(latecl);
zh = ur * Sind(latecl);
// If we are computing the Moon's position, this is already the geocentric position, and thus we
// simply set xg=xh, yg=yh, zg=zh. Otherwise we must also compute the Sun's position:
// convert lonsun, rs (where rs is the r computed here) to xs, ys:
xs = rs * Cosd(lonsun);
ys = rs * Sind(lonsun);
if (checkElement == 3){
xs = 0.0f;
ys = 0.0f;
}
// (Of course, any correction for precession should be added to lonecl and lonsun before
// converting to xh,yh,zh and xs,ys).
// Now convert from heliocentric to geocentric position:
xg = xh + xs;
yg = yh + ys;
zg = zh;
//We now have the planet's geocentric (Earth centered) position in rectangular, ecliptic coordinates.
//##### EQUATORIAL COORDINATES #####
// Let's convert our rectangular, ecliptic coordinates to rectangular, equatorial coordinates:
// simply rotate the y-z-plane by ecl, the angle of the obliquity of the ecliptic:
xe = xg;
ye = yg * Cosd(ecl) - zg * Sind(ecl);
ze = yg * Sind(ecl) + zg * Cosd(ecl);
// Finally, compute the planet's Right Ascension (RA) and Declination (Dec):
RA = Atan2(ye,xe);
Dec = Atan2(ze,Mathf.Sqrt(xe*xe+ye*ye));
// Compute the geocentric distance:
//rg = Mathf.Sqrt(xe*xe+ye*ye+ze*ze); // or use Mathf.Sqrt(xg*xg+yg*yg+zg*zg)
if (checkElement == 3){
//Add these terms to the Moon's distance (Earth radii):
r -= 0.58f * Cosd((Mm) - (2.0f*Dm*RADEG));
r -= 0.46f * Cosd(2.0f*Dm);
}
//This completes our computation of the equatorial coordinates.
/*
//##### MOON TOPOCENTRIC POSITION #####
if (checkElement == "moon"){
// The Moon's position, as computed earlier, is geocentric, i.e. as seen by an
// imaginary observer at the center of the Earth. Real observers dwell on the surface
// of the Earth, though, and they will see a different position - the topocentric position.
// This position can differ by more than one degree from the geocentric position. To compute
// the topocentric positions, we must add a correction to the geocentric position.
// Let's start by computing the Moon's parallax, i.e. the apparent size of the (equatorial)
// radius of the Earth, as seen from the Moon:
mpar = Mathf.Asin(1.0/r);
// where r is the Moon's distance in Earth radii. It's simplest to apply the correction
// in horizontal coordinates (azimuth and altitude): within our accuracy aim of 1-2 arc minutes,
// no correction need to be applied to the azimuth. One need only apply a correction to the
// altitude above the horizon:
//alt_topoc = alt_geoc - mpar * Mathf.Cos(alt_geoc); <-- not sure if necessary,
// Sometimes one need to correct for topocentric position directly in equatorial coordinates
// though, e.g. if one wants to draw on a star map how the Moon passes in front of the Pleiades,
// as seen from some specific location. Then we need to know the Moon's geocentric Right Ascension
// and Declination (RA, Decl), the Local Sidereal Time (LST), and our latitude (lat).
// Our astronomical latitude (lat) must first be converted to a geocentric latitude (gclat), and
// distance from the center of the Earth (rho) in Earth equatorial radii. If we only want an
// approximate topocentric position, it's simplest to pretend that the Earth is a perfect sphere,
// and simply set:
//gclat = lat, rho = 1.0 <--- nope, let's go all the way :)
//However, if we do wish to account for the flattening of the Earth, we instead compute:
gclat = use_latitude - 0.1924 * Sind(2.0*use_latitude);
rho = 0.99833 + 0.00167 * Cosd(2.0*use_latitude);
// Next we compute the Moon's geocentric Hour Angle (HA) from the Moon's geocentric RA.
// First we must compute LST as described in 5b above, then we compute HA as:
//HA = LST - RA;
HA = (LST*15.0) - ((RA * RADEG));
//We also need an auxiliary angle, g:
g = Mathf.Atan(Tand(gclat) / Cosd(HA));
// Now we're ready to convert the geocentric Right Ascention and Declination (RA, Dec)
// to their topocentric values (topRA, topDecl):
topRA = RA - mpar * rho * Cosd(gclat) * Sind(HA) / Cosd(Dec);
if (gclat != 0.0){
topDecl = Dec - (mpar * rho * Sind(gclat) * Sind((g) - (Dec*RADEG)) / Sind(g));
} else {
// (Note that if decl is exactly 90 deg, cos(Dec) becomes zero and we get a division by zero
// when computing topRA, but that formula breaks down only very close to the celestial poles
// anyway and we never see the Moon there. Also if gclat is precisely zero, g becomes zero too,
// and we get a division by zero when computing topDecl. In that case, replace the formula for
// topDecl with:
topDecl = Dec - (mpar * rho * Sind(-Dec) * Cosd(HA));
}
// which is valid for gclat equal to zero; it can also be used for gclat extremely close to zero).
//This correction to topocentric position can also be applied to the Sun and the planets.
// But since they're much farther away, the correction becomes much smaller. It's largest for Venus
// at inferior conjunction, when Venus' parallax is somewhat larger than 32 arc seconds. Within our
// aim of obtaining a final accuracy of 1-2 arc minutes, it might barely be justified to correct
// to topocentric position when Venus is close to inferior conjunction, and perhaps also when Mars
// is at a favourable opposition. But in all other cases this correction can safely be ignored
// within our accuracy aim. We only need to worry about the Moon in this case.
// If you want to compute topocentric coordinates for the planets too, you do it the same way as
// for the Moon, with one exception: the Moon's parallax is replaced by the parallax of the planet
// (ppar), as computed from this formula:
//ppar = (8.794/3600)_deg / r <--- we don't need this, I've commented it out.
// where r is the distance of the planet from the Earth, in astronomical units.
//Finally reassign position data
RA = topRA;
Dec = topDecl;
//assign specific variables
moonApogee = (r-57.517902)/5.97789;
}
*/
//##### POSITION OF PLUTO #####
// wait, wait wait! What about Pluto? Despite the recent controversial declassification
// of Pluto from being a "planet" planet, to being a "dwarf-planet" planet, that has nothing to do
// with the reasoning of why it isn't included here in these calculations!
// It simply is not visible to the human eye, and therefore I found it unnecessary to include in Tenkoku.
// Also the calculations for the positioning of Pluto have never been accurately described, as the other
// planets have been. What exists now is simply an analytic "hedge" and loses a lot of accuracy over
// a few hundred years. All of this is a moot point though, since it isn't actually visible.
}
//##### COMPUTE HOUR ANGLE #####
LHA = LST - ((RA*RADEG)/15.0f);
// Convert to Rectangular Coordinates
xr = Cosd(LHA*15.0f) * Mathf.Cos(Dec);
yr = Sind(LHA*15.0f) * Mathf.Cos(Dec);
zr = Mathf.Sin(Dec);
// Rotate Coordinates
xhor = xr * Sind(use_latitude) - zr * Cosd(use_latitude);
yhor = yr;
zhor = xr * Cosd(use_latitude) + zr * Sind(use_latitude);
//Compute azimuth and altitude
azimuth = Mathf.Atan2(yhor,xhor)*RADEG + 180.0f;
altitude = Asind(zhor);
}
public float Sind (float x){
return Mathf.Sin((x)*DEGRAD);
}
public float Cosd (float x){
return Mathf.Cos((x)*DEGRAD);
}
public float Tand (float x){
return Mathf.Tan((x)*DEGRAD);
}
public float Asind (float x){
return (RADEG*Mathf.Asin(x));
}
public float Acosd (float x){
return (RADEG*Mathf.Acos(x));
}
public float Atand (float x) {
return (RADEG*Mathf.Atan(x));
}
public float Atan2d (float x, float y) {
return (RADEG*Mathf.Atan2((y),(x)));
}
public float Rev( float x){
return x - Mathf.Floor(x/360.0f)*360.0f;
}
public float Cbrt( float x ) {
if ( x > 0.0f ){
x = Mathf.Exp( Mathf.Log(x) / 3.0f );
} else if ( x < 0.0f ){
x = -Mathf.Pow(-x,(1.0f/3.0f));
} else {
x = 0.0f;
}
return x;
}
public float Atan2( float y, float x ) {
if (x > 0.0f){
x = Mathf.Atan(y/x);
} else if (x < 0.0f){
x = Mathf.Atan(y/x) + (180.0f*_pi180);
}else if (x == 0.0f){
x = Mathf.Sign(y) * (90.0f*_pi180);
}
return x;
}
public float SolveAngle( float deg ) {
for (mA = 0; mA < iteration; mA++){
if (deg < 0.0f){
deg += 360.0f;
} else {
break;
}
}
for (mA = 0; mA < iteration; mA++){
if (deg > 360.0f){
deg -= 360.0f;
} else {
break;
}
}
return deg;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 15a22e9446401c34f85c82ea90b4227c
timeCreated: 1461353312
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,189 @@
using System;
using UnityEngine;
using System.Collections;
namespace Tenkoku.Core
{
[ExecuteInEditMode]
public class TenkokuCameraTools : MonoBehaviour
{
//Public Variables
public enum tenCamToolType{sky,skybox,particles,none};
public tenCamToolType cameraType;
public RenderTexture renderTexDiff;
//public Material skyMaterial;
//Private Variables
private Tenkoku.Core.TenkokuModule tenkokuModuleObject;
//private Renderer surfaceRenderer;
private Camera cam;
private Transform camTrans;
private Camera copyCam;
private Transform copyCamTrans;
private Matrix4x4 camMatrix;
//private float updateTimer = 0.0f;
//private int currResolution = 256;
//private bool doUpdate = false;
void Start () {
if (Application.isPlaying){
//tenkokuModuleObject = GameObject.Find("Tenkoku DynamicSky").gameObject.GetComponent<Tenkoku.Core.TenkokuModule>() as Tenkoku.Core.TenkokuModule;
tenkokuModuleObject = (Tenkoku.Core.TenkokuModule) FindObjectOfType(typeof(Tenkoku.Core.TenkokuModule));
cam = gameObject.GetComponent<Camera>() as Camera;
camTrans = gameObject.GetComponent<Transform>() as Transform;
if (tenkokuModuleObject != null){
copyCam = tenkokuModuleObject.mainCamera.GetComponent<Camera>();
copyCamTrans = tenkokuModuleObject.mainCamera.GetComponent<Transform>();
}
}
//BuildTexture();
//RenderSettings.skybox = skyMaterial;
}
//void Update () {
// if (!Application.isPlaying){
// RenderSettings.skybox = skyMaterial;
// }
//}
void LateUpdate () {
/*
if (!Application.isPlaying){
if (skyMaterial != null){
if (cameraType == tenCamToolType.sky){
RenderSettings.skybox = skyMaterial;
}
}
}
*/
if (Application.isPlaying){
/*
if (skyMaterial != null){
if (cameraType == tenCamToolType.sky){
if (RenderSettings.skybox == null){
RenderSettings.skybox = skyMaterial;
}
}
}
*/
//update camera tracking when necessary
if (tenkokuModuleObject.useCameraCam != null){
copyCam = tenkokuModuleObject.useCameraCam;//.GetComponent<Camera>();
if (tenkokuModuleObject.useCamera != null){
copyCamTrans = tenkokuModuleObject.useCamera;
}
CameraUpdate();
}
}
}
void CameraUpdate () {
if (copyCam != null && cam != null){
//set camera settings
cam.enabled = true;
camTrans.position = copyCamTrans.position;
camTrans.rotation = copyCamTrans.rotation;
cam.projectionMatrix = copyCam.projectionMatrix;
cam.fieldOfView = copyCam.fieldOfView;
cam.renderingPath = copyCam.actualRenderingPath;
cam.farClipPlane = copyCam.farClipPlane;
if (renderTexDiff != null){
//pass texture to shader
if (cameraType == tenCamToolType.sky){
if (tenkokuModuleObject.atmosphereModelTypeIndex == 0){
#if UNITY_5_6_OR_NEWER
cam.allowHDR = false;
#else
cam.hdr = false;
#endif
}
if (tenkokuModuleObject.atmosphereModelTypeIndex == 1){
#if UNITY_5_6_OR_NEWER
cam.allowHDR = true;
#else
cam.hdr = true;
#endif
}
//surfaceRenderer.material.SetTexture("_Tenkoku_SkyTex2",renderTexDiff);
}
//pass texture to shader
if (cameraType == tenCamToolType.skybox){
//force hdr when using Elek Atmosphere model
if (tenkokuModuleObject.atmosphereModelTypeIndex == 1){
#if UNITY_5_6_OR_NEWER
cam.allowHDR = true;
#else
cam.hdr = true;
#endif
}
cam.targetTexture = renderTexDiff;
Shader.SetGlobalTexture("_Tenkoku_SkyBox",renderTexDiff);
}
if (cameraType == tenCamToolType.particles){
cam.targetTexture = renderTexDiff;
Shader.SetGlobalTexture("_Tenkoku_ParticleTex",renderTexDiff);
}
//} else {
//BuildTexture();
}
}
}
//void BuildTexture(){
//build texture
// renderTexDiff = new RenderTexture(64,64,16,RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Linear);
// renderTexDiff.useMipMap = true;
// renderTexDiff.generateMips = true;
// cam.targetTexture = renderTexDiff;
//}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 36f066371677d9c45b38630d4ae3af14
timeCreated: 1461346682
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,384 @@
#if GAIA_PRESENT && UNITY_EDITOR
using UnityEngine;
using System.Collections;
using System;
using System.Reflection;
using UnityEditor;
using Tenkoku.Effects;
namespace Gaia.GX.TanukiDigital
{
/// <summary>
/// Tenkoku Setup
/// </summary>
public class Tenkoku_Gaia : MonoBehaviour
{
#region Generic informational methods
/// <summary>
/// Returns the publisher name if provided.
/// This will override the publisher name in the namespace ie Gaia.GX.PublisherName
/// </summary>
/// <returns>Publisher name</returns>
public static string GetPublisherName()
{
return "Tanuki Digital";
}
/// <summary>
/// Returns the package name if provided
/// This will override the package name in the class name ie public class PackageName.
/// </summary>
/// <returns>Package name</returns>
public static string GetPackageName()
{
return "Tenkoku";
}
#endregion
#region Methods exposed by Gaia as buttons must be prefixed with GX_
public static void GX_About()
{
EditorUtility.DisplayDialog("About Tenkoku", "Tenkoku is a system for lighting your scenes. Its well matched with Suimono.", "OK");
}
/// <summary>
/// Add Tenkoku to the scene
/// </summary>
public static void GX_AddTenkoku()
{
//Add the tenkoku prefab to the scene
//See if we can locate it
GameObject tenkokuPrefab = Gaia.Utils.GetAssetPrefab("Tenkoku DynamicSky");
if (tenkokuPrefab == null)
{
Debug.LogWarning("Unable to locate Tenkoku - Aborting!");
return;
}
//See if we can locate it
if (GameObject.Find("Tenkoku DynamicSky") != null)
{
Debug.LogWarning("Tenkoku Dynamic Sky already in scene - Aborting!");
return;
}
//See if we can create it
GameObject tenkokuObj = Instantiate(tenkokuPrefab);
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to creat Tenkoku object - Aborting!");
return;
}
else
{
tenkokuObj.name = "Tenkoku DynamicSky";
}
//See if we can configure it - via reflection as JS and C# dont play nice
//var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>() as Tenkoku.Core.TenkokuModule;
var tenkokuModule = (Tenkoku.Core.TenkokuModule) FindObjectOfType(typeof(Tenkoku.Core.TenkokuModule));
var tenkokuRand = new Tenkoku.Core.Random(123);
if (tenkokuModule != null)
{
//Set the reflection probe settings
tenkokuModule.enableProbe = true;
tenkokuModule.reflectionProbeFPS = 0.0f;
//Set scene lighting settings
//FieldInfo enableProbe = tenkokuModule.GetType().GetField("enableProbe", BindingFlags.Public | BindingFlags.Instance);
//if (enableProbe != null) enableProbe.SetValue(tenkokuModule, true);
//RenderSettings.ambientMode = AmbientMode.Flat;
//RenderSettings.ambientMode = Rendering.AmbientMode.Flat;
//Add some random clouds
tenkokuModule.weather_cloudAltoStratusAmt = tenkokuRand.Next(0.0f, 0.25f);
tenkokuModule.weather_cloudCirrusAmt = tenkokuRand.Next(0.0f, 0.5f);
tenkokuModule.weather_cloudCumulusAmt = tenkokuRand.Next(0.0f, 0.6f);
//Set the camera
Camera camera = Camera.main;
if (camera == null)
{
camera = FindObjectOfType<Camera>();
}
if (camera != null)
{
tenkokuModule.mainCamera = camera.transform;
//add fog effect to camera
camera.gameObject.AddComponent<TenkokuSkyFog>();
//set fog limits based on camera clip distance
tenkokuModule.fogDist = camera.farClipPlane * 0.99f;
}
}
//Disable the existing directional light if it exists
GameObject lightObj = GameObject.Find("Directional Light");
if (lightObj != null)
{
lightObj.SetActive(false);
}
}
public static void GX_SetMorning()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.currentHour = 7;
tenkokuModule.currentMinute = 30;
}
}
/// <summary>
/// Set the scene light to afternoon
/// </summary>
public static void GX_SetNoon()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.currentHour = 12;
tenkokuModule.currentMinute = 0;
}
}
/// <summary>
/// Set the scene light to evening
/// </summary>
public static void GX_SetEvening()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.currentHour = 17;
tenkokuModule.currentMinute = 20;
}
}
/// <summary>
/// Set the scene light to night
/// </summary>
public static void GX_SetNight()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.currentHour = 23;
tenkokuModule.currentMinute = 45;
}
}
/// <summary>
/// Set scene weather to clear
/// </summary>
public static void GX_WeatherClear()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.0f;
tenkokuModule.weather_cloudCirrusAmt = 0.0f;
tenkokuModule.weather_cloudCumulusAmt = 0.0f;
tenkokuModule.weather_OvercastAmt = 0.0f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.0f;
tenkokuModule.weather_SnowAmt = 0.0f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.25f;
}
}
/// <summary>
/// Set scene weather to light clouds
/// </summary>
public static void GX_WeatherLightClouds()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.1f;
tenkokuModule.weather_cloudCirrusAmt = 0.3f;
tenkokuModule.weather_cloudCumulusAmt = 0.0f;
tenkokuModule.weather_OvercastAmt = 0.0f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.0f;
tenkokuModule.weather_SnowAmt = 0.0f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.25f;
}
}
/// <summary>
/// Set scene weather to partly cloudy
/// </summary>
public static void GX_WeatherPartlyCloudy()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.3f;
tenkokuModule.weather_cloudCirrusAmt = 0.6f;
tenkokuModule.weather_cloudCumulusAmt = 0.7f;
tenkokuModule.weather_OvercastAmt = 0.0f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.0f;
tenkokuModule.weather_SnowAmt = 0.0f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.25f;
}
}
/// <summary>
/// Set scene weather to overcast
/// </summary>
public static void GX_WeatherOvercast()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.6f;
tenkokuModule.weather_cloudCirrusAmt = 0.8f;
tenkokuModule.weather_cloudCumulusAmt = 1.0f;
tenkokuModule.weather_OvercastAmt = 0.4f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.0f;
tenkokuModule.weather_SnowAmt = 0.0f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.25f;
}
}
/// <summary>
/// Set scene weather to rain shower
/// </summary>
public static void GX_WeatherRainShower()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.6f;
tenkokuModule.weather_cloudCirrusAmt = 0.8f;
tenkokuModule.weather_cloudCumulusAmt = 1.0f;
tenkokuModule.weather_OvercastAmt = 0.4f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.7f;
tenkokuModule.weather_SnowAmt = 0.0f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.3f;
}
}
/// <summary>
/// Set scene weather to snow storm
/// </summary>
public static void GX_WeatherSnowStorm()
{
GameObject tenkokuObj = GameObject.Find("Tenkoku DynamicSky");
if (tenkokuObj == null)
{
Debug.LogWarning("Unable to locate Tenkoku DynamicSky object - Aborting!");
return;
}
//See if we can configure it - via reflection as JS and C# dont play nice
var tenkokuModule = tenkokuObj.GetComponent<Tenkoku.Core.TenkokuModule>();
if (tenkokuModule != null)
{
tenkokuModule.weather_cloudAltoStratusAmt = 0.6f;
tenkokuModule.weather_cloudCirrusAmt = 0.8f;
tenkokuModule.weather_cloudCumulusAmt = 1.0f;
tenkokuModule.weather_OvercastAmt = 0.4f;
tenkokuModule.weather_cloudSpeed = 0.1f;
tenkokuModule.weather_RainAmt = 0.0f;
tenkokuModule.weather_SnowAmt = 0.7f;
tenkokuModule.weather_FogAmt = 0.0f;
tenkokuModule.weather_WindAmt = 0.1f;
}
}
#endregion
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9933d97583c6c2e459da3843e83e189a
timeCreated: 1454016098
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,145 @@
using System;
using UnityEngine;
namespace Tenkoku.Core
{
public class TenkokuGlobalSound : MonoBehaviour
{
//Public Variables
public AudioClip audioWind;
public AudioClip audioTurb1;
public AudioClip audioTurb2;
public AudioClip audioRain;
public AudioClip audioAmbDay;
public AudioClip audioAmbNight;
public float volWind = 1.0f;
public float volTurb1 = 1.0f;
public float volTurb2 = 1.0f;
public float volRain = 1.0f;
public float volAmbDay = 1.0f;
public float volAmbNight = 1.0f;
public bool enableSounds = true;
public bool enableTimeAdjust = true;
//Private Variables
private AudioSource sourceWind;
private AudioSource sourceTurb1;
private AudioSource sourceTurb2;
private AudioSource sourceRain;
private AudioSource sourceAmbDay;
private AudioSource sourceAmbNight;
private float _timescale;
void Start () {
sourceWind = gameObject.AddComponent<AudioSource>();
sourceTurb1 = gameObject.AddComponent<AudioSource>();
sourceTurb2 = gameObject.AddComponent<AudioSource>();
sourceRain = gameObject.AddComponent<AudioSource>();
sourceAmbDay = gameObject.AddComponent<AudioSource>();
sourceAmbNight = gameObject.AddComponent<AudioSource>();
sourceWind.volume = 0.0f;
sourceTurb1.volume = 0.0f;
sourceTurb2.volume = 0.0f;
sourceRain.volume = 0.0f;
sourceAmbDay.volume = 0.0f;
sourceAmbNight.volume = 0.0f;
sourceWind.Stop();
sourceTurb1.Stop();
sourceTurb2.Stop();
sourceRain.Stop();
sourceAmbDay.Stop();
sourceAmbNight.Stop();
}
void LateUpdate () {
if (enableSounds){
//cache time
_timescale = UnityEngine.Time.timeScale;
float sndTimeMod = 1.0f;
float sndPitchMod = 1.0f;
if (enableTimeAdjust){
sndTimeMod = Mathf.Clamp(Mathf.Abs(_timescale),0.2f,1f);
sndPitchMod = _timescale;
}
//float audioLength = setstep.length;
//float audioFrequency = setstep.frequency;
//float audioSampleRate = setstep.samples;
//float magnificationCalc = (((audioSampleRate/audioLength)));
sourceWind.volume = volWind * sndTimeMod;
sourceTurb1.volume = volTurb1 * sndTimeMod;
sourceTurb2.volume = volTurb2 * sndTimeMod;
sourceRain.volume = volRain * sndTimeMod;
sourceAmbDay.volume = volAmbDay * sndTimeMod;
sourceAmbNight.volume = volAmbNight * sndTimeMod;
sourceWind.pitch = sndPitchMod;
sourceTurb1.pitch = sndPitchMod;
sourceTurb2.pitch = sndPitchMod;
sourceRain.pitch = sndPitchMod;
sourceAmbDay.pitch = sndPitchMod;
sourceAmbNight.pitch = sndPitchMod;
if (audioWind != null && !sourceWind.isPlaying){
sourceWind.clip = audioWind;
sourceWind.loop = true;
sourceWind.Play();
}
if (audioTurb1 != null && !sourceTurb1.isPlaying){
sourceTurb1.clip = audioTurb1;
sourceTurb1.loop = true;
sourceTurb1.Play();
}
if (audioTurb2 != null && !sourceTurb2.isPlaying){
sourceTurb2.clip = audioTurb2;
sourceTurb2.loop = true;
sourceTurb2.Play();
}
if (audioRain != null && !sourceRain.isPlaying){
sourceRain.clip = audioRain;
sourceRain.loop = true;
sourceRain.Play();
}
if (audioAmbDay != null && !sourceAmbDay.isPlaying){
sourceAmbDay.clip = audioAmbDay;
sourceAmbDay.loop = true;
sourceAmbDay.Play();
}
if (audioAmbNight != null && !sourceAmbNight.isPlaying){
sourceAmbNight.clip = audioAmbNight;
sourceAmbNight.loop = true;
sourceAmbNight.Play();
}
} else {
sourceWind.Stop();
sourceTurb1.Stop();
sourceTurb2.Stop();
sourceRain.Stop();
sourceAmbDay.Stop();
sourceAmbNight.Stop();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ae3a54e3a8039cb498587d9391e7dd9f
timeCreated: 1461346149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@

using System;
using UnityEngine;
namespace Tenkoku.Core
{
public class TenkokuLib : MonoBehaviour
{
public Material skyMaterialElek;
public Material skyMaterialLegacy;
public Shader[] shaders;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6b1b953bcffe1de4ca26373eb69cea28
timeCreated: 1461082369
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,425 @@
using System;
using UnityEngine;
using System.Collections;
namespace Tenkoku.Core
{
public class TenkokuLightningFX : MonoBehaviour
{
//Public Variables
public bool startLightning = false;
public float lightningFrequency = 10.0f;
public float lightningDistance = 1.0f;
public float lightningSpeed = 2.0f;
public float lightningSysTime = 1.0f;
public float lightningIntensity = 5.0f;
public float lightningDirection = 180.0f;
public float lightningRandomRange = 0.0f;
public bool lightningUseLight = false;
public Vector3 boltPosStart;
public float boltLength = 2100.0f;
public float boltWidth = 100.0f;
public int boltPoints = 50;
public AudioClip[] audioThunderDist;
public AudioClip[] audioThunderMed;
public AudioClip[] audioThunderNear;
public GameObject[] thunderObjects;
//Private Variables
private Vector3 lightningUseVec;
private Light lightningLight;
private Transform lightningTrans;
private float lightningUseInt = 0.0f;
private float lightningFreqTime = 0.0f;
private float useLightningFrequency = 1.0f;
private float lightningTime = 0.0f;
private float useLightningSysTime = 0.0f;
private float boltTime = 0.0f;
private Tenkoku.Core.Random lightningRand;
private int srSeed;
private float useLightningRandPos = 0.0f;
private Light lightObjectWorld;
private Light lightObjectNight;
private LineRenderer lightningLine;
private Transform lightningLineTrans;
private AudioSource thunderObject;
private AudioSource[] thunderAudio;
private int currAudio = -1;
private bool startThunder = false;
private Tenkoku.Core.TenkokuModule tenkokuModule;
private float[] thunderVolume;
private float savefrequency = -1.0f;
//collect for GC
private float volEnable;
private int tX;
private float freq;
private int vX;
private Vector3[] lPositions;
private Vector3 usePos;
private float xR;
private Vector3 sPos;
private int px;
private AudioClip useAudio;
private float thunderDelay = 0.0f;
private float thunderVol = 1.0f;
private float thunderPitch = 1.0f;
private Vector3 thunderPosition = Vector3.zero;
private Vector3 lightningLightPosition = Vector3.zero;
private float _time;
private float _deltaTime;
void Start () {
//log objects
//tenkokuModule = GameObject.Find("Tenkoku DynamicSky").GetComponent<Tenkoku.Core.TenkokuModule>() as Tenkoku.Core.TenkokuModule;
tenkokuModule = (Tenkoku.Core.TenkokuModule) FindObjectOfType(typeof(Tenkoku.Core.TenkokuModule));
lightningLight = GameObject.Find("LIGHT_Lightning").GetComponent<Light>();
lightningTrans = GameObject.Find("LIGHT_Lightning").GetComponent<Transform>();
lightObjectWorld = GameObject.Find("LIGHT_World").GetComponent<Light>();
lightObjectNight = GameObject.Find("LIGHT_NightSky").GetComponent<Light>();
lightningLine = GameObject.Find("fxLightningRenderer").gameObject.GetComponent<LineRenderer>() as LineRenderer;
lightningLineTrans = GameObject.Find("fxLightningRenderer").gameObject.GetComponent<Transform>();
//set random factor
//lightningRand = new Tenkoku.Core.Random(System.Environment.TickCount);
srSeed = tenkokuModule.randSeed;
lightningRand = new Tenkoku.Core.Random(srSeed);
//initialize thunder audio objects
thunderVolume = new float[5];//Array(5);
thunderAudio = new AudioSource[5];//Array(5);
for (tX = 0; tX < thunderObjects.Length; tX++){
thunderObjects[tX] = new GameObject();
thunderObjects[tX].AddComponent<AudioSource>();
thunderObjects[tX].transform.parent = this.transform;
thunderObjects[tX].transform.name = "thunderAudio"+tX.ToString();
thunderAudio[tX] = thunderObjects[tX].GetComponent<AudioSource>() as AudioSource;
thunderVolume[tX] = 1.0f;
}
if (lightningLight != null){
lightningLight.renderMode = LightRenderMode.ForceVertex;
lightningLight.shadows = LightShadows.None;
}
}
void LateUpdate () {
//cache time variables for performance;
_time = UnityEngine.Time.time;
_deltaTime = UnityEngine.Time.deltaTime;
//use Tenkoku Random
if (tenkokuModule != null){
if (srSeed != tenkokuModule.randSeed){
srSeed = tenkokuModule.randSeed;
lightningRand = new Tenkoku.Core.Random(srSeed);
}
}
if (lightningRand == null){
lightningRand = new Tenkoku.Core.Random(srSeed);
}
//handle system values
freq = tenkokuModule.weather_lightning;
lightningDirection = tenkokuModule.weather_lightningDir;
lightningRandomRange = tenkokuModule.weather_lightningRange;
lightningFrequency = Mathf.Lerp(25.0f,1.0f,freq);
lightningIntensity = Mathf.Clamp(Mathf.Lerp(1.0f,10.0f,freq),0.0f,5.0f);
//reset based on frequency changes
if (freq != savefrequency && freq > 0.0f){
savefrequency = freq;
useLightningFrequency = lightningFrequency;
}
//clamp
lightningIntensity = Mathf.Clamp(lightningIntensity,0.0f,10.0f);
//enable lightening
volEnable = 0.0f;
if (tenkokuModule.enableSoundFX) volEnable = 1.0f;
if (freq <= 0.0f){
startLightning = false;
}
//set overall Thunder Volume
for (vX = 0; vX < thunderAudio.Length; vX++){
thunderAudio[vX].volume = thunderVolume[vX] * tenkokuModule.volumeThunder * volEnable;
}
//Lightning Timing
if (!startLightning){
lightningUseInt = 0.0f;
lightningTime = 0.0f;
useLightningSysTime = 0.0f;
lightningFreqTime = lightningFreqTime + (_deltaTime/useLightningFrequency);
if (lightningFreqTime >= 1.0f) startLightning = true;
} else {
//init settings
if (useLightningSysTime == 0.0f){
lightningDistance = lightningRand.Next(-0.3f,0.6f);
lightningDistance = Mathf.Clamp(lightningDistance,0.0f,1.0f);
lightningSpeed = lightningRand.Next(5.0f,12.0f);
lightningSysTime = lightningRand.Next(0.0f,1.4f);
lightningSysTime = Mathf.Clamp(lightningSysTime,0.2f,1.0f);
lightningUseLight = false;
if (lightningRand.Next(0.0f,1.5f + freq) >= 1.0f) lightningUseLight = true;
useLightningRandPos = lightningRand.Next(0.0f-lightningRandomRange,lightningRandomRange);
boltTime = 1.0f;
lightningFreqTime = 0.0f;
useLightningFrequency = lightningRand.Next(lightningFrequency-(lightningFrequency*0.75f),lightningFrequency + (lightningFrequency*0.25f));
}
//timers
useLightningSysTime = useLightningSysTime + _deltaTime;
lightningTime = lightningTime + (_deltaTime * lightningSpeed);
if (lightningTime <= 1.0f) lightningUseInt = Mathf.SmoothStep(lightningUseInt,lightningIntensity,lightningTime);
if (lightningTime > 1.0f) lightningUseInt = Mathf.SmoothStep(lightningUseInt,0.2f,lightningTime-1.0f);
//reset
if (useLightningSysTime >= lightningSysTime && lightningTime > 2.0f){
startLightning = false;
startThunder = false;
}
if (lightningTime > 2.0f){
lightningTime = 0.0f;
lightningSpeed = lightningRand.Next(5.0f,12.0f);
boltTime = boltTime + _deltaTime*lightningRand.Next(2.0f,10.0f);
boltPoints = Mathf.FloorToInt(lightningRand.Next(40.0f,80.0f));
}
//handle thunder
if (!startThunder){
startThunder = true;
ThunderHandler();
}
}
//position
lightningUseVec = Quaternion.Euler(Mathf.Lerp(-10.0f,-40.0f,lightningDistance), lightningDirection + useLightningRandPos, 0.0f) * Vector3.forward;
//set light
if (lightningLight != null){
if (lightningUseLight){
if (!tenkokuModule.allowMultiLights){
lightObjectWorld.enabled = false;
lightObjectNight.enabled = false;
}
lightningUseInt = lightningUseInt * Mathf.Lerp(0.0f, 2.0f, tenkokuModule.lightningColor.a);
lightningLight.enabled = true;
lightningLightPosition.x = Mathf.Clamp(0f-Mathf.Lerp(0f,-60f,lightningDistance),20f,90f);
lightningLightPosition.y = (lightningDirection+useLightningRandPos)-180f;
lightningLightPosition.z = 0.0f;
lightningTrans.eulerAngles = lightningLightPosition;
lightningLight.intensity = lightningUseInt * lightningRand.Next(0.4f,1.0f);
lightningLight.color = tenkokuModule.lightningColor;
} else {
lightningLight.enabled = false;
lightningLight.intensity = 0f;
}
if (lightningLight.intensity <= 0.05f && !tenkokuModule.allowMultiLights){
lightObjectWorld.enabled = true;
lightObjectNight.enabled = true;
lightningLight.enabled = false;
}
}
//send to shader
Shader.SetGlobalVector("Tenkoku_Vec_LightningFwd", lightningUseVec);
Shader.SetGlobalFloat("Tenkoku_LightningIntensity", 0.2f * (lightningUseInt + ((1f*(1f-lightningDistance))*lightningUseInt)));
Shader.SetGlobalFloat("Tenkoku_LightningLightIntensity", 0.2f*lightningLight.intensity);
Shader.SetGlobalColor("Tenkoku_LightningColor", tenkokuModule.lightningColor);
//-------------------------
//### Bolt Rendering ###
//-------------------------
if (Camera.main != null){
lightningLineTrans.position = Camera.main.transform.position;
//lightningLine.transform.Translate(lightningUseVec * 3000.0f, Space.Self);
lightningLineTrans.Translate(lightningUseVec * lightningRand.Next(2000f,3000f), Space.Self);
boltPosStart = lightningLineTrans.position;
boltPosStart.y = Mathf.Clamp(boltPosStart.y,500.0f,2000f);
if (lightningRand != null){
if (boltTime > lightningRand.Next(0.1f,1f) || lightningSysTime == 0f){
boltTime = 0f;
if (lightningLine != null){
//init positional array
boltPoints = Mathf.FloorToInt(Mathf.Clamp(boltPoints,40,80));
lPositions = new Vector3[boltPoints];
usePos = boltPosStart;
//set start position
lPositions[0] = boltPosStart;
//set positions
xR = 0.0f;
sPos = usePos;
#if UNITY_5_5_OR_NEWER
lightningLine.positionCount = lPositions.Length;
#else
lightningLine.SetVertexCount(lPositions.Length);
#endif
for (px = 0; px < lPositions.Length; px++){
//set base vertical position
sPos.y = usePos.y;
sPos.y = sPos.y - ((boltLength/(boltPoints-1))*px);
sPos.x = sPos.x - lightningRand.Next(((-100f/(boltPoints-1f))*px),((100f/(boltPoints-1f))*px));
if (px > 0 && px < boltPoints-1){
//set width variance
xR = ((px*1f)/(boltLength*1f))*_time;
sPos.x = sPos.x - Mathf.PerlinNoise(xR,xR)*lightningRand.Next(-1f,1f) * boltWidth;
sPos.z = sPos.z - Mathf.PerlinNoise(xR,xR)*lightningRand.Next(-1f,1f) * boltWidth;
//reset variance toward end
sPos.x = Mathf.Lerp(sPos.x,usePos.x, ((px*1f)/(boltPoints*1f)) * 0.1f );
sPos.z = Mathf.Lerp(sPos.z,usePos.z, ((px*1f)/(boltPoints*1f)) * 0.5f );
//set height variance
sPos.y = sPos.y - Mathf.PerlinNoise(xR,xR)*lightningRand.Next(-1f,1f)*0.5f;
}
lPositions[px] = sPos;
lightningLine.SetPosition(px,lPositions[px]);
}
}
}
}
}
}
void ThunderHandler(){
//---------------------------------
//### Thunder Audio Handling ###
//---------------------------------
//select audio object from pool
currAudio += 1;
if (currAudio >= thunderObjects.Length) currAudio = 0;
if (thunderObjects[currAudio] != null) thunderObject = thunderObjects[currAudio].GetComponent<AudioSource>() as AudioSource;
//Handle Audio effects
if (thunderObject != null){
thunderDelay = 0f;
thunderVol = 1f;
thunderPitch = 1f;
//set audio position
if (Camera.main != null){
thunderObject.transform.position = Camera.main.transform.position;
thunderObject.transform.Translate(lightningUseVec * 50.0f, Space.Self);
thunderPosition.x = thunderObject.transform.position.x;
thunderPosition.y = Camera.main.transform.position.y;
thunderPosition.z = thunderObject.transform.position.z;
thunderObject.transform.position = thunderPosition;
}
//distant
if (!lightningUseLight){
if (lightningDistance < 0.4f){
useAudio = audioThunderDist[Mathf.FloorToInt(lightningRand.Next(0f,audioThunderDist.Length*0.99f))];
thunderDelay = lightningRand.Next(0.7f,2.0f);
thunderVol = lightningRand.Next(0.2f,0.4f);
thunderPitch = lightningRand.Next(0.6f,0.8f);
}
if (lightningDistance >= 0.4f){
useAudio = audioThunderMed[Mathf.FloorToInt(lightningRand.Next(0f,audioThunderMed.Length*0.99f))];
thunderDelay = lightningRand.Next(0.7f,1.5f);
thunderVol = lightningRand.Next(0.4f,0.6f);
thunderPitch = lightningRand.Next(0.8f,0.9f);
}
}
if (lightningUseLight){
if (lightningDistance < 0.4f){
useAudio = audioThunderMed[Mathf.FloorToInt(lightningRand.Next(0f,audioThunderMed.Length*0.99f))];
thunderDelay = lightningRand.Next(0.1f,0.4f);
thunderVol = lightningRand.Next(0.5f,0.8f);
thunderPitch = lightningRand.Next(0.8f,1.0f);
}
if (lightningDistance >= 0.4f){
useAudio = audioThunderNear[Mathf.FloorToInt(lightningRand.Next(0.0f,audioThunderNear.Length*0.99f))];
thunderDelay = 0.0f;//lightningRand.Next(0.0,0.0f);
thunderVol = lightningRand.Next(0.8f,1.0f);
thunderPitch = lightningRand.Next(0.9f,1.2f);
}
}
//Play Sound
if (useAudio != null){
//set overall settings
thunderObject.spatialBlend = 0.75f;
thunderObject.minDistance = 50.0f;
thunderObject.maxDistance = 500.0f;
thunderObject.spread = 0f;
//set clip specific settings
thunderObject.clip = useAudio;
thunderObject.loop = false;
thunderVolume[currAudio] = thunderVol*1.4f;
thunderObject.volume = thunderVol*1.4f;
thunderObject.pitch = thunderPitch;
thunderObject.PlayDelayed(thunderDelay);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 93e492ef270bcf340ad2c7c81f3164cb
timeCreated: 1461162569
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More