Bladetrick Posted March 28, 2018 Share Posted March 28, 2018 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: And this is what actually happens: 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! Quote Link to comment Share on other sites More sharing options...
Guest Posted March 28, 2018 Share Posted March 28, 2018 Here we are: https://www.babylonjs-playground.com/#I4MFZ8#2 The texture coordinates must be between 0-textureSize so you must first convert coordinates to 0-1 range (remember that your object is centered on its 0,0,0) Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted March 28, 2018 Author Share Posted March 28, 2018 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 Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 28, 2018 Share Posted March 28, 2018 Square dynamic texture being stretched onto rectangular ground. Try replacing textureResolution parameter with ground (the receiving mesh) when creating dynamic texture. Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted April 2, 2018 Author Share Posted April 2, 2018 Apologies, but I ran into a problem. For kicks, I exchanged the ground obj for a sphere and everything blitzed. 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted April 2, 2018 Share Posted April 2, 2018 Once again without a repro it is impossible to help Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted April 2, 2018 Author Share Posted April 2, 2018 So sorry, here's the PG: https://www.babylonjs-playground.com/#I4MFZ8#3 And the original you helped me with is: https://www.babylonjs-playground.com/#I4MFZ8#2 Thank you Quote Link to comment Share on other sites More sharing options...
Guest Posted April 2, 2018 Share Posted April 2, 2018 Here is the fix for the white background: https://www.babylonjs-playground.com/#I4MFZ8#4 (check line #37, you were calling fill which does not exist) Can you tell me more about the other issue? I fill like the discs are correctly aligned on your sphere Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted April 3, 2018 Author Share Posted April 3, 2018 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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 3, 2018 Share Posted April 3, 2018 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. Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.