コード例 #1
0
    public static void GenerateMeshes(List <Vector3> vertices, List <Vector3> normals,
                                      List <int> triangles, List <Color32> colors, int[] ss,
                                      string tag = "RibbonObj", string gameobj = "Ribbons")
    {
        //	DuplicateVertices(vertices, normals, triangles, colors);
        tag = Ribbons.ribbontag;
        AddFirstFrontalFace(vertices, normals, triangles, colors, ss);
        AddLastFrontalFace(vertices, normals, triangles, colors, ss);
        MeshData mData = new MeshData();


        mData.vertices  = vertices.ToArray();
        mData.normals   = normals.ToArray();
        mData.triangles = triangles.ToArray();
        mData.colors    = colors.ToArray();

        /*
         * for(int i=0; i<mData.vertices.Length; i++) {
         *      mData.vertices[i] += Molecule.Model.MoleculeModel.Offset;
         * }
         */

        Splitting   split  = new Splitting();
        List <Mesh> meshes = split.Split(mData);

        SubGenerateMeshes(meshes, tag, gameobj);
    }
コード例 #2
0
        private void Poll()
        {
            var report = _device.ReadReport();

            if (report == null)
            {
                Logger.Debug("JoyCon Canceled " + this);
                return;
            }

            _device.Write(new byte[] { 0x01, 0x00 });
            var deviceData = _device.Read();

            if (deviceData.Status != HidDeviceData.ReadStatus.Success)
            {
                return;
            }

            var joyConState = JoyConInputUtils.ReadInput(deviceData.Data, Type);

            if (joyConState != null && !joyConState.Equals(CurrentState))
            {
                CurrentState = joyConState;
                Task.Run(() => DataUpdated?.Invoke(this, new JoyConDataUpdateEventArgs(this, joyConState)));

                if (IsPaired)
                {
                    //Splitting state changed?
                    if (_currentInSplittingState != (joyConState.SideLeftButton || joyConState.SideRightButton))
                    {
                        _currentInSplittingState = joyConState.SideLeftButton || joyConState.SideRightButton;
                        //Invoke splitting event async
                        Task.Run(() => Splitting?.Invoke(this, new JoyConSplittingEventArgs(
                                                             this, _currentInSplittingState ? SplittingType.ReadyToSplit : SplittingType.CancelSplitting
                                                             )));
                    }
                }
                else
                {
                    //Pairing state changed?
                    if (_currentInPairingState != joyConState.RearBackButton)
                    {
                        _currentInPairingState = joyConState.RearBackButton;
                        //Invoke ready to pair or paring cancel event async
                        Task.Run(() => Pairing?.Invoke(this, new JoyConPairingEventArgs(
                                                           this, _currentInPairingState ? PairingType.ReadyToPair : PairingType.CancelPairing
                                                           )));
                    }
                }
            }
        }
コード例 #3
0
        public override int GetHashCode()
        {
            var hashCode = -748668788;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Note);

            hashCode = hashCode * -1521134295 + IsSplitting.GetHashCode();
            hashCode = hashCode * -1521134295 + Splitting.GetHashCode();
            hashCode = hashCode * -1521134295 + Measurement.GetHashCode();
            hashCode = hashCode * -1521134295 + Quantity.GetHashCode();
            return(hashCode);
        }
コード例 #4
0
    /// <summary>
    /// Creates the surface objects.
    /// </summary>
    /// <param name='voxels'>
    /// Voxels, i.e. the scalar field used to compute the surface.
    /// </param>
    /// <param name='threshold'>
    /// The threshold on which the isosurface is based.
    /// </param>
    /// <param name='delta'>
    /// Delta parameter from the grid, basically the size of each cell.
    /// </param>
    /// <param name='origin'>
    /// Origin of the grid.
    /// </param>
    /// <param name='colors'>
    /// Colors. Kept from previous implementation, but doesn't do anything here. I'm only
    /// keeping it because I'm not sure what it was used for. --- Alexandre
    /// </param>
    /// <param name='tag'>
    /// Tag for the objects to be created.
    /// </param>
    /// <param name='electro'>
    /// True if this is an electrostatic field isosurface.
    /// </param>
    public static void CreateSurfaceObjects(float[,,] voxels, float threshold, Vector3 delta, Vector3 origin,
                                            Color[] colors, string tag = "SurfaceManager", bool electro = false)
    {
        ELECTRO = electro;
        Debug.Log(ELECTRO.ToString());
        if (ELECTRO)
        {
            ReadDX readDX = UI.GUIMoleculeController.readdx;
            origin = readDX.GetOrigin();
            delta  = readDX.GetDelta();
        }

        InitGenMesh(voxels, threshold, delta, origin, tag);
        SetDims();

        float    bMCTime = Time.realtimeSinceStartup;
        MeshData mData   = MarchingCubes.CreateMesh(VOXELS, 0, XDIM, 0, YDIM, 0, ZDIM);

        Debug.Log("Entire surface contains " + mData.vertices.Length.ToString() + " vertices.");
        float elapsed = 10f * (Time.realtimeSinceStartup - bMCTime);

        Debug.Log("GenerateMesh::MarchingCubes time: " + elapsed.ToString());
        OffsetVertices(mData);

        float         bSmooth       = Time.realtimeSinceStartup;
        AdjacencySets adjacencySets = new AdjacencySets(mData.triangles.Length);

        adjacencySets.AddAllTriangles(mData.triangles);
        SmoothFilter.AdjSetsSmoother(mData, adjacencySets);
        elapsed = Time.realtimeSinceStartup - bSmooth;
        Debug.Log("Smoothing time: " + elapsed.ToString());

        ProperlyCalculateNormals(mData);

        // Necessary for electrostatic fields isosurfaces
        Debug.Log(threshold.ToString());
        if (threshold < 0)
        {
            FlipTriangles(mData);
        }

        Splitting   splitting = new Splitting();
        List <Mesh> meshes    = splitting.Split(mData);

        CreateSurfaceObjects(meshes);
    }
コード例 #5
0
        public void Update()
        {
            if (ribbons == null)
            {
                ribbons = scene.ribbons;
            }
            if (postprocessing == null)
            {
                postprocessing = ribbons.postprocessing;
            }
            if (split == null)
            {
                split = postprocessing.split;
            }

            if (!SplitRegisteredEvents)
            {
                SplitRegisteredEvents = split.RegisterEvents();
            }
            // Debug.Log("splitting script: " + split);
        }
コード例 #6
0
 public PostProcessing()
 {
     Debug.Log("PostProcessing constructor.");
     split = new Splitting();
 }
コード例 #7
0
 public void ConsoleView(string input)
 {
     _ = new Splitting(input, out List <string> words);
     controller.ControllerOutput(words);
 }