Jump to content

Search the Community

Showing results for tags 'Merging meshes'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. I was trying to merge the individual "Letter" meshes of a "Label" into a single Mesh sub-class of Letter. I made changes to Mesh.MergeMeshes to handle optionally doing it to a sub-class, & allowed a mesh in the source array to be null (I use this for space characters). /** * Merge the array of meshes into a single mesh for performance reasons. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class. */public static MergeMeshes(meshes: Array<Mesh>, disposeSource = true, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh { if (!allow32BitsIndices) { var totalVertices = 0; // Counting vertices for (var index = 0; index < meshes.length; index++) { if (meshes[index]){ totalVertices += meshes[index].getTotalVertices(); if (totalVertices > 65536) { Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"); return null; } } } } // Merge var vertexData : VertexData; var otherVertexData : VertexData; var source : Mesh; for (index = 0; index < meshes.length; index++) { if (meshes[index]){ otherVertexData = VertexData.ExtractFromMesh(meshes[index], true); otherVertexData.transform(meshes[index].getWorldMatrix()); if (vertexData){ vertexData.merge(otherVertexData); }else{ vertexData = otherVertexData; source = meshes[index]; } } } if (!meshSubclass){ meshSubclass = new Mesh(source.name + "_merged", source.getScene()); } vertexData.applyToMesh(meshSubclass); // Setting properties meshSubclass.material = source.material; meshSubclass.checkCollisions = source.checkCollisions; // Cleaning if (disposeSource) { for (index = 0; index < meshes.length; index++) { if (meshes[index]){ meshes[index].dispose(); } } } return meshSubclass;}Because I am also using clones, & the merge process uses transforms, I had to change how getVerticesData optionally works (and plumbing of the in between function calls for this in Geometry: public getVerticesData(kind: string, copyWhenShared? : boolean): number[] { var vertexBuffer = this.getVertexBuffer(kind); if (!vertexBuffer) { return null; } var orig = vertexBuffer.getData(); if (!copyWhenShared || this._meshes.length === 1){ return orig; }else{ var len = orig.length; var copy = []; for (var i = 0; i < len; i++){ copy.push(orig[i]); } return copy; }}I call MergeMeshes in the Label class, with allow32BitIndices false here: /** * @override */public _layout(widthConstraint : number, heightConstraint : number): void { var mergeLater = !Label.NO_MERGING && !this._prohibitMerging && this.getSubPanels().length > 1; // always run super's _layout at least once with individual Letters super._layout(widthConstraint, heightConstraint); if (mergeLater){ var merged = new Letter(this.name + "-merged", DialogSys._scene); BABYLON.Mesh.MergeMeshes(this.getSubPanels(), true, false, merged); if (merged.getTotalVertices() > 0){ this.removeAll(); this.addSubPanel(merged); super._layout(widthConstraint, heightConstraint); }else console.log("merge failed- " + this.name); } }It runs, and some of the Display is shown, but I get 32 of the above errors in the titles. Any clues?
×
×
  • Create New...