UnityMol  0.9.6-875
UnityMol viewer / In developement
Volumetric.cs
Go to the documentation of this file.
1 
66 using UnityEngine;
67 using System.Collections.Generic;
68 using Molecule.Model;
69 
70 public abstract class Volumetric : MonoBehaviour {
71  public static float particleScale = 2.5f;
72  protected float ALPHA_THRESHOLD = 0.05f;
73 
74  protected bool raise = false;
75  protected float ALPHA_FACTOR = 7f;
76 
77  protected float[,,] density;
78 
79  protected ParticleSystem.Particle[] points;
80  protected List<ParticleSystem.Particle> dynPoints = new List<ParticleSystem.Particle>();
81  public int pNumber;
82  protected static Vector3 delta;
83  protected static Vector3 origin = MoleculeModel.MinValue;
84 
88  public abstract void Init();
89 
95  public abstract void CreatePoints();
96 
97  public void ShowHide(){
98  bool show = ElectrostaticManager.particleSystem.GetComponent<Renderer>().enabled;
99  ElectrostaticManager.particleSystem.GetComponent<Renderer>().enabled = !show;
100  }
105  public void Clear()
106  {
107  points = null;
108  pNumber = 0;
109  ElectrostaticManager.particleSystem.GetComponent<Renderer>().enabled = false;
110  dynPoints.Clear();
111  Destroy(this);
112  }
113 
119  protected void AlphaCulling(float cull) {
120  //dynPoints.RemoveAll(item => item.color.a < cull);
121  dynPoints.RemoveAll(item => item.startColor == Color.blue);
122  }
123 
127  protected void BuildParticleArray()
128  {
129  pNumber = dynPoints.Count;
130  points = new ParticleSystem.Particle[pNumber];
131  for(int i=0; i<pNumber; i++)
132  points[i] = dynPoints[i];
133  }
134 
140  protected void SetParticleSystem()
141  {
142 
143  CreatePoints();
144 
145  //AlphaCulling(0.10f); // you could further cull here.
147 
148  ElectrostaticManager.particleSystem.SetParticles(points, pNumber);
149  ElectrostaticManager.particleSystem.GetComponent<Renderer>().enabled = true;
150  }
151 }
float ALPHA_THRESHOLD
Definition: Volumetric.cs:72
abstract void CreatePoints()
Creates the points for this particle system.
static ParticleSystem particleSystem
ParticleSystem.Particle[] points
Definition: Volumetric.cs:79
void ShowHide()
Definition: Volumetric.cs:97
List< ParticleSystem.Particle > dynPoints
Definition: Volumetric.cs:80
static float particleScale
Definition: Volumetric.cs:71
abstract void Init()
Initializes this instance.
void SetParticleSystem()
Sets the particle system.
Definition: Volumetric.cs:140
void AlphaCulling(float cull)
Removes from the dynamic particle list all particles whose alpha component is lower than ALPHA_THRESH...
Definition: Volumetric.cs:119
static Vector3 delta
Definition: Volumetric.cs:82
int pNumber
Definition: Volumetric.cs:81
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule.
float[,,] density
Definition: Volumetric.cs:77
float ALPHA_FACTOR
Definition: Volumetric.cs:75
void Clear()
Clears this instance.
Definition: Volumetric.cs:105
void BuildParticleArray()
Builds the static particle array from the dynamic list.
Definition: Volumetric.cs:127
static Vector3 origin
Definition: Volumetric.cs:83