/// <summary> /// Initializes a new instance of the <see cref="DepthCueing"/> class. /// </summary> public DepthCueing() { // We get the ReadDX object and from it, the values we need. readDx = GUIMoleculeController.readdx; depth = readDx._grid; xDim = depth.GetLength(0); yDim = depth.GetLength(1); zDim = depth.GetLength(2); Debug.Log("Dimensions:"); Debug.Log(xDim.ToString()); Debug.Log(yDim.ToString()); Debug.Log(zDim.ToString()); Vector3 delta = readDx.GetDelta(); invDelta = delta; invDelta.x = 1f / delta.x; invDelta.y = 1f / delta.y; invDelta.z = 1f / delta.z; origin = readDx.GetOrigin(); // This is needed to correctly localize things. Unity's convention is different from our input data. origin.x = -origin.x; balls = GameObject.FindObjectsOfType(typeof(BallUpdate)) as BallUpdate[]; BuildColorList(); DepthCueing.reset = false; }
public GUIMoleculeController() { #if !UNITY_WEBPLAYER m_last_extSurf_Path = System.IO.Directory.GetCurrentDirectory(); #endif scenecontroller = GameObject.Find("LoadBox"); Molecule3DComp = scenecontroller.GetComponent <Molecule3D> (); /* * listatom = new GUIContent[11]; * listatom[0] = new GUIContent("Cube"); * listatom[1] = new GUIContent("Sphere"); * listatom[2] = new GUIContent("HyperBall"); * listatom[3] = new GUIContent("Raycasting"); * listatom[4] = new GUIContent("Common Billboard"); * listatom[5] = new GUIContent("RayCasting Billboard"); * listatom[6] = new GUIContent("HyperBall Billboard"); * listatom[7] = new GUIContent("RayCasting Sprite"); * listatom[8] = new GUIContent("Multi-Hyperball"); * listatom[9] = new GUIContent("CombineMesh HyperBall"); * listatom[10] = new GUIContent("ParticleBall"); * * listbond = new GUIContent[7]; * listbond[0] = new GUIContent("Cube"); * listbond[1] = new GUIContent("Line"); * listbond[2] = new GUIContent("HyperStick"); * listbond[3] = new GUIContent("Tube Stick"); * listbond[4] = new GUIContent("Billboard HyperStick"); * listbond[5] = new GUIContent("Particle Stick"); * listbond[6] = new GUIContent("No Stick"); */ //Get the ReadDX component readdx = scenecontroller.GetComponent <ReadDX>(); // Debug.Log("READDX GUIMolecule: " + readdx); // Make a GUIStyle that has a solid white hover/onHover background to indicate highlighted items listStyle = new GUIStyle(); listStyle.normal.textColor = Color.white; Texture2D tex = new Texture2D(2, 2); Color[] colors = new Color[4]; for (int i = 0; i < 4; i++) { colors [i] = Color.white; } tex.SetPixels(colors); tex.Apply(); listStyle.hover.background = tex; listStyle.onHover.background = tex; listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4; aTexture = (Texture2D)Resources.Load("EnergyGrayColorAlpha"); }
/// <summary> /// Creates the surface objects. /// </summary> /// <param name='voxels'> /// Voxels, i.e. the scalar field used to compute the surface. /// </param> /// <param name='threshold'> /// The threshold on which the isosurface is based. /// </param> /// <param name='delta'> /// Delta parameter from the grid, basically the size of each cell. /// </param> /// <param name='origin'> /// Origin of the grid. /// </param> /// <param name='colors'> /// Colors. Kept from previous implementation, but doesn't do anything here. I'm only /// keeping it because I'm not sure what it was used for. --- Alexandre /// </param> /// <param name='tag'> /// Tag for the objects to be created. /// </param> /// <param name='electro'> /// True if this is an electrostatic field isosurface. /// </param> public static void CreateSurfaceObjects(float[,,] voxels, float threshold, Vector3 delta, Vector3 origin, Color[] colors, string tag = "SurfaceManager", bool electro = false) { ELECTRO = electro; Debug.Log(ELECTRO.ToString()); if (ELECTRO) { ReadDX readDX = UI.GUIMoleculeController.readdx; origin = readDX.GetOrigin(); delta = readDX.GetDelta(); } InitGenMesh(voxels, threshold, delta, origin, tag); SetDims(); float bMCTime = Time.realtimeSinceStartup; MeshData mData = MarchingCubes.CreateMesh(VOXELS, 0, XDIM, 0, YDIM, 0, ZDIM); Debug.Log("Entire surface contains " + mData.vertices.Length.ToString() + " vertices."); float elapsed = 10f * (Time.realtimeSinceStartup - bMCTime); Debug.Log("GenerateMesh::MarchingCubes time: " + elapsed.ToString()); OffsetVertices(mData); float bSmooth = Time.realtimeSinceStartup; AdjacencySets adjacencySets = new AdjacencySets(mData.triangles.Length); adjacencySets.AddAllTriangles(mData.triangles); SmoothFilter.AdjSetsSmoother(mData, adjacencySets); elapsed = Time.realtimeSinceStartup - bSmooth; Debug.Log("Smoothing time: " + elapsed.ToString()); ProperlyCalculateNormals(mData); // Necessary for electrostatic fields isosurfaces Debug.Log(threshold.ToString()); if (threshold < 0) { FlipTriangles(mData); } Splitting splitting = new Splitting(); List <Mesh> meshes = splitting.Split(mData); CreateSurfaceObjects(meshes); }
public override void Init() { // We get the ReadDX object and from it, the values we need. readDx = GUIMoleculeController.readdx; density = readDx._grid; delta = readDx.GetDelta(); origin = readDx.GetOrigin(); // This is needed to correctly place the particles. origin.x = -origin.x; // Getting the bounds and amplitude of the electrostatics field. foreach (float f in density) { if (f > maxCharge) { maxCharge = f; } if (f < minCharge) { minCharge = f; } } // ChargeAmplitude = largest absolute value if ((-minCharge) > maxCharge) { chargeAmplitude = -minCharge; } else { chargeAmplitude = maxCharge; } Debug.Log("Amplitude:"); Debug.Log(chargeAmplitude.ToString()); // We get the parent object and a reference to its particle system, so we can control it. parentObj = GameObject.FindGameObjectWithTag("Volumetric"); pSystem = parentObj.GetComponent <ParticleSystem>(); // Creating the dynamic particle list, building the static particle array, // setting it to the particle system, and enabling the renderer. SetParticleSystem(); } // End of Init
public void init2() { // int ind = 0; ReadDX dx = GameObject.Find("LoadBox").GetComponent <ReadDX>(); for (int i = 0; i < _grid.GetLength(0) - 2; i++) { for (int j = 0; j < _grid.GetLength(1) - 2; j++) { for (int k = 0; k < _grid.GetLength(2) - 2; k++) { _grid[i, j, k] = dx.getGradient(i, j, k); // if (i== 50) // ("gradient : "+ReadDX.getGradient(i,j,k)+" grid : " + _grid[i,j,k]); // ind ++; } } } }