What Blender Export should I use?
-
- Posts: 11
- Joined: Sat Apr 09, 2011 8:12 pm
What Blender Export should I use?
im wondering how i would setup my mesh to have collision in bullet...
is there an export script(or whatever its called) in blender that i can use for Bullet Physics?
if so then please post a link, and i also wanna know how i would update my Blender to use this export..
is there an export script(or whatever its called) in blender that i can use for Bullet Physics?
if so then please post a link, and i also wanna know how i would update my Blender to use this export..
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: What Blender Export should I use?
The best is to use the built-in .bullet export in the Blender game engine, called through a Python command (the actual Bullet export happens in C/C++, unlike the common Python export scripts)
This requires Blender 2.57 (or later). Setup the collision shapes, rigid body info, constraints, soft body etc for the Blender game engine (BGE), hook up a BGE python script to a controller and run the BGE using the 'P' key/or menu. Here is the script:
See also exportBulletFile.blend in this archive:
http://bulletphysics.com/ftp/pub/test/i ... iles-2.zip
It will export most collision shape types, rigid body info, constraints and soft body data in a .bullet file.
Thanks,
Erwin
This requires Blender 2.57 (or later). Setup the collision shapes, rigid body info, constraints, soft body etc for the Blender game engine (BGE), hook up a BGE python script to a controller and run the BGE using the 'P' key/or menu. Here is the script:
Code: Select all
import PhysicsConstraints;
PhysicsConstraints.exportBulletFile("testFile.bullet")
http://bulletphysics.com/ftp/pub/test/i ... iles-2.zip
It will export most collision shape types, rigid body info, constraints and soft body data in a .bullet file.
Thanks,
Erwin
-
- Posts: 11
- Joined: Sat Apr 09, 2011 8:12 pm
Re: What Blender Export should I use?
Hey i believe i have everything setup satisfyingly, but:
i didnt completely understand what you were talking about. sorry, im not ultimately used to the new blender interface yet, you think you could give a few details?
also im glad for the answer
EDIT: i looked up some information and i figured out how to export it yay
now im wondering how i would use this in c++...
Erwin Coumans wrote: hook up a BGE python script to a controller and run the BGE using the 'P' key/or menu. Here is the script:
i didnt completely understand what you were talking about. sorry, im not ultimately used to the new blender interface yet, you think you could give a few details?
also im glad for the answer
EDIT: i looked up some information and i figured out how to export it yay
now im wondering how i would use this in c++...
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: What Blender Export should I use?
You can use btBulletWorldImporter.
See Bullet/Demos/SerializeDemo, it can load your .bullet file.
Thanks,
Erwin
See Bullet/Demos/SerializeDemo, it can load your .bullet file.
Thanks,
Erwin
-
- Posts: 11
- Joined: Sat Apr 09, 2011 8:12 pm
Re: What Blender Export should I use?
hey i got the importer to work, thanks to you xD but now im having another peoblem..
when i start my game, everything fine: gravity works and everything...
the only problem now, is that once my character falls, he falss through the landscape ._.
im wondering if something is wrong with the physics(i DID notice the box i set was moving slowly while on the plane in blender, i thought it was friction or whatever :/)
EDIT: hey i did some trial and error, and i found out that when i search for how many rigid bodies there are in the .bullet file, it says theres none...
is there a way to add them with the python code?
when i start my game, everything fine: gravity works and everything...
the only problem now, is that once my character falls, he falss through the landscape ._.
im wondering if something is wrong with the physics(i DID notice the box i set was moving slowly while on the plane in blender, i thought it was friction or whatever :/)
EDIT: hey i did some trial and error, and i found out that when i search for how many rigid bodies there are in the .bullet file, it says theres none...
is there a way to add them with the python code?
-
- Posts: 8
- Joined: Sat Apr 30, 2011 2:28 pm
Re: What Blender Export should I use?
Where did you find the .bullet file after running the script to export the file? I'm using Blender 2.57 and I believe the script is running (I see the print in the console and I added a print at the end which I also see in the console), but I can't find the .bullet file anywhere.
Thanks.
Thanks.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: What Blender Export should I use?
The file should go in the current working directory, typically next to the Blender.exe, unless you start it from a debugger etc.
You can chose an absolute path, for example under windows:
Thanks,
Erwin
You can chose an absolute path, for example under windows:
Code: Select all
PhysicsConstraints.exportBulletFile("c:/testFile.bullet")
Erwin
-
- Posts: 8
- Joined: Sat Apr 30, 2011 2:28 pm
Re: What Blender Export should I use?
Thanks, Erwin. Based on your response, I noticed that I was using "\" instead of "/" when I tried the absolute path. The file is being created now.
Thanks again.
Thanks again.
-
- Posts: 13
- Joined: Thu Apr 29, 2010 11:59 pm
Re: What Blender Export should I use?
I am trying your script in Blender 2.6 and it says the module doesnt exist...
Do you know if it was it taken out? Renamed?
Edit, my apologies. It seems you cannot run the script from the text editor window and that you must run it in game. Thanks Erwin.
Do you know if it was it taken out? Renamed?
Edit, my apologies. It seems you cannot run the script from the text editor window and that you must run it in game. Thanks Erwin.
-
- Posts: 3
- Joined: Thu Oct 01, 2009 1:23 pm
Re: What Blender Export should I use?
I got this export to work from Blender 2.62, but I've been trying to find a way to identify the object by it's Blender name.Erwin Coumans wrote:You can use btBulletWorldImporter.
See Bullet/Demos/SerializeDemo, it can load your .bullet file.
Thanks,
Erwin
According to the Bullet binary serialization doc:
http://bulletphysics.org/mediawiki-1.5. ... onstraints
However, the name is always exactly the same as the collision shape name, rather than a unique Blender name. This code:Setting and Getting the name for bodies, shapes and constraints
The Dynamica Maya plugin and Blender create unique names for all objects. This is useful to recognize objects, shapes and constraints, for example to bind them with graphics objects.
When saving the file, the btDefaultSerializer is created, and all names are registered using the registerNameForPointer method.
When loading the .bullet file, the m_name field is part of the structures: btCollisionObjectData, btRigidBodyData, btCollisionShapeData and btTypedConstraintData.
Also the 'btBulletWorldImporter::createRigidBody' methods passes this nams as one of the arguments, when available.
Code: Select all
int i;
for (i=0; i < m_dynamicsWorld->getNumCollisionObjects(); i++)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
printf(" object name = %s\n", body->getRootCollisionShape()->getName());
...
for every box collision shape.object name = Box
-
- Posts: 3
- Joined: Thu Oct 01, 2009 1:23 pm
Re: What Blender Export should I use?
Ok, I figured it out. It's not part of the btRigidBody object, but it must be extracted from the btBulletWorldImporter object:
Code: Select all
class btBulletWorldImporter* m_fileLoader;
...
int i;
for (i=0; i < m_fileLoader->getNumRigidBodies(); i++)
{
btCollisionObject* coll = m_fileLoader->getRigidBodyByIndex(i);
btRigidBody* body = btRigidBody::upcast(coll);
printf(" object name = %s\n", m_fileLoader->getNameForPointer(body)); // The Blender object name
...
jacket wrote:I got this export to work from Blender 2.62, but I've been trying to find a way to identify the object by it's Blender name.Erwin Coumans wrote:You can use btBulletWorldImporter.
See Bullet/Demos/SerializeDemo, it can load your .bullet file.
Thanks,
Erwin
According to the Bullet binary serialization doc:
http://bulletphysics.org/mediawiki-1.5. ... onstraints
However, the name is always exactly the same as the collision shape name, rather than a unique Blender name. This code:Setting and Getting the name for bodies, shapes and constraints
The Dynamica Maya plugin and Blender create unique names for all objects. This is useful to recognize objects, shapes and constraints, for example to bind them with graphics objects.
When saving the file, the btDefaultSerializer is created, and all names are registered using the registerNameForPointer method.
When loading the .bullet file, the m_name field is part of the structures: btCollisionObjectData, btRigidBodyData, btCollisionShapeData and btTypedConstraintData.
Also the 'btBulletWorldImporter::createRigidBody' methods passes this nams as one of the arguments, when available.
produces:Code: Select all
int i; for (i=0; i < m_dynamicsWorld->getNumCollisionObjects(); i++) { btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i]; btRigidBody* body = btRigidBody::upcast(obj); printf(" object name = %s\n", body->getRootCollisionShape()->getName()); ...
for every box collision shape.object name = Box
-
- Posts: 30
- Joined: Thu Feb 09, 2012 2:39 am
Re: What Blender Export should I use?
How can I see the script result? is there a debugging console?
I run the script as you say but there is no file output.
I'm using blender 2.67b
I run the script as you say but there is no file output.
I'm using blender 2.67b
-
- Posts: 1
- Joined: Sat Jan 30, 2016 3:32 pm
Re: What Blender Export should I use?
You can check out my answer on StackOverflow, there's also a link to the add-on which eases the export of the .bullet file a lot:
http://stackoverflow.com/a/35103472/324790
http://stackoverflow.com/a/35103472/324790