Jump to content

Reconciling the coordinates of a 3d object and its DynamicTexture


Bladetrick
 Share

Recommended Posts

Hello again!

 

So I started playing with the dynamic textures and ran across something funky.

I created a ground object with the dynamic texture and using a sample provided to me by Delkatosh, I generated a random disc over its surface. 

 

Next, I used .arc to create a circle on the ground object using the same coordinates. At this point I noticed two problems.  The first, and most alarming to me, was that the circle and disc didn't match up.  So the coordinate system on the mesh are not directly aligned to the texture's coordinate system? How do I reconcile the two?

 

Here's what I was hoping to achieve:

5abbb349eff64_Reconcileddiscs.PNG.7cbf818b4c1018c69d5ae521c3707abd.PNG

And this is what actually happens:

5abbb34d0dd18_Unreconcileddiscs.PNG.6c179e9b866092fe548f54ac847bdfaf.PNG

Here's the playground I was working with: https://www.babylonjs-playground.com/#I4MFZ8#1

 

So the other problem I noticed is the circles drawn by arc on the canvas became stretched into elliptical shapes. 

On this playground I used a sphere so you can clearly see the skewing of the shape:   https://www.babylonjs-playground.com/#RQGTKJ

 

Thank you for the time!  

Link to comment
Share on other sites

Lord, that was fast!   That looks like what I needed exactly.  I'll be sure to study it so I understand it.  Thank you!

 

By the way, the second problem I mentioned?  Would you happen to know why my

 

.arc(u * 512, v * 512, 5, 0, Math.PI * 2, true); 

 

end up looking like pills instead of circles?

 

Thanks again, Delta

Link to comment
Share on other sites

Apologies, but I ran into a problem.  For kicks, I exchanged the ground obj for a sphere and everything blitzed.

 

 whattheEFF.PNG.9de974a9276f55bd701d3d3ef0946d4b.PNG

 

In my project, I won't know what object will be loaded up.  Could be flat, could be a torus knot kind of thing.  How can I align the coordinates in these situations?

Also, how can I make the object white?  I tried to change the DynamicTexture to a white but it stays black no matter what I've tried.

 

Thank you

Link to comment
Share on other sites

Its like in the original post above.  The discs represent coordinate data I'm pulling from a database.  In the end result, the discs will not be generated.   I only did that to get a visual grip over what's going on.  The ovals are drawn on the dynamic texture but they're supposed to be in the exact same position as the discs.  In the original example you helped me with, we did it with a ground object and it worked well.  I switched to a sphere because I won't know what sort of shape or model I'll be getting in the end.  Unfortunately, the sphere seems to have thrown things off.

Link to comment
Share on other sites

Get a ball and a piece of paper. Wrap the paper around the ball, it is not possible to get each and every point on the paper to touch one point on the ball. When you map your rectangular image onto a sphere it is not possible to map each and every point on the rectangle to a point on the sphere. For example the all the points on the top edge of the image might be mapped to the 'north pole' of the sphere plus other distortions on the way down to the equator. Hence the sphere will throw thing out.

If you throw discs at different shapes then you need to throw them according to the shape.

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