summaryrefslogtreecommitdiffstats
path: root/src/fakerw
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-04-23 22:25:18 +0200
committeraap <aap@papnet.eu>2020-04-24 11:42:38 +0200
commitf03b4eec4c37eab75a5bd639279cfcc615105b01 (patch)
treec4be4fa57b16c61d45e8156a51dd07b11e049bba /src/fakerw
parentMerge branch 'master' of github.com:gtamodding/re3 (diff)
downloadre3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar.gz
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar.bz2
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar.lz
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar.xz
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.tar.zst
re3-f03b4eec4c37eab75a5bd639279cfcc615105b01.zip
Diffstat (limited to 'src/fakerw')
-rw-r--r--src/fakerw/fake.cpp46
-rw-r--r--src/fakerw/rphanim.h36
-rw-r--r--src/fakerw/rpskin.h18
-rw-r--r--src/fakerw/rtcharse.h14
-rw-r--r--src/fakerw/rtquat.h10
5 files changed, 116 insertions, 8 deletions
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index 3977007f..59c01c91 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -4,14 +4,10 @@
#include <rpworld.h>
#include <rpmatfx.h>
#include <rphanim.h>
+#include <rpskin.h>
#include <assert.h>
#include <string.h>
-// TODO: split image<->raster functions in two
-// implement raster context
-// BMP reader
-// geometry locking
-
using namespace rw;
RwUInt8 RwObjectGetType(const RwObject *obj) { return obj->type; }
@@ -55,7 +51,7 @@ RwMatrix *RwMatrixMultiply(RwMatrix * matrixOut, const RwMatrix * MatrixIn1, con
RwMatrix *RwMatrixTransform(RwMatrix * matrix, const RwMatrix * transform, RwOpCombineType combineOp)
{ matrix->transform(transform, (rw::CombineOp)combineOp); return matrix; }
//RwMatrix *RwMatrixOrthoNormalize(RwMatrix * matrixOut, const RwMatrix * matrixIn);
-//RwMatrix *RwMatrixInvert(RwMatrix * matrixOut, const RwMatrix * matrixIn);
+RwMatrix *RwMatrixInvert(RwMatrix * matrixOut, const RwMatrix * matrixIn) { Matrix::invert(matrixOut, matrixIn); return matrixOut; }
RwMatrix *RwMatrixScale(RwMatrix * matrix, const RwV3d * scale, RwOpCombineType combineOp)
{ matrix->scale(scale, (rw::CombineOp)combineOp); return matrix; }
RwMatrix *RwMatrixTranslate(RwMatrix * matrix, const RwV3d * translation, RwOpCombineType combineOp)
@@ -742,14 +738,24 @@ RwBool RpHAnimPluginAttach(void) {
return true;
}
+RwInt32 RpHAnimFrameGetID(RwFrame *frame) { return HAnimData::get(frame)->id; }
+
+RwInt32 RpHAnimIDGetIndex(RpHAnimHierarchy *hierarchy, RwInt32 ID) { return hierarchy->getIndex(ID); }
+
RwBool RpHAnimFrameSetHierarchy(RwFrame *frame, RpHAnimHierarchy *hierarchy) { HAnimData::get(frame)->hierarchy = hierarchy; return true; }
RpHAnimHierarchy *RpHAnimFrameGetHierarchy(RwFrame *frame) { return HAnimHierarchy::get(frame); }
-RwBool RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy *hierarchy, RpHAnimAnimation *anim) { hierarchy->currentAnim->setCurrentAnim(anim); return true; }
-RwBool RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy *hierarchy, RwReal time) { hierarchy->currentAnim->addTime(time); return true; }
+RpHAnimHierarchy *RpHAnimHierarchySetFlags(RpHAnimHierarchy *hierarchy, RpHAnimHierarchyFlag flags) { hierarchy->flags = flags; return hierarchy; }
+RwBool RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy *hierarchy, RpHAnimAnimation *anim) { hierarchy->interpolator->setCurrentAnim(anim); return true; }
+RwBool RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy *hierarchy, RwReal time) { hierarchy->interpolator->addTime(time); return true; }
+
+RwMatrix *RpHAnimHierarchyGetMatrixArray(RpHAnimHierarchy *hierarchy) { return hierarchy->matrices; }
RwBool RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy *hierarchy) { hierarchy->updateMatrices(); return true; }
+RpHAnimAnimation *RpHAnimAnimationCreate(RwInt32 typeID, RwInt32 numFrames, RwInt32 flags, RwReal duration)
+ { return Animation::create(AnimInterpolatorInfo::find(typeID), numFrames, flags, duration); }
+RpHAnimAnimation *RpHAnimAnimationDestroy(RpHAnimAnimation *animation) { animation->destroy(); return animation; }
RpHAnimAnimation *RpHAnimAnimationStreamRead(RwStream *stream) { return Animation::streamRead(stream); }
@@ -762,6 +768,13 @@ RwBool RpSkinPluginAttach(void) {
return true;
}
+RwUInt32 RpSkinGetNumBones( RpSkin *skin ) { return skin->numBones; }
+const RwMatrixWeights *RpSkinGetVertexBoneWeights( RpSkin *skin ) { return (RwMatrixWeights*)skin->weights; }
+const RwUInt32 *RpSkinGetVertexBoneIndices( RpSkin *skin ) { return (RwUInt32*)skin->indices; }
+const RwMatrix *RpSkinGetSkinToBoneMatrices( RpSkin *skin ) { return (const RwMatrix*)skin->inverseMatrices; }
+
+RpSkin *RpSkinGeometryGetSkin( RpGeometry *geometry ) { return Skin::get(geometry); }
+
RpAtomic *RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, RpHAnimHierarchy *hierarchy ) { Skin::setHierarchy(atomic, hierarchy); return atomic; }
RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ) { return Skin::getHierarchy(atomic); }
@@ -772,6 +785,23 @@ RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ) { retu
RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName) { rw::writeBMP(image, imageName); return image; }
RwImage *RtBMPImageRead(const RwChar * imageName) { return rw::readBMP(imageName); }
+#include "rtquat.h"
+
+RtQuat *RtQuatRotate(RtQuat * quat, const RwV3d * axis, RwReal angle, RwOpCombineType combineOp) { return quat->rotate(axis, angle/180.0f*3.14159f, (CombineOp)combineOp); }
+void RtQuatConvertToMatrix(const RtQuat * const qpQuat, RwMatrix * const mpMatrix) { mpMatrix->rotate(*qpQuat, COMBINEREPLACE); }
+
+
+#include "rtcharse.h"
+
+RwBool RtCharsetOpen(void) { return Charset::open(); }
+void RtCharsetClose(void) { return Charset::close(); }
+RtCharset *RtCharsetPrint(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y) { charSet->print(string, x, y, true); return charSet; }
+RtCharset *RtCharsetPrintBuffered(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y, RwBool hideSpaces) { charSet->printBuffered(string, x, y, hideSpaces); return charSet; }
+RwBool RtCharsetBufferFlush(void) { Charset::flushBuffer(); return true; }
+RtCharset *RtCharsetSetColors(RtCharset * charSet, const RwRGBA * foreGround, const RwRGBA * backGround) { return charSet->setColors(foreGround, backGround); }
+RtCharset *RtCharsetGetDesc(RtCharset * charset, RtCharsetDesc * desc) { *desc = charset->desc; return charset; }
+RtCharset *RtCharsetCreate(const RwRGBA * foreGround, const RwRGBA * backGround) { return Charset::create(foreGround, backGround); }
+RwBool RtCharsetDestroy(RtCharset * charSet) { charSet->destroy(); return true; }
diff --git a/src/fakerw/rphanim.h b/src/fakerw/rphanim.h
index 665e03f8..34dfeb09 100644
--- a/src/fakerw/rphanim.h
+++ b/src/fakerw/rphanim.h
@@ -1,20 +1,56 @@
#pragma once
+#include "rtquat.h"
+
//struct RpHAnimHierarchy;
typedef rw::HAnimHierarchy RpHAnimHierarchy;
//struct RpHAnimAnimation;
typedef rw::Animation RpHAnimAnimation;
+#define rpHANIMSTDKEYFRAMETYPEID 0x1
+
+typedef rw::HAnimKeyFrame RpHAnimStdKeyFrame;
+
+enum RpHAnimHierarchyFlag
+{
+ rpHANIMHIERARCHYSUBHIERARCHY = rw::HAnimHierarchy::SUBHIERARCHY,
+ rpHANIMHIERARCHYNOMATRICES = rw::HAnimHierarchy::NOMATRICES,
+
+ rpHANIMHIERARCHYUPDATEMODELLINGMATRICES = rw::HAnimHierarchy::UPDATEMODELLINGMATRICES,
+ rpHANIMHIERARCHYUPDATELTMS = rw::HAnimHierarchy::UPDATELTMS,
+ rpHANIMHIERARCHYLOCALSPACEMATRICES = rw::HAnimHierarchy::LOCALSPACEMATRICES
+};
+
+#define rpHANIMPOPPARENTMATRIX rw::HAnimHierarchy::POP
+#define rpHANIMPUSHPARENTMATRIX rw::HAnimHierarchy::PUSH
+
RwBool RpHAnimPluginAttach(void);
+RwBool RpHAnimFrameSetID(RwFrame *frame, RwInt32 id);
+RwInt32 RpHAnimFrameGetID(RwFrame *frame);
+
+RwInt32 RpHAnimIDGetIndex(RpHAnimHierarchy *hierarchy, RwInt32 ID);
+
RwBool RpHAnimFrameSetHierarchy(RwFrame *frame, RpHAnimHierarchy *hierarchy);
RpHAnimHierarchy *RpHAnimFrameGetHierarchy(RwFrame *frame);
+RpHAnimHierarchy *RpHAnimHierarchySetFlags(RpHAnimHierarchy *hierarchy, RpHAnimHierarchyFlag flags);
+RpHAnimHierarchyFlag RpHAnimHierarchyGetFlags(RpHAnimHierarchy *hierarchy);
+
RwBool RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy *hierarchy, RpHAnimAnimation *anim);
RwBool RpHAnimHierarchySetCurrentAnimTime(RpHAnimHierarchy *hierarchy, RwReal time);
RwBool RpHAnimHierarchySubAnimTime(RpHAnimHierarchy *hierarchy, RwReal time);
RwBool RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy *hierarchy, RwReal time);
+RwMatrix *RpHAnimHierarchyGetMatrixArray(RpHAnimHierarchy *hierarchy);
RwBool RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy *hierarchy);
+#define rpHANIMHIERARCHYGETINTERPFRAME( hierarchy, nodeIndex ) \
+ ( (void *)( ( (RwUInt8 *)&(hierarchy->interpolator[1]) + \
+ ((nodeIndex) * \
+ hierarchy->interpolator->currentAnimKeyFrameSize) ) ) )
+
+
+RpHAnimAnimation *RpHAnimAnimationCreate(RwInt32 typeID, RwInt32 numFrames, RwInt32 flags, RwReal duration);
+RpHAnimAnimation *RpHAnimAnimationDestroy(RpHAnimAnimation *animation);
RpHAnimAnimation *RpHAnimAnimationStreamRead(RwStream *stream);
diff --git a/src/fakerw/rpskin.h b/src/fakerw/rpskin.h
index dd8551ae..1ffc9f27 100644
--- a/src/fakerw/rpskin.h
+++ b/src/fakerw/rpskin.h
@@ -2,7 +2,25 @@
#include <rphanim.h>
+//struct RpSkin;
+typedef rw::Skin RpSkin;
+
+struct RwMatrixWeights
+{
+ RwReal w0;
+ RwReal w1;
+ RwReal w2;
+ RwReal w3;
+};
+
RwBool RpSkinPluginAttach(void);
+RwUInt32 RpSkinGetNumBones( RpSkin *skin );
+const RwMatrixWeights *RpSkinGetVertexBoneWeights( RpSkin *skin );
+const RwUInt32 *RpSkinGetVertexBoneIndices( RpSkin *skin );
+const RwMatrix *RpSkinGetSkinToBoneMatrices( RpSkin *skin );
+
+RpSkin *RpSkinGeometryGetSkin( RpGeometry *geometry );
+
RpAtomic *RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, RpHAnimHierarchy *hierarchy );
RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic );
diff --git a/src/fakerw/rtcharse.h b/src/fakerw/rtcharse.h
new file mode 100644
index 00000000..10eb1f32
--- /dev/null
+++ b/src/fakerw/rtcharse.h
@@ -0,0 +1,14 @@
+#pragma once
+
+typedef rw::Charset RtCharset;
+typedef rw::Charset::Desc RtCharsetDesc;
+
+RwBool RtCharsetOpen(void);
+void RtCharsetClose(void);
+RtCharset *RtCharsetPrint(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y);
+RtCharset *RtCharsetPrintBuffered(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y, RwBool hideSpaces);
+RwBool RtCharsetBufferFlush(void);
+RtCharset *RtCharsetSetColors(RtCharset * charSet, const RwRGBA * foreGround, const RwRGBA * backGround);
+RtCharset *RtCharsetGetDesc(RtCharset * charset, RtCharsetDesc * desc);
+RtCharset *RtCharsetCreate(const RwRGBA * foreGround, const RwRGBA * backGround);
+RwBool RtCharsetDestroy(RtCharset * charSet);
diff --git a/src/fakerw/rtquat.h b/src/fakerw/rtquat.h
new file mode 100644
index 00000000..3cf15f5a
--- /dev/null
+++ b/src/fakerw/rtquat.h
@@ -0,0 +1,10 @@
+#pragma once
+
+typedef rw::Quat RtQuat;
+
+RwBool RtQuatConvertFromMatrix(RtQuat * const qpQuat, const RwMatrix * const mpMatrix);
+RtQuat *RtQuatRotate(RtQuat * quat, const RwV3d * axis, RwReal angle, RwOpCombineType combineOp);
+const RtQuat *RtQuatQueryRotate(const RtQuat *quat, RwV3d * unitAxis, RwReal * angle);
+RwV3d *RtQuatTransformVectors(RwV3d * vectorsOut, const RwV3d * vectorsIn, const RwInt32 numPoints, const RtQuat *quat);
+
+void RtQuatConvertToMatrix(const RtQuat * const qpQuat, RwMatrix * const mpMatrix);