Rojo3d. 3D engine for Construct 2

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

    I have no input on that other than yes you can access values in an array immediately after you set them.

    Maybe your logic just isn’t correct for what you’re doing. It could be helpful to output what’s going on at each step to debug things. Or maybe simplify the data you’re using to be able to analyze what’s it’s doing better.

    As is I can’t make sense of it. Arrays are useful but i find code using them often unreadable

    Thanks for reply. Ok. But here I'm only working with one number, dividing it and adding to another array cell, o this is as simple as can be. When I'm checking < in condition, the division by 10 in action doesn't divide by 10. Will investigate further then.

    EDIT. It's working today :> Now I'm literally few days away from completing the mesh gen stage :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound megatronx

    Can any of you help me please?

    I am trying to convert 3D pos into 2D pos, but I had no success...

    {I forgot to completely translate the comment from portuguese to english, but

    the function call is:

    Function.Call("Convert3Dto2D", <layername>, x, y, z, camx, camy, camz)

    and ignore the extra things that are written there, it was for testing and it failed}

    *There is some events that were cut off... But it is basically:

    Rojo3D.orientXX("camera")+DedicatedTo3DConversion.Get("X") +

    Rojo3D.orientXY("camera")+DedicatedTo3DConversion.Get("Y") +

    Rojo3D.orientXZ("camera")+DedicatedTo3DConversion.Get("Z")

    ...... (and similar to the rest)

    * The yellow box is the image that I am trying to set the 2D pos from the 3D pos conversion.

    * The 3D pos is from that mesh that looks a lot like a Minecraft piston block.

    But the conversion isn't accurate and sometimes when I rotate the camera It gets off the object.

    Also, if I go foward the object it stills visible at screen

    Also+ , If I turn around from that position from last image I won't see it anyway and inside the debugg console will show it's position will be really away.

    *I think with these I could achieve the '3D text'

  • I can't help you with that. I only use x,y,z from 3d plugin, but I do camera rotation with my own system that works with c2 stuff and is understandable to me ( I yet to understand rotation vectors and how to use them )

    This is using Simple Mouse Lock plugin

  • I am also using something to similar to what you did. Although I am not talking about player rotation/orientation. I am trying to figure out what those guys who developed 3D things were thinking (laughs even more like the Joker)... I am becoming crazzy ;(

    What I am trying to do is the function in most engines called as "WorldToScreenCoordinates(layer, posx, posy, posz)" and Construct 3 also have that, right now I just tried reading the code they have (Opening the 3d example project 'high-tech vision' and pression 'F12' to open Google Chrome DevTools and searched at 'Sources') and it was a bit complicated to find where it was since it was... well a big code :P ...

    Anyway, I found it, but I still don't get some parts and for the second one I guess I have answer...

    First! How do I get the value of 'viewportMatrix'

    Second! How do I get the value of 'projectionMatrix'?

    Is the First the values of (orientXX, orientXY, orie...)?

    The second one I think it is named as 'projMat' inside R0J0hound runtime.js code, I just have to figure out how to program javascript and add it inside Construct 2 as an expression.

  • All you need is the camera position (cx,cy,cz), the fov, and the scroll position (scrollx, scrolly) apparently. Math below is adapted from the Wikipedia about 3d projection.

    screenx = (x-cx)/(z-cz)/tan(fov/2)+scrollx
    screeny = (y-cy)/(z-cz)/tan(fov/2)+scrolly

    There is no expression to get the fov so you’ll just have to remember it from when you set it.

    Not tested.

  • All you need is the camera position (cx,cy,cz), the fov, and the scroll position (scrollx, scrolly) apparently. Math below is adapted from the Wikipedia about 3d projection.

    screenx = (x-cx)/(z-cz)/tan(fov/2)+scrollx
    screeny = (y-cy)/(z-cz)/tan(fov/2)+scrolly

    There is no expression to get the fov so you’ll just have to remember it from when you set it.

    Not tested.

    What this is for? What could I do with it too?

    megamente Br

  • This is for "3D Text", like when you pass nearby a NPC and have a ballon for dialog, or to display enemy health bar or as I said '3D texting'! :)

    Thanks R0J0!

    I will test it right now!

    This will be edited:

    Status: Final result: it doesn't BUT! You gave an idea and I think I might now can move on!

    Plus: I think I almost found a 'formula' by testing some other formulas and combining them and testing, etc.

    * Dictionary: DedicatedTo3DConversion

    * Add keys:

    ** DedicatedTo3DConversion.Get("Dist") = distance(x, y, camx, camy)

    ** Camera2D.Angle == Rojo Z rotation

    ** PlayerAngleY.Angle == Rojo Y rotation

    ** DedicatedTo3DConversion.Get("LayerWidth") = viewportRight(Layer)-viewportLeft(Layer)

    ** DedicatedTo3DConversion.Get("LayerHeihgt") = viewportBottom(Layer)-viewportTop(Layer)

    X2d: (DedicatedTo3DConversion.Get("Dist") * cos(Camera2D.Angle) * DedicatedTo3DConversion.Get("LayerWidth")*2) /(DedicatedTo3DConversion.Get("Dist") * cos(Camera2D.Angle) +DedicatedTo3DConversion.Get("LayerWidth"))

    Y2d: (DedicatedTo3DConversion.Get("Z") - DedicatedTo3DConversion.Get("CamZ")* sin(-PlayerAngleY.Angle) *DedicatedTo3DConversion.Get("LayerHeight")) /DedicatedTo3DConversion.Get("Dist") * cos(-Camera2D.Angle) + DedicatedTo3DConversion.Get("LayerHeight")/2

    *The last time I tested it was almost working just have to do some changes for when the object isn't at the players angle of view, but this is for later.

  • It calculates the position on the screen from an xyz position. Actually I forgot to take the camera rotation into account.

    Take the xyz subtract the camera position, then multiply that by the orientation matrix.

    Xyz = (Xyz-camera.xyz)*camera.orientationMatrix

    z = z*tan(fov/2)

    ScreenX = x/z +scrollx

    ScreenY = y/z +scrolly

    Wikipedia or something would be a good source for how to multiply a vector by a matrix. Honestly you probably could use a dummy object to do all the calculations.

    Maybe:

    Set position to xyz

    Move by offset -“camera”

    Rotate by camera

    Set z to z*tan(fov/2)

    Set xy to x/z+scrollx, x/z+scrolly

    But I honestly don’t recall how the plug-in works exactly.

  • If I'd be doing a text bubble, I guess I'd work with billboards and would look for a way to turn text in to a texture. Would have to load in additional bubble graphics. Any thought how to do it with PASETER R0J0hound ?

    As for field of view, would love to make a 3d camera cone for tests, but if I won't I'll work with what c2 offers, so fov plugin. I think it's much better to work with what there is in c2 already and with additional events extend those plugins to work in 3d then inventing all of the systems from scratch if it isn't necessarry.

  • Forget what I just said, my code doesn't work at all, I forgot to move my camera lol, when I move it breaks the code...

  • If I'd be doing a text bubble, I guess I'd work with billboards and would look for a way to turn text in to a texture. Would have to load in additional bubble graphics. Any thought how to do it with PASETER R0J0hound ?

    As for field of view, would love to make a 3d camera cone for tests, but if I won't I'll work with what c2 offers, so fov plugin. I think it's much better to work with what there is in c2 already and with additional events extend those plugins to work in 3d then inventing all of the systems from scratch if it isn't necessarry.

    I tried doing something with paster, but it looks like I have to always take a screenshot for it to work? I still stand trying to understand the Paster plugin.

  • Srry, What is scrollx?

    Plus, you talked about wikipedia and I search and found this:

    (I forgot it was translated, but here the link: https://en.wikipedia.org/wiki/3D_projection)

    ... let's see what I can get... (I should had listened to math class lol)

    ** I didn't understand how to get the E value {E xyz}? It's the depth? It's the FOV? How?

  • Btw. Instead of dictionary you should use local variables. They are faster performing.

    As for the speech bubble, in my opinion you should do it just with 2d canvas, and ignore the plugin. You can scale the bubble by dividing it's size by distance, and you can set it x and y on screen in many different but simple ways.

    Scroll x/y are probably same variables as the ones I use in my code for camx camy.

  • Ex = scrollx

    Ey = scrolly

    Ez = 1/tan(fov/2)

    So ex,ey is the center of the screen, and ez if that. That formula was buried in a paragraph after the equations in Wikipedia.

    At a glance it looks like you’re building the camera orientation matrix with rotations? I’ll leave it to you to verify if your math is correct. I get lost looking at it.

    Fov is just a number. The number of degrees in a field of vision. By default 90 maybe? I think you were thinking about something else?

    In general I made little effort to interface this plug-in with any other plug-in or other parts of construct. This was mostly for my sanity. The only plug-in it works with is sprite in that it can grab the current texture from a sprite. I may of may not have made it work with anything else such as tiledbg, 9patch, paster etc. as I recall they each stored their texture differently.

    Paster is simple to use. Just do some small tests with it. If it still doesn’t make sense then no worries.

    For text to textures you could paste the text to a paster object, then use the paster.imageUrl expression to load it into a texture.

  • I think I might use local variables then. I didn't want use them before because I thought it would make the debug window be messy.

    I will mess around with everything you told me and see what the result will be.

    ++ Try again with the Paster plugin with a can learn how to use it correctly.

    Do I have to position it behind the text

    Then I make its length the same of the text.

    Then I also I change the resolution to fit it's size

    Then? I use 'paste object'?

    This object must be a third object like a plane and that plane will 'screenshot' the area? Or the object selected must be the text?

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