R0J0hound's Recent Forum Activity

  • Here's an updated example that lets you have separate bodies of water. It works by finding the neighbors with some overlap checks at the start of the layout.

    ucd5a2abe2f0714ec71b0606ebed.dl.dropboxusercontent.com/cd/0/get/Ch7IcrW4DHIWILpC17Yi1FvgrIeDf8-Pnr81Ch3SLmo_KamVt05OA9rtaCdsMWePsIHCgdVo6jOs3I0MfJHnoHOX58cBgD-ZE2wguwesPN3BuOwJTvfHLgEkc1B_xGONuSkoZDs05JiNDQ7Tko9j_pjz/file

    Applying it to a distort mesh or drawing it with the canvas is something I'll leave to the users of c3. It should be straightforward.

  • Hi,

    Glad it’s been useful.

    If you set k2 to 0 the water is no longer connected to each other. So it needs to be greater than zero for they affect each other.

    The dt is indeed to make it frame rate independent. Basically it follows the formula: speed*time=distance

    It’s utilizing iids to access neighboring instances. So currently it works with only one body of water. I have a few ideas how to get multiple to work. One is to clone the object type for each pool and duplicate the events. Another is to store the iids in an array per pool to access neighbors. A third is to just use some instance variable that store the next and previous iid. Should be able to setup the last one with a loop at the start of layout.

    I’ll mess with that later today.

  • Here's one way to do it with springs. One spring to maintain a water level and two more to make the water level between two points match. You merely need to tune the spring forces and damping to adjust how it looks.

    ucf2a11f334d46110519f819fd5e.dl.dropboxusercontent.com/cd/0/get/Ch7vYh--jU8AMsyt5ReLbLq-kExRCVzwwMlWuGBDoLZUsYHl7kHY7JHH_qvecmyL7O6q3OnyU6H-XJSog8NCN5xDS7-7VkS-vhDR13COPdnCbcZnE4zJVwxp-I_K9I7PDXeaCNmpQJOdfDyWArxLhV5s/file

  • Hi,

    There is no anti-aliasing done.

    To use a texture on a model there are two steps

    1. Load the texture from a file or sprite to a tag. The tag is to refer to it later.

    2. Tell an object to use a particular loaded texture. Should be an action under 3D appearance or something.

  • You probably could get better performance by reducing the number of instances of the plugin. But I guess it depends on what you’re doing.

    With the tags it’s just one per mesh. I was considering adding a group feature but I don’t have enough to time to implement it and test it without breaking things.

    When creating 3D objects you can copy another object so you don’t have to set up each attribute. But other than that there’s no way to change a bunch of objects at once without a loop.

  • That’s called “broad phase” collision detection. Basically doing approximate collision detections by using a distance check or something. Other ways are using bounding boxes, bsp, quad tree, collision cells, etc. construct already does it somewhat with the overlapping condition.

    Anyways you can do that with events but you’d have to actually do it and test if it improves performance. The overhead of implementing those things with events can often result in things being slower oddly enough.

    Anyways the logic of the distance check you describe could be:

    For each sprite

    For each terrain

    Compare distance between sprite and terrain <100

    Sprite overlaps terrain.

    But with events you already reduce the terrain loop by doing this instead:

    For each sprite

    Sprite overlaps terrain

    For each terrain.

    But that’s mainly because internally construct can filter the objects faster than you can do manually with events which are slower.

    You other idea of adding and removing objects as needed is another idea. But you’ll have to test it. This plugin was made so you only have to make events to update objects you want to move. All the static objects will just redraw fairly efficiently. Adding/loading on the fly would be slower but it may end up being faster in the long run. But you’d have to actually test it out.

  • I aim for simple and easy to read with my events if I can. Using arrays to store object info instead of sprites may or may not be better, it just depends on how you want to implement it.

    You can sort arrays, but you can also sort sprites with “for each ordered”, just use the stop loop action when loopindex=0 if you just want the closest. Or use a higher number to do stuff with more.

    The only time I use an array for terrain is if it’s in a grid formation, in which case a tilemap can work too for 2d. If the terrain is different sizes and whatnot I’d just use sprites.

    Not sure I grasp your distance calculation. Would a 3D distance calc work better?

    Sqrt((x1-x2)^2+(y1-y2)^2+(z1-z2)^2)

    I have no technical expertise with the fov behavior. I find behaviors seldom do what I want so I’m more inclined to do stuff from scratch than do things to bend behaviors to my will.

    For your last question I think there’s a misunderstanding.

    You get the position of objects with the x,y and z expressions as I recall.

    The orientXX/Xy...Zz expressions is the orientation matrix of the 3D object. Aka. How it’s rotated.

    You can think of those as three vectors.

    OrientXX/Y/Z is the left vector of an object

    OrientYX/y/z is the up vector of an object

    OrientZx/y/z is the forward vector of an object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The plugin is at the point where some design choices early on make it hard to change things without breaking stuff. Plus the event system's speed and limits make it hard to allow the amount of flexibility I'd like without being overly verbose and complex. Anyways, that's partially personal opinion. Construct makes some complex stuff simple and some simple things overly complex.

    As for your wishlist:

    *The view distance is just an artifact of how the fog is implemented. There are pros and cons of either. Rewriting the plugin to have alternative options for everything would be an option i suppose.

    *As I recall I try to fit the shadow frustum to just fit around the view frustum for maximum shadow detail. It's not perfect because some things off camera aren't being included due to some approximations on my part. There are alternate ways to do it, such as fitting the shadow frustum over the whole scene, but the tradeoff is giant scenes would have low res shadows. But I agree more work would need to be needed with shadows but it turned into just fiddling with settings to see what works well which was too time consuming.

    *blend modes would be nice.

    *opacity is already doable. You just have to turn on "transparent yes" in the object settings. The caveat is it's done per object. So it just draws objects back to front. Per polygon would be better, but more complex to do with how the renderer is implemented, also it still would have cases where the sorting would be off. Best would be an algo called "depth peeling" but it's slower.

    *normals are already in the plugin. As long as an obj file has normals in it you'll have normals, which is used for smooth shading. If you mean normal textures, then no, only one diffuse texture is used.

    *Collisions and raycasts are highly requested things. I have a good idea how to do them but I don't find I enjoy finding a way to make it usable in the limits of construct's event system.

    Overall, I may work on this more, but I'm more inclined to work on other things first if I find the time and motivation to code.

    -cheers

  • So, creating the mesh is something you’d probably do just once. Like:

    Start of layout

    — vertex (100,0,0)

    — vertex (100,100,0)

    — vertex (0,0,0)

    — save as mesh “triangle”

    Now it looks like you have a bunch of imagepoints that make up the polygon border of the image. You need to convert that to triangles. One simple way to do that is to do a triangle fan.

    Something like this. P is the imagepoint you want to start the fan from, best if you use a concave point. Ipx and ipy is sprite.imagepointX/y, and count is sprite.imagepointCount. I just didn’t want to type that all out.

    Var p=1
    Var i=0
    Start of layout
    — repeat count-2 times
    — — set i to p
    — — vertex(ipx(i), ipy(i), 0)
    — — set i to (loopindex+p)%count+1
    — — vertex(ipx(i), ipy(i), 0)
    — — set i to (loopindex+p+1)%count+1
    — — vertex(ipx(i), ipy(i), 0)
    — save as mesh “triFan”

    Notice it matters what imagepoint you start with. See below. Also this won’t work for all shapes, but hopefully will. For any shape that doesn’t work with a triangle fan, you’d need full blown triangulation of polygons.

    Also I guess I didn’t specify uvs. For any imagepoint you can convert it to uvs with

    U=(Sprite.imagepointX(i)-sprite.bboxLeft)/sprite.width.

    V will be similar but with y, top and height.

  • There isn’t a distance limit so you just have to play with the numbers.

    Basically it’s a mix between the acceleration and spring stiffness. When the spring is stretched far enough it will counteract the acceleration.

    The damping makes it less springy. Set it to 0 to see it bounce all over. The damping slows it down.

    320 and 240 were just half the 640,480 window.

    I used the layout size to limit the position we use to the scroll area. It’s not needed if you had unbounded scrolling.

    The a and d variable are just the angle and distance from the camera to the mouse.

    There’s always some feature I forget about with my examples. You may still be about to use screen shake after you set the mouse position. Or we could do our own with some random values added to the scroll position.

  • CustomMovement is unwieldy, I never use it.

    Here's what I came up with:

    uc28e693f766bf5e2ddf38d380a6.dl.dropboxusercontent.com/cd/0/get/Ch8-T02aEJyAzQn74kIvy-wDSb0RedhOCGClH1axrMgxrt4WEc12t6vGSeG2qJqdhieZBuAqCC5p6nFXND5Gh31h56mcBxtnL3sTn0Fu9LbBhgkRAUj-HmP_gDVRpARoHHfSrwA-nRH8kvyWdGfEWQOk/file

    or radial instead

    ucfe657ef0730f61b9a5ece746cd.dl.dropboxusercontent.com/cd/0/get/Ch_XTCSEhokxRSj_SlrcujhBnrqSm3gqBilAkP77jGHvr0zkiw3Tac1WZUxrk-6-8la20jmSwjw2uB289nwxBpY0QEQFN4jKWrsMn4s30ZbtWAqAcD01-cB4r72Aechkw_cGuDrlx92onGFR0WKbUlIU/file

    Basically the camera is controlled by a damped spring which gives nice easing in and out. There are three variables you can tune:

    acceleration controls how fast it moves.

    stiffness controls how far you can look and how fast it returns to the center.

    damping gets rid of bouncing. higher values also make everything more sluggish. too low and there will be overshoot.

    Edit:

    Here the spring is applied to the whole camera instead of just the look around:

    uc3fa2ea77441290562065074715.dl.dropboxusercontent.com/cd/0/get/Ch_WcxhMvNEvefAdeGJiUy4hmQcaRssZo5K0EONGB1YhQMH592naiXM-hjv_DekRoM1jbO76nBe4HZSdSwHKroaRq1IQf2cWc9nfUOBbCqyjRXFD5JuLoTkr1dSbjbzb-Pn-_9XS2yUUZuTRXzxIegTH/file

    Kind of gives the impression of a real camera operator.

    Edit2:

    uc24788ec6ed8e453a318d48783e.dl.dropboxusercontent.com/cd/0/get/Ch_6OPGOWrZ2xN72T7lSLjlpCWzhbYRnEsSp2sgl7S0AmL9q8F_r0hEDASUlhJgyN3obA7po5prePsV3XAE6CF011nT2mfJmOHnJrRqUggRfa-YIdj21QMpjEj3R2L0i-pbMuuLnAg7MIjtSmk11nFER/file

    Fix to ease down when scrolling to the edge of the layout.

  • Probably the solution is to not use lerp. Instead move the scroll around by applying an acceleration which would eliminate the jarring. The idea is you’d want an ease in and out instead of the jarring ease out that typical uses of lerp provides.

    I don’t have the time today to make a complete example but the basic logic would be:

    Mouse is in edge region? Accelerate camera to a max distance

    Else decelerate back to 0.

    Anyways there’s more to it than that. The acceleration provides the smooth motion and you can utilize a formula so you can gradually stop at a specific location.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound