This commit is contained in:
2025-05-13 04:46:54 +03:00
parent e2b013a9f9
commit 0335ce61c5
48 changed files with 4915 additions and 0 deletions
Binary file not shown.
+30
View File
@@ -0,0 +1,30 @@
fileFormatVersion: 2
guid: 86f810fe59465a94dbba4736f65f0d3f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

+107
View File
@@ -0,0 +1,107 @@
fileFormatVersion: 2
guid: 9d3d521edbb1c604dacd9bbf11f84763
TextureImporter:
fileIDToRecycleName:
2186277476908879412: ImportLogs
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
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
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
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: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 512
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 512
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 512
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
+94
View File
@@ -0,0 +1,94 @@
Shader "Unlit/Corner"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v){
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
static const float3x3 sobelX = float3x3(
float3(-1, 0, 1),
float3(-2, 0, 2),
float3(-1, 0, 1)
);
static const float3x3 sobelY = float3x3(
float3(-1, -2, -1),
float3(0, 0, 0),
float3(1, 2, 1)
);
float sobelFilter(sampler2D image, float2 uv, float3x3 kernel) {
float2 textureSize = float2(512, 512);
float sum = 0.0f;
for (int y = -1; y <= 1; ++y) {
for (int x = -1; x <= 1; ++x) {
sum += tex2D(image, uv + float2((float)x / textureSize.x, (float)y / textureSize.y)).r * kernel[y + 1][x + 1];
}
}
return sum;
}
float4 frag (v2f i) : SV_Target{
float2 textureSize = float2(512,512);
float2 texelSize = 1.0f / textureSize;
float Ix = tex2D(_MainTex, i.uv + float2(texelSize.x, 0.0f)).r - tex2D(_MainTex, i.uv).r;
float Iy = tex2D(_MainTex, i.uv + float2(0.0f, texelSize.y)).r - tex2D(_MainTex, i.uv).r;
float2x2 jacobi;
jacobi[0][0] = Ix * Ix;
jacobi[0][1] = Ix * Iy;
jacobi[1][0] = Ix * Iy;
jacobi[1][1] = Iy * Iy;
float jacobian = (Ix * Ix) * (Iy * Iy) - (Ix * Iy) * (Ix * Iy);
//return tex2D(_MainTex, i.uv).r;
float sX = sobelFilter(_MainTex, i.uv, sobelX);
float sY = sobelFilter(_MainTex, i.uv, sobelY);
//return sX;
return sY;
return sX*sX + sY*sY;
//return jacobian == 0;
//return abs(float4(Ix, Iy, 0, 1));
}
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7e2286fc7b91c35469eb39d0c66eba97
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
+76
View File
@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: CornerDetect
m_Shader: {fileID: 4800000, guid: 7e2286fc7b91c35469eb39d0c66eba97, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: fb6789922a8c9aa4e85e6bcf6a5f7ac3, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56e91ef516947df4385804a3b2b84bec
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+16
View File
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CornerDetection : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8197f690aac11ac40ad267b52fe6823a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+604
View File
@@ -0,0 +1,604 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &4873657
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 4873661}
- component: {fileID: 4873660}
- component: {fileID: 4873659}
- component: {fileID: 4873658}
m_Layer: 0
m_Name: Quad
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!64 &4873658
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 4873657}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_SkinWidth: 0.01
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &4873659
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 4873657}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 468f9e6e87e792c4594b1b37d13f095f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &4873660
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 4873657}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &4873661
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 4873657}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.171, y: -0.081, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &221353322
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 221353324}
- component: {fileID: 221353323}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &221353323
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 221353322}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &221353324
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 221353322}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &262705771
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 262705775}
- component: {fileID: 262705774}
- component: {fileID: 262705773}
- component: {fileID: 262705772}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!64 &262705772
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 262705771}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &262705773
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 262705771}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &262705774
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 262705771}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &262705775
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 262705771}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &630284674
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 630284676}
- component: {fileID: 630284675}
m_Layer: 0
m_Name: PlaneFunction
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &630284675
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 630284674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 047a5591222758c4db9336f0487a60ea, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &630284676
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 630284674}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.3030643, y: -5.214313, z: 5.6082625}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &825649645
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 825649649}
- component: {fileID: 825649648}
- component: {fileID: 825649647}
- component: {fileID: 825649646}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &825649646
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 825649645}
m_Enabled: 1
--- !u!124 &825649647
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 825649645}
m_Enabled: 1
--- !u!20 &825649648
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 825649645}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &825649649
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 825649645}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1243060069
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1243060071}
- component: {fileID: 1243060070}
m_Layer: 0
m_Name: Gaussian
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1243060070
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1243060069}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 13fc9c842dc37f04bba7ac31704aab8e, type: 3}
m_Name:
m_EditorClassIdentifier:
a: 1
b: 0
c: 0.5
NormalDistrubution: 0
--- !u!4 &1243060071
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1243060069}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.3221803, y: -9.275501, z: 11.499779}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1404314766
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1404314768}
- component: {fileID: 1404314767}
m_Layer: 0
m_Name: Plot2D
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1404314767
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1404314766}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a7f5b7d1ffa828a4c9ed02cefa69397a, type: 3}
m_Name:
m_EditorClassIdentifier:
Function: {fileID: 1243060070}
ArgsBounds: {x: -2, y: -2, z: 4, w: 4}
ViewBounds: {x: -1, y: -1, z: 2, w: 2}
USamples: 100
VSamples: 100
--- !u!4 &1404314768
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1404314766}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1447860296
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1447860298}
- component: {fileID: 1447860297}
m_Layer: 0
m_Name: Checker
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1447860297
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447860296}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8197f690aac11ac40ad267b52fe6823a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1447860298
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447860296}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.078730464, y: 4.7860336, z: 0.53436375}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 949d5d8ddea5ae045b24916d6ebdaf01
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f51c0e91651c0e7439c4af60207c9216
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+18
View File
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(LSystem))]
public class LSystemEditor : Editor {
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("Rebuild"))
{
(target as LSystem).RebuildTree();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe8f2f90a448c7b47a55792cf31d1fa5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: fb6789922a8c9aa4e85e6bcf6a5f7ac3
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
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
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
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: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
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:
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Function2D : MonoBehaviour {
public virtual double Evaluate(double u, double v) { return 0.0; }
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c9a663e836bb7846bdf2cf744b30782
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+99
View File
@@ -0,0 +1,99 @@
fileFormatVersion: 2
guid: 1e104a01c03b29c4d9235c1170d36c3e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 0
Exclude Win64: 0
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+20
View File
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class GaussFunction : Function2D {
public double a;
public double b;
public double c = 1.0;
public bool NormalDistrubution = true;
public override double Evaluate(double u, double v) {
double x = Math.Sqrt(u * u + v * v);
double aValue = NormalDistrubution ? (1.0 / (c * Math.Sqrt(2.0 * Math.PI))) : a;
return aValue * Math.Exp(-(((x - b)* (x - b)) / (2*c*c)));
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 13fc9c842dc37f04bba7ac31704aab8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+211
View File
@@ -0,0 +1,211 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
public class LSystem : MonoBehaviour {
public string Premise = "FFFA";
public string[] Rules = new string[] { "A=!\"[B]////[B]////B", "B=&FFFA" };
public string ContextIgnore = "F+-";
public float StepSize = 0.1f;
public float StepSizeScale = 0.9f;
public float Angle = 28.0f;
public float AngleScale = 0.7f;
public uint Generations = 7;
private List<List<Vector3>> _branches = new List<List<Vector3>>();
// Use this for initialization
void Start () {
}
private void OnValidate()
{
// RebuildTree();
}
private string DrawReductionTree(GOLD.Reduction Root)
{
//This procedure starts the recursion that draws the parse tree.
StringBuilder tree = new StringBuilder();
tree.AppendLine("+-" + Root.Parent.Text(false));
DrawReduction(tree, Root, 1);
return tree.ToString();
}
private void DrawReduction(StringBuilder tree, GOLD.Reduction reduction, int indent)
{
//This is a simple recursive procedure that draws an ASCII version of the parse
//tree
int n;
string indentText = "";
for (n = 1; n <= indent; n++) {
indentText += "| ";
}
//=== Display the children of the reduction
for (n = 0; n < reduction.Count(); n++) {
switch (reduction[n].Type()) {
case GOLD.SymbolType.Nonterminal:
GOLD.Reduction branch = (GOLD.Reduction)reduction[n].Data;
tree.AppendLine(indentText + "+-" + branch.Parent.Text(false));
DrawReduction(tree, branch, indent + 1);
break;
default:
string leaf = (string)reduction[n].Data;
tree.AppendLine(indentText + "+-" + leaf);
break;
}
}
}
public void RebuildTree(){
MyParser parser = new MyParser();
parser.Setup();
MemoryStream ms = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(@"F(x)=F(7+-x/2)"));
StreamReader sr = new StreamReader(ms);
parser.Parse(sr);
var tree = parser.program;
var treeTxt = DrawReductionTree(tree);
Debug.Log(treeTxt);
string result = Premise;
for(uint g = 0; g < Generations; ++g)
{
string tmp = "";
for(int j = 0; j < result.Length; ++j)
{
string replacement = result[j].ToString();
foreach (var rule in Rules)
{
if(result[j] == rule[0])
{
replacement = rule.Substring(2);
break;
}
}
tmp += replacement;
}
result = tmp;
}
Debug.Log("Final result: " + result);
RunTurtle(result);
}
struct TurtleState
{
public Vector3 position;
public Matrix4x4 mat;
public List<Vector3> points;
}
void RunTurtle(string commandLine)
{
Stack<TurtleState> states = new Stack<TurtleState>();
TurtleState state = new TurtleState();
state.mat = Matrix4x4.identity;
state.position = Vector3.zero;
_branches.Clear();
state.points = new List<Vector3>();
state.points.Add(state.position);
for(int i = 0; i < commandLine.Length; ++i)
{
char cmd = commandLine[i];
if(cmd == 'F')
{
state.position = state.position + state.mat.MultiplyVector(Vector3.up);
state.points.Add(state.position);
}else if(cmd == '+')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(0, 0, -Angle)) ;
}
else if (cmd == '-')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(0, 0, Angle));
}
else if (cmd == '[')
{
states.Push(state);
state.points = new List<Vector3>();
state.points.Add(state.position);
}
else if (cmd == ']')
{
state = states.Pop();
_branches.Add(state.points);
}
else if (cmd == '/')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(0, -Angle, 0));
}
else if (cmd == '\\')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(0, Angle, 0));
}
else if (cmd == '&')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(Angle, 0, 0));
}
else if (cmd == '^')
{
state.mat = state.mat * Matrix4x4.Rotate(Quaternion.Euler(-Angle, 0, 0));
}
}
_branches.Add(state.points);
}
private void OnDrawGizmos()
{
Gizmos.matrix = transform.localToWorldMatrix;
foreach(var branch in _branches)
{
if(branch.Count > 1)
{
for (int i = 0; i < branch.Count - 1; ++i)
{
Gizmos.DrawLine(branch[i], branch[i + 1]);
}
}
}
}
// Update is called once per frame
void Update () {
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b24d986ba12e0ac4bb039c209f2adafa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+681
View File
@@ -0,0 +1,681 @@
using System.IO;
using UnityEngine;
public class MyParser
{
private GOLD.Parser parser = new GOLD.Parser();
private enum SymbolIndex
{
@Eof = 0, // (EOF)
@Error = 1, // (Error)
@Whitespace = 2, // Whitespace
@Minus = 3, // '-'
@Minusminus = 4, // '--'
@Exclam = 5, // '!'
@Exclameq = 6, // '!='
@Quote = 7, // '"'
@Percent = 8, // '%'
@Percenteq = 9, // '%='
@Amp = 10, // '&'
@Ampamp = 11, // '&&'
@Ampeq = 12, // '&='
@Lparen = 13, // '('
@Rparen = 14, // ')'
@Times = 15, // '*'
@Timeseq = 16, // '*='
@Comma = 17, // ','
@Div = 18, // '/'
@Diveq = 19, // '/='
@Colon = 20, // ':'
@Question = 21, // '?'
@Backslash = 22, // '\'
@Caret = 23, // '^'
@Careteq = 24, // '^='
@Pipe = 25, // '|'
@Pipepipe = 26, // '||'
@Pipeeq = 27, // '|='
@Tilde = 28, // '~'
@Plus = 29, // '+'
@Plusplus = 30, // '++'
@Pluseq = 31, // '+='
@Lt = 32, // '<'
@Ltlt = 33, // '<<'
@Ltlteq = 34, // '<<='
@Lteq = 35, // '<='
@Eq = 36, // '='
@Minuseq = 37, // '-='
@Eqeq = 38, // '=='
@Gt = 39, // '>'
@Minusgt = 40, // '->'
@Gteq = 41, // '>='
@Gtgt = 42, // '>>'
@Gtgteq = 43, // '>>='
@A = 44, // A
@Charliteral = 45, // CharLiteral
@Decliteral = 46, // DecLiteral
@F = 47, // F
@False = 48, // false
@Hexliteral = 49, // HexLiteral
@Identifier = 50, // Identifier
@Realliteral = 51, // RealLiteral
@Stringliteral = 52, // StringLiteral
@True = 53, // true
@Addexp = 54, // <Add Exp>
@Andexp = 55, // <And Exp>
@Args = 56, // <Args>
@Assignop = 57, // <AssignOp>
@Compareexp = 58, // <Compare Exp>
@Conditionalexp = 59, // <Conditional Exp>
@Equalityexp = 60, // <Equality Exp>
@Expression = 61, // <Expression>
@Expressionlist = 62, // <Expression List>
@Formalparams = 63, // <FormalParams>
@Formalparamslist = 64, // <FormalParamsList>
@Literal = 65, // <Literal>
@Logicalandexp = 66, // <Logical And Exp>
@Logicalorexp = 67, // <Logical Or Exp>
@Logicalxorexp = 68, // <Logical Xor Exp>
@Match = 69, // <Match>
@Matchleftcontext = 70, // <MatchLeftContext>
@Matchprime = 71, // <MatchPrime>
@Matchrightcontext = 72, // <MatchRightContext>
@Multexp = 73, // <Mult Exp>
@Opname = 74, // <OpName>
@Opsleft = 75, // <OpsLeft>
@Opsleftlist = 76, // <OpsLeftList>
@Opsright = 77, // <OpsRight>
@Opsrightlist = 78, // <OpsRightList>
@Orexp = 79, // <Or Exp>
@Primary = 80, // <Primary>
@Primaryexp = 81, // <Primary Exp>
@Replace = 82, // <Replace>
@Rule = 83, // <Rule>
@Shiftexp = 84, // <Shift Exp>
@Unaryexp = 85 // <Unary Exp>
}
private enum ProductionIndex
{
@Assignop_Eq = 0, // <AssignOp> ::= '='
@Assignop_Minusgt = 1, // <AssignOp> ::= '->'
@Literal_True = 2, // <Literal> ::= true
@Literal_False = 3, // <Literal> ::= false
@Literal_Decliteral = 4, // <Literal> ::= DecLiteral
@Literal_Hexliteral = 5, // <Literal> ::= HexLiteral
@Literal_Realliteral = 6, // <Literal> ::= RealLiteral
@Literal_Charliteral = 7, // <Literal> ::= CharLiteral
@Literal_Stringliteral = 8, // <Literal> ::= StringLiteral
@Opname_Plus = 9, // <OpName> ::= '+'
@Opname_Minus = 10, // <OpName> ::= '-'
@Opname_Amp = 11, // <OpName> ::= '&'
@Opname_Caret = 12, // <OpName> ::= '^'
@Opname_Backslash = 13, // <OpName> ::= '\'
@Opname_Div = 14, // <OpName> ::= '/'
@Opname_Pipe = 15, // <OpName> ::= '|'
@Opname_Exclam = 16, // <OpName> ::= '!'
@Opname_Quote = 17, // <OpName> ::= '"'
@Opname_A = 18, // <OpName> ::= A
@Opname_F = 19, // <OpName> ::= F
@Opsrightlist = 20, // <OpsRightList> ::= <OpsRight>
@Opsrightlist2 = 21, // <OpsRightList> ::= <OpsRightList> <OpsRight>
@Opsright = 22, // <OpsRight> ::= <OpName>
@Opsright2 = 23, // <OpsRight> ::= <OpName> <Args>
@Expressionlist = 24, // <Expression List> ::= <Expression>
@Expressionlist_Comma = 25, // <Expression List> ::= <Expression> ',' <Expression List>
@Expression_Eq = 26, // <Expression> ::= <Conditional Exp> '=' <Expression>
@Expression_Pluseq = 27, // <Expression> ::= <Conditional Exp> '+=' <Expression>
@Expression_Minuseq = 28, // <Expression> ::= <Conditional Exp> '-=' <Expression>
@Expression_Timeseq = 29, // <Expression> ::= <Conditional Exp> '*=' <Expression>
@Expression_Diveq = 30, // <Expression> ::= <Conditional Exp> '/=' <Expression>
@Expression_Careteq = 31, // <Expression> ::= <Conditional Exp> '^=' <Expression>
@Expression_Ampeq = 32, // <Expression> ::= <Conditional Exp> '&=' <Expression>
@Expression_Pipeeq = 33, // <Expression> ::= <Conditional Exp> '|=' <Expression>
@Expression_Percenteq = 34, // <Expression> ::= <Conditional Exp> '%=' <Expression>
@Expression_Ltlteq = 35, // <Expression> ::= <Conditional Exp> '<<=' <Expression>
@Expression_Gtgteq = 36, // <Expression> ::= <Conditional Exp> '>>=' <Expression>
@Expression = 37, // <Expression> ::= <Conditional Exp>
@Conditionalexp_Question_Colon = 38, // <Conditional Exp> ::= <Or Exp> '?' <Or Exp> ':' <Conditional Exp>
@Conditionalexp = 39, // <Conditional Exp> ::= <Or Exp>
@Orexp_Pipepipe = 40, // <Or Exp> ::= <Or Exp> '||' <And Exp>
@Orexp = 41, // <Or Exp> ::= <And Exp>
@Andexp_Ampamp = 42, // <And Exp> ::= <And Exp> '&&' <Logical Or Exp>
@Andexp = 43, // <And Exp> ::= <Logical Or Exp>
@Logicalorexp_Pipe = 44, // <Logical Or Exp> ::= <Logical Or Exp> '|' <Logical Xor Exp>
@Logicalorexp = 45, // <Logical Or Exp> ::= <Logical Xor Exp>
@Logicalxorexp_Caret = 46, // <Logical Xor Exp> ::= <Logical Xor Exp> '^' <Logical And Exp>
@Logicalxorexp = 47, // <Logical Xor Exp> ::= <Logical And Exp>
@Logicalandexp_Amp = 48, // <Logical And Exp> ::= <Logical And Exp> '&' <Equality Exp>
@Logicalandexp = 49, // <Logical And Exp> ::= <Equality Exp>
@Equalityexp_Eqeq = 50, // <Equality Exp> ::= <Equality Exp> '==' <Compare Exp>
@Equalityexp_Exclameq = 51, // <Equality Exp> ::= <Equality Exp> '!=' <Compare Exp>
@Equalityexp = 52, // <Equality Exp> ::= <Compare Exp>
@Compareexp_Lt = 53, // <Compare Exp> ::= <Compare Exp> '<' <Shift Exp>
@Compareexp_Gt = 54, // <Compare Exp> ::= <Compare Exp> '>' <Shift Exp>
@Compareexp_Lteq = 55, // <Compare Exp> ::= <Compare Exp> '<=' <Shift Exp>
@Compareexp_Gteq = 56, // <Compare Exp> ::= <Compare Exp> '>=' <Shift Exp>
@Compareexp = 57, // <Compare Exp> ::= <Shift Exp>
@Shiftexp_Ltlt = 58, // <Shift Exp> ::= <Shift Exp> '<<' <Add Exp>
@Shiftexp_Gtgt = 59, // <Shift Exp> ::= <Shift Exp> '>>' <Add Exp>
@Shiftexp = 60, // <Shift Exp> ::= <Add Exp>
@Addexp_Plus = 61, // <Add Exp> ::= <Add Exp> '+' <Mult Exp>
@Addexp_Minus = 62, // <Add Exp> ::= <Add Exp> '-' <Mult Exp>
@Addexp = 63, // <Add Exp> ::= <Mult Exp>
@Multexp_Times = 64, // <Mult Exp> ::= <Mult Exp> '*' <Unary Exp>
@Multexp_Div = 65, // <Mult Exp> ::= <Mult Exp> '/' <Unary Exp>
@Multexp_Percent = 66, // <Mult Exp> ::= <Mult Exp> '%' <Unary Exp>
@Multexp = 67, // <Mult Exp> ::= <Unary Exp>
@Unaryexp_Exclam = 68, // <Unary Exp> ::= '!' <Unary Exp>
@Unaryexp_Tilde = 69, // <Unary Exp> ::= '~' <Unary Exp>
@Unaryexp_Minus = 70, // <Unary Exp> ::= '-' <Unary Exp>
@Unaryexp_Plusplus = 71, // <Unary Exp> ::= '++' <Unary Exp>
@Unaryexp_Minusminus = 72, // <Unary Exp> ::= '--' <Unary Exp>
@Unaryexp = 73, // <Unary Exp> ::= <Primary Exp>
@Primaryexp = 74, // <Primary Exp> ::= <Primary>
@Primaryexp_Lparen_Rparen = 75, // <Primary Exp> ::= '(' <Expression> ')'
@Primary = 76, // <Primary> ::= <Literal>
@Primary_Identifier = 77, // <Primary> ::= Identifier
@Args_Lparen_Rparen = 78, // <Args> ::= '(' <Expression List> ')'
@Formalparamslist_Comma_Identifier = 79, // <FormalParamsList> ::= <FormalParamsList> ',' Identifier
@Formalparamslist_Identifier = 80, // <FormalParamsList> ::= Identifier
@Formalparams_Lparen_Rparen = 81, // <FormalParams> ::= '(' <FormalParamsList> ')'
@Opsleft = 82, // <OpsLeft> ::= <OpName>
@Opsleft2 = 83, // <OpsLeft> ::= <OpName> <FormalParams>
@Opsleftlist = 84, // <OpsLeftList> ::= <OpsLeft>
@Opsleftlist2 = 85, // <OpsLeftList> ::= <OpsLeftList> <OpsLeft>
@Matchleftcontext_Lt = 86, // <MatchLeftContext> ::= <OpsLeftList> '<'
@Matchprime = 87, // <MatchPrime> ::= <OpsLeftList>
@Matchrightcontext_Gt = 88, // <MatchRightContext> ::= '>' <OpsLeftList>
@Match = 89, // <Match> ::= <MatchPrime>
@Match2 = 90, // <Match> ::= <MatchLeftContext> <MatchPrime>
@Match3 = 91, // <Match> ::= <MatchPrime> <MatchRightContext>
@Match4 = 92, // <Match> ::= <MatchLeftContext> <MatchPrime> <MatchRightContext>
@Replace = 93, // <Replace> ::= <OpsRightList>
@Rule = 94 // <Rule> ::= <Match> <AssignOp> <Replace>
}
public GOLD.Reduction program; //You might derive a specific object
public void Setup()
{
//This procedure can be called to load the parse tables. The class can
//read tables using a BinaryReader.
parser.LoadTables(@"C:\Users\l-pro\Desktop\lsystem.egt");
// parser.LoadTables(Path.Combine(Application.StartupPath, "grammar.egt"));
}
public bool Parse(TextReader reader)
{
//This procedure starts the GOLD Parser Engine and handles each of the
//messages it returns. Each time a reduction is made, you can create new
//custom object and reassign the .CurrentReduction property. Otherwise,
//the system will use the Reduction object that was returned.
//
//The resulting tree will be a pure representation of the language
//and will be ready to implement.
GOLD.ParseMessage response;
bool done; //Controls when we leave the loop
bool accepted = false; //Was the parse successful?
parser.Open(reader);
parser.TrimReductions = false; //Please read about this feature before enabling
done = false;
while (!done)
{
response = parser.Parse();
switch (response)
{
case GOLD.ParseMessage.LexicalError:
Debug.Log("LexicalError");
//Cannot recognize token
done = true;
break;
case GOLD.ParseMessage.SyntaxError:
Debug.Log("SyntaxError");
//Expecting a different token
done = true;
break;
case GOLD.ParseMessage.Reduction:
//Create a customized object to store the reduction
Debug.Log("Reduction");
//parser.CurrentReduction = CreateNewObject(parser.CurrentReduction as GOLD.Reduction);
break;
case GOLD.ParseMessage.Accept:
Debug.Log("Accept");
//Accepted!
program = (GOLD.Reduction) parser.CurrentReduction; //The root node!
done = true;
accepted = true;
break;
case GOLD.ParseMessage.TokenRead:
Debug.Log("TokenRead");
//You don't have to do anything here.
break;
case GOLD.ParseMessage.InternalError:
Debug.Log("InternalError");
//INTERNAL ERROR! Something is horribly wrong.
done = true;
break;
case GOLD.ParseMessage.NotLoadedError:
Debug.Log("NotLoadedError");
//This error occurs if the CGT was not loaded.
done = true;
break;
case GOLD.ParseMessage.GroupError:
Debug.Log("GroupError");
//GROUP ERROR! Unexpected end of file
done = true;
break;
}
} //while
return accepted;
}
private object CreateNewObject(GOLD.Reduction r)
{
object result = null;
switch( (ProductionIndex) r.Parent.TableIndex())
{
case ProductionIndex.Assignop_Eq:
Debug.Log("<AssignOp> ::= '='");
break;
case ProductionIndex.Assignop_Minusgt:
Debug.Log("<AssignOp> ::= '->'");
break;
case ProductionIndex.Literal_True:
Debug.Log("<Literal> ::= true");
break;
case ProductionIndex.Literal_False:
Debug.Log("<Literal> ::= false");
break;
case ProductionIndex.Literal_Decliteral:
Debug.Log("<Literal> ::= DecLiteral: " + r.get_Data(0));
break;
case ProductionIndex.Literal_Hexliteral:
Debug.Log("<Literal> ::= HexLiteral");
break;
case ProductionIndex.Literal_Realliteral:
Debug.Log("<Literal> ::= RealLiteral");
break;
case ProductionIndex.Literal_Charliteral:
Debug.Log("<Literal> ::= CharLiteral");
break;
case ProductionIndex.Literal_Stringliteral:
Debug.Log("<Literal> ::= StringLiteral");
break;
case ProductionIndex.Opname_Plus:
Debug.Log("<OpName> ::= '+'");
break;
case ProductionIndex.Opname_Minus:
Debug.Log("<OpName> ::= '-'");
break;
case ProductionIndex.Opname_Amp:
Debug.Log("<OpName> ::= '&'");
break;
case ProductionIndex.Opname_Caret:
Debug.Log("<OpName> ::= '^'");
break;
case ProductionIndex.Opname_Backslash:
Debug.Log("<OpName> ::= '\'");
break;
case ProductionIndex.Opname_Div:
Debug.Log("<OpName> ::= '/'");
break;
case ProductionIndex.Opname_Pipe:
Debug.Log("<OpName> ::= '|'");
break;
case ProductionIndex.Opname_Exclam:
Debug.Log("<OpName> ::= '!'");
break;
case ProductionIndex.Opname_Quote:
Debug.Log("<OpName> ::= \"");
break;
case ProductionIndex.Opname_A:
Debug.Log("<OpName> ::= A");
break;
case ProductionIndex.Opname_F:
Debug.Log("<OpName> ::= F");
break;
case ProductionIndex.Opsrightlist:
Debug.Log("<OpsRightList> ::= <OpsRight>");
break;
case ProductionIndex.Opsrightlist2:
Debug.Log("<OpsRightList> ::= <OpsRightList> <OpsRight>");
break;
case ProductionIndex.Opsright:
Debug.Log("<OpsRight> ::= <OpName>:" + r.get_Data(0));
break;
case ProductionIndex.Opsright2:
Debug.Log("<OpsRight> ::= <OpName> <Args>:" +r.get_Data(0));
break;
case ProductionIndex.Expressionlist:
Debug.Log("<Expression List> ::= <Expression>");
break;
case ProductionIndex.Expressionlist_Comma:
Debug.Log("<Expression List> ::= <Expression> ',' <Expression List>");
break;
case ProductionIndex.Expression_Eq:
Debug.Log("<Expression> ::= <Conditional Exp> '=' <Expression>");
break;
case ProductionIndex.Expression_Pluseq:
Debug.Log("<Expression> ::= <Conditional Exp> '+=' <Expression>");
break;
case ProductionIndex.Expression_Minuseq:
Debug.Log("<Expression> ::= <Conditional Exp> '-=' <Expression>");
break;
case ProductionIndex.Expression_Timeseq:
Debug.Log("<Expression> ::= <Conditional Exp> '*=' <Expression>");
break;
case ProductionIndex.Expression_Diveq:
Debug.Log("<Expression> ::= <Conditional Exp> '/=' <Expression>");
break;
case ProductionIndex.Expression_Careteq:
Debug.Log("<Expression> ::= <Conditional Exp> '^=' <Expression>");
break;
case ProductionIndex.Expression_Ampeq:
Debug.Log("<Expression> ::= <Conditional Exp> '&=' <Expression>");
break;
case ProductionIndex.Expression_Pipeeq:
Debug.Log("<Expression> ::= <Conditional Exp> '|=' <Expression>");
break;
case ProductionIndex.Expression_Percenteq:
Debug.Log("<Expression> ::= <Conditional Exp> '%=' <Expression>");
break;
case ProductionIndex.Expression_Ltlteq:
Debug.Log("<Expression> ::= <Conditional Exp> '<<=' <Expression>");
break;
case ProductionIndex.Expression_Gtgteq:
Debug.Log("<Expression> ::= <Conditional Exp> '>>=' <Expression>");
break;
case ProductionIndex.Expression:
Debug.Log("<Expression> ::= <Conditional Exp>");
break;
case ProductionIndex.Conditionalexp_Question_Colon:
Debug.Log("<Conditional Exp> ::= <Or Exp> '?' <Or Exp> ':' <Conditional Exp>");
break;
case ProductionIndex.Conditionalexp:
Debug.Log("<Conditional Exp> ::= <Or Exp>");
break;
case ProductionIndex.Orexp_Pipepipe:
Debug.Log("<Or Exp> ::= <Or Exp> '||' <And Exp>");
break;
case ProductionIndex.Orexp:
Debug.Log("<Or Exp> ::= <And Exp>");
break;
case ProductionIndex.Andexp_Ampamp:
Debug.Log("<And Exp> ::= <And Exp> '&&' <Logical Or Exp>");
break;
case ProductionIndex.Andexp:
Debug.Log("<And Exp> ::= <Logical Or Exp>");
break;
case ProductionIndex.Logicalorexp_Pipe:
Debug.Log("<Logical Or Exp> ::= <Logical Or Exp> '|' <Logical Xor Exp>");
break;
case ProductionIndex.Logicalorexp:
Debug.Log("<Logical Or Exp> ::= <Logical Xor Exp>");
break;
case ProductionIndex.Logicalxorexp_Caret:
Debug.Log("<Logical Xor Exp> ::= <Logical Xor Exp> '^' <Logical And Exp>");
break;
case ProductionIndex.Logicalxorexp:
Debug.Log("<Logical Xor Exp> ::= <Logical And Exp>");
break;
case ProductionIndex.Logicalandexp_Amp:
Debug.Log("<Logical And Exp> ::= <Logical And Exp> '&' <Equality Exp>");
break;
case ProductionIndex.Logicalandexp:
Debug.Log("<Logical And Exp> ::= <Equality Exp>");
break;
case ProductionIndex.Equalityexp_Eqeq:
Debug.Log("<Equality Exp> ::= <Equality Exp> '==' <Compare Exp>");
break;
case ProductionIndex.Equalityexp_Exclameq:
Debug.Log("<Equality Exp> ::= <Equality Exp> '!=' <Compare Exp>");
break;
case ProductionIndex.Equalityexp:
Debug.Log("<Equality Exp> ::= <Compare Exp>");
break;
case ProductionIndex.Compareexp_Lt:
Debug.Log("<Compare Exp> ::= <Compare Exp> '<' <Shift Exp>");
break;
case ProductionIndex.Compareexp_Gt:
Debug.Log("<Compare Exp> ::= <Compare Exp> '>' <Shift Exp>");
break;
case ProductionIndex.Compareexp_Lteq:
Debug.Log("<Compare Exp> ::= <Compare Exp> '<=' <Shift Exp>");
break;
case ProductionIndex.Compareexp_Gteq:
Debug.Log("<Compare Exp> ::= <Compare Exp> '>=' <Shift Exp>");
break;
case ProductionIndex.Compareexp:
Debug.Log("<Compare Exp> ::= <Shift Exp>");
break;
case ProductionIndex.Shiftexp_Ltlt:
Debug.Log("<Shift Exp> ::= <Shift Exp> '<<' <Add Exp>");
break;
case ProductionIndex.Shiftexp_Gtgt:
Debug.Log("<Shift Exp> ::= <Shift Exp> '>>' <Add Exp>");
break;
case ProductionIndex.Shiftexp:
Debug.Log("<Shift Exp> ::= <Add Exp>");
break;
case ProductionIndex.Addexp_Plus:
Debug.Log("<Add Exp> ::= <Add Exp> '+' <Mult Exp>");
break;
case ProductionIndex.Addexp_Minus:
Debug.Log("<Add Exp> ::= <Add Exp> '-' <Mult Exp>");
break;
case ProductionIndex.Addexp:
Debug.Log("<Add Exp> ::= <Mult Exp>");
break;
case ProductionIndex.Multexp_Times:
Debug.Log("<Mult Exp> ::= <Mult Exp> '*' <Unary Exp>");
break;
case ProductionIndex.Multexp_Div:
Debug.Log("<Mult Exp> ::= <Mult Exp> '/' <Unary Exp>");
break;
case ProductionIndex.Multexp_Percent:
Debug.Log("<Mult Exp> ::= <Mult Exp> '%' <Unary Exp>");
break;
case ProductionIndex.Multexp:
Debug.Log("<Mult Exp> ::= <Unary Exp>");
break;
case ProductionIndex.Unaryexp_Exclam:
Debug.Log("<Unary Exp> ::= '!' <Unary Exp>");
break;
case ProductionIndex.Unaryexp_Tilde:
Debug.Log("<Unary Exp> ::= '~' <Unary Exp>");
break;
case ProductionIndex.Unaryexp_Minus:
Debug.Log("<Unary Exp> ::= '-' <Unary Exp>");
break;
case ProductionIndex.Unaryexp_Plusplus:
Debug.Log("<Unary Exp> ::= '++' <Unary Exp>");
break;
case ProductionIndex.Unaryexp_Minusminus:
Debug.Log(" <Unary Exp> ::= '--' <Unary Exp>");
break;
case ProductionIndex.Unaryexp:
Debug.Log("<Unary Exp> ::= <Primary Exp>");
break;
case ProductionIndex.Primaryexp:
Debug.Log("<Primary Exp> ::= <Primary>");
break;
case ProductionIndex.Primaryexp_Lparen_Rparen:
Debug.Log("<Primary Exp> ::= '(' <Expression> ')'");
break;
case ProductionIndex.Primary:
Debug.Log("<Primary> ::= <Literal>");
break;
case ProductionIndex.Primary_Identifier:
Debug.Log("<Primary> ::= Identifier: " + r.get_Data(0));
break;
case ProductionIndex.Args_Lparen_Rparen:
Debug.Log("<Args> ::= '(' <Expression List> ')'");
break;
case ProductionIndex.Formalparamslist_Comma_Identifier:
Debug.Log("<FormalParamsList> ::= <FormalParamsList> ',' Identifier");
break;
case ProductionIndex.Formalparamslist_Identifier:
Debug.Log("< FormalParamsList> ::= Identifier: " + r.get_Data(0));
break;
case ProductionIndex.Formalparams_Lparen_Rparen:
Debug.Log("< FormalParams> ::= '(' <FormalParamsList> ')'");
break;
case ProductionIndex.Opsleft:
Debug.Log("<OpsLeft> ::= <OpName>");
break;
case ProductionIndex.Opsleft2:
Debug.Log("<OpsLeft> ::= <OpName> <FormalParams>");
break;
case ProductionIndex.Opsleftlist:
Debug.Log("<OpsLeftList> ::= <OpsLeft>");
break;
case ProductionIndex.Opsleftlist2:
Debug.Log("<OpsLeftList> ::= <OpsLeftList> <OpsLeft>");
break;
case ProductionIndex.Matchleftcontext_Lt:
Debug.Log("<MatchLeftContext> ::= <OpsLeftList> '<'");
break;
case ProductionIndex.Matchprime:
Debug.Log("<MatchPrime> ::= <OpsLeftList>");
break;
case ProductionIndex.Matchrightcontext_Gt:
Debug.Log("<MatchRightContext> ::= '>' <OpsLeftList>");
break;
case ProductionIndex.Match:
Debug.Log("<Match> ::= <MatchPrime>");
break;
case ProductionIndex.Match2:
Debug.Log("<Match> ::= <MatchLeftContext> <MatchPrime>");
break;
case ProductionIndex.Match3:
Debug.Log("<Match> ::= <MatchPrime> <MatchRightContext>");
break;
case ProductionIndex.Match4:
Debug.Log("<Match> ::= <MatchLeftContext> <MatchPrime> <MatchRightContext>");
break;
case ProductionIndex.Replace:
Debug.Log("<Replace> ::= <OpsRightList>");
break;
case ProductionIndex.Rule:
Debug.Log("<Rule> ::= <Match> <AssignOp> <Replace>");
break;
} //switch
return result;
}
}; //MyParser
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 748b688ccda93e344901a7a101666acc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+76
View File
@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Lens
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.719
- _GlossyReflections: 1
- _Metallic: 0.77
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bed699302eed2384f888b027d5c06e4c
timeCreated: 1497022653
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+1761
View File
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4422d50adf83b7f4281a4831484733a5
timeCreated: 1497018731
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2462dedac3604d249b25b8c67e0f6cb7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+26
View File
@@ -0,0 +1,26 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Checker
m_Shader: {fileID: 4800000, guid: 7e2286fc7b91c35469eb39d0c66eba97, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 9d3d521edbb1c604dacd9bbf11f84763, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: []
m_Colors: []
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 468f9e6e87e792c4594b1b37d13f095f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+11
View File
@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaneFunction2D : Function2D {
public override double Evaluate(double u, double v)
{
return 2.0f;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 047a5591222758c4db9336f0487a60ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+69
View File
@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Plot2D : MonoBehaviour {
public Function2D Function;
public Vector4 ArgsBounds = new Vector4(0, 0, 1, 1);
public Vector4 ViewBounds = new Vector4(0, 0, 1, 1);
public int USamples = 10;
public int VSamples = 10;
private Vector3[] _points;
private void OnValidate()
{
if(USamples < 2) {
USamples = 2;
}
if (VSamples < 2) {
VSamples = 2;
}
}
private void OnDrawGizmos()
{
if(Function == null) {
return;
}
var pointsCount = USamples * VSamples;
if(_points == null || _points.Length != pointsCount) {
_points = new Vector3[USamples * VSamples];
}
for (int vI = 0; vI < VSamples; ++vI) {
double lV = (double)vI / (VSamples - 1);
for (int uI = 0; uI < USamples; ++uI) {
double lU = (double)uI / (USamples - 1);
double u = lU * ArgsBounds.z + ArgsBounds.x;
double v = lV * ArgsBounds.w + ArgsBounds.y;
double z = Function.Evaluate(u, v);
double x = lU * ViewBounds.z + ViewBounds.x;
double y = lV * ViewBounds.w + ViewBounds.y;
_points[vI * USamples + uI] = new Vector3((float)x, (float)z, (float)y);
}
}
for(int y = 0; y < VSamples; ++y) {
for (int x = 1; x < USamples; ++x) {
Gizmos.DrawLine(_points[y * USamples + (x - 1)], _points[y * USamples + x]);
}
}
for (int y = 1; y < VSamples; ++y) {
for (int x = 0; x < USamples; ++x) {
Gizmos.DrawLine(_points[(y - 1) * USamples + x], _points[y * USamples + x]);
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7f5b7d1ffa828a4c9ed02cefa69397a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+16
View File
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlotSampler : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07f58c9abbb13ee4bbd9abeb6c2eb8bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+281
View File
@@ -0,0 +1,281 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class Polynom : MonoBehaviour {
public float[] Coeffs = new float[] { 0, 0, 0.01f, 0, 0.01f };
public PlotSampler Sampler;
public TraceRay PlotTraceRay;
public int lonSamples = 256;
public int latSamples = 50;
void Start () {
}
void Update () {
}
float Sagitta(float r) {
float y = 0;
int i = 0;
for (i = 4; i >= (int) 2; i--) {
y = y * r + Coeffs[i];
}
y *= Mathf.Pow(r, i + 1);
return y;
}
float Derivative(float r){
float y = 0;
int i = 0;
for (i = 4; i >= 2; i--) {
y = y * r + i * Coeffs[i];
}
y *= Mathf.Pow(r, i);
return y;
}
public float Fx(float x){
return Mathf.Pow(x, 4) * Coeffs[4] + Mathf.Pow(x, 2) * Coeffs[2];
}
Vector3 Normal(Vector3 point){
float r = Mathf.Sqrt(point.x * point.x + point.z * point.z);
if(r == 0) {
return Vector3.up;
} else {
var d = Derivative(r);
return new Vector3(point.x * d / r, -1, point.z * d / r).normalized * -1.0f;
}
}
float RayPlaneDistance(Ray plane, Ray ray)
{
return (Vector3.Dot(plane.origin, plane.direction) - Vector3.Dot(plane.direction, ray.origin)) / (Vector3.Dot(ray.direction, plane.direction));
}
bool Intersect(Ray ray, float startX, float maxX, ref Vector3 point)
{
Ray p = new Ray();
// initial intersection with z=0 plane
{
float s = ray.direction.y;
if (s == 0)
return false;
float a = -ray.origin.y / s;
if (a < 0)
return false;
p.origin = (ray.origin + ray.direction * a).normalized * startX;
}
// p.origin = new Vector3(startX, 0, 0);
// p.direction = Normal(p.origin).normalized;
int n = 64; // avoid infinite loop
while (n-- != 0) {
float new_sag = Sagitta(new Vector2(p.origin.x, p.origin.z).magnitude);
float old_sag = p.origin.y;
// project previous intersection point on curve
p.origin = new Vector3(p.origin.x, new_sag, p.origin.z);
// stop if close enough
if (Mathf.Abs(old_sag - new_sag) < 1e-6)
break;
// get curve tangeante plane at intersection point
p.direction = Normal(p.origin);
// intersect again with new tangeante plane
float a = RayPlaneDistance(p, ray);
// if (a < 0)
// return false;
p.origin = ray.origin + ray.direction * a;
}
if(n <=0) {
return false;
}
if(Vector3.Dot(-ray.direction, Normal(p.origin)) < 0.0f) {
return false;
}
if((new Vector2(p.origin.x, p.origin.z)).sqrMagnitude > (maxX * maxX)) {
return false;
}
point = p.origin;
return true;
}
bool Intersect(Ray ray, ref Vector3 point)
{
var extremums = FindExtremums(4.0f);
extremums.Add(4);
List<float> startPoints = new List<float>();
for (int i = 0; i < extremums.Count - 1; ++i) {
startPoints.Add((extremums[i] + extremums[i + 1]) * 0.5f);
}
List<Vector3> points = new List<Vector3>();
foreach (var e in startPoints) {
if (Intersect(ray, e, 4.0f, ref point)) {
points.Add(point);
}
}
if(points.Count > 0) {
point = points.OrderBy(v => (v - ray.origin).magnitude).First();
return true;
} else {
return false;
}
}
List<float> FindExtremums(float range)
{
List<float> result = new List<float>();
List<float> points = new List<float>();
for (int i = 0; i < 10; ++i) {
points.Add(Derivative(i / 10.0f * range));
}
for (int i = 0; i < 10 - 1; ++i) {
if(Mathf.Abs(points[i]) < 0.000001f) {
result.Add(points[i]);
} else if (Mathf.Abs(points[i + 1]) < 0.000001f) {
result.Add(points[i + 1]);
i++;
} else {
if(Mathf.Sign(points[i]) != Mathf.Sign(points[i + 1])) {
//find zero with secant
float x1 = i / 10.0f * range;
float x2 = (x1 + ((i + 1) / 10.0f * range)) * 0.5f;
float y1 = Derivative(x1);
float y2 = Derivative(x2);
int id = 0;
while (true) {
id++;
if(id > 100) {
break;
}
if (Mathf.Abs(y2) < 0.000001f || Mathf.Abs(y2 - y1) < 0.000001f) {
break;
}
float d = (x2 - x1) / (y2 - y1);
var x2_ = x2;
x2 = x1 - Derivative(x1) * d;
x1 = x2_;
y1 = Derivative(x1);
y2 = Derivative(x2);
}
result.Add(x2);
}
}
}
return result;
}
private void OnDrawGizmos()
{
Gizmos.matrix = transform.localToWorldMatrix;
var extremums = FindExtremums(4.0f);
var maxPoint = extremums.Max();
var minPoint = extremums.Min();
foreach (var ext in extremums) {
Gizmos.color = Color.red;
Gizmos.DrawLine(new Vector3(ext, 0, 0), new Vector3(ext, 100, 0));
}
Gizmos.color = Color.white;
List<Vector3> oldPlot = new List<Vector3>();
for (int j = 0; j < latSamples; ++j) {
// Gizmos.matrix = Matrix4x4.Rotate(Quaternion.AngleAxis(360/20*j, Vector3.up)) * transform.localToWorldMatrix;
Vector3 last = Vector3.zero;
for (int i = 0; i <= lonSamples; ++i) {
float x = (i / (float)lonSamples - 0.5f) * 2.0f * 4.0f;
float val = Fx(x);
Gizmos.color = (Color.Lerp(Color.red, Color.green, (val - minPoint) / (maxPoint - minPoint)));
Vector3 current = Quaternion.AngleAxis(360 / (float)latSamples * j, Vector3.up) * new Vector3(x, val, 0);
if(oldPlot.Count <= i) {
oldPlot.Add(current);
} else {
Gizmos.DrawLine(oldPlot[i], current);
oldPlot[i] = current;
}
if (i != 0) {
Gizmos.DrawLine(last, current);
}
last = current;
}
}
Gizmos.matrix = transform.localToWorldMatrix;
if (Sampler != null) {
float sagitta = Sagitta(Sampler.transform.position.x);
float derivative = Derivative(Sampler.transform.position.x);
Gizmos.DrawWireSphere(new Vector3(Sampler.transform.position.x, sagitta, 0), 0.1f);
Gizmos.color = Color.red;
Gizmos.DrawLine(new Vector3(Sampler.transform.position.x, sagitta, 0), new Vector3(Sampler.transform.position.x, sagitta, 0) + new Vector3(1, derivative, 0) * 0.5f);
Gizmos.color = Color.blue;
Gizmos.DrawLine(new Vector3(Sampler.transform.position.x, sagitta, 0), new Vector3(Sampler.transform.position.x, sagitta, 0) + Normal(new Vector3(Sampler.transform.position.x, sagitta, 0)));
//float sagitta = Sagitta(Sampler.transform.position.x);
}
if(PlotTraceRay != null) {
Vector3 intersection = Vector3.zero;
if(Intersect(new Ray(PlotTraceRay.transform.position, PlotTraceRay.transform.forward), ref intersection)) {
Gizmos.DrawWireCube(intersection, Vector3.one * 0.1f);
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbd305bbce2b1d64b90f69227b4d83ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+364
View File
@@ -0,0 +1,364 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using System.Linq;
public class Geometry{
public List<Vector3> vertices = new List<Vector3>();
public List<int> indices = new List<int>();
public List<Vector3> normals = new List<Vector3>();
public void StoreToMesh(Mesh mesh){
mesh.subMeshCount = 1;
mesh.Clear();
mesh.vertices = vertices.ToArray();
mesh.normals = normals.ToArray();
mesh.SetIndices(indices.ToArray(), MeshTopology.Triangles, 0);
mesh.RecalculateBounds();
}
}
public abstract class GeometryProcessor {
public abstract Geometry Execute (Geometry geometry);
}
public class GenCylinder : GeometryProcessor
{
public float Radius = 1.0f;
public float Height = 1.0f;
public int Tesselation = 16;
public static Geometry Execute(Geometry geometry, float radius, float height, int tesselation = 16)
{
var processor = new GenCylinder();
processor.Radius = radius;
processor.Height = height;
processor.Tesselation = tesselation;
return processor.Execute(geometry);
}
public override Geometry Execute(Geometry geometry)
{
if(geometry == null)
{
throw new System.Exception("Geometry is null");
}
var vertexOffset = geometry.vertices.Count;
//vertices
for (int i = 0; i < Tesselation; ++i)
{
float angle = 360.0f / Tesselation * i;
float x = Mathf.Sin(angle * Mathf.Deg2Rad) * Radius;
float z = Mathf.Cos(angle * Mathf.Deg2Rad) * Radius;
float halfH = Height * 0.5f;
geometry.vertices.Add(new Vector3(x, halfH, z));
geometry.vertices.Add(new Vector3(x, -halfH, z));
var normal = new Vector3(x, 0, z).normalized;
geometry.normals.Add(normal);
geometry.normals.Add(normal);
}
//indices
for (int i = 0; i < Tesselation; ++i)
{
int t0 = i * 2 + 0;
int b0 = i * 2 + 1;
int t1 = ((i + 1) % Tesselation) * 2 + 0;
int b1 = ((i + 1) % Tesselation) * 2 + 1;
geometry.indices.Add(t0 + vertexOffset);
geometry.indices.Add(b0 + vertexOffset);
geometry.indices.Add(t1 + vertexOffset);
geometry.indices.Add(t1 + vertexOffset);
geometry.indices.Add(b0 + vertexOffset);
geometry.indices.Add(b1 + vertexOffset);
}
return geometry;
}
}
public static class SphereUtils
{
public static float SphereCenterOffset(float sphereRadius, float visibleRadius)
{
return Mathf.Sqrt(sphereRadius * sphereRadius - visibleRadius * visibleRadius);
}
}
public class GenSphericalCap : GeometryProcessor
{
public float Radius = 1.0f;
public float CapRadius = 1.0f;
public int RTesselation = 16;
public int CTesselation = 16;
public static Geometry Execute(Geometry geometry, float radius, float capRadius, int tessR = 16, int tessC = 16)
{
GenSphericalCap processor = new GenSphericalCap();
processor.Radius = radius;
processor.CapRadius = capRadius;
processor.RTesselation = tessR;
processor.CTesselation = tessC;
return processor.Execute(geometry);
}
public override Geometry Execute(Geometry geometry)
{
int vertexOffset = geometry.vertices.Count;
for (int i = 0; i < CTesselation; ++i)
{
int pointsCount = i == 0 ? 1 : RTesselation;
//generate circle
for (int j = 0; j < pointsCount; ++j)
{
float angle = 360.0f / RTesselation * j;
float rCircle = Radius / (CTesselation - 1) * i;
float x = Mathf.Sin(angle * Mathf.Deg2Rad) * rCircle;
float z = Mathf.Cos(angle * Mathf.Deg2Rad) * rCircle;
float y = (SphereUtils.SphereCenterOffset(CapRadius, rCircle) - SphereUtils.SphereCenterOffset(CapRadius, Radius)) * Mathf.Sign(CapRadius);
geometry.vertices.Add(new Vector3(x, y, z));
geometry.normals.Add(Vector3.up);
}
}
//indices
for (int i = 0; i < CTesselation - 1; ++i)
{
if (i == 0)
{
for (int j = 0; j < RTesselation; ++j)
{
geometry.indices.Add(0 + vertexOffset);
geometry.indices.Add(j + 1 + vertexOffset);
geometry.indices.Add((j + 1) % RTesselation + 1 + vertexOffset);
}
vertexOffset += 1;
}
else
{
for (int j = 0; j < RTesselation; ++j)
{
int a0 = RTesselation * (i - 1) + j;
int a1 = RTesselation * (i - 1) + (j + 1) % RTesselation;
int b0 = RTesselation * (i - 0) + j;
int b1 = RTesselation * (i - 0) + (j + 1) % RTesselation;
geometry.indices.Add(a0 + vertexOffset);
geometry.indices.Add(b0 + vertexOffset);
geometry.indices.Add(a1 + vertexOffset);
geometry.indices.Add(b0 + vertexOffset);
geometry.indices.Add(b1 + vertexOffset);
geometry.indices.Add(a1 + vertexOffset);
}
}
}
return geometry;
}
}
public class AttachGeometry : GeometryProcessor
{
public List<Geometry> Others = new List<Geometry>();
public static Geometry Execute(Geometry geometry, IEnumerable<Geometry> others)
{
var processor = new AttachGeometry();
processor.Others.AddRange(others);
return processor.Execute(geometry);
}
public override Geometry Execute(Geometry geometry)
{
foreach(var other in Others)
{
var indexOffset = geometry.vertices.Count;
geometry.vertices.AddRange(other.vertices);
geometry.normals.AddRange(other.normals);
geometry.indices.AddRange(other.indices.Select(v => v + indexOffset));
}
return geometry;
}
}
public class VectorOffset : GeometryProcessor
{
public Vector3 Offset = Vector3.zero;
public static Geometry Execute(Geometry geometry, Vector3 offset) {
var processor = new VectorOffset();
processor.Offset = offset;
return processor.Execute(geometry);
}
public override Geometry Execute(Geometry geometry){
for(int i = 0; i < geometry.vertices.Count; ++i) {
geometry.vertices[i] += Offset;
}
return geometry;
}
}
public class FlipFaces : GeometryProcessor
{
public static Geometry ExecuteStatic(Geometry geometry)
{
var processor = new FlipFaces();
return processor.Execute(geometry);
}
public override Geometry Execute(Geometry geometry)
{
for (int i = 0; i < geometry.indices.Count; i+=3)
{
var tmp = geometry.indices[i];
geometry.indices[i] = geometry.indices[i + 1];
geometry.indices[i + 1] = tmp;
}
for (int i = 0; i < geometry.normals.Count; ++i)
{
geometry.normals[i] = -geometry.normals[i];
}
return geometry;
}
}
public class ThinLense : MonoBehaviour {
public float R1;
public float R2;
public float LensIOR = 1.5f;
public float EnvironmentIOR = 1.0f;
public float RLense;
public float Thickness = 0.1f;
[Range(3, 128)]
public int tessR = 32;
[Range(2, 128)]
public int tessC = 32;
private void OnValidate()
{
if(RLense < 0)
{
RLense = 0;
}
/*if(R1 < RLense)
{
R1 = RLense;
}*/
if(Thickness < 0.0f)
{
Thickness = 0.0f;
}
UpdateMesh();
}
float FocalLength()
{
float rcpF = (LensIOR - EnvironmentIOR) * ((1.0f / R1) - (1.0f / R2));
return 1.0f / rcpF;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void UpdateMesh()
{
var mr = GetComponent<MeshRenderer>();
if(mr == null)
{
mr = gameObject.AddComponent<MeshRenderer>();
}
var mf = GetComponent<MeshFilter>();
if(mf == null)
{
mf = gameObject.AddComponent<MeshFilter>();
}
var m = mf.sharedMesh;
if(m == null)
{
m = new Mesh();
mf.sharedMesh = m;
}
if(Mathf.Abs(R1) < RLense)
{
return;
}
//generate cylinder
var cyl = GenCylinder.Execute(new Geometry(), RLense, Thickness, tessR);
var cap1 = GenSphericalCap.Execute(new Geometry(), RLense, R1, tessR, tessC);
cap1 = VectorOffset.Execute(cap1, new Vector3(0, Thickness * 0.5f, 0));
var cap2 = GenSphericalCap.Execute(new Geometry(), RLense, R2, tessR, tessC);
cap2 = VectorOffset.Execute(cap2, new Vector3(0, -Thickness * 0.5f, 0));
cap2 = FlipFaces.ExecuteStatic(cap2);
AttachGeometry.Execute(new Geometry(), new []{cyl, cap1, cap2 }).StoreToMesh(m);
}
private void OnDrawGizmos()
{
Handles.matrix = transform.localToWorldMatrix;
//Handles.DrawWireDisc(Vector3.zero, Vector3.up, RLense);
//Gizmos.DrawWireSphere(Vector3.up * - SphereUtils.SphereCenterOffset(R1, RLense), R1);
Handles.matrix = Matrix4x4.identity;
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 616ee3eac1037f041aefec1caa1ce347
timeCreated: 1497015654
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+21
View File
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TraceRay : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private void OnDrawGizmos()
{
Gizmos.DrawLine(transform.position, transform.position + transform.forward);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 048f3b29954301848937334ad8a973cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+33
View File
@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class ZemaxConstructor : MonoBehaviour {
public enum SurfaceType
{
Standard
}
[Serializable]
public class Surface
{
public SurfaceType Type;
public float Radius;
public float Thickness;
public float SemiDiameter;
}
public Surface[] surfaces;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e85aaff5e2886e4d9ca1bdcf39a3fe8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: