[ SOLVED ] Is it possible to add basic primitive objects from stratch [ PYTHON ]

Is it possible to add basic primitive objects from stratch using PYTHON (?)
(It would be BPY coded to work with the actual BGE PYTHON)

1 Like

bpy.ops.mesh. primitive_cube_add ( size=2.0 , calc_uvs=True , enter_editmode=False , align=‘WORLD’ , location=(0.0 , 0.0 , 0.0) , rotation=(0.0 , 0.0 , 0.0) )

@kabu
1st of all thx, but this will only work in Blender, not BGE.
I would like a way to add basic primitives with BGE PYTHON.

mesh creation has been on the upbge todo for a long time. currently i dont think its possible yet.

I understand this as, simple cube,sphere,etc?
Not from scratch, but if you place it in an inactive layer then you can add it with addObject into the active layer. and build/do things with it.

Oh, sorry, misread the category

@Cotaks
I would like to build objects as found in the add_primitive_object menu
(Like for dynamic_level_design, etc…)

@kabu

No worries.
Thx for your time (really) :wink: :+1:

-|[RandomPerson]|-

The BGE does not support generation of meshes. It does not even add a face to an existing mesh.

If that is what you want, you can’t get it. The BGE is not sufficient for model creation.

If you think about creating a level editor. You can do that with predefined objects (even primitives). Either they are preloaded (see Cotaks reply) or you load them dynamically with LibLoad.

LibNew allows you to create independent copies of an object that you can manipulate (move vertices and/or UV coordinates).

I think this is only worth if you want to provide some sort of level editor to the end user, when you want full control of it’s capabilities. If you want it for you own purposes, I think Blender (not BGE) ist the better Leveleditor. It might have too much freedom and you might need to write some addons to support your workflow.

Hello @Monster

I thought BGE could do anything :wink:

Anyway thx.

I did a simple scenario some time ago, its like a primitive minecraft… you can add several objects from a list, rotate, erase, etc.

Look at this video:

I did this with logic bricks, I know , not the best way to do but I get it to work.

@mataii

Thx, but no Thx.

I’m asking for BPY to BGE code for adding primitive objects 100.0% from scratch directly from Blender Source Code.

bpy is not supported by BGE.
So no you can’t

UPBGE got better support @BluePrintRandom has made some nice stuff with it. but still you can’t create it from scratch. @BluePrintRandom correct me if i am wrong.

@Cotaks

Understood.

I think this thread is finished anyway . . .

in upbge_eevee we can wield all of bpy in realtime :smiley:

not in upbge 0.2.4 and before etc

inside bge you could just add a single copy of each primitive type to a hidden layer,
maybe even a few different variations (cylinder 8 - 16 - 32 - 64) etc

using GLSL you can

Or directly adding the feature to UPBGE’s sources. People often forget about this, although it might sound complicated, it is not impossible to do :slight_smile: