Jump to content

.babylon import position


cefleet
 Share

Recommended Posts

Greetings all,

I have a small issue with importing a mesh and setting the position. My scenario is this:

I have "detectors" (invisible mesh boxes) in my scene. When the player mesh collides with these detectors something happens. The player mesh is imported after the scene is loaded so the detectors are already activated.  Well I have one that is sitting around the position {x:0, y:0, z:0}. So as soon as the player is loaded it fires the detector action (because the players' location is 0,0,0 from blender). Even if I set the position right as it is imported. 

Now I know of a workaround of just editing the players location in the .babylon file. But I was wondering if there was another way to bring the mesh into the new position without starting at the origin.  Any help would be appreciated.   

Link to comment
Share on other sites

Yeah, I thought of that. The problem there is that I have teenagers making the models for the game(s), and for various reasons I tell them to make the origin of all there models 0, 0, 0.  Changing by hand in the .babylon isn't a really a problem. I can just add it to a tasks in grunt. I was just wondering if there was a "pre-render" way of doing it. Thanks for the insight though.

Link to comment
Share on other sites

Can you condition your triggering your mesh also being isEnabled()?  I myself plan on making .blend per character.  It is good practice to define them at 0,0.  I do not want everything showing up there briefly in the wrong place.

 

I am going to add a 'Load Disabled' check box in the Mesh custom exporter properties of Blender.  When checked, you can do anything you want, and this or its children are not going to show.  You can then place it where it is supposed to be in the scene & setEnabled(true);

Link to comment
Share on other sites

Done, well at least on my version.  Turns out enabled was already being written in .babylon file.  It was just that it was hard coded to True.

 

It is also being written into .babylon visible.  This is triggered by the property 'hide_render'.  I cannot find this in the interface.  If you can either not wait for my next release, or you do not want to hide the meshes children, all you have to do is find in the User Interface where this is checked.

 

If you can condition your triggering, then never mind.

Link to comment
Share on other sites

@RaananW Yeah. I have been doing that but like I said the triggers are already activated before the player is ever loaded so even instantly it fires off the trigger. My workaround works fine. I just don't want to do a workaround if there is a "correct" way of doing it. 

 

@JCPalmer Sound good. I actually wanted to chat with you about stealing  using some of your code for exporter with what I am working on.

Link to comment
Share on other sites

Ah, found the hide_render button.  It is the little camera icon at the right end of the line in the outliner for the mesh.  Have to document that in my next Tower of Babel documentation update.

 

As far as code forking, everything is Apache 2.0. You might want to wait till my next version comes out (soon).  Also there are really 2 exporters, based off the same code base.  The Tower of Babel system writes Typescript / Javascript instead.  It also does shape keys.  TOB is actually the system I develop with.  I use Netbean's ability to diff / edit 2 arbitrary files.  I end up "clicking" most of the changes from TOB to the official exporter.

Link to comment
Share on other sites

Well, I'm not aiming to making a new exporter, thus the reason for using your code base. I teach kids to make video games and I use my game engine (A3D) built around babylonjs and blender as the tools. My end goal is to allow students (or anybody that wants to use A3D) to be able to launch a basic game from blender. I am just not really familiar with blender's python UI api. I need some examples to look at and modify.

Currently I just have a lightly custom version of the official exporter. Right now it has some basic "types" for meshes like Obstacle, Actor, Enemy, Spawn, Trigger etc., and each item type has an option that is a json object. also when you export you are given options for the type of module to export to (scroller, platformer, adventure).

Then just just launch the game with node.js http-server. 

Eventually I want to have it where you can have external mesh loaders, pre-built materials (from the material libraries), and where there is a "build and launch" button from the blender UI. 

I just need to get a better grasp of howto make a blender plugin...

Link to comment
Share on other sites

Actually, I do not Python, or didn't when I started refactoring it.  I have enough experience & am stubborn enough to get away with a lot of stuff these days.

 

Did not know Javascript or Typescript either.

 

Just start, which you did.  There are sites which describe python.  Just do a search starting with Blender.  I must have done 1000.

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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