Hi all,
This is another basic question and the title says it all. In my initial experimentation with mixing C++ and Python, I’ve been able to access, from the python-side, int, float and char data types with success, but whenever I try and access a container like a vector, this is the error yielded:
AttributeError: 'genModule.TestClass' object has no attribute 'group_of_ints'
From this code, on the C++ side:
class TestClass{
PUBLISHED:
int firstTest;
NodePath workingNp;
std::vector<int> group_of_ints;
void modifyFirstTestValue(int newVal, NodePath& sentNp)
{
firstTest = newVal;
workingNp = sentNp;
NodePath dummy_node= sentNp.attach_new_node("Dummy Node Name");
}
NodePath returnDummyNp(NodePath sentParentNp, LVecBase3* sentVec)
{
NodePath dummy_node = sentParentNp.attach_new_node("fillMeUp");
sentParentNp.set_pos(sentVec->get_x(), sentVec->get_y(), sentVec->get_z());
return dummy_node;
}
};
The python side that uses this module:
instTest=genModule.TestClass()
instTest.firstTest=5
instTest.modifyFirstTestValue(3324,render)
b3=LVecBase3(1.000,300.000,0.000)
npDummi=instTest.returnDummyNp(traker,b3)
print(instTest.group_of_ints)#<this yields the error...
I also noticed that I can’t play around with the vector container from the C++ side like this:
group_of_ints.assign(5,1)
Yields this error from the C++ side:
/c/Panda3D-1.10.10-x64/P3DModuleBuilder-master/P3DModuleBuilder-master/source/example.h:31:2:
error: unknown type 'group_of_ints'
group_of_ints.assign(5,1)
^~~~~~~~~~~~~
/c/Panda3D-1.10.10-x64/P3DModuleBuilder-master/P3DModuleBuilder-master/source/example.h:31:15:
error: syntax error, unexpected '.'
group_of_ints.assign(5,1)
So how can this be resolved? Moreso, what ways are typically used to initiate containers, modify them, pass them (or their contents) back and forth between Python and C++ in Panda3D? It doesn’t necessarily have to be vector containers.
Thanks and sorry for these basic questions…