~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to source/gameengine/Ketsji/KX_GameObject.cpp

  • Committer: Dietrich Bollmann
  • Date: 2009-04-26 06:25:14 UTC
  • mfrom: (184.1.520)
  • Revision ID: diresu@web.de-20090426062514-ly27wepl1t5d7p8s
Update to state of blender repository from 2009-04-26 revision 19927.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: KX_GameObject.cpp 19885 2009-04-23 00:32:33Z campbellbarton $
 
2
 * $Id: KX_GameObject.cpp 19922 2009-04-25 07:17:36Z campbellbarton $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
1133
1133
        KX_PYATTRIBUTE_RW_FUNCTION("state",             KX_GameObject, pyattr_get_state,        pyattr_set_state),
1134
1134
        KX_PYATTRIBUTE_RO_FUNCTION("meshes",    KX_GameObject, pyattr_get_meshes),
1135
1135
        KX_PYATTRIBUTE_RW_FUNCTION("localOrientation",KX_GameObject,pyattr_get_localOrientation,pyattr_set_localOrientation),
1136
 
        KX_PYATTRIBUTE_RO_FUNCTION("worldOrientation",KX_GameObject,pyattr_get_worldOrientation),
 
1136
        KX_PYATTRIBUTE_RW_FUNCTION("worldOrientation",KX_GameObject,pyattr_get_worldOrientation,pyattr_set_worldOrientation),
1137
1137
        KX_PYATTRIBUTE_RW_FUNCTION("localPosition",     KX_GameObject, pyattr_get_localPosition,        pyattr_set_localPosition),
1138
1138
        KX_PYATTRIBUTE_RW_FUNCTION("worldPosition",     KX_GameObject, pyattr_get_worldPosition,    pyattr_set_worldPosition),
1139
1139
        KX_PYATTRIBUTE_RW_FUNCTION("localScaling",      KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
1515
1515
        return PyObjectFrom(self->NodeGetWorldOrientation());
1516
1516
}
1517
1517
 
 
1518
int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 
1519
{
 
1520
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 
1521
        
 
1522
        /* if value is not a sequence PyOrientationTo makes an error */
 
1523
        MT_Matrix3x3 rot;
 
1524
        if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, "))
 
1525
                return NULL;
 
1526
 
 
1527
        if (self->GetSGNode() && self->GetSGNode()->GetSGParent()) {
 
1528
                self->NodeSetLocalOrientation(self->GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
 
1529
        }
 
1530
        else {
 
1531
                self->NodeSetLocalOrientation(rot);
 
1532
        }
 
1533
        
 
1534
        self->NodeUpdateGS(0.f);
 
1535
        return 0;
 
1536
}
 
1537
 
1518
1538
PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
1519
1539
{
1520
1540
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
1530
1550
        
1531
1551
        /* if value is not a sequence PyOrientationTo makes an error */
1532
1552
        MT_Matrix3x3 rot;
1533
 
        if (!PyOrientationTo(value, rot, "gameOb.orientation = sequence: KX_GameObject, "))
 
1553
        if (!PyOrientationTo(value, rot, "gameOb.localOrientation = sequence: KX_GameObject, "))
1534
1554
                return NULL;
1535
1555
 
1536
1556
        self->NodeSetLocalOrientation(rot);
2170
2190
PyObject* KX_GameObject::PySetOrientation(PyObject* value)
2171
2191
{
2172
2192
        ShowDeprecationWarning("setOrientation()", "the orientation property");
2173
 
        MT_Matrix3x3 matrix;
2174
 
        if (PyObject_IsMT_Matrix(value, 3) && PyMatTo(value, matrix))
2175
 
        {
2176
 
                NodeSetLocalOrientation(matrix);
2177
 
                NodeUpdateGS(0.f);
2178
 
                Py_RETURN_NONE;
2179
 
        }
 
2193
        MT_Matrix3x3 rot;
 
2194
        
 
2195
        /* if value is not a sequence PyOrientationTo makes an error */
 
2196
        if (!PyOrientationTo(value, rot, "gameOb.setOrientation(sequence): KX_GameObject, "))
 
2197
                return NULL;
2180
2198
 
2181
 
        MT_Quaternion quat;
2182
 
        if (PyVecTo(value, quat))
2183
 
        {
2184
 
                matrix.setRotation(quat);
2185
 
                NodeSetLocalOrientation(matrix);
2186
 
                NodeUpdateGS(0.f);
2187
 
                Py_RETURN_NONE;
2188
 
        }
2189
 
        return NULL;
 
2199
        NodeSetLocalOrientation(rot);
 
2200
        NodeUpdateGS(0.f);
 
2201
        Py_RETURN_NONE;
2190
2202
}
2191
2203
 
2192
2204
PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args)