Jump to content

create a viewcube with multimaterial


Dad72
 Share

Recommended Posts

Hi,

 

I create a ViewCube to inform the view of the window (front, back, top, bottom, left, right).  I apply a dynamic texture with a multimaterial. I used an orthographic camera to display the cube in the upper right hand corner with a layerMask. so far, all are well.
 
But I have some difficulty for submeshes portion of the cube that I do not fully understand.
 
this:
viewcube.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 4, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 4, 8, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(2, 0, verticesCount, 8, 12, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(3, 0, verticesCount, 12, 16, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(4, 0, verticesCount, 16, 20, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(5, 0, verticesCount, 20, 24, viewcube));
Could you help me please you. I create the sample on the playground to reproduce what I have done so far.

 

http://www.babylonjs-playground.com/#1Z5260

 

Thanks for help

Link to comment
Share on other sites

Hey dad,

 

is that the expected result? http://www.babylonjs-playground.com/#1Z5260#1

 

I think the vertices count on each side is 6 instead of 4, because it uses triangles and they don't really share their vertices (not sure why they don't, though).

        viewcube.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 6, viewcube));	viewcube.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 6, 12, viewcube));	viewcube.subMeshes.push(new BABYLON.SubMesh(2, 0, verticesCount, 12, 18, viewcube));	viewcube.subMeshes.push(new BABYLON.SubMesh(3, 0, verticesCount, 18, 24, viewcube));	viewcube.subMeshes.push(new BABYLON.SubMesh(4, 0, verticesCount, 24, 30, viewcube));	viewcube.subMeshes.push(new BABYLON.SubMesh(5, 0, verticesCount, 30, 36, viewcube));

Let me know if that was what you need or if I misunderstood you somehow :)

Link to comment
Share on other sites

Hmm, I think I confused something there....

 

the 5th paramerter should always be the indexCount, so not the end index but the number of how many indices belong to that submesh... so in your case I assume it should always be 4. The stuff I said about 6 vertices is probably nonsense :P I figured I was imaginening something wrong when I looked at the total verticesCount, which is 24.... what makes total sense for a cube... 6 sides with 4 vertices each... but somehow I didn't get it to work yet... maybe it's too late and I just don't see what's going on anymore. Just for the sake of completeness my failed attempt: http://www.babylonjs-playground.com/#1Z5260#5

 

EDIT: There http://www.babylonjs-playground.com/#1Z5260#6 all faces... it is 6 vertices per side of the cube... and the 5th parameter in this case should always be 6 then. Now I just can't comprehend why the verciesCount is 24 :-"

 

... I guess I better go to sleep! :P

 

Maybe as an alternative you can use this create box per face texture thing somehow?

http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors

 

EDIT2: About the positioning... if you leave the x coordinate for writing the text null it gets centered: http://www.babylonjs-playground.com/#1Z5260#7

 

But I fear I can't tell you how the avoid that upside down back face. Maybe somebody else has a hint.

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...