I have this method building up a sphere model from scratch using 3 parameters for it. It’s working fine and yielding nice results. Since I do not want to create a new model (meaning the overhead of calculating every single coordinate of every single vertex) every time I need a sphere model I would like to write the EggData to some file and maybe reuse it once I require a model with similar parameter settings.
Basically this is how I’m trying to achieve it
// sphere model creation code goes here
// save the model to disk
// try to load it
NodePath npModel = (NodePath)load_egg_file("test1.egg");
Now this looks fairly simple and straight forward: Just saving the model and loading it right up again. Even so the output looks like this
Error in test1.egg at line 505, column 0:
Undefined vertex pool testPool
Now I checked test1.egg and the line referred to, line 505, is the line after the last line of egg data in the file. Even more confusing, the name “testPool” is referred to throughout the whole egg file, not only in the last line.
The name itself is of course the name I used for the EggVertexPool when creating the sphere model - so much is obvious. But I don’t want to load the EggVertexPool data from the file. I only want the nodepath containing the loaded EggData, just as the method suggests it does.
I also tried using EggData::read() but the result was the same, only flooding my std_out with numerous assertion failures on top of it.
What am I doing wrong ?
These were the sources I used. In addition I checked the EggLoader class but could not see anything like an advanced load_egg_file() method.
The error message means that the vertex pool was not defined within the file. That’s why you didn’t get the message until the last line of the file–it wasn’t until the reader reached the last line that it realized the vertex pool was undefined.
It probably means you failed to add your EggVertexPool into the egg file somewhere. You just need to add it to some group within the egg file before you write it out.
Note that there are also other ways to solve this particular problem. For instance, once you have a sphere model, you can use:
newSphere = sphere.copy_to(newParent)
to make a new copy of that sphere model. If you want to save it for a later session, you can use:
to write it as a bam file, which you can then read later with WindowFramework::load_model(). (For that matter, you can also use WindowFramework::load_model() to load your egg file that you’ve written out.)
Thanks, I wasn’t looking at WindowFramework before. Some more documentation regarding C++ would really make life easier here
Now another question turned up though. I’m trying to rescale my model using NodePath::set_scale() just as the manual suggests to do but for some reason that rescaling is ignored (at least at rendering level, since I get the same visual as before).
I guess I did something wrong when creating the model in the first place. What things are there to consider, keep in mind, etc. when creating a model? I created it with some simple polygon/vertex calculations.
Hmm, there’s no such thing as a model that was constructed too incorrectly to be scaled.
Perhaps you are inadvertently scaling the camera as well? If you scale a node that is a parent of both the camera and the model (e.g. render), then both the camera and the model will be scaled together, with the result being no visual change in scale. (It is as if you shrink your house while you’re standing inside it, getting shrunk too. It all still looks the same.)