Example #1
0
        public static ColliderComponent makeBox(SpatialVectorDouble size, SpatialVectorDouble localPosition, SpatialVectorDouble localRotation)
        {
            ColliderComponent result = new ColliderComponent(EnumType.BOX, localPosition, localRotation);

            result.mesh = PlatonicFactory.createBox(size.x, size.y, size.z);
            return(result);
        }
Example #2
0
            public static void DrawOctahedron(ICoreScene3D dc, XYZ center, float radius, int lod, ColorStyle color, bool faceFlip)
            {
                if (lod < 0)
                {
                    return;
                }

                var ctx = new PlatonicFactory
                {
                    _Center   = center,
                    _Radius   = radius,
                    _Color    = color,
                    _FaceFlip = faceFlip,
                    _Context  = dc
                };

                // top 4
                ctx.DrawTriangle(lod, XYZ.UnitX, XYZ.UnitY, XYZ.UnitZ);
                ctx.DrawTriangle(lod, XYZ.UnitZ, XYZ.UnitY, -XYZ.UnitX);
                ctx.DrawTriangle(lod, -XYZ.UnitX, XYZ.UnitY, -XYZ.UnitZ);
                ctx.DrawTriangle(lod, -XYZ.UnitZ, XYZ.UnitY, XYZ.UnitX);

                // bottom 4
                ctx._FaceFlip = !ctx._FaceFlip;
                ctx.DrawTriangle(lod, XYZ.UnitX, -XYZ.UnitY, XYZ.UnitZ);
                ctx.DrawTriangle(lod, XYZ.UnitZ, -XYZ.UnitY, -XYZ.UnitX);
                ctx.DrawTriangle(lod, -XYZ.UnitX, -XYZ.UnitY, -XYZ.UnitZ);
                ctx.DrawTriangle(lod, -XYZ.UnitZ, -XYZ.UnitY, XYZ.UnitX);
            }
Example #3
0
        void buildAndAddRenderingMesh(GameObjectTemplate template, PhysicsComponent physicsComponent)
        {
            if (template.meshPath == "meta:fromMainShape")   // the mesh is derived from the mainshape
            {
                MeshWithExplicitFaces renderMesh;

                if (template.mainMassShapeType == "box")
                {
                    renderMesh = PlatonicFactory.createBox(template.mainMassDimensions[0], template.mainMassDimensions[1], template.mainMassDimensions[2]);
                }
                else
                {
                    throw new NotImplementedException("meta:fromMainShape mesh path is not implemented for shape " + template.meshPath + "!");
                }

                MeshComponent meshComponent = new MeshComponent();
                meshComponent.mesh = renderMesh;

                TransformedMeshComponent transformedMeshComponentForRendering = new TransformedMeshComponent();
                transformedMeshComponentForRendering.meshComponent = meshComponent;

                softwareRenderer.physicsAndMeshPairs.Add(new PhysicsComponentAndMeshPair(physicsComponent, transformedMeshComponentForRendering));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Example #4
0
            public static void DrawIcosahedron(ICoreScene3D dc, XYZ center, float radius, int lod, ColorStyle color, bool faceFlip)
            {
                if (lod < 0)
                {
                    return;
                }

                var ctx = new PlatonicFactory
                {
                    _Center   = center,
                    _Radius   = radius,
                    _Color    = color,
                    _FaceFlip = faceFlip,
                    _Context  = dc
                };

                // 5 faces around point 0
                ctx.DrawTriangle(lod, _ICOVRT0, _ICOVRT11, _ICOVRT5);
                ctx.DrawTriangle(lod, _ICOVRT0, _ICOVRT5, _ICOVRT1);
                ctx.DrawTriangle(lod, _ICOVRT0, _ICOVRT1, _ICOVRT7);
                ctx.DrawTriangle(lod, _ICOVRT0, _ICOVRT7, _ICOVRT10);
                ctx.DrawTriangle(lod, _ICOVRT0, _ICOVRT10, _ICOVRT11);

                // 5 adjacent faces
                ctx.DrawTriangle(lod, _ICOVRT1, _ICOVRT5, _ICOVRT9);
                ctx.DrawTriangle(lod, _ICOVRT5, _ICOVRT11, _ICOVRT4);
                ctx.DrawTriangle(lod, _ICOVRT11, _ICOVRT10, _ICOVRT2);
                ctx.DrawTriangle(lod, _ICOVRT10, _ICOVRT7, _ICOVRT6);
                ctx.DrawTriangle(lod, _ICOVRT7, _ICOVRT1, _ICOVRT8);

                // 5 faces around point 3
                ctx.DrawTriangle(lod, _ICOVRT3, _ICOVRT9, _ICOVRT4);
                ctx.DrawTriangle(lod, _ICOVRT3, _ICOVRT4, _ICOVRT2);
                ctx.DrawTriangle(lod, _ICOVRT3, _ICOVRT2, _ICOVRT6);
                ctx.DrawTriangle(lod, _ICOVRT3, _ICOVRT6, _ICOVRT8);
                ctx.DrawTriangle(lod, _ICOVRT3, _ICOVRT8, _ICOVRT9);

                // 5 adjacent faces
                ctx.DrawTriangle(lod, _ICOVRT4, _ICOVRT9, _ICOVRT5);
                ctx.DrawTriangle(lod, _ICOVRT2, _ICOVRT4, _ICOVRT11);
                ctx.DrawTriangle(lod, _ICOVRT6, _ICOVRT2, _ICOVRT10);
                ctx.DrawTriangle(lod, _ICOVRT8, _ICOVRT6, _ICOVRT7);
                ctx.DrawTriangle(lod, _ICOVRT9, _ICOVRT8, _ICOVRT1);
            }
Example #5
0
            // https://en.wikipedia.org/wiki/Platonic_solid

            public static void DrawTetrahedron(ICoreScene3D dc, XYZ center, float radius, int lod, ColorStyle color, bool faceFlip)
            {
                if (lod < 0)
                {
                    return;
                }

                var ctx = new PlatonicFactory
                {
                    _Center   = center,
                    _Radius   = radius,
                    _Color    = color,
                    _FaceFlip = faceFlip,
                    _Context  = dc
                };

                ctx.DrawTriangle(lod, _TETRAVRT0, _TETRAVRT1, _TETRAVRT2);
                ctx.DrawTriangle(lod, _TETRAVRT3, _TETRAVRT0, _TETRAVRT2);
                ctx.DrawTriangle(lod, _TETRAVRT3, _TETRAVRT1, _TETRAVRT0);
                ctx.DrawTriangle(lod, _TETRAVRT3, _TETRAVRT2, _TETRAVRT1);
            }