Rojo3d. 3D engine for Construct 2

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

    Hi, maybe you cold give me a technical advice?

    My game is moving forward every day, with the method "two steps forward, one step back".

    I'm at the point where I have thought trough stopping using standard sprites (with roughly 12 collision mask points) and instead focus solely on 3D objects with assumption that it will release some of the cpu.

    So far I've been using sprites as a collision detector as well as reference for 3d mesh.

    With collisions the event started like this:

    - for each actor, actor overlapping terrain, for each terrain.

    but since I want to make sprites redundant I am thinking of putting all terrain data in to arrays. So first all level data will be in an array, roughly 2k objects with their data per level, or roughly 200 objects per room in a level. These are terrain object and each of them is a cell contenting Json data with npc's and other things that I load temp array with and place on the map. Checking if their are active can be done trough var change in an array. but I'm also considering having another array just with id's and distance to npc, so that I can sort it quickly according to distance and stop loop if distance is greater then a value.

    Here are my doubts come in:

    - if I sort array with 100 entries (if I use active objects array) or 2k entries ( if I do all checks inside map array), then check distance up to a certain distance and then pick those objects and do my collision code ( which is ellipse radius calculation done twice, once on xy plane and another on plane created by calculated radius and z to calculate z to place object on. Also first radius calculation is used as collision with walls if player is below floor range). Will that work as good or better then using LOS plugin to check x'y in one of the arrays, or work as good or better then checking overlapping with sprite? And how would that work if I had 40 npcs needing to check their surrounding to see if they are colliding with anything?

    Also, the checks are spread across several ticks with counter, so if counter is 1 I do this and that, and then counter = 2 and so on. Obviously that is necessary.

    Also, if id go with that, which 3D object position property would be mirroring of a sprite. Would that be XX, YX, ZX or XX, XY, XZ? I don't understand why there is so many variants for position in 3D, please explain.

    Best

    M

  • 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.

  • 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 behaviour. I find behaviours seldom do what I want so I’m more inclined to do stuff from scratch than do things to bend behaviours 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.

    Ok, cool. Thanks for the answers and 3d distance calculations. I will think of its use for sure.

    But let me elaborate. The distance would be there to first check for objects within radius form the actor, and after that those objects that are near the actor are checked for collisions with it. Atm I'm doing isOverlapping,for each overlapping to test collision with grounds and walls for all actors. But since this is the only top condition to pick and check collisions, my idea is to get rid of those sprites and just test for nearby 3d objects with data inside array and then do radius check if actor is colliding.

    Also the level loading is dynamic, or rather positioning of the objects is based on what is in the level array. If player has LOS to position, I pick idling terrain sprite, then set all of its values from data stored in array, then pick mesh and set it's parameters with values taken from the sprite. I've created level exporter you see. It exports everything in to array. Then I'm applying that data live based on objects XY in the array using LOS. This way I can have big levels with number of sprites under 200. But for each sprite I do need to update 3d mesh, static once, but others like those for actors or liquid and billboards all the time. In this case it feels like sprites are only a middle-man, and could be completely omitted. I already got rid of sprites for billboards like trees etc. But my worry is that 2k objects in array that needs to test against number of actors so that i can select which ones will be testing collisions against might impact performance more then if i have 111 terrain sprites at all times.

    Idea is to narrow it down by first testing which level objects are visible to the player and then put them all in to it's own array and do sorting based on distance and only check collisions for those objects that have distance lower then some value, and stop the loop. And then do the same for other actors in the scene. I imagine this is how its done when picking overlapping objects, with the difference that if the sprite object has collision poly with more points then 4, like in my case my ellipses have 12, that collision check might have same or bigger impact on performance then simple distance check for nearby objects and then testing each for collision with radius from the center of each object.

    Ik this is a lot in realm of theory. I guess I have to try it and if it won't perform well, I will get back to using sprites.

  • 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.

  • 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.

    All right, thanks, I'll be testing. I want to streamline the code. My current performance is smooth solid, but it hits 95% to 98% on i78750h with 1050ti and 32gb of hyperx ram. 70% of it are draw calls. Each terrain sprite has 4 meshes attached to it and there are 4 rojo3d plugins on different layers. SO my hope is that I can lower the cpu usage, and with array technique i can lower the number of 3d objects. Will test :)

  • R0J0hound Question re MeshTag:

    I don't suppose there is mesh IID or UID, isn't it?

    Would be cool to be able to set up all meshes of same group with single action without loops. Ie: MeshTag: cube, MeshId = 0 - pick all else pick nth.

  • 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.

  • Hello R0j0hound!

    An impressive job, no doubt. And I'm probably doing it wrong (after all, I've only been working with the plugin for a few hours), but still, I have some doubts.

    First of all, 3D models do not appear anti-aliased. I wonder if I am doing something wrong (probably) or vice versa, this is how the plugin works.

    And how do I load the textures? The only thing I've managed to do is load them through a sprite, but it doesn't affect the model.

    In any case, thank you soooo much for the plugion and for not forgetting the C2 users!

  • 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.

  • Thanks! I will check it ASAP!

  • Thanks! I will check it ASAP!

    You can use image shaders to trick AA or just render in higher resolution with high quality up scaling and downscaling.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had a little fun with Rojo3d and I'm impressed. I will definitely do something in my spare time, maybe some kind of ps1 demake horror.

    I have not tested this idea yet but for example: rigged obj are not suported but I can swap obj frame seq files and sync them to the animated sprite frame for easier control?

    like: if sprite(walk animation) is frame 1 then show walk_frame1.obj ...

  • Hi,

    Yes can do that and swap the meshes used on the fly no problem. I imagine it would work well for stop motion.

  • Any change to continue updating this plugin?

    It's just the EASIEST plugin ever to program on C2.

    This is better than all the other ones (Babylon, Q3D, three.js) and it haven't had any bug until now! Different from the others that say that there was a problem on the code.

    Will you ever update it again? If so, can you implement: support to import animations and 3d physics (to check collision)?

    It would just enough be the best C2 3D plugin ever!

  • Glad you’ve found it useful. I’m not currently developing it further. I coded myself into a corner and would need to take time to figure out the best way to rewrite it and I don’t have the same momentum or time to do that at this time.

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