MackeyK24

[SOLVED] - Create Capsule Mesh

Recommended Posts

I don't seem to see a CreateCapsule in MeshBuilder... I see the CreateCylinder but it does not have "Top" and "Bottom" part of a capsule.

How can i create a capsule... Note i already "STEAL" pieces of code from framework to make box and sphere collider meshes... But don't know how to create an actual sphere... Anybody know how... This is what my existing "STOLEN" code looks like for box and sphere... Pretty simple... was hoping capsule would be just as simple:

        private static applyBoxCollider(box:BABYLON.Mesh, options: { size?: number, width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, updatable?: boolean }, scene: Scene): void {
            options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
            box.sideOrientation = options.sideOrientation;
            var vertexData = VertexData.CreateBox(options);
            vertexData.applyToMesh(box, options.updatable);
        }

        private static applySphereCollider(sphere:BABYLON.Mesh, options: { segments?: number, diameter?: number, diameterX?: number, diameterY?: number, diameterZ?: number, arc?: number, slice?: number, sideOrientation?: number, updatable?: boolean }, scene: any): void {
            options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
            sphere.sideOrientation = options.sideOrientation;
            var vertexData = VertexData.CreateSphere(options);
            vertexData.applyToMesh(sphere, options.updatable);
        }

        private static updateSideOrientation(orientation: number, scene: Scene): number {
            if (orientation == Mesh.DOUBLESIDE) {
                return Mesh.DOUBLESIDE;
            }
            if (orientation === undefined || orientation === null) {
                return Mesh.FRONTSIDE;
            }
            return orientation;
        }

 

@Sebavan or @Deltakosh You guys know where I'm going with this... It for "Colliders & Triggers" support in the toolkit :)

 

Share this post


Link to post
Share on other sites

Hi Mack.  I'm not one of them guys, but I found this PG...

http://www.babylonjs-playground.com/#13HGWT#2

Whomever created this... was using spheres merged-onto a cylinder... to create a capsule.  Recently, I learned how to create hemispheres... using meshbuilder.

I replaced the spheres with the hemispheres (no real reason... just prettier in wireframe)  :D

It looks as though the hemi's have caps, but they don't.  The cylinder has caps, and no easy removal.

You may wish to use a meshBuilder tube (has capping options) instead of a cylinder.  Hope this helps.  Perhaps createCapsule is in our future, eh?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.