Exemplo n.º 1
0
        public override void Run(string path)
        {
            SU.EntitiesRef entities = SUHelper.Initialize();

            SU.GeometryInputRef geometry = new SU.GeometryInputRef();
            SU.GeometryInputCreate(geometry);

            foreach (SU.Point3D p in points)
            {
                SU.Point3D pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(geometry, pc);
            }

            SU.LoopInputRef loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            long faceIndex;

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            SU.EntitiesFill(entities, geometry, true);

            SUHelper.Finalize(path + @"\PlainQuad.skp");
        }
Exemplo n.º 2
0
        public override void Run(string path)
        {
            SU.EntitiesRef entities = SUHelper.Initialize();

            SU.GeometryInputRef geometry = new SU.GeometryInputRef();
            SU.GeometryInputCreate(geometry);

            foreach (SU.Point3D p in points)
            {
                SU.Point3D pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(geometry, pc);
            }

            SU.LoopInputRef loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            long faceIndex;

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            SU.MaterialRef material = new SU.MaterialRef();
            SU.MaterialCreate(material);
            SU.MaterialSetName(material, "Pure Red");
            SU.MaterialSetColor(material, new SU.Color {
                red = 0xFF, alpha = 0xFF
            });
            SU.MaterialInput materialInput = new SU.MaterialInput();
            materialInput.materialRef = material;
            SU.GeometryInputFaceSetFrontMaterial(geometry, 0, materialInput);

            SU.EntitiesFill(entities, geometry, true);

            SUHelper.Finalize(path + @"\RedQuad.skp");
        }
        public override void Run(string path)
        {
            SU.EntitiesRef entities = SUHelper.Initialize();

            SU.GeometryInputRef geometry = new SU.GeometryInputRef();
            SU.GeometryInputCreate(geometry);

            foreach (SU.Point3D p in points)
            {
                SU.Point3D pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(geometry, pc);
            }

            SU.LoopInputRef loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            long faceIndex;

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            SU.MaterialRef material = new SU.MaterialRef();
            SU.MaterialCreate(material);
            SU.MaterialSetName(material, "Placeholder");
            SU.TextureRef texture = new SU.TextureRef();
            SU.TextureCreateFromFile(
                texture,
                "PlaceHolderRGBY.png",
                SU.MetersToInches,
                SU.MetersToInches);
            SU.MaterialSetTexture(material, texture);

            SU.MaterialInput materialInput = new SU.MaterialInput();
            materialInput.materialRef = material;
            materialInput.numUVCoords = 4;

            materialInput.materialRef = material;

            materialInput.SetUVCoords(
                new SU.Point2D(0, 0),
                new SU.Point2D(1, 0),
                new SU.Point2D(1, .5),
                new SU.Point2D(0, .5));

            materialInput.SetVertexIndices(0, 1, 2, 3);

            SU.GeometryInputFaceSetFrontMaterial(geometry, faceIndex, materialInput);


            loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 3);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 4);
            SU.LoopInputAddVertexIndex(loop, 5);

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            materialInput             = new SU.MaterialInput();
            materialInput.materialRef = material;
            materialInput.numUVCoords = 4;

            materialInput.materialRef = material;

            materialInput.SetUVCoords(
                new SU.Point2D(0, .5),
                new SU.Point2D(1, .5),
                new SU.Point2D(1, 1),
                new SU.Point2D(0, 1));

            materialInput.SetVertexIndices(3, 2, 4, 5);

            SU.GeometryInputFaceSetFrontMaterial(geometry, faceIndex, materialInput);
            SU.EntitiesFill(entities, geometry, true);

            SUHelper.Finalize(path + @"\TwoQuadsSeamslessTexture.skp");
        }
Exemplo n.º 4
0
        public override void Run(string path)
        {
            SU.EntitiesRef entities = SUHelper.Initialize();

            // Create two Component Definitions.

            SU.ComponentDefinitionRef fanCD = new SU.ComponentDefinitionRef();
            SU.ComponentDefinitionCreate(fanCD);
            SU.ComponentDefinitionSetName(fanCD, "Fan");
            SU.ComponentDefinitionSetDescription(fanCD, "A six-bladed fan on the Y axis");

            SU.ComponentDefinitionRef bladeCD = new SU.ComponentDefinitionRef();
            SU.ComponentDefinitionCreate(bladeCD);
            SU.ComponentDefinitionSetName(bladeCD, "Fan Blade");
            SU.ComponentDefinitionSetDescription(bladeCD, "Trapezoidal blade offset from axis");

            // Add CDs to the model.)

            SU.ComponentDefinitionRef[] defs = new SU.ComponentDefinitionRef[2];
            defs[0] = fanCD;
            defs[1] = bladeCD;

            SUHelper.ModelAddComponentDefinitions(defs);

            // The Fan CD only has instances of the blade, and no
            // geometry of its own. Create the blade geometry and
            // put it into the blade's entities.


            SU.GeometryInputRef bladeGeo = new SU.GeometryInputRef();
            SU.GeometryInputCreate(bladeGeo);

            foreach (SU.Point3D p in bladePoints)
            {
                SU.Point3D pc;

                pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(bladeGeo, pc);
            }

            SU.LoopInputRef loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            long faceIndex;

            SU.GeometryInputAddFace(bladeGeo, loop, out faceIndex);

            SU.EntitiesRef bladeEnts = new SU.EntitiesRef();
            SU.ComponentDefinitionGetEntities(bladeCD, bladeEnts);
            SU.EntitiesFill(bladeEnts, bladeGeo, true);

            // Add six instances of the blade to the fan definition.

            for (int i = 0; i < 6; ++i)
            {
                AddBlade(
                    i,
                    fanCD,
                    bladeCD,
                    (15.0 / 360.0) * 2 * Math.PI,
                    2 * i * Math.PI / 6);
            }

            // Add one instance of the fan to the model.

            SU.ComponentInstanceRef fi = new SU.ComponentInstanceRef();
            SU.ComponentDefinitionCreateInstance(fanCD, fi);

            SU.EntitiesAddInstance(entities, fi, null);

            SUHelper.Finalize(path + @"\SixQuadFan.skp");
        }
Exemplo n.º 5
0
        public override void Run(string path)
        {
            SU.EntitiesRef entities = SUHelper.Initialize();

            SU.GeometryInputRef geometry = new SU.GeometryInputRef();
            SU.GeometryInputCreate(geometry);

            foreach (SU.Point3D p in parentPoints)
            {
                SU.Point3D pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(geometry, pc);
            }

            SU.LoopInputRef loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            long faceIndex;

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            SU.EntitiesFill(entities, geometry, false);

            // Now the child.

            SU.ComponentDefinitionRef cd = new SU.ComponentDefinitionRef();
            SU.ComponentDefinitionCreate(cd);

            // Add CD to the model.)

            SU.ComponentDefinitionRef[] defs = new SU.ComponentDefinitionRef[1];
            defs[0] = cd;

            // You leave this out and SketchUp will add the definitions to the model
            // itself when it opens the model. But it will prompt you on close to save
            // the "changes" it thinks that adding the definitions made.

            SUHelper.ModelAddComponentDefinitions(defs);

            // Get the CD's Entities.

            SU.EntitiesRef cdEnts = new SU.EntitiesRef();
            SU.ComponentDefinitionGetEntities(cd, cdEnts);

            // Define a Geometry for the CD.

            geometry = new SU.GeometryInputRef();
            SU.GeometryInputCreate(geometry);

            foreach (SU.Point3D p in childPoints)
            {
                SU.Point3D pc = p;

                pc.x *= SU.MetersToInches;
                pc.y *= SU.MetersToInches;
                pc.z *= SU.MetersToInches;

                SU.GeometryInputAddVertex(geometry, pc);
            }

            loop = new SU.LoopInputRef();
            SU.LoopInputCreate(loop);

            SU.LoopInputAddVertexIndex(loop, 0);
            SU.LoopInputAddVertexIndex(loop, 1);
            SU.LoopInputAddVertexIndex(loop, 2);
            SU.LoopInputAddVertexIndex(loop, 3);

            SU.GeometryInputAddFace(geometry, loop, out faceIndex);

            // Fill the CD's Entities with the Geometry.

            SU.EntitiesFill(cdEnts, geometry, true);

            SU.ComponentDefinitionSetName(cd, "Quad in XY");
            SU.ComponentDefinitionSetDescription(cd, "A flat square with normal on positive Z");

            // Create an instance of the CD.

            SU.ComponentInstanceRef ci = new SU.ComponentInstanceRef();
            SU.ComponentDefinitionCreateInstance(cd, ci);

            SU.ComponentInstanceSetName(ci, "Child Quad");

            SU.EntitiesAddInstance(entities, ci, null);
            SUHelper.Finalize(path + @"\TwoQuadsParentChild.skp");
        }