Ejemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_GeometryGroup g         = new GH_GeometryGroup();
            bool             isDynamic = true;
            Material         iMaterial = PhysXManager.Physics.CreateMaterial(0.5f, 0.5f, 0.5f);

            DA.GetData(0, ref g);
            DA.GetData(1, ref isDynamic);
            DA.GetData(2, ref iMaterial);

            List <Mesh> meshes = new List <Mesh>();

            List <IGH_GeometricGoo> group = new List <IGH_GeometricGoo>(g.Objects);

            for (int i = 0; i < group.Count; i++)
            {
                Mesh m = new Mesh();
                group[i].CastTo(out m);
                meshes.Add(m);
            }


            if (isDynamic)
            {
                PxGhRigidDynamic rigidDynamic = new PxGhRigidDynamicCMesh(Plane.WorldXY, meshes, iMaterial, 1);
                DA.SetData(0, rigidDynamic);
            }
            else
            {
                PxGhRigidStatic rigidStatic = new PxGhRigidStaticCMesh(Plane.WorldXY, meshes, iMaterial);
                DA.SetData(0, rigidStatic);
            }
        }
Ejemplo n.º 2
0
    //this constructor is for the cases where this object has to be reconstructed from
    //a dictionary with json strings of all its fields
    public GeomObject(Dictionary <string, string> xmlDict)
    {
        _name       = xmlDict["name"];//this is the default value for name
        _memberDict = DeserializeFromString <Dictionary <string, List <IGH_Goo> > >(xmlDict["data"]);

        //now getting the visibility and bakability settings
        _visibility = DeserializeFromString <Dictionary <string, bool> >(xmlDict["Visibility"]);
        _bakability = DeserializeFromString <Dictionary <string, bool> >(xmlDict["Bakability"]);
        GH_GeometryGroup grp = new GH_GeometryGroup();
    }
Ejemplo n.º 3
0
    //removes the data with that key from this object

    //this function gets all the geometry as a group (nested if the members are already groups themselves))
    public GH_GeometryGroup GetGeometryGroup(GeometryFilter filter = GeometryFilter.ALL)
    {
        GH_GeometryGroup geoGrp = new GH_GeometryGroup();

        foreach (string key in _memberDict.Keys)
        {
            if (!this._visibility.ContainsKey(key) || !this._bakability.ContainsKey(key))
            {
                continue;
            }
            if (filter == GeometryFilter.VISIBLE && !this._visibility[key])
            {
                continue;
            }
            if (filter == GeometryFilter.BAKABLE && !this._bakability[key])
            {
                continue;
            }
            if (filter == GeometryFilter.VISIBLE_AND_BAKABLE && (!this._bakability[key] && !this._visibility[key]))
            {
                continue;
            }

            GH_GeometryGroup subGrp = new GH_GeometryGroup();
            foreach (var goo in _memberDict[key])
            {
                if (!typeof(IGH_GeometricGoo).IsAssignableFrom(goo.GetType()))
                {
                    continue;
                }
                subGrp.Objects.Add((IGH_GeometricGoo)goo);
            }
            geoGrp.Objects.Add(subGrp);
        }
        return(geoGrp);
    }