private void select(PointCloudBehaviour building) { this.selectedBuilding = building; this.selectionMarker.CoordinatesWGS84 = this.selectedBuilding.GetComponent <LocationMarkerBehaviour>().CoordinatesWGS84; var shape = this.selectedBuilding.GetComponent <PointCloudBehaviour>().PointCloud.Shape; this.selectionRenderer.positionCount = shape.Length; this.selectionRenderer.SetPositions(shape.Select(p => new Vector3(p.x, 0.25f, p.y)).ToArray()); }
public static void DisplayPlane(Plane plane, PointCloudBehaviour pointCloudBehaviour) { GameObject planeGameObject = new GameObject(); var planeBehaviour = planeGameObject.AddComponent <PlaneBehaviour>(); planeBehaviour.Plane = plane; planeBehaviour.PointCloudBehaviour = pointCloudBehaviour; planeGameObject.transform.parent = pointCloudBehaviour.transform; planeBehaviour.Initialize(); planeBehaviour.gameObject.layer = 9; }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <PointCloudBehaviour> .Create(graph, template); PointCloudBehaviour clone = playable.GetBehaviour(); MarchingCubesManagerRef.defaultValue = FindObjectOfType(typeof(DensityFieldManager)) as DensityFieldManager; clone.MarchingCubesManagerRef = MarchingCubesManagerRef.Resolve(graph.GetResolver()); clone.RegisterPointCloudClip(); return(playable); }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <PointCloudBehaviour> .Create(graph, template); PointCloudBehaviour clone = playable.GetBehaviour(); //connect first marching cubes manager that is found in the scene DensityFieldManager[] managers = FindObjectsOfType(typeof(DensityFieldManager)) as DensityFieldManager[]; if (managers.Length > 0) { MarchingCubesManagerRef.defaultValue = managers[0]; } clone.MarchingCubesManagerRef = MarchingCubesManagerRef.Resolve(graph.GetResolver()); clone.RegisterPointCloudClip(); return(playable); }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { int inputCount = playable.GetInputCount(); bool densityFieldCleared = false; #if !UNITY_EDITOR //check the current time of timeline /* PlayableDirector director = DFMRef_.gameObject.GetComponent<PlayableDirector>(); * int frame = -1; * * if (director != null) * { #if UNITY_PS4 * int frameRate = 60; #else * int frameRate = 90; #endif * //frame = (int)(director.time * frameRate); * } * * if (lastMixerFrame == frame) * return; * * lastMixerFrame = frame;*/ #endif for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.0f) { ScriptPlayable <PointCloudBehaviour> inputPlayable = (ScriptPlayable <PointCloudBehaviour>)playable.GetInput(i); float time = (float)inputPlayable.GetTime(); PointCloudBehaviour input = inputPlayable.GetBehaviour(); #if UNITY_EDITOR if (input.PointCloudDirectory != input.PointCloudDirectoryInternal) { input.SetFrameFileList(); } #endif if (input.frameFiles.Length == 0) { continue; } if (!densityFieldCleared) { ClearDensityField(DFMRef_.Resolution); densityFieldCleared = true; } int newFrame = (int)(time * 30.0f); float fraction = (time * 30.0f) - (int)(time * 30.0f); Shader.SetGlobalFloat("_ArtSpaces_frame_fraction", fraction); bool forceReload = false; if (newFrame - input.frameNo != 0 && newFrame - input.frameNo != 1) { forceReload = true; #if UNITY_EDITOR UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); #endif } input.frameNo = newFrame; if (input.frameNo >= input.frameFiles.Length) { input.frameNo = input.frameFiles.Length - 1; } int nextFrameNo = newFrame + 1; if (nextFrameNo >= input.frameFiles.Length) { nextFrameNo = input.frameFiles.Length - 1; } SetParticleClipFrameName(input.GetHashCode(), input.frameFiles[input.frameNo], input.frameFiles[nextFrameNo], fraction, inputWeight * input.influence, DFMRef_.Resolution, input.scale.x, input.scale.y, input.scale.z, input.translate.x, input.translate.y, input.translate.z, forceReload); //Debug.Log("Current frame: " + input.frameNo + " Next frame: " + nextFrameNo + " fraction: " + fraction); } } DFMRef_.numPointCloudParticles_ = GenerateDensityField(GetHashCode()); if (DFMRef_.numPointCloudParticles_ >= 0) { DFMRef_.particleBuffer_.SetData(particles_, 0, 0, DFMRef_.numPointCloudParticles_); } }
void Awake() { if (Instance) { LogError ("Only one instance of PointCloudBehaviour allowed!"); } Instance = this; Application.targetFrameRate = 60; }