//const double jBase = 2455198.0;
        void InitBuffer(RenderContext renderContext)
        {
            if (!init)
            {
                if (renderContext.gl == null)
                {
                    starProfile = (ImageElement)Document.CreateElement("img");
                    starProfile.AddEventListener("load", delegate(ElementEvent e)
                    {
                        imageReady = true;
                    }, false);

                    starProfile.Src = "/images/starProfile.png";

                    worldList = new Vector3d[points.Count];
                    transformedList = new Vector3d[points.Count];

                    int index = 0;
                    foreach (Vector3d pnt in points)
                    {
                        // todo filter by date
                        DataItem item = new DataItem();
                        item.Location = pnt;
                        item.Tranformed = new Vector3d();
                        item.Size = sizes[index];
                        item.Color = colors[index];
                        worldList[index] = item.Location;
                        transformedList[index] = item.Tranformed;
                        items.Add(item);
                        index++;
                    }
                }
                else
                {
                    if (pointBuffers.Count == 0)
                    {
                        if (starTexture == null)
                        {
                            starTexture = Planets.LoadPlanetTexture("/images/starProfile.png");
                        }

                        int count = this.points.Count;

                        TimeSeriesPointVertexBuffer pointBuffer = null;
                        TimeSeriesPointVertex[] pointList = null;

                        int countLeft = count;
                        int index = 0;
                        int counter = 0;
                        foreach (Vector3d point in points)
                        {
                            if (counter >= 100000 || pointList == null)
                            {
                                if (pointBuffer != null)
                                {
                                    pointBuffer.Unlock();
                                }
                                int thisCount = Math.Min(100000, countLeft);

                                countLeft -= thisCount;
                                pointBuffer = new TimeSeriesPointVertexBuffer(thisCount);

                                pointList = (TimeSeriesPointVertex[])pointBuffer.Lock(); // Lock the buffer (which will return our structs)

                                pointBuffers.Add(pointBuffer);
                                pointBufferCounts.Add(thisCount);
                                counter = 0;
                            }
                            pointList[counter] = new TimeSeriesPointVertex();
                            pointList[counter].Position = point;
                            pointList[counter].PointSize = sizes[index];
                            pointList[counter].Tu = (float)(dates[index].StartDate );
                            pointList[counter].Tv = (float)(dates[index].EndDate );
                            pointList[counter].Color = colors[index];
                            index++;
                            counter++;
                        }

                        if (pointBuffer != null)
                        {
                            pointBuffer.Unlock();
                        }
                    }
                }

                init = true;
            }
        }
Exemple #2
0
        public void Prepare()
        {
            worldList = new Vector3d[table.Count];
            transformedList = new Vector3d[table.Count];

            int index = 0;
            foreach (string[] row in table)
            {
                DataItem item = new DataItem();
                item.EventTime = Date.Parse(row[DateColumn]);
                double radius = (earthRadius - double.Parse(row[depthColumn])*1000)/ earthRadius;
                item.Location = Coordinates.GeoTo3dRad(double.Parse(row[latColumn]), double.Parse(row[lngColumn])+180, radius);
                item.Tranformed = new Vector3d();
                item.Size = (float)Math.Pow(2, double.Parse(row[magColumn]))/50;

                worldList[index] = item.Location;
                transformedList[index] = item.Tranformed;
                items.Add(item);
                index++;
            }
        }
        //const double jBase = 2455198.0;
        void InitBuffer(RenderContext renderContext)
        {
            if (!init)
            {
                if (renderContext.gl == null)
                {
                    starProfile = (ImageElement)Document.CreateElement("img");
                    starProfile.AddEventListener("load", delegate(ElementEvent e)
                    {
                        imageReady = true;
                    }, false);

                    starProfile.Src = "/images/starProfile.png";

                    worldList       = new Vector3d[points.Count];
                    transformedList = new Vector3d[points.Count];

                    int index = 0;
                    foreach (Vector3d pnt in points)
                    {
                        // todo filter by date
                        DataItem item = new DataItem();
                        item.Location          = pnt;
                        item.Tranformed        = new Vector3d();
                        item.Size              = sizes[index];
                        item.Color             = colors[index];
                        worldList[index]       = item.Location;
                        transformedList[index] = item.Tranformed;
                        items.Add(item);
                        index++;
                    }
                }
                else
                {
                    if (pointBuffers.Count == 0)
                    {
                        if (starTexture == null)
                        {
                            starTexture = Planets.LoadPlanetTexture("/images/starProfile.png");
                        }

                        int count = this.points.Count;

                        TimeSeriesPointVertexBuffer pointBuffer = null;
                        TimeSeriesPointVertex[]     pointList   = null;

                        int countLeft = count;
                        int index     = 0;
                        int counter   = 0;
                        foreach (Vector3d point in points)
                        {
                            if (counter >= 100000 || pointList == null)
                            {
                                if (pointBuffer != null)
                                {
                                    pointBuffer.Unlock();
                                }
                                int thisCount = Math.Min(100000, countLeft);

                                countLeft  -= thisCount;
                                pointBuffer = new TimeSeriesPointVertexBuffer(thisCount);

                                pointList = (TimeSeriesPointVertex[])pointBuffer.Lock(); // Lock the buffer (which will return our structs)

                                pointBuffers.Add(pointBuffer);
                                pointBufferCounts.Add(thisCount);
                                counter = 0;
                            }
                            pointList[counter]           = new TimeSeriesPointVertex();
                            pointList[counter].Position  = point;
                            pointList[counter].PointSize = sizes[index];
                            pointList[counter].Tu        = (float)(dates[index].StartDate);
                            pointList[counter].Tv        = (float)(dates[index].EndDate);
                            pointList[counter].Color     = colors[index];
                            index++;
                            counter++;
                        }

                        if (pointBuffer != null)
                        {
                            pointBuffer.Unlock();
                        }
                    }
                }

                init = true;
            }
        }