Rojo3d. 3D engine for Construct 2

From the Asset Store
Casino? money? who knows? but the target is the same!
  • R0J0hound

    I have a question, but actually re another subject. I have a problem figuring out how to do something with bitwise auto tiling and diagonal tiles. SO I have those diagonal tiles, which half is of a tile type, and another needs to be selected according to neighbouring tiles of another type, and I can't figure out how to do it, so If you have any suggestions it will be appreciated.

  • R0J0hound

    I have a question, but actually re another subject. I have a problem figuring out how to do something with bitwise auto tiling and diagonal tiles. SO I have those diagonal tiles, which half is of a tile type, and another needs to be selected according to neighbouring tiles of another type, and I can't figure out how to do it, so If you have any suggestions it will be appreciated.

    I would appreciate to know too how to do this bitwise auto tiling...

    I saw in the internet that is possible to make ambient shadows, like minecraft does, with that:

    Link: https://0fps.net/2013/07/03/ambient-occlusion-for-minecraft-like-worlds/

    I know it isn't the exact same thing as megatronx said, although I think this might be the same way.

    I haven't read it yet, but it doesn't look easy to convert into C2 Events Style.

  • MegaMente Br

    Here's the tuto code.tutsplus.com/how-to-use-tile-bitmasking-to-auto-tile-your-level-layouts--cms-25673t

    I've implemented 8directional version.

    This is the code to put in to BIT variable I'm using for my project, but you will have to customise it cause I'm using variables. It checks if the tile at xy is same as the current tile, and if so it ads a number.

    varTileType = (Tilemap.TileAt(x, y)

    ((Tilemap.TileAt(x+1, y) = TileType)*16) +( (Tilemap.TileAt(x, y +1) = TileType)*64 )+ ((Tilemap.TileAt(x-1,y ) = TileType)*8 )+ ( (Tilemap.TileAt(x,y -1) = TileType)*2) + ( (Tilemap.TileAt(x+1, y+1) = TileType)*128 * ((Tilemap.TileAt(x+1, y) = TileType)) *((Tilemap.TileAt(x, y+1) = TileType)) )+( (Tilemap.TileAt(x-1, y +1) = TileType)*32 *((Tilemap.TileAt(x,y+1) = TileType)) *((Tilemap.TileAt(x-1, y) = TileType)) )+( (Tilemap.TileAt(x-1, y -1) = TileType)*1*((Tilemap.TileAt(x-1, y) = TileType))*((Tilemap.TileAt(x, y-1) = TileType)) ) + ( (Tilemap.TileAt(x+1,y-1) = TileType)*4*((Tilemap.TileAt(x, y-1) = TileType)) *((Tilemap.TileAt(x+1, y) = TileType)) )

    Then you need to create array with 256 cells. Each cell coresponding to the table below should have a tile number.

    ( first number is the array cell column and second number is the tile number )

    { 2 = 1, 8 = 2, 10 = 3, 11 = 4, 16 = 5, 18 = 6, 22 = 7, 24 = 8, 26 = 9, 27 = 10, 30 = 11, 31 = 12, 64 = 13, 66 = 14, 72 = 15, 74 = 16, 75 = 17, 80 = 18, 82 = 19, 86 = 20, 88 = 21, 90 = 22, 91 = 23, 94 = 24, 95 = 25, 104 = 26, 106 = 27, 107 = 28, 120 = 29, 122 = 30, 123 = 31, 126 = 32, 127 = 33, 208 = 34, 210 = 35, 214 = 36, 216 = 37, 218 = 38, 219 = 39, 222 = 40, 223 = 41, 248 = 42, 250 = 43, 251 = 44, 254 = 45, 255 = 46, 0 = 47 }

    Then all you have to do is to have appropriately placed tiles on the tilemap's tileset.

  • R0J0hound

    I am having some issues with rendering, can you help me?

    The problem:

    - I have a mesh of a cube.obj (16, 16, 16) (X, Y, Z) (created using a 3rd program)

    - When I change Z to a higher number using events, I start to "fly", it's like with the object was pushed down by 8 pixels and there will be a gap between me and the object "floor".

    Do you know what might be the problem?

  • R0J0hound

    I am having some issues with rendering, can you help me?

    The problem:

    - I have a mesh of a cube.obj (16, 16, 16) (X, Y, Z) (created using a 3rd program)

    - When I change Z to a higher number using events, I start to "fly", it's like with the object was pushed down by 8 pixels and there will be a gap between me and the object "floor".

    Do you what might be the problem?

    Probably an origin point problem. You have to place it more precisely in your 3d program.

  • I still got no sucess, the origin point is centered at the 3rd program. It seems to lose this information when I import into C2...

    The object size at the 3rd program is (16, 16, 16)

    When, inside C2, I change to (64,64,64) the Z scale gets messed up and I will find myself 'flying' and the object will be bigger but not enough to fill the gap...

    When I try to change the Z origin to the bottom or top it it still to have the same problem when I change value... I'll try to change the 3rd program, but I don't it might be it...

  • You can look at the obj file in a text editor to see if it looks correct. The lines starting with v are the vertices and there is only 8 of them if it’s a cube.

    Other than that I can’t really help. The obj file format is simple and having it load with the wrong offset and size isn’t really the kind of mistake that would happen in the loader.

    So I guess just try to fix the cube in that 3d program, and maybe check the meshes you’re using for the ground or other objects you’re trying to align with.

  • I still got no sucess, the origin point is centered at the 3rd program. It seems to lose this information when I import into C2...

    The object size at the 3rd program is (16, 16, 16)

    When, inside C2, I change to (64,64,64) the Z scale gets messed up and I will find myself 'flying' and the object will be bigger but not enough to fill the gap...

    When I try to change the Z origin to the bottom or top it it still to have the same problem when I change value... I'll try to change the 3rd program, but I don't it might be it...

    Or just create the box in c2 with vertices. One of ROOj examples have the code for the box.

  • megatronx

    I didn't found the page about Rojo talking about it, was he talking about cubes or triangles? (the triangles one I found, but I was hoping to find the one talking about the cube already made by him...)

    Also, have you done raycasting in you project? Or won't it have it?

  • megatronx

    I didn't found the page about Rojo talking about it, was he talking about cubes or triangles? (the triangles one I found, but I was hoping to find the one talking about the cube already made by him...)

    Also, have you done raycasting in you project? Or won't it have it?

    Hi, I will be doing raycasting at some point. I will share it with you once done, but that's still some time away. Right now I'm still designing level building system.

    As for the box, simplest way i think is to create a sprite 10x10px, set 4 origin points and then at start of the level use them when creating vertexes. You will need to create a plane 6 times and each plane is 2 triangles, so 6 verts in total per plane. The UV order for each plane is 00 01 11 11 10 00. Example of creating a plane for side using image point sprites:

    ip1 ip2 This is how the sprites imagepoints are set

    ip4 ip3

    And this is creating a plane for wall using imagepoint1 and imagepoint2

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 0 UV 00

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 0 UV 01

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 10 UV 11

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 10 UV 11

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 10 UV 10

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 0 UV 00

    Without imagepoints you create plane just like this

    -create vert at X -1 Y -1 Z 0 UV 00

    -create vert at X -1 Y 1 Z 0 UV 01

    -create vert at X 1 Y 1 Z 1 UV 11

    -create vert at X 1 Y 1 Z 1 UV 11

    -create vert at X 1 Y -1 Z 1 UV 10

    -create vert at X -1 Y -1 Z 0 UV 00

    Then you'd need to scale it. Doing it this way will create origin point in the center of the plane.

    When you will be creating plane for top and bottom of the cube, you have to use all 4 image points and keep Z at 0, but wij sides you need to use only 2 image points and instead increase Z by a number. The order of vert creation can change, but the first and last, as well 2 middle ones must be in the same point. You can experiment.

    Once you create all planes, use save verts as mesh. Call the mesh and then create object and use that mesh. If you want different textures on each side, you got to have a texture with those sides and then set UV in such way that it is drawing only those tiles of the texture.

  • Interesting, and thank you for the explanation I will try that, maybe It would be faster...

    ** About the raycast: I would be very interested too, soon I might upload here the template I made and it does have raycast, but it's laggy because it does too much collision checks per tick and it might not precise for very small positions also it only detect collisions for cubic meshes.

  • Interesting, and thank you for the explanation I will try that, maybe It would be faster...

    ** About the raycast: I would be very interested too, soon I might upload here the template I made and it does have raycast, but it's laggy because it does too much collision checks per tick and it might not precise for very small positions also it only detect collisions for cubic meshes.

    You probably need to limit the ray tests to a distance. for each rayAsset, distance < then, raycast.

  • Seems interesting. I coded to cast a ray every 1/24 seconds and detect almost 304 different points in the ray of length 76.

  • You probably need to limit the ray tests to a distance. for each rayAsset, distance < then, raycast.

    But if there is too much objects inside a layout?

    Like inside a Minecraft world there will be a radius of 4 blocks and almost everytime there is a block around the player...

    In other words: it will always be casting rays anyway.

    I mean, maybe I could test if what you said but instead ofy position, I test the position of the point in the ray near to the block... That would be equivalent to what I am doing to test if the point is overlapping a 3d cube.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > You probably need to limit the ray tests to a distance. for each rayAsset, distance < then, raycast.

    But if there is too much objects inside a layout?

    Like inside a Minecraft world there will be a radius of 4 blocks and almost everytime there is a block around the player...

    In other words: it will always be casting rays anyway.

    I mean, maybe I could test if what you said but instead ofy position, I test the position of the point in the ray near to the block... That would be equivalent to what I am doing to test if the point is overlapping a 3d cube.

    Depends what you are using. If you are using tilemap then you got to check tiles in front of the player within distance and if you are using sprite object you could use line of sight "is in sight" condition, and then test for ray cast.

    To calculate direction of casting depending on the players angle do something like this:

    ax= cos(player.angle) -distance, ay = -sin(player.angle) -distance

    Might not work straight away, you might need to change symbols from + to - for example to get correct direction, but if I recollect this is generally how you do it.

    And if you have sprite with line of sight then it will change the angle within the plugin itself automatically.

    But then you say it is like MC with loads of blocks. Max objects before NW.js starts slowing down is something like 40x40x2 ( this was my map x,y as well as objects for billboards above it , but more than that there will be a stutter, tested on i7-8750h as well as on 12700h! ).So you will need to nest arrays, and depending on player position access them, then arrays within them and place blocks accordingly. To do that each block has to have a boo that defines its availability. You will also need to keep track of which arrays been already used and which aren't. SO you could use second line of sight, larger and longer, and anything that is not in it will automatically have that flag set to off, and then from this pool you can pick as many as you have availed to fill up the terrain, while also keeping track of things in another array. This doesn't have to to work every frame thought, but every several ticks.

    Make yourself a tick clock. Have a global variable T and set it to (T+1)%6 for example, so this will give you numbers from 0 to 5, and then you can decide what happens when. Obviously action related stuff has to run every tick.

    This seams complicated but it isn't really, and you can have this system up and running within a day or two, just need to plan it out on page of a3 paper and you will know exactly what you are going to do.

    Also, lest say your cube is 10x10x10, then you can repeat the ray test n/10 times, so per grid and not per pixel.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)