PJani
25-02-2010 14:06:38
Hy i have boost python as a script engine in Ogre with c++. It works like charm, but now i have problem. I don't know where i can get or build BOOST_PYTHON_MODULE(...) for Vector3, Quaternion, Matrix.
Any help,...will help.
I'm not sure how to answer your question

-- if you use the Python-Ogre module from your python engine then you get access to everything.
Without knowing your interface between your engine and the python scripting I'm not sure which way to point you -- after all you could simply implement them as python classes...
Or are you actually looking for a way to interface between Ogre and Python ? (hence use Python-Ogre)
Regards
Andy
PJani
27-02-2010 10:03:38
Currently i had to write my own Vector3, Quaternion c++ wrap, but then i allways need to wrap other objects which makes code slow and clogged. And for every class i want to extend i need to write c++ wrap.
example what i mean, but this is stupid.
void export_module_pyvector3()
{
python::class_<PyVector3>("Vector3", python::init<double,double,double>())
.def(python::init<python::list>())
.def("get",&PyVector3::lVector3)
.def("x",&PyVector3::x)
.def("y",&PyVector3::y)
.def("z",&PyVector3::z)
;
}
PyVector3::PyVector3(double x,double y,double z)
{
m_Vec = Ogre::Vector3(x,y,z);
}
PyVector3::PyVector3(Ogre::Vector3 mVec):m_Vec(mVec)
{
//Nothing
}
PyVector3::PyVector3(python::list l)
{
//if(l.length==3){
double x = python::extract<double>(l[0]);
double y = python::extract<double>(l[1]);
double z = python::extract<double>(l[2]);
m_Vec = Ogre::Vector3(x,y,z);
/*}else{
m_Vec = Ogre::Vector3(0,0,0);
}*/
}
Ogre::Vector3 PyVector3::Vector3()
{
return m_Vec;
}
python::list PyVector3::lVector3()
{
python::list l;
l.append(m_Vec.x);
l.append(m_Vec.y);
l.append(m_Vec.z);
return l;
}
float PyVector3::x()
{
return m_Vec.x;
}
float PyVector3::y()
{
return m_Vec.y;
}
float PyVector3::z()
{
return m_Vec.z;
}
i need something like this for real Ogre vector3, quaternion and matrix. If anyone has these would it be great.
python::class_<PyVector3>("Vector3", python::init<double,double,double>())
.def(python::init<python::list>())
.def("get",&PyVector3::lVector3)
.def("x",&PyVector3::x)
.def("y",&PyVector3::y)
.def("z",&PyVector3::z)
;