Jump to content

Is it possible to intersect with blender obj ? Solved


Recommended Posts

Hello again forum, i hope you have a nice day :) 

I would like to build a maze game, The maze will be generated on blender as .obj format. 

I know this is the code for intersect mesh for babylon mesh object, does blender use the same syntax as this ? :) 


Any advice or tips will be greatly appreciated, Thank you :) 
Cheers :) 

if (snake.intersectsMesh(box1, false)) {
					up = false;
					down = false;
					right = false;
					moving = false;		


Link to comment
Share on other sites

Hi G!  Sorry for slow replies.  You will be using Blender as a mesh modeler, and not programming any "game logic" in Blender.  Just make the maze... good old mesh... and get it imported into BJS.  After that, I think BJS intersectsMesh will work just fine.

Again, no code needed in Blender... so no worries about syntax.  Just make a good model, export it with the newest exporter, import into a playground scene, and then we'll see what kind of fun we can have. :)  I hope I haven't misunderstood your question.  If I have, please correct me, thx.

Sometimes, folks make mazes inside BJS scene, and don't need Blender.  We once had a maze-game contest here on the forum, and some fine examples were created.

Here is a simple one... https://www.babylonjs-playground.com/#26LA7B#23

It has good working cam-intersects/ellipse, good minZ for when you hit your face on a wall... and working cursor keys.  Seems ok, for a little playground.

Davrous once created mazes from QR-code things.  His playground demo is substantially larger.  :)  All in all, a playground search for 'maze' returns a good pile to tour-through, if wanted.  Perhaps you begin your maze game with JS-generated maze... like some of those demos.  Later, you can change-to Blender-made maze, if wanted.  But JS-generated maze is more fun... because it is easy/fast to change.

Perhaps your player/character will still need Blender modeling, though... for chase/follow cam-view.  Hope this helps.  Maybe others will comment soon.

Link to comment
Share on other sites

@giorfasolini : While you can build a maze in Blender , it will be a static mesh. Using a script to create the maze and then using a few objects imported from Blender (solid walls, walls with opening etc.) ,you can build a dynamic maze.

I will try to post my contest entry which did exactly tat.

cheers, gryff :)

Link to comment
Share on other sites

@Wingnut   @gryff

Hello, Thanks for your reply. So far i have implemented physic in babylon js . However i think blender is insufficient to make maze, because what i use is physic impostor, and they cant detect a hole in blender.

Here's some screenshot, as can be seen the purple one is a maze i made with blender. And physic cant detect a hole i made in blender. Is there any way to bypass or solve this? :)





Link to comment
Share on other sites

Hi gio.  Ummm... in this case, you could/should use CannonJS "MeshImpostor" only.  No other impostors will work correctly (unless you build a complex parent/child structure).

With CannonJS MeshImpostor, "holes" will be ok. 

Note:  CannonJS MeshImpostor ONLY interact with sphereImpostors.  So, even if your player is a box, you must use sphereImpostor on player.  (or MANY little sphereImpostors connected into a structure/shape, possibly connected with physics joints). 

I stole a little testing playground.  MeshImpostor on "Bonehead"... but he seems to interact with boxImpostor JUST FINE!  Maybe I lied about "sphereImpostor only".  :o  Anyway, make edits, do RUNS, make saves, see what is learned.

It LOOKS LIKE... um... the "concave area" (hole area) in back of skull... has invisible impostor blocking it.  Need to test... perhaps try pouring many little balls and cubes into inverted skull... see what happens.  heh.  Notice line 36... automatic Bonehead drift-along rate... adjustable.

Oh how I wish I could mesh.showImpostor().  Someday, maybe.  Meantime, we cover it with little snowballs... so we can see impostor shape/size.  :D

Link to comment
Share on other sites

@giorfasolini : I don't have any experience with using physics so I will leave you in Wingy's capable hands.

In the meantime @Wingnut, the image below is my " toolbox-o-Blender-pieces" - 512 vertices total and used to build a maze through scripting  by creating instances in BJS

My entry in the maze contest went AWOL when Dropbox changed its usage criteria - so I have finally redone them on github.

Full Maze - this includes an intro with music but basically something just to watch although the book, the wizard and his hell hound are all done in Blender.

Maze (no intro). Try to escape - there are four 5x5 cell mazes each generated by a script so they will be different every time. As a little trick you can jump to the next maze by hitting  the I key on the keyboard

cheers, gryff :)



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...