R0J0hound's Recent Forum Activity

  • Like I've said in the mode7.fx topic I've abandoned it. It does some math to get the look, but it's not clean to make positioning other objects work well.

    But I wanted to play with shaders more, although I don't want to make addons. Anyways here's a mode7 implementation that may be useful. I tried to make it as streamlined as possible.

    construct.net/en/forum/construct-2/your-construct-creations-23/mode7-via-webgl-javascript-155359

  • Here's a test to use custom webgl to do mode7 perspective on a texture.

    * It's free to use.

    * Doesn't use the mode7.fx. It's less fiddly.

    * let's you position objects on the ground.

    * Doesn't work with minifier.

    Look at capx for more usage notes.

    dropbox.com/s/8nqw4dy6z2elaa5/mode7js.capx

  • tarek2

    Yeah, that looks like a bug.

    In Event 20 remove the action "node: set dist to dist+2", i forgot to remove that.

    dropbox.com/s/vto9mwobq9uoqsx/power_with_id_multi_source.capx

    HolidayExplanation

    The third example, with that bug fixed, works best for evenly spreading out the power.

    I modified the example to transfer where the power is coming from and tried showing power consumption:

    dropbox.com/s/562xjz7t3rmbrop/power_with_id_multi_source2.capx

    Passing the genId is kind of ambiguous. One will arbitrarily be the owner when there is a tie.

  • Dug up a plugin rex made that looks like it may help.

    c2rexplugins.weebly.com/rex_mode7perspective.html

  • You do not have permission to view this post

  • You do not have permission to view this post

  • I see you used the second example.

    To know what source the power is coming from you could add another parameter to the power function to be the generatorID.

    So when calling the power function from the source nodes it would be

    Power(node.uid, 0, node.generatorID)

    Or however you want to identify the generator.

    Then in the function you can set the Id of the nodes from param(2),

    And when you call the function again, also pass param(2).

    If that makes sense. You’d probably want to reset the id for all the nodes in the same place that powered is set to false.

    I’m alway from my pc till probably Monday, and I don’t really use c3, although looking at projects from my phone is cool.

    So in general you just need to know if something is connected to power and what that power source is? Does the number of linkages from the power source matter?

    You say each component uses power. Is it distributed evenly over everything that’s connected? Or does each component use the power it needs and pass the leftover power down the wire?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I thought i'd have a go at this. Can be done with a flood fill.

    dropbox.com/s/7yyocrr06epdufe/power.capx

    It starts at the source, marks it as powered, and recursively follows the connected wires to power them.

    dropbox.com/s/z2ulq22r0qup7um/power_with_id.capx

    But if you want the distance from the source of every component then the above still works for one source.

    dropbox.com/s/vto9mwobq9uoqsx/power_with_id_multi_source.capx

    For multiple sources we have to spread one layer at a time.

    sources are all set to zero. loop over the 0s and set unpowered connected to 1. Once done do the same for two and so on.

    A nice reference. If we are just powering things it's basically a flood fill. Otherwise it's a breadth first search, which isn't too different.

    redblobgames.com/pathfinding/tower-defense

    -cheers

  • The whole screen is game to draw to as long as the bounding box is in the view.

    I haven’t explored c3’s renderer but it’s likely a batched renderer similar to C2. As such you’re limited to features exposed to to the renderer. Drawing to a texture is probably just an undocumented feature. C2’s renderer had it as a feature at least. It’s used for drawing effects and layers with force own texture. The paster plugin utilized this, although there is more setup and such.

    Now in C2 there was also a function in the renderer to complete all current batches. This was useful to let the renderer finish what it was doing and then you could do anything you desired with all of webgl as long as you preserved the webgl state to what construct had it at. This can kill the benefits of batching so I doubt this way would be officially supported. C3 probably has a similar undocumented function in its renderer.

    Examples in C2 are the dragon bones plugin and some more recent 3D experiments I posted capx for.

    Anyways, webgl provides a couple clipping ideas. One is *********** It limits what is drawn to a rectangle on the screen.

    The other is stencil buffers. You can draw anything to the buffer and then you can draw to the screen like normal and the stencil acts like a mask.

    Anyways just some ideas.

  • Instead of creating multiple canvas objects could you not just have 1 and just draw all the circles you need on that one object?

  • The original mode7 topic I thought had info on it.

    Anyways the gist of positioning stuff is:

    // get position relative to camera

    xx = (x-cam.x)* cos(-cam.angle) - (y-cam.y)* sin(-cam.angle)

    yy = 200

    zz = (x-cam.x)* sin(-cam.angle) + (y-cam.y)* cos(-cam.angle)

    screenx = xx/zz + xcenterScreen

    screeny = yy/zz + ycenterScreen

    if zz<1

    then hide object

    else show object

    However, the scale is probably off. Shaders deal with 0-1 scale in spots.

    It subtracts the cameras position from the points position, rotates it in the opposite direction of the cameras angle and then projects it to The screen.

    The shader merely does the opposite. The exact scales can be found by reversing the math found in the shader itself.

    Or you can find the scale by trial and error. Basically before getting the screen coordinates multiply some numbers against xx, yy and zz. Realistically yy should Just be the Ground height. Zz adjusts the intensity of the perspective and xx is the general scale.

    You could even open up the behavior that rex made to get the math he used which is based on reversing the math in the shader.

    I abandoned The shader long ago and don’t want to open it. It’s fiddly and needs to be rewritten. Fiddly in that the scale of things is pretty specific as I recall.

  • In rough pseudocode you can place them like this:

    start of layout

    for i from 0 to 10

    for j from 0 to 10

    -- create hex at (i*xspace+startX, (j+(i%2)/2)*yspace+startY)

    ex:

    dropbox.com/s/zv2ks44yr3lf14j/hex_grid_gen.capx

    also a great resource on hex grids:

    redblobgames.com/grids/hexagons