implemented skinned peds, no cutscene hands yet

This commit is contained in:
aap
2020-04-23 22:25:18 +02:00
parent 6467e2003a
commit f03b4eec4c
49 changed files with 1869 additions and 301 deletions

View File

@ -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; }

View File

@ -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);

View File

@ -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 );

14
src/fakerw/rtcharse.h Normal file
View File

@ -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);

10
src/fakerw/rtquat.h Normal file
View File

@ -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);