Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: samsquared on December 16, 2012, 12:19:47 AM
-
Hello all!
I am curious: can you procedurally generate terrain, or, well, anything, in Playmaker? Such as using a black-and-white image to generate a Minecraft-life terrain. Is there a way to do such things in Playmaker?
Thank you!
-
theoretically yes, that's possible, and a terrain from an image shouldn't even be all that hard. Practically you would need to write some actions for it though. Do you know how to code?
-
Yes, I do know how to code/script. I am very curious, however, how to do so within Playmaker. I just downloaded PM and have been learning it bit by bit. What would be the process from within PM, not a script?
-
well, you'd start off by writing the actions you need. In this case this would be
Get Image Pixel height
Get Image Pixel width
Get Pixel Color at (Vector2)
Transform Vertex (+ apply changes)
Then you create your plane. Make sure it's always 1/1/1 (well, you can change it later). If you make a raycast then and transform the resulting vector3 to the local space of the plane then:
The most left point in the middle is (-.5/0/0) . The most left point is (.5/0/0).
So if you add .5 to the x and the y space, then you will get the texture space of that plane on that point.
Then you use the get Vertex Position action and go through all the vertices in the list. you get the texture position as I explained above. Then you use GetPixelColor and get the value of that height at that point. Then you use TransformVertex accordingly.
A while back I wanted to make a tutorial, but I didn't find any good subjects etc. So I'll do this instead I think. It may take some time though, so you may want to do it on your own first.