Drawing primitives ?


#1

Hello,

I am unable to find in the manual - methods / functions to draw primitives - like sphere / cube / cylinder etc.
at run time using code.

Can anybody please advice on how to achieve these ?

Thnaks,


#2

Somewhere someday I read that Panda3D does not render primitives, if you want to render a cube, sphere, etc. you need to have the egg file with the model … But as I know there are “primitives” on default Panda3D dist like cube.egg, sphere.egg, etc. but see yourself. :smiley:


#3

@EdmundosTown: Thank you. So the bottom line is I will have to always load 3D models from hard disk - even when I am trying draw simple primitives like - sphere, cone, cube, cylinder etc. I guess it is a lacking feature in Panda3D which is commonly available in other engines.


#4

If you look at other engines that can draw primitives, actually they do this task in other terms, I mean, you need to load a library wich contain vertex per vertex of a primitive, library that lives in the hard disk, or you have to call a function with sometimes goes to the hard disk an load a binary file to the memory. Something like that happens with bam files:

By the way, you can add this particular feature creating by yourself a library that contain “loaded-bam-files” so you can include and setup more quickly

:slight_smile: Hope I help. Good coding.


#5

@EdmundosTown: Thank you for your reply. Actually I think I have used the wrong term - “other engines”.

The fact is, I am coming from a Dark Basic pro background which has inbuilt functions create primitives at runtime with the option to specify the number of polygons that should be used to draw the sphere. And I am sure that no model gets loaded by the fact that Dark Basic Pro does not come with a default set models within its installation package like Panda. I am not comparing Dark Basic Pro with Panda here. I am just querying if such facilities are available in Panda too. So please do not start throwing flames at me … :slight_smile:


#6

I think Panda only understands very basic primitives
-Triangles
-Tristrips
-Trifans
-Lines
-Linestrips
-Points

Check this out:
panda3d.org/manual/index.php/GeomPrimitive

Also, you can procedurally generate cubes spheres or a even a torus knot with one function… but you will need to write that function yourself, panda can help with that:
panda3d.org/manual/index.php … rtexFormat
panda3d.org/manual/index.php … ex_formats
panda3d.org/manual/index.php … VertexData
panda3d.org/manual/index.php … ve_objects
panda3d.org/manual/index.php … cene_graph


#7

@wezu: Thank you for your help.