Jump to content

Help with Dynamic Textures


dbawel
 Share

Recommended Posts

Hi jahow,

 

This is the method I was using for my first version app.  However, when a remote user changes the color(texture) they are using to draw, I need to have a sepeate canvas or more for each remote texture for each local user.  DO you see a way to have an virtually unlimited # of 2D canvas' sending color info to the dynamic texture?  There in is my problem, as I already have this multiuser reatime drawing app working, but only drawing with the color that the loacal user has selected.  When a remote user selects a sepeate color, I can't have so many additional canvas' in every local scene in which I'm passing the pickinfo coordinates - actually I can, but not with different tectures applied.  If you have a solution to this, I'd love to study it.

 

Cheers.

Link to comment
Share on other sites

Well then, why just broadcast the painting coordinates to other clients, and not the painting color with it? Why limit yourself to drawing on the canvas using only the color your current user has selected?

 

Sorry if these are stupid questions.

Link to comment
Share on other sites

Hi jahow,

 

That's what we're currently doing, and will have to release the first version with this limitation.  However, we hope to find a way to draw using multiple colors simultanoisly onto a dynamic texture.  I've written something similar using C#, but not compatible in all browsers and OS - and the reaction from users is astounding.  It really drives home the multiuser aspect.

 

By the way, your draw script is really brilliant.  I'm still trying to understand all that you are doing.

Link to comment
Share on other sites

Okay, got it. I'm sure you'll work something out.

 

About the draw script in the PG, I've done almost nothing. The drawing code has been done by iiceman, I just added a fix in the pickResult.getTextureCoordinates function that would keep it from functioning altogether :)

Link to comment
Share on other sites

I tried to understand what exactly you did to map the texture coordinates... but I failed :P Can you explain or recommend a tutorial? (or write one yourself? ;) ) I see what you did, but I have no clue why... it is nothing I could have figured out myself with my current knowledge.

Link to comment
Share on other sites

It mainly has to do with the barycentric coordinates of the picked point: bu and bv.

 

I've expanded the picking tutorial to describe that: http://doc.babylonjs.com/page.php?p=22111

 

Basically these coordinates tell you how the picked point is "influenced" by the three vertices of the polygon it's on. The influences are computed as follows:

  • 1-bu-bv for the vertex n. 0
  • bu for the vertex n. 1
  • bv for the vertex n. 2

This can be used to determine the position of the picked point, but also its color, texture coordinates, normal, and any other attribute that can be interpolated between the three vertices. To interpolate an attribute (of any kind) you have to use the following equation:

interpolated_attribute = vertex0_attribute * (1-bu-bv) + vertex1_attribute * bu + vertex2_attribute * bv;

Which is... the equation of a barycenter :)

Link to comment
Share on other sites

Hmmm... I see... not sure if i actually understand..but I get the idea I guess :P But what about pickResult.getTextureCoordinates()? What do I use that for? And shouldn't that be the same like what you did? And if not, can we (and if I say we I mean one of you awesome contributer to babylon guys) add that barycenter stuff in a function like pickResult.getBaryTextureCoordinates(), too, so that I don't have to understand/remember it? ;)

Link to comment
Share on other sites

Ah, I see, I compared the result of getTextureCoordinates with your texture coordinates and they were different... so the bug fix is already on the way and just not in the playground, yet? If that is fixed it makes it really comfortable to draw on dynamic textures... nice! :)

Link to comment
Share on other sites

Just for the sake of completeness the easy-to-use after bugfix version: http://www.babylonjs-playground.com/#9U086#4

 

Trying some stress test: simulating 100 users drawing pretty much at the same time: http://www.babylonjs-playground.com/#9U086#5 not sure how representative that is, but looks funky :D

 

Edit:

Once again I have no clue what I am doing, but it's fun: http://www.babylonjs-playground.com/#9U086#6 (trying to simulate a bit more realistic drawing behavior, only 50 users now);

 

Well, and just for the fun of it another version: http://www.babylonjs-playground.com/#9U086#7

Link to comment
Share on other sites

  • 3 months later...

Just for the sake of completeness the easy-to-use after bugfix version: http://www.babylonjs-playground.com/#9U086#4

 

Trying some stress test: simulating 100 users drawing pretty much at the same time: http://www.babylonjs-playground.com/#9U086#5 not sure how representative that is, but looks funky :D

 

Edit:

Once again I have no clue what I am doing, but it's fun: http://www.babylonjs-playground.com/#9U086#6 (trying to simulate a bit more realistic drawing behavior, only 50 users now);

 

Well, and just for the fun of it another version: http://www.babylonjs-playground.com/#9U086#7

 

Hi iiceman,

 

This looks great. For my work I need something exactly like this for drawing with mouse. But I also needed some points on the drawn figure ( as many points as possible). Is there any way I can get some sample points on the drawn figure ?

 

I am referring to the version you have posted under this url: http://www.babylonjs-playground.com/#9U086#4.

 

I do not need the sphere, I will only draw on a plane with mouse.

 

Many Thanks in advance.

 

Neel.

Link to comment
Share on other sites

  • 2 weeks later...

Hi iiceman,

 

Sorry I was bit busy with other stuff, so could not reply early.

 

My bad, my language was confusing enough. What I mean is, it would be nice to have some coordinates of points on the drawn curve. For example I draw a curve with mouse ( any shape), and I get some coordinates of points on that curve, say (x1,y1), (x2,y2), (x3,y3)...as many as possible. I am not sure whether it is feasible.

 

Please let me know if this is understandable ( I am preety bad in communicating :) ) or else I will try to explain differently.

 

Thanks.

Neel.

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