Jump to content

Decals


fenomas
 Share

Recommended Posts

Hi dbawel... nice words... and know that YOU are one of the Brainiacs, too.  You have taught us TONS... and we highly anticipate seeing (and hearing about) your project.

 

DB, are users painting/drawing on the dynamic texture... while it is mapped onto something OTHER THAN a plane?  In other words... given a 5-sided cylinder, are the users painting/drawing upon the sides of the cylinder?

 

So, when you save these textures, they are often "specially painted" for certain mesh shapes?  Are you wanting the texture to "carry along with it"... some information about what mesh shape this texture was created-upon?

 

Otherwise, the mapping of the texture... onto ANY mesh... is really determined by the UVs of the mesh.  SO a dynamic texture that was drawn-upon while the texture was mapped on a 5-side cylinder... will likely look like crap when mapped onto a box.  The user did the drawing, while it was mapped onto a 5-sided cylinder (example).

 

How would you "carry" the information about WHAT MESH the DT was drawn-upon initially?  Not sure.  I think I would try to append the mesh constructor line onto the image data... as a sub-array.  For example, somehow store BABYLON.Mesh.CreateCylinder("cyl1", 4, 3, 3, 5, scene); WITH the texture.  Later, when you load it into the project, you can grab the constructor line, and make the exact mesh that the original DT was drawn-upon.  Then the mapping will be perfect, because you have presented the DT exactly how is was painted.

 

Just some thoughts.  Not sure how the subject went here, but I'm game.  :)

Link to comment
Share on other sites

I'm using a process very similar to joshcamas' projecting through a canvas with a texture (color), and a second canvas as a mask canvas with a brush gradient the same color as the object -which is a Babylon ground object and appending the dynamic texture on the ground object with an x,y pick and pointerdown event. I don't foresee the uv mapping as an issue, although I am moving the ground object's local center axis to mirror the canvas' x,y pick point.

@wingnut and @dad72 - You guys are always gracious in your kind words towards the various skill sets found on this forum. Perhaps one day I'll actually earn the respect you give. Maybe this next app might give me the props to stand among the greater group. In the meantime, I'm good just to have a voice here.

And @dad72 - so I should be able to pass the dynamic texture back though the canvas to record it? I had not considered this, if possible, this would simplify the process greatly. I'll give it a shot - thanks.

Also thanks for the advice to use an array to store and recall the pick info to reconstruct the color as bitmap onto a plane- which is all I should need for v1. Things will get more interesting when I implement more complex mesh geometry in the collaborative design process. I'll then need to restore the exact geometry and uv mapping or it will not have any relevance to the initial session.

I look forward to the feedback from posting here, as I'm sure there will be obvious improvements that I won't see as the only developer on the app. That is, once I finally get the gui integrated, the necessary use of so many canvas' got real confusing real fast. But I feel I'm close now -just a few bugs to fix - features, right?

Link to comment
Share on other sites

Yes this texture can be recharged from a dynamic texture after being saved.

loadedTexture = new Image();loadedTexture.crossOrigin = "Anonymous";cheminImage = "root/"+nameTexture+".png?" + (new Date()).getTime(); //Important:  ?" + (new Date()).getTime();  For the cache of the textures.loadedTexture.src = cheminImage;loadedTexture.onload = function() {	textureContext.save();	textureContext.clearRect(0, 0, textureSize.width, textureSize.height);	textureContext.drawImage(loadedTexture, 0, 0);	textureContext.restore();	textureGround.update();}
Link to comment
Share on other sites

  • 1 year later...

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