playMaker

Author Topic: Generating terrain with PM?  (Read 2554 times)

samsquared

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Generating terrain with PM?
« on: December 15, 2012, 10:19:47 PM »
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!

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: Generating terrain with PM?
« Reply #1 on: December 16, 2012, 01:07:08 AM »
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?
Best,
Sven

samsquared

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Generating terrain with PM?
« Reply #2 on: December 16, 2012, 02:33:54 PM »
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?


kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: Generating terrain with PM?
« Reply #3 on: December 18, 2012, 04:38:41 AM »
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.
Best,
Sven