Beispiel #1
0
static int pyQuat___init__(pyQuat* self, PyObject* args, PyObject* kwds) {
    float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
    PyObject* init = NULL;
    static char* kwlist[] = { _pycs("X"), _pycs("Y"), _pycs("Z"), _pycs("W"), NULL };
    static char* kwlist2[] = { _pycs("quat"), NULL };
    static char* kwlist3[] = { _pycs("angle"), _pycs("axis"), NULL };

    if (PyArg_ParseTupleAndKeywords(args, kwds, "ffff", kwlist, &x, &y, &z, &w)) {
        (*self->fThis) = hsQuat(x, y, z, w);
    } else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "fO", kwlist3, &w, &init)) {
        if (pyVector3_Check(init)) {
            (*self->fThis) = hsQuat(w, *((pyVector3*)init)->fThis);
            return 0;
        } else {
            PyErr_SetString(PyExc_TypeError, "__init__ expects a quaternion or an angle and axis");
            return -1;
        }
    } else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist2, &init)) {
        if (init == NULL) {
            (*self->fThis) = hsQuat();
            return 0;
        }
        if (pyQuat_Check(init)) {
            (*self->fThis) = (*((pyQuat*)init)->fThis);
        } else {
            PyErr_SetString(PyExc_TypeError, "__init__ expects a quaternion or an angle and axis");
            return -1;
        }
    } else {
        return -1;
    }

    return 0;
}
void plGenericPhysical::IReadHKPhysical(hsStream* S, plResManager* mgr) {
    fPos.read(S);
    float rad = S->readFloat();
    hsVector3 axis;
    axis.read(S);
    fRot = hsQuat(rad, axis);

    unsigned int hMemberGroup, hReportGroup, hCollideGroup;
    fMass = S->readFloat();
    fFriction = S->readFloat();
    fRestitution = S->readFloat();
    fBounds = (plSimDefs::Bounds)S->readInt();
    fMemberGroup = plHKSimDefs::getMemGroup(hMemberGroup = S->readInt());
    fReportGroup = plHKSimDefs::getRepGroup(hReportGroup = S->readInt(), hMemberGroup);
    fCollideGroup = plHKSimDefs::getColGroup(hCollideGroup = S->readInt(), hMemberGroup);
    fDisableReport = S->readBool();
    fDisableCollide = S->readBool();

    if (fBounds == plSimDefs::kHullBounds) {
        fVerts.resize(S->readInt());
        for (size_t i=0; i<fVerts.size(); i++)
            fVerts[i].read(S);
    } else if (fBounds == plSimDefs::kSphereBounds) {
        fOffset.read(S);
        fRadius = S->readFloat();
    } else {    // Box, Proxy, Explicit
        fVerts.resize(S->readInt());
        for (size_t i=0; i<fVerts.size(); i++)
            fVerts[i].read(S);
        fIndices.resize(S->readInt() * 3);
        for (size_t i=0; i<fIndices.size(); i++)
            fIndices[i] = S->readShort();
    }

    fObjectKey = mgr->readKey(S);
    fProps.read(S);
    fSceneNode = mgr->readKey(S);
    fLOSDBs = S->readInt();
    fSubWorld = mgr->readKey(S);
    fSoundGroup = mgr->readKey(S);

#ifdef DEBUG
    unsigned int memGroup = plHKSimDefs::setMemGroup(this);
    unsigned int repGroup = plHKSimDefs::setRepGroup(this);
    unsigned int colGroup = plHKSimDefs::setColGroup(this);
    bool showAll = false;
    // now compare
    if (memGroup != hMemberGroup) {
        showAll = true;
        plDebug::Warning("%s memGroup changed: 0x%08X => 0x%08X",
                getKey()->toString().cstr(), hMemberGroup, memGroup);
    }
    if (repGroup != hReportGroup) {
        showAll = true;
        plDebug::Warning("%s repGroup changed: 0x%08X => 0x%08X",
                getKey()->toString().cstr(), hReportGroup, repGroup);
    }
    if (colGroup != hCollideGroup) {
        showAll = true;
        plDebug::Warning("%s colGroup changed: 0x%08X => 0x%08X",
                getKey()->toString().cstr(), hCollideGroup, colGroup);
    }
    if (showAll) {
        plDebug::Debug("%s original HK flags: memGroup = 0x%08X, repGroup = 0x%08X, colGroup = 0x%08X",
                getKey()->toString().cstr(), hMemberGroup, hReportGroup, hCollideGroup);
        plDebug::Debug("%s Generic data: memGroup = 0x%08X, repGroup = 0x%08X, colGroup = 0x%08X",
                getKey()->toString().cstr(), fMemberGroup, fReportGroup, fCollideGroup);
        plString info = plString::Format("%s LOSDBs = 0x%08X, properties: ", getKey()->toString().cstr(), fLOSDBs);
        for (size_t i=0; i<fProps.size(); i++) {
            if (fProps.get(i)) {
                info += fProps.getName(i);
                info += " ";
            }
        }
        plDebug::Debug(info);
    }
#endif
}
Beispiel #3
0
static PyObject* pyQuat_positive(pyQuat* self) {
    return pyQuat_FromQuat(hsQuat(+(self->fThis->X), +(self->fThis->Y),
                                  +(self->fThis->Z), +(self->fThis->W)));
}
Beispiel #4
0
static PyObject* pyQuat_absolute(pyQuat* self) {
    return pyQuat_FromQuat(hsQuat(fabs(self->fThis->X),
                                  fabs(self->fThis->Y),
                                  fabs(self->fThis->Z),
                                  fabs(self->fThis->W)));
}
Beispiel #5
0
static PyObject* pyQuat_negative(pyQuat* self) {
    return pyQuat_FromQuat(hsQuat(-(self->fThis->X), -(self->fThis->Y),
                                  -(self->fThis->Z), -(self->fThis->W)));
}