Jump to content

geometry vertices positions


Diaco
 Share

Recommended Posts

Hi guys :)

how can I get geometry vertices , in three.js i can get positions with box.geometry.vertices  and returns coordinate for 8 points ( of a box ) ;

now via Bjs i tried to use box.getVerticesData(BABYLON.VertexBuffer.PositionKind);  , but seems returns 24 points !

am I wrong or Babylon js use duplicate/separate vertices for each face ! if so , how can I avoid to return duplicated coordinate ?

thanks in advance .

Link to comment
Share on other sites

Welcome to the forum. Here are some previous topics that might help

See my post in above topic for Oct 8 that starts

DB I just like the way Jerome applied texture in the new Createxxx method applied to CreateBox. Will get round to multi-materials when I am exhausted from this method. Thank you for the support

Link to comment
Share on other sites

JohnK , Thanks for the reply :)

I've read those topics , But seems there're some issues!

since I used BABYLON.VertexBuffer.PositionKind , I suppose  it should return just vertices positions, not other coordinates ! 

on the other hand, I think it's possible to join vertices with same coordinates since three.js already doing that for all basic meshes.

is that really a bug or it's by design , is this correct from performance wise !

if so , what's the fastest solution to avoid getting duplicated coordinates ?

Link to comment
Share on other sites

11 hours ago, adam said:

See how Temechon deals with this in his tree generator tutorial:

http://www.pixelcodr.com/tutos/trees/trees.html

scroll down to Foliage Creation section.

Note a breaking change in

var vertexData = BABYLON.VertexData.CreateSphere(2,sizeBranch); //this line for BABYLONJS2.2 or earlier when tree generator first coded

var vertexData = BABYLON.VertexData.CreateSphere({segments:2, diameter:sizeBranch}); //this line for BABYLONJS2.3 or later

Link to comment
Share on other sites

For reasons of my own I have been looking at removing duplicated vertices. This is my current stage

http://www.babylonjs-playground.com/#1JBMJ3#7

By using the debug layer you can see that the number of vertices is 366. If you then comment line 69 so that the reduction is not applied the number of vertices is 435.

What I have not checked yet is whether this affects subMeshes (in fact I have not checked for any affect it might have and was not going to release it yet but you asked about avoiding duplicated vertices).

Whether this is a useful procedure I do not yet know but it is a start if you want it.

Link to comment
Share on other sites

@adam @JohnK Thanks :) 

JohnK : Great job ! , am i right about vertexData.applyToMesh();   or something like that for other indices ; can be useful to optimise scene objects , and make better performance for big projects ?! since it reduced scene  indices !

I really appreciate your help :)

 

Link to comment
Share on other sites

Nice John.  I wonder what kind of performance gains you can get from this.  I'm thinking it would noticeable when working with large updatable meshes.

On 9/4/2016 at 9:12 AM, JohnK said:

What I have not checked yet is whether this affects subMeshes

I had to try:

http://playground.babylonjs.com/#T40FK#60

Edit:

I guess it might work if you optimize first and then apply the submeshes.

yes:

http://playground.babylonjs.com/#T40FK#61

although for some reason it changes the green a little.

It changes the normals.

normals without removeDuplicates:

http://playground.babylonjs.com/#T40FK#63

normals with removeDuplicates:

http://playground.babylonjs.com/#T40FK#62

after recomputing the normals:

http://playground.babylonjs.com/#T40FK#65

Link to comment
Share on other sites

On 9/3/2016 at 9:30 PM, Diaco said:

is this correct from performance wise !

I just was looking at the docs and ran into mesh.convertToUnindexedMesh().

https://doc.babylonjs.com/tutorials/Optimizing_your_scene#turning-adapttodeviceratio-off

" For example this works very well for a cube where it is more efficient to send 32 positions instead of 24 positions and 32 indices. "

Sometimes it is more efficient to have duplicate vertices and to not use indices.

Link to comment
Share on other sites

But ya know what's gonna happen, right?  Some Wingnut is going to create a playground demo, and say "Woah, dude.. I plotted 8 verts, and now I have 24!  Dude! 

I mean, he's like... and she's like... and we're all like... DUDE!   I mean... your engine is all up-in-my-mesh, harshin' my bloat!"

(What did he say?)   :)  Ok, I'm done yapping pointlessly, now.

Jerome has 33 less posts than I, but 39 more LIKES!   Dude!! 

Link to comment
Share on other sites

On 03/09/2016 at 4:28 AM, Diaco said:

how can I avoid to return duplicated coordinate ?

@Diaco been thinking further about this as I tried to remove some seemingly extra vertices from a sphere but then Raanan pointed out a possible downside. Think I have come up with an explanation in this topic that may to useful

 

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...