Colouring EggPolygons

I’m trying to build a simple model using EggData and EggPolygons. I’ve managed to build a white cube, but now I want to set the colours of each side. EggPolygon has as setColor() method (inherited from EggAttributes) which takes an LVecBase4f. Is this the right method to use? If so, how do I construct a LVecBase4f?

Malcolm

I’m assuming you’re building this in code? LVecBase4f is renamed into python as Vec4. As such, C++ error messages requesting them will happily accept the other :slight_smile:

I’m only writing python. I assumed that the API reference documentation is for Python, not C++. Is that incorrect?

In any case: poly.setColor(Vec4(r,g,b,a)) works. Thanks.

Malcolm

The API reference documentation is indeed intended for Python, but much of it is auto-generated from documentation that was written for C++, so sometimes you have to do a little mental renaming yourself.

It’s a bit unfortunate, but it’s not the end of the world.

David

So where do I look to find the “real” names?

Malcolm

Most class and method names are the same between C++ and Python, subject to our standard renaming rule: that underscores in C++ names are removed, and the next letter following an underscore is made uppercase.

The list of exceptions can be found in direct/src/ffi/FFIRename.py. In particular, classRenameDictionary in that module lists the C++ names and their corresponding Python names.

If you ask the reason why we do all this renaming at all, well, it all has to do with the history of the VR Studio and the convoluted path we took to evolve the Panda3D codebase to where it is now. Now it’s too late to change it, since we’ve got too much code in different places that depends on the names as they are. Consider it part of the kruft that comes along with any major project like this. And as kruft goes, I think we’re not doing too bad. :slight_smile:

David