{"author_link":"\/users\/nardandas","author_name":"nardandas","author_uid":"nardandas","comments":[],"epoch":1665129261,"event":"LD51","format":"md","ldjam_node_id":309351,"likes":9,"metadata":{"p_key":"168988","p_author":"nardandas","p_authorkey":"1015003","p_urlkey":"396747","p_title":"Lil technical post","p_cat":"LDJam ","p_event":"LD51","p_time":"1665129261","p_likes":"9","p_comments":"0","p_status":"WAYBACK","us_key":"1015003","us_name":"nardandas","us_username":"nardandas","event_start":"1664496000","event_key":"114","event_name":"Ludum Dare 51"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD51","removed_author":false},"_superparent":296586,"_trust":1,"author":15003,"body":"I've seen a few folks wondering how I did my game, so I'm going to show a little bit of it here. As you see the plants aren't at all 3D, just really simple 2D geometry. I regenerate the mesh each frame as the wind and all affects it, on the CPU. I think it'd best be done on the GPU, but this way kept all the data easily accessible to me to use in other systems. Yes my game is horribly coupled, it's just a fact of some of these jam games. \n\nThe way I generate the geometry is rather simple. First, all of the pieces of the plant - all the stems and leaves and flowers - are stored as lengths and angles, so we have to transform those into positions. During this step we consider the current wind - a two octave perlin noise generator, and apply that to the angle based on a weird cross-product like thing. The wind at this point is converted into an angle, which is a rather weird conversion, but works cohesively with the rest of the system. The mesh is then generated by taking these positions and generating vertices along the length between each position, based on a list defined for each type of piece. We linearly interpolate between the start perpendicular vector and the end perpendicular vector to make the ends all match up. That's really it!\n\nThe plants are defined in a little language I wrote myself for this jam for no real reason, a bit of it looks like this\n\n\nleaf: ((.1, .3, 1, .8, .2, 0), #69cc45, 0, 0.3, .3, .01, .1)\n\nstem: ((1, 1), #376339, 5, .8, .2, .4, 0) \n\ntiny_stem: ((1, 1), #69cc45, 5, .4, .2, .2, .05)\n\nflower: ((.1, .1, .9, 1.3, 0), #d14232, 0, 0.4, .4, .05, .12)\n\ns=stem, max_inhib=14, height = .3, dist_stem = 8:\n\n```(\n\n  (\n\n    [leaf, angle=30, a_size=.7, len=2.5 {.7}\n\n  ) {.2}\n\n  [\n\n    stem, angle=-12, size = 0.95, len=.6 {1}\n\n  ] {.3}\n\n  +[\n\n    stem, angle=10, size=.9, len = .6 {.4}\n\n  ] {.2}\n\n) {.1}```\n\n\nYou'll notice a lot of unnamed numbers, this was a mistake. I'd rather have done this in json I think. The basic idea of how the data is stored is sound. It's basically that we have a list of piece types at the top, then a list of conditions, and under each condition, a list of things that can generate if it's met. It's a variation on an L system. The things in () are \"roll each\", the things in [] are \"pick one\", and the things in +[] are \"pick at least one\". This makes the growing system pretty expressive. The things in the {} are the chances for each thing. \n\nCurrently it doesn't consider the amount of sun or anything else. I want it to eventually.\n\nThis wasn't very in depth but I hope it's interesting and answers some questions!\n\nhttps:\/\/ldjam.com\/events\/ludum-dare\/51\/silvi","comments":0,"created":"2022-10-07T07:43:44Z","files":[],"files-timestamp":0,"id":309351,"love":9,"love-timestamp":"2022-10-07T09:28:51Z","meta":[],"modified":"2022-10-07T09:28:51Z","name":"Lil technical post","node-timestamp":"2022-10-07T08:09:01Z","parent":306809,"parents":[1,5,9,296586,306809],"path":"\/events\/ludum-dare\/51\/silvi\/lil-technical-post","published":"2022-10-07T07:54:21Z","scope":"public","slug":"lil-technical-post","subsubtype":"","subtype":"","type":"post","version":963783},"node_metadata":{"n_key":"309351","n_urlkey":"396747","n_parent":"306809","n_path":"\/events\/ludum-dare\/51\/silvi\/lil-technical-post","n_slug":"lil-technical-post","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"15003","n_created":"1665128624","n_modified":"1665134931","n_version":"963783","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/51\/silvi\/lil-technical-post","text":"I've seen a few folks wondering how I did my game, so I'm going to show a little bit of it here. As you see the plants aren't at all 3D, just really simple 2D geometry. I regenerate the mesh each frame as the wind and all affects it, on the CPU. I think it'd best be done on the GPU, but this way kept all the data easily accessible to me to use in other systems. Yes my game is horribly coupled, it's just a fact of some of these jam games. \n\nThe way I generate the geometry is rather simple. First, all of the pieces of the plant - all the stems and leaves and flowers - are stored as lengths and angles, so we have to transform those into positions. During this step we consider the current wind - a two octave perlin noise generator, and apply that to the angle based on a weird cross-product like thing. The wind at this point is converted into an angle, which is a rather weird conversion, but works cohesively with the rest of the system. The mesh is then generated by taking these positions and generating vertices along the length between each position, based on a list defined for each type of piece. We linearly interpolate between the start perpendicular vector and the end perpendicular vector to make the ends all match up. That's really it!\n\nThe plants are defined in a little language I wrote myself for this jam for no real reason, a bit of it looks like this\n\n\nleaf: ((.1, .3, 1, .8, .2, 0), #69cc45, 0, 0.3, .3, .01, .1)\n\nstem: ((1, 1), #376339, 5, .8, .2, .4, 0) \n\ntiny_stem: ((1, 1), #69cc45, 5, .4, .2, .2, .05)\n\nflower: ((.1, .1, .9, 1.3, 0), #d14232, 0, 0.4, .4, .05, .12)\n\ns=stem, max_inhib=14, height = .3, dist_stem = 8:\n\n```(\n\n  (\n\n    [leaf, angle=30, a_size=.7, len=2.5 {.7}\n\n  ) {.2}\n\n  [\n\n    stem, angle=-12, size = 0.95, len=.6 {1}\n\n  ] {.3}\n\n  +[\n\n    stem, angle=10, size=.9, len = .6 {.4}\n\n  ] {.2}\n\n) {.1}```\n\n\nYou'll notice a lot of unnamed numbers, this was a mistake. I'd rather have done this in json I think. The basic idea of how the data is stored is sound. It's basically that we have a list of piece types at the top, then a list of conditions, and under each condition, a list of things that can generate if it's met. It's a variation on an L system. The things in () are \"roll each\", the things in [] are \"pick one\", and the things in +[] are \"pick at least one\". This makes the growing system pretty expressive. The things in the {} are the chances for each thing. \n\nCurrently it doesn't consider the amount of sun or anything else. I want it to eventually.\n\nThis wasn't very in depth but I hope it's interesting and answers some questions!\n\nhttps:\/\/ldjam.com\/events\/ludum-dare\/51\/silvi","title":"Lil technical post","wayback_source":[]}