Beginner's questions

Hey there,

I’m new to Panda3D but have read parts of the manual, worked through some of the samples, etc. Still, there’s a LOT of stuff I don’t know about but that’s not the problem. The real problem is, I have never done any work with Blender/Maya/3dsmax/etc. so I have no knowledge what so ever about creating models. Now that appears to be some problem as almost everything I try to display requires me to load some model…

Suppose I just wanna display 2 planes being orthogonal to each other - e.g. described by normal vectors (0,0,1) and (0,1,0). I don’t care about textures, surface structure or any other neat detail. I just want two mono-color planes that I can move around (along a plane’s normal vector). Do I REALLY have to create models for that ?

Thanks,
Amnu

there are several ways you can do that.

  1. (easy) there are several models in the models folder included in the panda3d distribution. (in the models folder)
  2. (easy) there are several models in the samples which you can copy somewhere else and use them (for example there is a plane.egg.pz in the Asteroids/models folder.
  3. (easy) there are additional models you can download (under Downloads), the art-gallery.zip.
  4. (moderate) you can use the CardMaker (here’s some sample usage: panda3d.org/manual/index.php/S … eplacement)
  5. (complex) you can use the EggData (or GeomVertexWriter) interface to generate a model by generating points, triangles etc. (panda3d.org/manual/index.php/W … ut_to_Disk).

you may even find someone who makes very simple models for you, eighther in the forums or in irc if you ask nicely.

i’ve created a package of the basic primitives, because i’ve think this could be useful for everyone, and maybe even included in panda3d:

nouser.org/PMW/pmwiki.php/Re … Primitives

Hey, thanks on the basic primitives, Hypnos. Those are useful. :slight_smile:

I’d like to toss this one in too. It’s a flash light! I use it to visualize where my lights appear when in level-edit mode.

Flashlight Egg w/ Blender source file

If you would like more detailed models, there are a bunch of models under the Download page in the Panda Art package. They were created by students at CMU and serve as good place-holder art if you need it.

I would like to generate egg data within a C++ application and apparently I’m lacking quite some information on how to do this. Simply doing

#include "eggPolygon.h"
EggPolygon* pPoly = new EggPolygon();

will get me all kinds of ugly “unresolved external symbol” errors. I checked
http://www.panda3d.org/manual/index.php/Writing_3D_Models_out_to_Disk on how to do this but clicking “C++” will not change anything, displaying the python code anyway. I could not find anything useful anywhere else in the manual either.

The online API reference is available in Python only so I can’t find anything useful there either.

Edit:
The library missing to resolve these external references appears to be “libpandaegg.lib”. Did I miss some hint to this ? Can’t imagine this is not documented somewhere and people are left guessing.

Hmm, I don’t know of any documents that explicitly state which symbol requires which library. It’s true that would be useful information to include. Perhaps that can be worked into the generated API somehow.

Note that, since EggPolygon inherits (eventually) from ReferenceCount, the above code is slightly incorrect. You should use:

PT(EggPolygon) pPoly = new EggPolygon();

David

To clarify: in C++, Panda makes liberal use of automatic reference counting. This should be documented on this page, though that looks pretty incomplete.

A short summary: a large number of classes in Panda inherit from a base class called ReferenceCount. These objects must be treated a little differently from conventional objects: when allocated, their reference count is initially zero. You are expected to immediately increment the reference count, and when the reference count is later decremented back to zero, the object will be automatically deleted.

You are not expected to increment and decrement the reference counts explicitly, however. This is handled automatically by Panda’s “magic pointer” class, a template class called PointerTo, which is abbreviated with the macro PT. In general, PT(MyClass) can be treated the same as (MyClass *), and should be read “pointer to MyClass”. PT(MyClass) is special, though, because when you assign a pointer value into it, it will increment the pointer’s reference count; and when you assign a new value (or destruct the PT(MyClass) itself), it will decrement the pointer’s reference count.

Thus, in Panda, you don’t actually need to do anything special to manage reference counts other than to be careful to use PT(MyClass) instead of MyClass * to store pointers to things that inherit from ReferenceCount.

There are a few other fiddly rules. You can’t ever explicitly delete a ReferenceCount object, because then you’ll get a double-delete when the reference count tries to delete it too. You normally don’t create automatic or local ReferenceCount objects, instead you always use the new operator to allocate one from the heap (though there’s a way to create an automatic instance if you need to, but that’s more advanced).

When we pass a ReferenceCount object into a method, we normally accept it with a MyClass * pointer on the parameter list, because in that case we don’t really need the overhead of PT(MyClass), since the reference count is still held by the caller. When we return a ReferenceCount object from a method, we either return a PT(MyClass) if the method is not retaining ownership of the object internally, or we return a MyClass * if it is (in which case, again, it doesn’t need the overhead of PT(MyClass)). In general, though, if you have any doubt, you should use a PT(MyClass) to store a pointer to a ReferenceCount object.

David

Thanks for the informative reply, I really did not know about this. Now a couple of things make sense to me :slight_smile:
I find it inconsistent to have some objects use the auto pointer mechanism while others don’t but I’m sure you have your reasons.

Let’s try this

PT(EggVertexPool) pVertexPool = new EggVertexPool("newVertexPool");
PT(EggVertex) pVertex = new EggVertex();
pVertex->set_pos(LPoint3d(10, 10, 10));
pVertexPool->add_vertex(pVertex);

I get an “Access violation reading” exception. The problem occurs with

pVertexPool->add_vertex(pVertex);

and when tracking the problem down it appears the objects themselves, namely of type EggVertexPool and EggVertex, were not created. Checking the local symbols at the time of the exception those variables only hold void pointers to memory blocks, meaning they are empty.

This is somewhat confusing - isn’t the "new " statement enough to create objects using the “PT” statement ? I can call the objects’ constructors directly when assigning local variables of the direct objects’ types instead of using the “PT” syntax. So

EggVertexPool blubb("blubb");
PT(EggVertexPool) pVertexPool = &blubb;

works fine for the first statement (object created & holding object specifig information, e.g. name) but after the second statement the variable “pVertexPool” is still a void pointer. I realize I am not supposed to do this but I thought I could at least get some debugging information out of it, yet not even this works. I’m confused.

EDIT:
When tryin to access the object directly, e.g.

EggVertexPool blubb("blubb");
blubb.clear_name();

I get an memory access violation even though the local symbols table tells me there is an accessible object called “blubb” of type “EggVertexPool” with _name == “blubb”. I can even read out its memory address but I can’t use it for method calls.

Well, all my fault. I must have overseen the big warning saying I need VS2008 for getting all this running (under Windows that is).

Well, it’s working now. The heap corruption was a result of cross library calls between msvc8 and msvc9 dlls.

useful converse thanks for sharing… folks

Hi all,

I am starting to love panda (after fighting to dead with ogre)
and I have a rather simple question. Is there a nice way
to get over the following situation?:

I’m using panda as my renderer stage, so I would like it
to run separately from my main thread (which deals with
networking and maybe user input) but the thing is, to
accomplish that i am using the threading module of python,
and I need to define a ‘run’ method, but panda has already
one defined, so i would overwrite that method…

Any simple, clean solution?

Regards

it’s recommended to use panda’s default game loop and make your game task and event based. it might be a bit unfamilliar at first. but once you understood the concept it’s a lot easier than having your own custom game loop.

if you really want to make your own you can make your own. but it’s really not recommended.
so is using python threads. since panda is c++ it doesnt work well with python threading. it comes with it’s own threading module.

i really really recommend you learn about panda’s task and event systems. not only will it make things a lot more easy for you. but also spares you the trouble of messing with your own game-loop.

Thanks for the quick reply, I guess you are very right.

Regards