Esempio n. 1
0
        private void CreateBodies(StarScan.ScanNode node, int subnode)
        {
            rBodyObjects.Clear();

            bodyinfo = new List <BodyInfo>();

            bool sysenabled = false;

            if (subnode > 0 && node.NodeType == StarScan.ScanNodeType.barycentre && node.Children != null)
            {
                node       = node.Children.Values[subnode - 1];
                sysenabled = true;
            }

            displaycontrol.ApplyToControlOfName("sys*", (c) => { c.Visible = sysenabled; });

            BodyInfo.CreateInfoTree(node, null, -1, 0, bodyinfo);

            foreach (var o in bodyinfo)
            {
                System.Diagnostics.Debug.Write($"Body {o.scannode.OwnName} {o.scannode.scandata?.StarType} {o.scannode.scandata?.PlanetClass} Lvl {o.scannode.Level} ");

                if (o.kepler != null)
                {
                    System.Diagnostics.Debug.Write($"SMA {o.kepler.SemiMajorAxis / oneAU_m} AU {o.kepler.SemiMajorAxis / 1000} km " +
                                                   $" Ecc {o.kepler.Eccentricity} Orbital Period {o.kepler.OrbitalPeriodS / 24 / 60 / 60 / 365} Y Radius {o.scannode.scandata.nRadius} m CM {o.kepler.CentralMass} axt {o.scannode.scandata.nAxialTilt}");
                }

                System.Diagnostics.Debug.WriteLine("");

                if (o.kepler != null)
                {
                    Vector4[]     orbit = o.kepler.Orbit(currentjd, 0.1, mscaling);
                    GLRenderState lines = GLRenderState.Lines(1);
                    lines.DepthTest = false;

                    o.orbitpos.ColorIndex = node.scandata?.nRadius != null ? 0 : 1;

                    var riol = GLRenderableItem.CreateVector4(items, PrimitiveType.LineStrip, lines, orbit, o.orbitpos);
                    rBodyObjects.Add(orbitlineshader, riol);

                    GLRenderState quad = GLRenderState.Quads(cullface: false);
                    quad.DepthTest = false;
                    var s       = 100000e3f * mscaling;
                    var quadpos = new Vector4[] { new Vector4(-s, 0, -s, 1), new Vector4(-s, 0, +s, 1), new Vector4(+s, 0, +s, 1), new Vector4(+s, 0, -s, 1) };
                    var plane   = GLRenderableItem.CreateVector4(items, PrimitiveType.Quads, quad, quadpos, o.bodypos);
                    rBodyObjects.Add(bodyplaneshader, plane);
                }
            }

            int bodies = bodyinfo.Count;

            // hold planet and barycentre positions/sizes/imageno
            bodymatrixbuffer.AllocateBytes(GLBuffer.Mat4size * bodies);

            GLRenderState rt = GLRenderState.Tri();

            rt.DepthTest = false;
            var ribody = GLRenderableItem.CreateVector4Vector2Matrix4(items, PrimitiveType.Triangles, rt, spherebuffer, spheretexcobuffer, bodymatrixbuffer,
                                                                      spherebuffer.Length / sizeof(float) / 4,
                                                                      ic: bodies, matrixdivisor: 1);

            rBodyObjects.Add(bodyshader, ribody);

            rifind = GLRenderableItem.CreateVector4Vector2Matrix4(items, PrimitiveType.Triangles, GLRenderState.Tri(), spherebuffer, spheretexcobuffer, bodymatrixbuffer,
                                                                  spherebuffer.Length / sizeof(float) / 4,
                                                                  ic: bodies, matrixdivisor: 1);
        }