Esempio n. 1
0
 public FloatList(FloatList other) : this(LandmarkDetectorPINVOKE.new_FloatList__SWIG_1(FloatList.getCPtr(other)), true)
 {
     if (LandmarkDetectorPINVOKE.SWIGPendingException.Pending)
     {
         throw LandmarkDetectorPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 2
0
 public FloatListEnumerator(FloatList collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
Esempio n. 3
0
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ if (list == null)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ list  = EditorUtility.GetPropertyObject <FloatList>(property);
/*AUTO SCRIPT*/ rList = new ReorderableList(list, typeof(float), true, false, true, true);
/*AUTO SCRIPT*/                         // rList.onAddCallback += data => { list.Add(defaultVal); };
/*AUTO SCRIPT*/                         // rList.onChangedCallback += data=> {
/*AUTO SCRIPT*/                         // };
/*AUTO SCRIPT*/ }
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ numLines = 3 + list.Count;
/*AUTO SCRIPT*/ var title  = new GUIContent($" {label.text}");
/*AUTO SCRIPT*/ var height = base.GetPropertyHeight(property, label);
/*AUTO SCRIPT*/ var rect   = new Rect(position.x, position.y, position.width, height);

/*AUTO SCRIPT*/ EditorGUI.BeginChangeCheck();
/*AUTO SCRIPT*/ rList.DoList(rect);
/*AUTO SCRIPT*/ EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), title);
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ if (EditorGUI.EndChangeCheck())
            {
/*AUTO SCRIPT*/ property.serializedObject.ApplyModifiedProperties();
            }
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ }
    // MARK: PulseDataConsumer methods

    // Consume pulse data
    override internal void UpdateFromPulse(FloatList times, FloatList values)
    {
        for (int i = 0; i < times.Count; ++i)
        {
            AddPoint(times.Get(i), values.Get(i));
        }
    }
        private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // Return if its not in one of the data/file columns OR if this is the first time column is being populated
            if (e.ColumnIndex < 0 || e.RowIndex == 0)
            {
                return;
            }
            PerformanceFile ctfFile = (PerformanceFile)dataGridView.Columns[e.ColumnIndex].Tag;
            //MessageBox.Show(e.RowIndex.ToString());
            // Set the new value in the backend
            FloatList fList = ((FloatList)ctfFile.entry[_rowIndex]);

            if (e.RowIndex == 1)
            {
                if (string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()))
                {
                    dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = fList.step;
                    return;
                }
                fList.step = (float)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                //MessageBox.Show(fList.unknown.ToString());
            }
            else
            {
                if (string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()))
                {
                    dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = fList.items[e.RowIndex - 2];
                    return;
                }
                fList.items[e.RowIndex - 2] = (float)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
            }
            ctfFile.entry[_rowIndex] = fList;
            ctfFile.hasChanges       = true;
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var anim = serializedObject.FindProperty("anim");

        EditorGUILayout.PropertyField(anim);

        if (IntList != null)
        {
            IntList.DoLayoutList();
        }
        if (FloatList != null)
        {
            FloatList.DoLayoutList();
        }
        if (BoolList != null)
        {
            BoolList.DoLayoutList();
        }
        if (TriggerList != null)
        {
            TriggerList.DoLayoutList();
        }

        serializedObject.ApplyModifiedProperties();
    }
        public void SerializeParameters(UIElementCollection parameterGrid, string shaderName)
        {
            ShaderName = shaderName;

            ClearLists();

            foreach (var p in parameterGrid)
            {
                if (p is BoolView)
                {
                    var vm = (p as BoolView).DataContext as BoolViewModel;
                    BoolList.Add(new SerializeHolder <bool>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is IntView)
                {
                    var vm = (p as IntView).DataContext as IntViewModel;
                    IntList.Add(new SerializeHolder <int>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is FloatView)
                {
                    var vm = (p as FloatView).DataContext as FloatViewModel;
                    FloatList.Add(new SerializeHolder <float>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is Float2View)
                {
                    var vm = (p as Float2View).DataContext as Float2ViewModel;
                    Float2List.Add(new SerializeHolder <Float2>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is Float3View)
                {
                    var vm = (p as Float3View).DataContext as Float3ViewModel;
                    Float3List.Add(new SerializeHolder <Float3>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is Float4View)
                {
                    var vm = (p as Float4View).DataContext as Float4ViewModel;
                    Float4List.Add(new SerializeHolder <Float4>(vm.ShaderName, vm.ContentValue));
                }
                else if (p is Texture2DView)
                {
                    var vm = (p as Texture2DView).DataContext as Texture2DViewModel;
                    Texture2DList.Add(new SerializeHolder <string>(vm.ShaderName, vm.FileName));
                }
            }

            var    ofd           = new SaveFileDialog();
            string baseDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

            ofd.InitialDirectory = baseDirectory;
            ofd.DefaultExt       = ".xml";
            ofd.Filter           = "XML files (.xml)|*.xml";
            if (ofd.ShowDialog() == true)
            {
                using (var f = File.Create(ofd.FileName))
                {
                    XmlSer.Serialize(f, this);
                }
            }
        }
Esempio n. 8
0
 public void SetRange(int index, FloatList values)
 {
     LandmarkDetectorPINVOKE.FloatList_SetRange(swigCPtr, index, FloatList.getCPtr(values));
     if (LandmarkDetectorPINVOKE.SWIGPendingException.Pending)
     {
         throw LandmarkDetectorPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 9
0
        /**
         * Gets arrays {xyz,uvw,rgb} of cell coordinates, normals and colors. In
         * these arrays, the specified cells are represented by quads with specified
         * size, and colors corresponding to a property gotten from each cell.
         * @param size the size (in samples) of the quads.
         * @param cmap the colormap used to compute rgb colors from floats.
         * @param cells the cells for which to compute quads.
         * @param get1 used to get the float from a cell to be colormapped.
         * @param lhc true, if left-handed coordinate system; false, otherwise.
         * @return arrays {xyz,uvw,rgb}.
         */
        private static float[][] getXyzUvwRgb(
            float size, ColorMap cmap, FaultCell[] cells,
            Get1 get1, bool lhc)
        {
            FloatList xyz = new FloatList();
            FloatList uvw = new FloatList();
            FloatList fcl = new FloatList();

            size *= 0.5f;
            float[] qa = { 0.0f, -size, -size };
            float[] qb = { 0.0f, size, -size };
            float[] qc = { 0.0f, size, size };
            float[] qd = { 0.0f, -size, size };
            if (lhc)
            {
                float[] qt = qb; qb = qc; qc = qt;
                qt = qd; qa = qd; qd = qt;
            }
            foreach (FaultCell cell in cells)
            {
                float   x1 = cell.x1;
                float   x2 = cell.x2;
                float   x3 = cell.x3;
                float   w1 = cell.w1;
                float   w2 = cell.w2;
                float   w3 = cell.w3;
                float   fp = ArrayMath.toRadians(cell.fp);
                float   ft = ArrayMath.toRadians(cell.ft);
                float   cp = (float)Math.Cos(fp);
                float   sp = (float)Math.Sin(fp);
                float   ct = (float)Math.Cos(ft);
                float   st = (float)Math.Sin(ft);
                float[] ra = rotatePoint(cp, sp, ct, st, qa);
                float[] rb = rotatePoint(cp, sp, ct, st, qb);
                float[] rc = rotatePoint(cp, sp, ct, st, qc);
                float[] rd = rotatePoint(cp, sp, ct, st, qd);
                float   a1 = x1 + ra[0], a2 = x2 + ra[1], a3 = x3 + ra[2];
                float   b1 = x1 + rb[0], b2 = x2 + rb[1], b3 = x3 + rb[2];
                float   c1 = x1 + rc[0], c2 = x2 + rc[1], c3 = x3 + rc[2];
                float   d1 = x1 + rd[0], d2 = x2 + rd[1], d3 = x3 + rd[2];
                xyz.add(a3); xyz.add(a2); xyz.add(a1);
                xyz.add(b3); xyz.add(b2); xyz.add(b1);
                xyz.add(c3); xyz.add(c2); xyz.add(c1);
                xyz.add(d3); xyz.add(d2); xyz.add(d1);
                uvw.add(w3); uvw.add(w2); uvw.add(w1);
                uvw.add(w3); uvw.add(w2); uvw.add(w1);
                uvw.add(w3); uvw.add(w2); uvw.add(w1);
                uvw.add(w3); uvw.add(w2); uvw.add(w1);
                float fc = get1(cell);
                fcl.add(fc);
                fcl.add(fc);
                fcl.add(fc);
                fcl.add(fc);
            }
            float[] fc2 = fcl.trim();
            float[] rgb = cmap.getRgbFloats(fc2);
            return(new float[][] { xyz.trim(), uvw.trim(), rgb });
        }
 private void ClearLists()
 {
     BoolList.Clear();
     IntList.Clear();
     FloatList.Clear();
     Float2List.Clear();
     Float3List.Clear();
     Float4List.Clear();
 }
Esempio n. 11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public HeroList()
 {
     ints         = new IntList();
     floats       = new FloatList();
     bools        = new BoolList();
     strings      = new StringList();
     gameObjects  = new GameObjectList();
     heroObjects  = new HeroObjectList();
     unityObjects = new UnityObjectList();
 }
Esempio n. 12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="list">The hero list to construct.</param>
 public HeroList(HeroList list)
 {
     visible      = list.visible;
     ints         = (list.ints == null) ? new IntList() : list.ints.Clone(list.ints);
     floats       = (list.floats == null) ? new FloatList() : list.floats.Clone(list.floats);
     bools        = (list.bools == null) ? new BoolList() : list.bools.Clone(list.bools);
     strings      = (list.strings == null) ? new StringList() : list.strings.Clone(list.strings);
     gameObjects  = (list.gameObjects == null) ? new GameObjectList() : list.gameObjects.Clone(list.gameObjects);
     heroObjects  = (list.heroObjects == null) ? new HeroObjectList() : list.heroObjects.Clone(list.heroObjects);
     unityObjects = (list.unityObjects == null) ? new UnityObjectList() : list.unityObjects.Clone(list.unityObjects);
 }
Esempio n. 13
0
        public FloatList GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = LandmarkDetectorPINVOKE.FloatList_GetRange(swigCPtr, index, count);
            FloatList             ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FloatList(cPtr, true);

            if (LandmarkDetectorPINVOKE.SWIGPendingException.Pending)
            {
                throw LandmarkDetectorPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 14
0
        public static FloatList Repeat(float value, int count)
        {
            global::System.IntPtr cPtr = LandmarkDetectorPINVOKE.FloatList_Repeat(value, count);
            FloatList             ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FloatList(cPtr, true);

            if (LandmarkDetectorPINVOKE.SWIGPendingException.Pending)
            {
                throw LandmarkDetectorPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 15
0
        /// <summary>
        ///		Sets the distance at which level-of-detail (LOD) levels come into effect.
        /// </summary>
        /// <remarks>
        ///		You should only use this if you have assigned LOD indexes to the Technique
        ///		instances attached to this Material. If you have done so, you should call this
        ///		method to determine the distance at which the lowe levels of detail kick in.
        ///		The decision about what distance is actually used is a combination of this
        ///		and the LOD bias applied to both the current Camera and the current Entity.
        /// </remarks>
        /// <param name="lodDistances">
        ///		A list of floats which indicate the distance at which to
        ///		switch to lower details. They are listed in LOD index order, starting at index
        ///		1 (ie the first level down from the highest level 0, which automatically applies
        ///		from a distance of 0).
        /// </param>
        public void SetLodLevels(FloatList lodDistanceList)
        {
            // clear and add the 0 distance entry
            lodDistances.Clear();
            lodDistances.Add(0.0f);

            for (int i = 0; i < lodDistanceList.Count; i++)
            {
                float val = (float)lodDistanceList[i];

                // squared distance
                lodDistances.Add(val * val);
            }
        }
    public override bool Calculate()
    {
        IModule3D value = Inputs[0].GetValue <IModule3D>();

        if (value == null)
        {
            return(false);
        }
        ControlPointList value2 = Inputs[1].GetValue <ControlPointList>();

        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve && (value2 == null || value2.points.Count == 0))
        {
            return(false);
        }
        FloatList value3 = Inputs[2].GetValue <FloatList>();

        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace && (value3 == null || value3.points.Count == 0))
        {
            return(false);
        }
        IModule3D module3D = target.CreateModule(value);

        if (module3D == null)
        {
            return(false);
        }
        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve)
        {
            Curve curve = module3D as Curve;
            curve.ClearControlPoints();
            List <ControlPoint> controls = value2.GetControls();
            foreach (ControlPoint item in controls)
            {
                curve.AddControlPoint(item);
            }
        }
        else if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace)
        {
            Terrace terrace = module3D as Terrace;
            terrace.ClearControlPoints();
            foreach (float point in value3.points)
            {
                float input = point;
                terrace.AddControlPoint(input);
            }
        }
        Outputs[0].SetValue(module3D);
        return(true);
    }
Esempio n. 17
0
 // Use this for initialization
 void Start()       //初始化
 {
     blast_object_stop       = new GameObjectList[blast_object_list.Length];
     blast_object_active     = new GameObjectList[blast_object_list.Length];
     blast_object_activetime = new FloatList[blast_object_list.Length];
     for (int i = 0; i < blast_object_list.Length; i++)
     {
         blast_object_stop[i]       = new GameObjectList();
         blast_object_active[i]     = new GameObjectList();
         blast_object_activetime[i] = new FloatList();
     }
     // blast_flag=true;
     // blast_object_number=0;
     // blast_position=Vector3.up;
 }
Esempio n. 18
0
        /**
         * Returns an array of packed (x,y,z) coordinates for a fault curve.
         * The fault curve is everywhere tangent to fault dip, and contains the
         * point for this cell. Returned coordinates are in above-to-below order.
         * @return array of packed (x,y,z) coordinates.
         */
        public float[] getFaultCurveXyz()
        {
            FloatList xyz = new FloatList();

            float[] p = new float[3];

            // Gather xyz for this cell and above this cell by walking up dip.
            FaultCell cell = this;

            p[0] = x1; p[1] = x2; p[2] = x3;
            for (int j1 = cell.i1; j1 == cell.i1; --j1)
            {
                xyz.add(p[2]); xyz.add(p[1]); xyz.add(p[0]);
                cell = cell.walkUpDipFrom(p);
            }

            // Remember the number of xyz gathered, including xyz for this cell.
            int na = xyz.n / 3;

            // Gather xyz for cells below this one by walking down dip. We have
            // already gathered the xyz for this cell, so now we skip to the one
            // below it.
            cell = this;
            p[0] = x1; p[1] = x2; p[2] = x3;
            cell = cell.walkDownDipFrom(p); // skip this cell
            for (int j1 = this.i1 + 1; j1 == cell.i1; ++j1)
            {
                xyz.add(p[2]); xyz.add(p[1]); xyz.add(p[0]);
                cell = cell.walkDownDipFrom(p);
            }

            // Flip the order of all xyz gathered above this cell while walking up.
            float[] xyzs = xyz.trim();
            for (int ia = 1, i = ia * 3, ja = na - 1, j = ja * 3; ia < ja; ++ia, i += 3, --ja, j -= 3)
            {
                float xi = xyzs[i];
                float yi = xyzs[i + 1];
                float zi = xyzs[i + 2];
                xyzs[i]     = xyzs[j];
                xyzs[i + 1] = xyzs[j + 1];
                xyzs[i + 2] = xyzs[j + 2];
                xyzs[j]     = xi;
                xyzs[j + 1] = yi;
                xyzs[j + 2] = zi;
            }
            return(xyzs);
        }
Esempio n. 19
0
        /**
         * Returns an array of packed (x,y,z) coordinates for a fault trace.
         * The fault trace is everywhere tangent to fault strike, and contains
         * the point for this cell. Returned coordinates are left-to-right order.
         * @return array of packed (x,y,z) coordinates.
         */
        public float[] getFaultTraceXyz()
        {
            FloatList xyz = new FloatList();

            // First gather coordinates for this cell.
            xyz.add(x3); xyz.add(x2); xyz.add(x1);

            // Then gather coordinates for cells to the left of this cell. Take care
            // to handle the case in which this cell is found while walking left.
            FaultCell c;

            for (c = this.cl; c != null && c != this; c = c.cl)
            {
                xyz.add(c.x3); xyz.add(c.x2); xyz.add(c.x1);
            }

            // Remember number of xyz gathered, including xyz for this cell.
            int nl = xyz.n / 3;

            // If we did not end at this cell, then gather coordinates of all
            // cells to the right of this cell.
            if (c != this)
            {
                for (c = this.cr; c != null; c = c.cr)
                {
                    xyz.add(c.x3); xyz.add(c.x2); xyz.add(c.x1);
                }
            }

            // Flip the order of all xyz gathered left of this cell.
            float[] xyzs = xyz.trim();
            for (int il = 1, i = il * 3, jl = nl - 1, j = jl * 3; il < jl; ++il, i += 3, --jl, j -= 3)
            {
                float xi = xyzs[i];
                float yi = xyzs[i + 1];
                float zi = xyzs[i + 2];
                xyzs[i]     = xyzs[j];
                xyzs[i + 1] = xyzs[j + 1];
                xyzs[i + 2] = xyzs[j + 2];
                xyzs[j]     = xi;
                xyzs[j + 1] = yi;
                xyzs[j + 2] = zi;
            }
            return(xyzs);
        }
Esempio n. 20
0
    // Use this for initialization
    void Start()       //初始化
    {
        attackObject_listbuff = new GameObjectList[attackObject_list.Length];
        for (int i = 0; i < attackObject_listbuff.Length; i++)
        {
            attackObject_listbuff[i] = new GameObjectList();
        }

        attackObject_active_listbuff = new GameObjectList[attackObject_list.Length];
        for (int i = 0; i < attackObject_listbuff.Length; i++)
        {
            attackObject_active_listbuff[i] = new GameObjectList();
        }

        attackObject_active_listtime = new FloatList[attackObject_list.Length];
        for (int i = 0; i < attackObject_listbuff.Length; i++)
        {
            attackObject_active_listtime[i] = new FloatList();
        }
    }
Esempio n. 21
0
        public static FloatList ConvertFloatList(string vec)
        {
            FloatList list = new FloatList();

            try {
                string   strPos = vec;
                string[] resut  = strPos.Split(s_ListSplitString, StringSplitOptions.RemoveEmptyEntries);
                if (resut != null && resut.Length > 0 && resut[0] != "")
                {
                    for (int index = 0; index < resut.Length; index++)
                    {
                        list.Add((float)Convert.ChangeType(resut[index], typeof(float)));
                    }
                }
            } catch (System.Exception ex) {
                list.Clear();
                LogSystem.Error("ConvertFloatList {0} Exception:{1}/{2}", vec, ex.Message, ex.StackTrace);
                throw;
            }

            return(list);
        }
    // MARK: PulseDataConsumer methods

    // Consume pulse data
    override internal void UpdateFromPulse(FloatList times, FloatList values)
    {
        // Update display at a certain frequency
        float currentTime = Time.time;

        if (frequency > 0 && currentTime < previousTime + 1 / frequency)
        {
            return;
        }

        previousTime = currentTime;

        // Only display last value from list
        int   lastIndex = values.Count - 1;
        float dataValue = values.Get(lastIndex);

        // Apply multiplier, decimals truncating
        dataValue *= multiplier;
        string decimalCode = "F" + decimals.ToString();
        string dataString  = dataValue.ToString(decimalCode);

        // Update displayed value with prefix and suffix
        textRenderer.text = prefix + dataString + suffix;
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var exeType = serializedObject.FindProperty("exeType");

        EditorGUILayout.PropertyField(exeType);
        var DelayTime = serializedObject.FindProperty("DelayTime");

        EditorGUILayout.PropertyField(DelayTime);
        var anim = serializedObject.FindProperty("anim");

        EditorGUILayout.PropertyField(anim);
        var AnimatorController = serializedObject.FindProperty("AnimatorController");

        EditorGUILayout.PropertyField(AnimatorController);

        if (IntList != null)
        {
            IntList.DoLayoutList();
        }
        if (FloatList != null)
        {
            FloatList.DoLayoutList();
        }
        if (BoolList != null)
        {
            BoolList.DoLayoutList();
        }
        if (TriggerList != null)
        {
            TriggerList.DoLayoutList();
        }

        serializedObject.ApplyModifiedProperties();
    }
Esempio n. 24
0
        public void Draw()
        {
            if (DynamoAsm.HasShutdown)
            {
                return;
            }

            if (this.RenderDescription == null)
            {
                this.RenderDescription = new RenderDescription();
            }
            else
            {
                this.RenderDescription.ClearAll();
            }

            foreach (GraphicItem g in _graphicItems)
            {
                FloatList point_vertices = g.point_vertices_threadsafe();

                for (int i = 0; i < point_vertices.Count; i += 3)
                {
                    this.RenderDescription.points.Add(new Point3D(point_vertices[i],
                                                                  point_vertices[i + 1], point_vertices[i + 2]));
                }

                SizeTList num_line_strip_vertices = g.num_line_strip_vertices_threadsafe();
                FloatList line_strip_vertices     = g.line_strip_vertices_threadsafe();

                int counter = 0;

                foreach (uint num_verts in num_line_strip_vertices)
                {
                    for (int i = 0; i < num_verts; ++i)
                    {
                        Point3D p = new Point3D(
                            line_strip_vertices[counter],
                            line_strip_vertices[counter + 1],
                            line_strip_vertices[counter + 2]);

                        this.RenderDescription.lines.Add(p);

                        counter += 3;

                        if (i == 0 || i == num_verts - 1)
                        {
                            continue;
                        }

                        this.RenderDescription.lines.Add(p);
                    }
                }

                FloatList triangle_vertices = g.triangle_vertices_threadsafe();

                List <int>     indices_front = new List <int>();
                List <int>     indices_back  = new List <int>();
                List <Point3D> vertices      = new List <Point3D>();

                for (int i = 0; i < triangle_vertices.Count / 9; ++i)
                {
                    for (int k = 0; k < 3; ++k)
                    {
                        int index = i * 9 + k * 3;

                        Point3D new_point = new Point3D(triangle_vertices[index],
                                                        triangle_vertices[index + 1],
                                                        triangle_vertices[index + 2]);

                        bool new_point_exists = false;
                        for (int l = 0; l < vertices.Count; ++l)
                        {
                            Point3D p = vertices[l];
                            if ((p.X == new_point.X) && (p.Y == new_point.Y) && (p.Z == new_point.Z))
                            {
                                indices_front.Add(l);
                                new_point_exists = true;
                                break;
                            }
                        }

                        if (new_point_exists)
                        {
                            continue;
                        }

                        indices_front.Add(vertices.Count);
                        vertices.Add(new_point);
                    }

                    int a = indices_front[indices_front.Count - 3];
                    int b = indices_front[indices_front.Count - 2];
                    int c = indices_front[indices_front.Count - 1];

                    indices_back.Add(c);
                    indices_back.Add(b);
                    indices_back.Add(a);
                }

                this.RenderDescription.meshes.Add(new Mesh3D(vertices, indices_front));
                this.RenderDescription.meshes.Add(new Mesh3D(vertices, indices_back));
            }
        }
Esempio n. 25
0
 private void AddPurposeData(float[][] driveData, TreeData<float[][]> current, SparseArray<float> production, FloatList purposeDrive, FloatList purposeOther)
 {
     var cat = current.Children;
     if ( cat != null )
     {
         var length = cat.Length;
         for ( int i = 0; i < length; i++ )
         {
             AddPurposeData( driveData, cat[i], production, purposeDrive, purposeOther );
         }
     }
     else
     {
         // we only add in end nodes
         var zones = this.Root.ZoneSystem.ZoneArray.GetFlatData();
         var numberOfZones = zones.Length;
         var data = current.Result;
         // shortcut invalid modes
         if ( data == null ) return;
         var flatProduction = production.GetFlatData();
         if ( driveData == data )
         {
             // Auto drive case
             Parallel.For( 0, numberOfZones, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }, delegate(int i)
             {
                 var increment = 0f;
                 int regionIndex;
                 if ( !this.InverseLookup( zones[i].RegionNumber, out regionIndex ) )
                 {
                     // if this zone isn't part of a region we are processing just continue
                     return;
                 }
                 increment = purposeDrive[regionIndex] * SumWentHere( current, i );
                 flatProduction[i] += increment;
             } );
         }
         else
         {
             // not auto drive case
             Parallel.For( 0, numberOfZones, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }, delegate(int i)
             {
                 var increment = 0f;
                 int regionIndex;
                 if ( !this.InverseLookup( zones[i].RegionNumber, out regionIndex ) )
                 {
                     // if this zone isn't part of a region we are processing just continue
                     return;
                 }
                 increment = purposeOther[regionIndex] * SumWentHere( current, i );
                 flatProduction[i] += increment;
             } );
         }
     }
 }
Esempio n. 26
0
 private bool CompareParameterCount(FloatList data)
 {
     return(RegionNumbers.Count == data.Count);
 }
Esempio n. 27
0
        private void AddPurposeData(float[][] driveData, TreeData <float[][]> current, SparseArray <float> production, FloatList purposeDrive, FloatList purposeOther)
        {
            var cat = current.Children;

            if (cat != null)
            {
                var length = cat.Length;
                for (int i = 0; i < length; i++)
                {
                    AddPurposeData(driveData, cat[i], production, purposeDrive, purposeOther);
                }
            }
            else
            {
                // we only add in end nodes
                var zones         = Root.ZoneSystem.ZoneArray.GetFlatData();
                var numberOfZones = zones.Length;
                var data          = current.Result;
                // shortcut invalid modes
                if (data == null)
                {
                    return;
                }
                var flatProduction = production.GetFlatData();
                if (driveData == data)
                {
                    // Auto drive case
                    Parallel.For(0, numberOfZones, new ParallelOptions {
                        MaxDegreeOfParallelism = Environment.ProcessorCount
                    }, delegate(int i)
                    {
                        if (!InverseLookup(zones[i].RegionNumber, out int regionIndex))
                        {
                            // if this zone isn't part of a region we are processing just continue
                            return;
                        }
                        flatProduction[i] += purposeDrive[regionIndex] * SumWentHere(current, i);
                    });
                }
                else
                {
                    // not auto drive case
                    Parallel.For(0, numberOfZones, new ParallelOptions {
                        MaxDegreeOfParallelism = Environment.ProcessorCount
                    }, delegate(int i)
                    {
                        if (!InverseLookup(zones[i].RegionNumber, out int regionIndex))
                        {
                            // if this zone isn't part of a region we are processing just continue
                            return;
                        }
                        flatProduction[i] += purposeOther[regionIndex] * SumWentHere(current, i);
                    });
                }
            }
        }
Esempio n. 28
0
 private bool CompareParameterCount(FloatList data)
 {
     return this.RegionNumbers.Count == data.Count;
 }
Esempio n. 29
0
        /// <summary>
        /// Get a value from a float field in a hero object template.
        /// This is for a field that contains Variable, Property, Global.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldID">ID assigned to the action field.</param>
        /// <returns>The value from a float field.</returns>
        public static float GetValueC(HeroKitObject heroKitObject, int actionFieldID, HeroObject heroObject)
        {
            // Get the action
            HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action];

            // exit early if object does not exist
            if (heroObject == null)
            {
                Debug.LogError(HeroKitCommonRuntime.NoHeroObjectDebugInfo(action.actionTemplate.name, 0, heroKitObject));
                return(0f);
            }

            // Get the item type
            int   itemType  = action.actionFields[actionFieldID].ints[3];
            float itemValue = 0f;

            // Get the slot in the list that contains the item
            int slotID = action.actionFields[actionFieldID].ints[2] - 1;

            // Get the lists
            FloatList targetList   = null;
            string    itemTypeName = "";
            string    heroName     = "";

            if (itemType == 0)
            {
                Debug.LogError("Float type was never specified for " + action.actionTemplate.name + " " + HeroKitCommonRuntime.GetHeroDebugInfo(heroKitObject));
                return(0f);
            }
            else if (itemType == 1)
            {
                heroName     = heroObject.name;
                itemTypeName = "Variables";
                targetList   = heroObject.lists.floats;
            }
            else if (itemType == 2)
            {
                heroName     = heroObject.name;
                itemTypeName = "Properties";
                int propertyID = action.actionFields[actionFieldID].ints[7] - 1;
                if (propertyID < 0)
                {
                    Debug.LogError("Property slot does not exist!");
                }
                targetList = heroObject.propertiesList.properties[propertyID].itemProperties.floats;
            }
            else if (itemType == 3)
            {
                heroName     = "n/a";
                itemTypeName = "Globals";
                targetList   = HeroKitDatabase.GetGlobals().floats;
            }

            // exit early if the slot in the list does not exist
            if (targetList.items.Count <= slotID || slotID < 0)
            {
                Debug.LogError(HeroKitCommonRuntime.NoVariableDebugInfo(action.actionTemplate.name, heroName, itemTypeName, "Float", slotID, 0, heroKitObject));
                return(0f);
            }

            // get the item in the list slot
            itemValue = targetList.items[slotID].value;

            // Return the item
            return(itemValue);
        }
Esempio n. 30
0
        public static void DrawLibGGraphicItem(NodeModel node, object geom, RenderDescription rd, Octree.OctreeSearch.Octree octree)
        {
            var selected = DynamoSelection.Instance.Selection.Contains(node);
            var g        = geom as GraphicItem;

            if (g is CoordinateSystem)
            {
                #region draw coordinate systems

                var line_strip_vertices = g.line_strip_vertices_threadsafe();

                for (int i = 0; i < line_strip_vertices.Count; i += 6)
                {
                    var p1 = new Point3D(
                        line_strip_vertices[i],
                        line_strip_vertices[i + 1],
                        line_strip_vertices[i + 2]);

                    var p2 = new Point3D(
                        line_strip_vertices[i + 3],
                        line_strip_vertices[i + 4],
                        line_strip_vertices[i + 5]);

                    if (i < 6)
                    {
                        rd.XAxisPoints.Add(p1);
                        rd.XAxisPoints.Add(p2);
                    }
                    else if (i >= 6 && i < 12)
                    {
                        rd.YAxisPoints.Add(p1);
                        rd.YAxisPoints.Add(p2);
                    }
                    else
                    {
                        rd.ZAxisPoints.Add(p1);
                        rd.ZAxisPoints.Add(p2);
                    }
                }

                #endregion
            }
            else
            {
                #region draw points

                var point_vertices = g.point_vertices_threadsafe();

                for (int i = 0; i < point_vertices.Count; i += 3)
                {
                    if (selected)
                    {
                        rd.SelectedPoints.Add(new Point3D(point_vertices[i],
                                                          point_vertices[i + 1], point_vertices[i + 2]));
                    }
                    else
                    {
                        rd.Points.Add(new Point3D(point_vertices[i],
                                                  point_vertices[i + 1], point_vertices[i + 2]));
                    }
                }

                #endregion

                #region draw lines

                SizeTList num_line_strip_vertices = g.num_line_strip_vertices_threadsafe();
                FloatList line_strip_vertices     = g.line_strip_vertices_threadsafe();

                int counter = 0;

                foreach (uint num_verts in num_line_strip_vertices)
                {
                    for (int i = 0; i < num_verts; ++i)
                    {
                        var p = new Point3D(
                            line_strip_vertices[counter],
                            line_strip_vertices[counter + 1],
                            line_strip_vertices[counter + 2]);

                        if (selected)
                        {
                            rd.SelectedLines.Add(p);
                        }
                        else
                        {
                            rd.Lines.Add(p);
                        }

                        counter += 3;

                        if (i == 0 || i == num_verts - 1)
                        {
                            continue;
                        }

                        if (selected)
                        {
                            rd.SelectedLines.Add(p);
                        }
                        else
                        {
                            rd.Lines.Add(p);
                        }
                    }
                }

                #endregion

                #region draw surface

                //var sw = new Stopwatch();
                //sw.Start();

                var builder = new MeshBuilder();
                var points  = new Point3DCollection();
                var tex     = new PointCollection();
                var norms   = new Vector3DCollection();
                var tris    = new List <int>();

                FloatList triangle_vertices = g.triangle_vertices_threadsafe();
                FloatList triangle_normals  = g.triangle_normals_threadsafe();

                for (int i = 0; i < triangle_vertices.Count; i += 3)
                {
                    var new_point = new Point3D(triangle_vertices[i],
                                                triangle_vertices[i + 1],
                                                triangle_vertices[i + 2]);

                    var normal = new Vector3D(triangle_normals[i],
                                              triangle_normals[i + 1],
                                              triangle_normals[i + 2]);

                    //find a matching point
                    //compare the angle between the normals
                    //to discern a 'break' angle for adjacent faces
                    //int foundIndex = -1;
                    //for (int j = 0; j < points.Count; j++)
                    //{
                    //    var testPt = points[j];
                    //    var testNorm = norms[j];
                    //    var ang = Vector3D.AngleBetween(normal, testNorm);

                    //    if (new_point.X == testPt.X &&
                    //        new_point.Y == testPt.Y &&
                    //        new_point.Z == testPt.Z &&
                    //        ang > 90.0000)
                    //    {
                    //        foundIndex = j;
                    //        break;
                    //    }
                    //}

                    //if (foundIndex != -1)
                    //{
                    //    tris.Add(foundIndex);
                    //    continue;
                    //}

                    tris.Add(points.Count);
                    points.Add(new_point);
                    norms.Add(normal);
                    tex.Add(new System.Windows.Point(0, 0));

                    octree.AddNode(new_point.X, new_point.Y, new_point.Z, node.GUID.ToString());
                }

                //builder.AddTriangles(points, norms, tex);
                builder.Append(points, tris, norms, tex);

                //sw.Stop();
                //Debug.WriteLine(string.Format("{0} elapsed for drawing geometry.", sw.Elapsed));

                //don't add empty meshes
                if (builder.Positions.Count > 0)
                {
                    if (selected)
                    {
                        rd.SelectedMeshes.Add(builder.ToMesh(true));
                    }
                    else
                    {
                        rd.Meshes.Add(builder.ToMesh(true));
                    }
                }

                #endregion
            }
        }
Esempio n. 31
0
        private void AddPurposeData(IPurpose purpose, float[][] driveData, SparseArray <float> production, FloatList purposeDrive, FloatList purposeOther)
        {
            var modes = purpose.Flows;

            if (modes == null)
            {
                return;
            }
            var length = modes.Count;

            for (int i = 0; i < length; i++)
            {
                AddPurposeData(driveData, modes[i], production, purposeDrive, purposeOther);
            }
        }
Esempio n. 32
0
    // MARK: Custom methods

    // Abstract method exposing time points and data field values
    // to be consumed by the implemented subclass
    abstract internal void UpdateFromPulse(FloatList times, FloatList values);
Esempio n. 33
0
 private void AddPurposeData(IPurpose purpose, float[][] driveData, SparseArray<float> production, FloatList purposeDrive, FloatList purposeOther)
 {
     var modes = purpose.Flows;
     if ( modes == null ) return;
     var length = modes.Count;
     for ( int i = 0; i < length; i++ )
     {
         AddPurposeData( driveData, modes[i], production, purposeDrive, purposeOther );
     }
 }