How to draw a custom texture/material in polygon (square, ...)? #287
Replies: 4 comments 3 replies
-
Hi!
Yes, if you are drawing a plane, you can just use the X and Z world coordinates of the points as the UV coordinates.
Yes, you can apply rotation and scale to the UV coordinates.
In the Stack Overflow tutorial that you referenced the plane is created as an object. It may be just more difficult to apply a texture to more complex objects. |
Beta Was this translation helpful? Give feedback.
-
Hi @grassydragon , Thank you a lot for your answer!
Yes, I'm drawing only a plane. Can you please write me more about this solution? I have But how can I transform it to the UV coordinates? And then draw it on the surface? I'm trying to find more info about it but documentation about ARCore/SceneForm is ... isn't :) Can you please write me some more info? Where should I start? What methods to use? |
Beta Was this translation helpful? Give feedback.
-
You can first try using them as is because the texture will repeat when you go out of bounds.
You need to generate triangles using your points. For example, The main goal is to find a way to generate triangles to render your polygon and the other things should be similar to the Stack Overflow code. |
Beta Was this translation helpful? Give feedback.
-
Thank you. I will look at it. One more question: what if we limit the points to 4? (user define 4 points/anchors) It will be 4 vertex/vertices of the polygon. Then we will draw this polygon/object. But with depth (height) of that object will be small (a few pixels) so it will look like a plane. And then we can draw texture on it. What do you think about it? Is it possible? Maybe it will be easier than the solution with generating triangles to render a polygon. Is it possible in SceneView to render polygon defined by 4 vertexes? |
Beta Was this translation helpful? Give feedback.
-
I'm trying to draw texture inside defined points (3, 4 or more points).
I found this: https://stackoverflow.com/questions/54433707/how-to-draw-a-polygon-with-sceneform-arcore and it's a good start.
Then I found this tutorial: https://catlikecoding.com/unity/tutorials/procedural-meshes/creating-a-mesh/ and updated the code from the previous post. Like this:
Now it's draw texture inside 4 points (you have to insert points in correct order). But it's drawn as two triangles. So the common edges may not fit exactly.
Is it possible to somehow draw texture/material inside defined points in SceneView? Something like this:
Also, it's possible to rotate or zoom in/out the texture?
EDIT: Or maybe draw it as a model/object with texture?
Beta Was this translation helpful? Give feedback.
All reactions