3d raycasting and obj loader test.

1 favourites
  • 9 posts
From the Asset Store
Soldier Test
$9.99 USD
A Construct version 2 & 3 "Stand-alone" RPG game with "In-Game Module" (IGM) integration.
  • Here is a test of a way to do precise 3d raycasting against a triangle mesh.

    Construct doesn't provide a way to access the mesh of 3d objects, so this instead loads the triangles from an obj file into an array, and then uses mesh distort to display it.

    dropbox.com/s/uy6yfhpag7d1t2p/obj_loader_and_raycast.c3p

    Anyways, I'm pretty much at a stopping point with this. Developed further I can think of some uses, but performance isn't great with events, and currently I'd need to make the game work with the remaining 8 events.

  • I was thinking some time ago about loading the obj file into the mesh distort. Thank you for this example file.

  • You’re welcome. In it I opted to duplicate the vertices when making the triangle list. If you just stored the indices you would have less points to transform. Also you can make the obj loader support quads too, which would be more efficient with distort meshes, but I opted to just use triangles because I needed that for the raycasting. And actually it should be possible to use less distorted to display a mesh if the mesh is made of triangle strips, but that would take more effort to design.

    -cheers

  • Thanks for the clarification. I had a little fun with your project and while seeing math behind "Cross Product of 3D Vectors, polygon normal..." my brain melted. Then I added magnitude to obj z variable and regained consciousness.

    I like how it deforms.

    Going back to your 3d raycasting math, I thought it would be fun to deform(push) polygons in the oposite normal direction in the array by clicking it(some kind of object destruction on time)...I will back to this someday :)

    Best

  • Hey that’s a pretty cool result you got. I’m glad it was usable enough to allow changes. Utilizing the fact mesh points can’t go negative was clever.

    Anyways, I agree the math is hard to read in parts, especially when I used arrays. I’m always trying to find ways to make the math look cleaner if possible.

    That deforming idea sounds like a doable thing. I probably just need the raycast to also return the triangle index.

    Cheers

  • Hi, Do you have a simpler way to do 3d raycasting with just the normal 3dboxes? Like pointing at a 3dbox wall in 3d first person and spawn a little box where your pointing.

    Kinda like minecraft building I guess. This example is way out of my league lol.

  • This was built around casting rays against arbitrary triangles, and trying to fit it within 25 events. It may be possible to simply since 3D objects are limited, or there may be other approaches.

    Anyways I have no alternatives currently.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ah ok, thx =)

  • 3d physic 3d collision 3d shadow c3 need it!

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