Registering New Object types like PowerUp,Armour, Spawns etc

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
CoreDumped
Posts: 1
Joined: Fri Feb 11, 2011 5:03 pm

Registering New Object types like PowerUp,Armour, Spawns etc

Post by CoreDumped » Fri Feb 11, 2011 5:15 pm

Hi, Im trying to use blender as a level editor for my custom game engine.
Right now i have a python script that exports the spatial information of the meshes in the scene and load it in the engine.

However, i would also like to define custom objects in blender. i.e., from the Shift+A menu (or programatically), i want to place custom types of objects like PowerUp, Armour, along side other objects like Mesh, Curve etc

so from my export script when i do

Code: Select all

Scene.GetCurrent().objects.selected.type
I would like to see it returns 'PowerUp' (just like how i see 'Mesh' when i select a mesh)

As for the representation of these custom objects in the 3D view, i can draw something like a cube or a sphere in the screen.

Is this possible to do this using python? If not, can you point where I should look at to modify in C?

Thanks in advance.

jesterKing
Site Admin
Posts: 1848
Joined: Fri Oct 18, 2002 12:48 pm
Location: Finland

Post by jesterKing » Thu Feb 24, 2011 3:05 pm

Either use mesh objects or empty objects, and tag them with extra information (idprops or custom props).

In your exporter you can then look for this extra info and export accordingly.

See https://svn.blender.org/svnroot/bf-blen ... h_torus.py for an example how to add a new mesh type and have it show in the mesh menu.

Do something similar for your object type (add to correct menu), and have your operator tag the object with the necessary info too.

/Nathan

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest