Search the Community

Showing results for tags 'submesh'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 14 results

  1. Instance SubMesh Frustum Culling

    Hello! I discovered, what i call a bug, with instances and frustum culling. When the original mesh got submeshes the submesh culling of the instances relate to the position of the original mesh. This results in disappearing instances (submeshes) when the original mesh leaves the frustum. My quick hack was BABYLON.SubMesh.prototype.isInFrustum = function (frustumPlanes) { if( this._mesh._isAllwaysInFrustum )return true; var boundingInfo = this.getBoundingInfo(); if (!boundingInfo) { return false; } return boundingInfo.isInFrustum(frustumPlanes); }; //then setting orginalMesh._isAllwaysInFrustum = true; I think the current behaviour is not intended.
  2. Hello, No bug, no issue today ! I was just wondering about the choice of linking materialDefines to subMeshes, rather than directly on materials themselves. Does that mean that two subMeshes could have the same material, but different defines ? As the material updates the defines depending on its own properties (not the properties of the subMesh), I can hardly see how it's possible. I would love to see an example of this if you have one. I mean, I'm missing something. I'm quite sure this choice has been made for a good reason. But I don't get why. Thanks for your help !
  3. Hi Folks, I have a really stupid question about SubMesh. When and where do we need to create SubMeshes instead of a Mesh? In other world, what is the advantage of SubMesh compared to Mesh? I saw that OBJ loader create just one SubMesh under a Mesh and the Material is attached to the SubMesh instead of the Mesh. So, I am a little bit confused.. But I am sure there must be a reason. And what is the materialIndex stands for? It seems that its parent Mesh can only have one Material so that the index should always be zero? Thanks
  4. Hi, I'm trying to show the bounding box of a subMesh only. So I tried: scene.getBoundingBoxRenderer().renderList.push(subMesh.getBoundingInfo().boundingBox); scene.getBoundingBoxRenderer().render(); and the same thing with creating a new BoundingBoxRenderer but nothing append... Using mesh.showBoundingBox = true; and mesh.showSubMeshesBoundingBox = true; always show ALL the bounding boxes... So, is it possible to do what I'm expecting or am I just doing something wrong ?
  5. I'm new to BabylonJS. I've been successful at integrating the framework within an Angular 2 project. Now, I'm trying to integrate 3D models from the Unity Asset Store. I used the Unity exporter to generate a .babylon file. It rendered a gray beagle. The console complained about an old PBR Material version. I removed the albedo property and the error went away. So, did my beagle. I've attached my log from the console. I'm not sure where to start troubleshooting. What is the common approach to integrate 3D models into Babylonjs? Is there some linting tool to troubleshoot the .babylon file? Is my problem somewhere else? Thanks,
  6. Is it possible to detect an intersection between a mesh and a submesh of another mesh?
  7. Hey everyone! I'm trying to extract VerticeData from a SubMesh to create an other mesh but i always failed. I want to extract indices, positions, normals and uvs for the moment: Indices: var result = new VertexData(); var indices = subMesh.getMesh().getIndices(); for (var index = subMesh.indexStart; index < subMesh.indexStart + subMesh.indexCount; index++) { result.indices.push(indices[index]); } Positions and normals: var positions = subMesh.getMesh().getVerticesData(BABYLON.VertexBuffer.PositionKind, copyWhenShared); var vertex; for (var index = subMesh.indexStart; index < subMesh.indexStart + subMesh.indexCount; index+=3) { vertex = new BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(positions[index], positions[index + 1], positions[index + 2]), worldMatrix); result.positions.push(vertex.x); result.positions.push(vertex.y); result.positions.push(vertex.z); } Anyone to help me?
  8. I have observed that sub meshes can solve many issues for dynamically changing materials for parts of meshes. "Dynamic" changing of materials is meant to mean changing the material of parts of the scene content on demand while the application is running. It is understood by me that in order to increase general performance of the BABYLON engine, one should reduce the total number of meshes in the scene. This has certainly been an observed truth in my implementation of BABYLON for our application. We see that this truth, however can become problematic when several large meshes exist, and then many sub meshes are created for assigning materials to parts of the mesh. As I understand from forum research, empirical analysis, and reviewing BABYLON source code, the number of sub meshes is directly linked to the number GL draw calls. If the scene is organized with several large meshes, you will still see inferior FPS performance if many sub meshes are added to each mesh. This is true, even if many of the sub meshes reference a small number of materials. To visualize this problem, I will use the example of a large horse (metaphorically) being the entire contents of the scene. In this case, we will have a single mesh, containing all the vertices to draw this horse. Dynamically, we wish to change this horse to a zebra - where the vertices are identical to the horse, but instead we add black and white stripes to the horse. I have explored two options to accomplish this "zebra-fication". 1) (Non-submesh solution) Manipulating the index and vertex arrays themselves, it is possible to "pull" apart all the white parts of the zebra into a single mesh, and all the black parts of the zebra into a separate mesh. This performs wonderfully from a FPS perspective, but is not wonderful for the array manipulation itself. This is also NOT using the concept of sub meshes whatsoever. The problem, once again with this solution is not the render performance, but the operation of creating the two meshes. It can also be considered that once indexes are manipulated, we could retain the use of a single mesh, and since the indexes are reorganized and are concurrent with respect to their materials, we could also use 2 submeshes. 2) (Submesh solution) An elegant solution in terms of performance of the "zebra-fication" is to cut up the horse mesh into white and black stripes with sub meshes. The performance of creating these sub meshes is very good - as expected. The problem with this solution, as I introduced in the beginning paragraph, is that for each "stripe/submesh" we see a separate GL draw call. My post is intended to firstly inquire if there is a way to bridge the gap between the low cost for the zebra-fication with submeshes while also keeping GL draw calls low and therefore FPS high. As I understand it, I cannot currently have my cake and eat it too. My post is also intended to inquire about a possible enhancement to the BABYLON engine, which I am more than happy to code, test, and post to the BABYLON source. This would be an optional structure to pass multiple sub meshes to the rendering manager, where these sub meshes share the same material index. It should also be noted that these sub meshes do not need to have consecutive start/end indexes. Therefore, one could still enjoy the excellent sub mesh performance while "zebrafying", and also enjoy great FPS performance. I am more than happy to discuss design details with this enhancement if this enhancement would be allowed to the source code. It may also be possible to enhance the submesh class so that non sequential ranges of indexes could be added. This may be an easier and more elegant solution. With this solution, one could create two submeshes (one white, one black), and specify the various index ranges for each white and black stripe respectively. Thank you for your time
  9. Hello ! In the mesh object, there is an array called subMeshes containing the different materials applied to the mesh. It would be cool to be able to access to the position of the "submesh". For example, a black textured material for the boots and we can get the center position of the boots. It sounds maybe useless because some materials are applied everywhere so : a way to access to the position of a specific part of the mesh, a vertex group (in Blender) for example. Is there a way to access to the position of a bone in world global space and then copy this position for a mesh (without attachToBone) ? I tried to check the numbers in all the matrices included Worldmatrix but it doesn't give the right thing. Thx for your attention.
  10. Hey guys I am trying to figure something out. I have a scene with a handful of identically sized boxes that can be moved around and rotated independently. When I move a box I can check which other box is closest to it and whether it is "in range" (ie distance is less than a set value) by checking distance between currentBox.position and each boxes.position. If they are in range then I can highlight it somehow (currently I set .visibility on both boxes to 0.5). This works quite well. When boxes are moved out of range again they become unhighlighted (ie .visibility=1 is set to 1); However I want to make it more specific and highlight the specific face on each box that are closest. Context: this is a first step to creating a kind of "snap-to" function that will allow boxes to be snapped together without needing user to accurately rotate and align the boxes. So user moves box A within range of box B, the closest faces are highlighted and then when mouse button is released they snap together with Box A translating automatically to align with Box B. I started by adapting the boxes at point of creation to contain subMeshes for each side. The intention here was to use the method above but instead of iterating through each box in my boxes array, was to iterate through each subMesh in each box in my array and apply the same logic to determine their distance. However the snag ... subMesh has no ".position" member so comparing currentBox.subMesh.position with boxes[j].subMesh[k].position does not work. I have a sinking feeling I am going to have to compare the sets of vertices that make up each face/side of each box. Not only is this more comparisons to perform on each move of the mouse and therefore a potential performance hit, but it also leads to some pretty complicated logic. In other words what is the criteria for nearest face .. I can't say "if the four vertices outlining a box side are all closes to the four vertices on a particular side of my currentBox" as if the box faces are not parallel you could find that the "nearest face" actually has some of its vertices that are further away from currentBox face than some other faces. I'll try and work up a quick playground to demonstrate what I mean but while I do, has anyone done this before? I cannot find anything on search her or google but it seems that it must have been thought about before? Thanks in advance, Richard
  11. I'm having issues with parts of my model not showing when it extends beyond the bounding box at the edge of the screen. I tried using the extendSize property, but it doesn't seem to have any effect. Has anyone had any success with updating the size of the bounding box?
  12. Hi Gang! Many questions. (sorry) **** Does anyone know the history-of or reason-for... During the creation of a SubMesh, it is automatically placed into the mesh.subMeshes array. Is this somewhat new? Anyone know? MY reason for wanting to know? Visit Kostar's cool Tiled Ground Tutorial... particularly playground demo #5. See line 61, where our friend is pushing newly-created subMesh into the tiledGround.subMeshes array? Well... that's no good. Inserting a console.log near line 65, reports that there are 128 subMeshes in Kostar's 64-tile ground. (double, and we know why) Here is my own clone of Kostar's demo #5 - with console.log line showing 128 count. A little adjustment to line 61, and things start working good, with a count of 64. Maybe Kostar needs a mail. Maybe auto-pushing subMesh upon creation... is a bad idea. Dunno. Anyone know any history? Is auto-pushing subMeshes... something new? Bad? Good? Thoughts? (thx)
  13. Picking a submesh

    Hey ho, another two quick (and hopefully easy) question, please have a look here: 1) I am trying to create a tiles ground with 4 submeshes. I start with zero submeshes. I am pushing submeshes 4 times... I end up with 8 submeshes... ... ... eh? I feel like I am missing something here, please tell me what's going on. I assume the 8 submeshes are the triangles that I see in the wireframe... but why? 2) How can I pick a submesh? The scene.pick returns the clicked mesh, but how would I determine the submesh at the clicked position? (Edit: I searched and didn't find anything about picking a submesh at all, but somebody must have done that before, I think. Maybe it's too easy so nobody else ever asked :-/ ) Easy questions, right? Enlighten me please!
  14. Dislocated Submeshs

    Hey folks, once again a got a (newbie) question. I made a mesh in Blender, pretty much my first real try, so please don't laugh too hard The Problem is that it consists of 3 meshes: body, face and eyes and if i place the face as submesh (and the eyes as submesh of face). I end up getting the wrong position for the submehes when I load the main mesh in my Babylon scene. (zoom out a bit and u see the black face and the blue eyes above the body) So... what am I doing wrong? (Hints for better modeling are greatly appreciated as well ) PS: I tried to attach the files I used (babylon and blend, alternatively rar with both of them in it) and always got this: bobbin.babylonYou aren't permitted to upload this kind of filebobbin.blendYou aren't permitted to upload this kind of filebobbin.rarYou aren't permitted to upload this kind of file Am I allowed to upload at all? And if so. what am I allowed to upload?