3 using System.Collections.Generic;
19 public static float cutX = 1f;
20 public static float cutY = 0f;
21 public static float cutZ = 0f;
33 private List<GameObject>
surfaceList =
new List<GameObject>();
34 private List<GameObject>
surfacePos =
new List<GameObject>();
35 private List<GameObject>
surfaceNeg =
new List<GameObject>();
70 bTime = Time.realtimeSinceStartup;
75 foreach(GameObject surfaceObj
in surfaceObjs) {
80 int nbVertices = mesh.vertices.Length;
81 Color32[] meshColors =
new Color32[nbVertices];
82 for(
int i=0; i<nbVertices; i++) {
83 meshColors[i] = Color.white;
85 mesh.colors32 = meshColors;
88 int nbVertices = mesh.vertices.Length;
91 Vector3[] vertices = mesh.vertices;
92 Color32[] meshColors =
new Color32[nbVertices];
98 for(
int i=0; i<atomLocs.Count; i++) {
105 for(
int i=0; i<nbVertices; i++) {
133 valtype =
float.Parse (type);
138 valtype = (valtype -
valmin) / (valmax -valmin);
145 mesh.colors32 = meshColors;
149 float minDist =
float.MaxValue;
150 Color minColor = Color.magenta;
154 Debug.Log (
"dist " + dist);
169 return GameObject.Find(
"SurfaceManager");
174 foreach(GameObject surfaceObj
in surfaceObjs) {
177 float elapsed = 100f * (Time.realtimeSinceStartup -
bTime);
178 Debug.Log(
"SurfaceManager::Update Atom Color total processing time: " + elapsed.ToString());
183 for(
int i=0; i<surfaceObjs.Length; i++)
189 for(
int i=0; i<surfaceObjs.Length; i++)
206 surfaceList.Add(surface);
209 surfacePos.Add(surface);
212 surfaceNeg.Add(surface);
216 return surfaceList.ToArray();
219 return surfaceNeg.ToArray();
222 return surfacePos.ToArray();
230 surfaceList.Remove(Surface);
233 surfaceInitialized =
false;
236 for(
int i=0;i<surfacePos.Count;i++){
237 Object.Destroy(surfacePos[i]);
238 surfacePos.Remove(surfacePos[i]);
243 for(
int i=0;i<surfaceNeg.Count;i++){
244 Object.Destroy(surfaceNeg[i]);
245 surfaceNeg.Remove(surfaceNeg[i]);
261 pdb2den =
new GameObject (
"pdb2den OBJ");
271 if (!surfaceInitialized) {
273 surfaceInitialized =
true;
278 if(surfaceInitialized){
288 pdb2den =
new GameObject (
"pdb2den OBJ");
297 if(!surfaceInitialized) {
299 surfaceInitialized =
true;
305 if(VolumetricDensityObj == null){
306 VolumetricDensityObj =
new GameObject(
"VolumetricDensity");
307 volumetricDensityscript = VolumetricDensityObj.AddComponent<
VolumetricDensity>();
310 if (volumetricDensityActivated)
311 volumetricDensityscript.
Init ();
313 volumetricDensityscript.
Clear ();
320 Surface.GetComponent<Renderer>().enabled = !Surface.GetComponent<Renderer>().enabled;
328 foreach (GameObject Surface
in SurfacesNeg)
329 Surface.GetComponent<Renderer>().enabled = !Surface.GetComponent<Renderer>().enabled;
335 Surface.GetComponent<Renderer>().enabled = !Surface.GetComponent<Renderer>().enabled;
340 GameObject[] surfaceObjs = surfaceManager.
getSurfaces();
341 Shader vertexcolored = Shader.Find (
"Vertex Colored");
342 Shader matcapcut = Shader.Find (
"Mat Cap Cut");
343 foreach (GameObject surfaceObj
in surfaceObjs) {
344 if (surfaceObj.GetComponent<Renderer>().material.shader == vertexcolored) {
345 surfaceObj.GetComponent<Renderer>().material.shader = matcapcut;
346 surfaceObj.GetComponent<Renderer>().material.SetTexture (
"_MatCap", (Texture)Resources.Load (
"lit_spheres/divers/daphz1"));
348 surfaceManager.InitTree ();
349 surfaceManager.ColorVertices ();
359 foreach (GameObject Surface
in Surfaces) {
360 Surface.GetComponent<Renderer>().material.SetColor(
"_Color", Color.white);
366 foreach (GameObject Surface
in Surfaces) {
367 Surface.GetComponent<Renderer>().material.SetColor(
"_Color", SurfaceColor.
color);
368 Surface.GetComponent<Renderer>().material.SetColor(
"_ColorIN", SurfaceInsideColor.
color);
373 foreach (GameObject Surface
in Surfaces) {
374 Surface.GetComponent<Renderer>().material.SetVector(
"_SurfacePos", Surface.transform.position);
379 Surface.GetComponent<Renderer>().material.SetFloat(
"_cut", (
float)cutMode);
384 foreach (GameObject Surface
in Surfaces) {
385 if(extSurf!=null || surfaceTextureName!=null){
386 if(externalSurfaceTexture){
388 Surface.GetComponent<Renderer>().material.SetTexture(
"_MatCap",extSurf);
390 Surface.GetComponent<Renderer>().material.SetTexture(
"_MatCap",
ToGray(extSurf));
395 Surface.GetComponent<Renderer>().material.SetTexture(
"_MatCap",(Texture)Resources.Load(surfaceTextureName));
397 Surface.GetComponent<Renderer>().material.SetTexture(
"_MatCap",
ToGray((Texture)Resources.Load(surfaceTextureName)));
402 Surface.GetComponent<Renderer>().material.SetTexture(
"_MatCap",(Texture)Resources.Load(
"lit_spheres/divers/daphz1"));
474 for(
int i=0;i<surfaceList.Count;i++)
489 public Texture2D
ToGray(Texture texture){
490 Texture2D tex2D = (Texture2D)texture;
491 Texture2D grayTex =
new Texture2D(tex2D.width, tex2D.height);
494 for (
int y = 0; y < tex2D.height; ++y) {
495 for (
int x = 0; x < tex2D.width; ++x) {
496 grayScale = tex2D.GetPixel(x, y).r * 0.21f + tex2D.GetPixel(x, y).g * 0.71f + tex2D.GetPixel(x, y).b * 0.07f;
497 alpha = tex2D.GetPixel(x, y).a;
498 grayTex.SetPixel (x, y,
new Color(grayScale, grayScale, grayScale, alpha));
506 for(
int i=0;i<surfaceList.Count;i++){
508 surfaceList[i].GetComponent<MeshRenderer>().material = (Material) Resources.Load(
"Materials/transSurface");
510 surfaceList[i].GetComponent<MeshRenderer>().material = (Material) Resources.Load(
"Materials/matcapSurface");
515 for(
int i=0;i<surfaceList.Count;i++){
516 surfaceList[i].GetComponent<MeshRenderer>().material.color = newcolor;
static bool volumetricDensityActivated
static void useChainColor()
static ColorObject SurfaceColor
static GameObject VolumetricDensityObj
List< GameObject > surfaceNeg
static bool useHetatmForSurface
void SetTransparentSurface(bool transparent)
static void useBFactorColor()
static void useEnglemanColor()
static void SurfaceRenderUp()
void addSurfaceNeg(GameObject surface)
void TranPDBtoDEN(float resolution=DEFAULT_RESOLUTION, bool cap=true)
static void useEinsenbergColor()
static AtomModel GetModel(string type)
static void ShowHideSurfaces()
static void GenerateSurfaceBfact()
static bool externalSurfaceTexture
GameObject[] getSurfaces()
static Vector3 Offset
The offset for the molecule.
void RecenterFieldLines(Vector3 pos)
GameObject[] getSurfacesPos()
Color GetClosestAtomColor(Vector3 pos)
static void ProSurface(float seuil)
GameObject[] getSurfacesNeg()
void RecenterSurfaces(Vector3 pos)
static GameObject pdb2den
void ShowHideSurfacePos()
static void InitEisenberg()
static void InitCutParameters()
static void ShowHideVolumetricDensity()
void ShowHideSurfaceNeg()
void resetSurfaceColors()
static void setBrightness(float value)
static bool surfColHydroKD
static List< float > BFactorList
Bfactor of each atom.
static bool surfColHydroEng
string GetClosestAtomType(Vector3 pos)
static Color GetAtomColor(string atomType)
static float GetMax(List< float > ListValues)
Find the max value of a list of float.
static VolumetricDensity volumetricDensityscript
static void useWhiteOctanolColor()
static void usePropertiesColor()
static string surfaceTextureName
static ElectrostaticManager getElectrostaticManager()
static string m_last_extSurf_Path
!WiP Includes FLAGS of GUI.
List< GameObject > surfaceList
static List< Vector3 > atomLocations
static Color32 GetColorChain(string type)
static ColorObject SurfaceInsideColor
static string GetBFStyle(float BFValue)
static Vector3 MaxValue
The "biggest" corner of the bounding box that encloses the molecule.
override void Init()
Initializes this instance.
static void useKyteAndDoolittleColor()
static List< Color > atomsColorList
The color of each atom.
GameObject getParentGameObject()
static bool useSugarForSurface
void ColorVertices(Mesh mesh)
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule.
static List< Color > atomColors
static void InitWhiteOct()
void SetTransparentSurfaceColor(Color newcolor)
static SurfaceManager getSurfaceManager()
void addSurfacePos(GameObject surface)
static float GetMin(List< float > ListValues)
Find the min value of a list of float.
static bool grayscalemode
static void InitKyteDoo()
void addSurface(GameObject surface)
static bool surfaceInitialized
void ResetColorVertices(Mesh mesh)
static bool surfaceFileExists
static void GenerateSurface()
void Clear()
Clears this instance.
Texture2D ToGray(Texture texture)
Return the grayscale version of a texture
static void InitEngleman()
static float surfaceThreshold
static bool surfColHydroWO
void ResetColorVertices()
static void InitPhysChim()
static void setColorWeight(float value)
List< GameObject > surfacePos
static Color32 GetColorHydro(string type)
static bool surfColHydroEis
static List< float[]> atomsLocationlist
The coordinates of each atom.