Exemplo n.º 1
0
 private InstancedModel GenerateAtomModel(Atom atom, Matrix matrix)
 {
     List<OptionalDataBuffer> list = new List<OptionalDataBuffer>(){GenerateColorBuffer(atom)};
     return new InstancedModel(GetAtomMesh(), matrix, list);
 }
Exemplo n.º 2
0
        private ColorBuffer GenerateColorBuffer(Atom atom)
        {
            var N_VERTICES = (ATOM_STACKS + 1) * ATOM_SLICES;
            List<Vector3> colors = new List<Vector3>();
            for (int i = 0; i < N_VERTICES; i++) colors.Add(atom.Color);

            colors.Add(atom.Color);

            var vertices = GetAtomMesh().GetVertices();

            for (int j = 0; j < N_VERTICES; j++)
            {
                float distance = GetMagnitude(vertices[j] - ATOM_LIGHT_POSITION);
                float scaledDistance = distance / ATOM_LIGHT_POWER;
                Vector3 luminosity = ATOM_LIGHT_COLOR * (1 - scaledDistance);

                if (luminosity.X > 0 && luminosity.Y > 0 && luminosity.Z > 0)
                    colors[j] += luminosity;
            }

            return new ColorBuffer(colors);
        }
Exemplo n.º 3
0
 private Matrix GenerateAtomMatrix(Vector3 position, Atom atom)
 {
     var matrix = Matrix.Translation(position);
     var shellCount = new Vector3(atom.ElectronShellCount);
     return Matrix.Scaling(new Vector3(ATOM_SCALE) * shellCount) * matrix;
 }