public WaveGridWindow() { InitializeComponent(); _grid = new WaveGrid(GridSize); // 10x10 grid slidPeakHeight.Value = _firstPeak; _grid.SetCenterPeak(_firstPeak); meshMain.Positions = _grid.Points; meshMain.TriangleIndices = _grid.TriangleIndices; // On each WheelMouse change, we zoom in/out a particular % of the original distance const double ZoomPctEachWheelChange = 0.02; zoomDelta = Vector3D.Multiply(ZoomPctEachWheelChange, camMain.LookDirection); }
// Start/stop animation private void btnStart_Click(object sender, RoutedEventArgs e) { if (!_rendering) { _grid = new WaveGrid(GridSize); // 10x10 grid _grid.SetCenterPeak(_firstPeak); meshMain.Positions = _grid.Points; _lastTimeRendered = 0.0; CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); btnStart.Content = "Stop"; slidPeakHeight.IsEnabled = false; _rendering = true; } else { CompositionTarget.Rendering -= new EventHandler(CompositionTarget_Rendering); btnStart.Content = "Start"; slidPeakHeight.IsEnabled = true; _rendering = false; } }
void Start() { #if UNITY_EDITOR print("UNITY_EDITOR"); #endif #if UNITY_IPHONE print("UNITY_IPHONE"); #endif mouseDown = false; lastUpdateTime = 0; theMesh = meshFilter.mesh; int arrSize = gridDimensionX*gridDimensionY; origUV1s = new Vector2[arrSize]; //origUV2s = new Vector2[arrSize]; uvs = new Vector2[arrSize]; uv2s = new Vector2[arrSize]; Vector2 o = new Vector2(0.5f,0.5f); Vector2[] uv = theMesh.uv; Array.Copy(uv,uvs,arrSize); Array.Copy(uv,origUV1s,arrSize); //Debug.Log("Expected uv count " + arrSize + " real count " + uv.Length); for(int i = 0; i < arrSize; ++i) { //origUV1s[i] = uvs[i] = uv[i]; uv2s[i] = o; } if(useNative) { InitWaves(gridDimensionX,gridDimensionY); // "pin" the array in memory, so we can pass direct pointer to it's data to the plugin, // without costly marshaling of array of structures. //gchColorsPointer = GCHandle.Alloc(colors, GCHandleType.Pinned); gchOrigUV1sPointer = GCHandle.Alloc(origUV1s, GCHandleType.Pinned); gchUV1sPointer = GCHandle.Alloc(uvs, GCHandleType.Pinned); gchUV2sPointer = GCHandle.Alloc(uv2s, GCHandleType.Pinned); print ("Using native"); } else { waveGrid = new WaveGrid(gridDimensionX, gridDimensionY); print ("Not using native"); } }