Added *very* simple frame transformation.

This commit is contained in:
Angelo Papenhoff 2015-01-12 17:42:44 +01:00
parent 2ff25d928e
commit 8e181bcae3
3 changed files with 39 additions and 15 deletions

16
TODO
View File

@ -14,22 +14,20 @@ Clump & related:
texcoord texcoord
- implement plugins: - implement plugins:
Clump Clump
Collision R* Collision
Frame Frame
HAnim HAnim
Atomic Atomic
Right To Render ((Particles))
(Particles) R* Pipeline Set
Pipeline Set
Geometry Geometry
-Native Data -Native Data
(Morph) ((Morph))
-Skin -Skin
2dfx R* 2dfx
Material Material
Right To Render R* Reflection mat
Reflection mat R* Specular Mat
Specular Mat
UV Anim UV Anim
Texture Texture
(Sky Mipmap Val) (Sky Mipmap Val)

View File

@ -15,6 +15,7 @@ namespace Rw {
Frame::Frame(void) Frame::Frame(void)
{ {
this->parent = NULL;
this->child = NULL; this->child = NULL;
this->next = NULL; this->next = NULL;
this->root = NULL; this->root = NULL;
@ -24,6 +25,7 @@ Frame::Frame(void)
this->matrix[5] = 1.0f; this->matrix[5] = 1.0f;
this->matrix[10] = 1.0f; this->matrix[10] = 1.0f;
this->matrix[15] = 1.0f; this->matrix[15] = 1.0f;
this->dirty = true;
constructPlugins(); constructPlugins();
} }
@ -98,6 +100,33 @@ Frame::count(void)
return count; return count;
} }
void
Frame::updateLTM(void)
{
if(!this->dirty)
return;
Frame *parent = (Frame*)this->parent;
if(parent){
parent->updateLTM();
#define L(i,j) this->ltm[i*4+j]
#define A(i,j) parent->ltm[i*4+j]
#define B(i,j) this->matrix[i*4+j]
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
L(i,j) = A(0,j)*B(i,0)
+ A(1,j)*B(i,1)
+ A(2,j)*B(i,2)
+ A(3,j)*B(i,3);
#undef L
#undef A
#undef B
this->dirty = false;
}else{
memcpy(this->ltm, this->matrix, 16*4);
this->dirty = false;
}
}
static Frame* static Frame*
sizeCB(Frame *f, void *size) sizeCB(Frame *f, void *size)
{ {
@ -323,9 +352,9 @@ Clump::frameListStreamRead(Stream *stream, Frame ***flp, int32 *nf)
f->matrix[13] = buf.pos[1]; f->matrix[13] = buf.pos[1];
f->matrix[14] = buf.pos[2]; f->matrix[14] = buf.pos[2];
f->matrix[15] = 1.0f; f->matrix[15] = 1.0f;
f->matflag = buf.matflag;
if(buf.parent >= 0) if(buf.parent >= 0)
frameList[buf.parent]->addChild(f); frameList[buf.parent]->addChild(f);
f->matflag = buf.matflag;
} }
for(int32 i = 0; i < numFrames; i++) for(int32 i = 0; i < numFrames; i++)
frameList[i]->streamReadPlugins(stream); frameList[i]->streamReadPlugins(stream);
@ -447,12 +476,7 @@ Atomic::streamGetSize(void)
static void static void
readAtomicRights(Stream *stream, int32, void *, int32, int32) readAtomicRights(Stream *stream, int32, void *, int32, int32)
{ {
// uint32 version;
//stream->seek(-4);
//version = stream->readU32();
stream->read(atomicRights, 8); stream->read(atomicRights, 8);
// printf("atomicrights: %s %X %X %X\n", DebugFile, LibraryIDUnpackVersion(version), buffer[0], buffer[1]);
// printf("atomicrights: %X %X %X\n", LibraryIDUnpackVersion(version), buffer[0], buffer[1]);
} }
static void static void

View File

@ -27,6 +27,7 @@ struct Frame : PluginBase<Frame>, Object
// temporary // temporary
int32 matflag; int32 matflag;
bool dirty;
Frame(void); Frame(void);
Frame(Frame *f); Frame(Frame *f);
@ -35,6 +36,7 @@ struct Frame : PluginBase<Frame>, Object
Frame *removeChild(void); Frame *removeChild(void);
Frame *forAllChildren(Callback cb, void *data); Frame *forAllChildren(Callback cb, void *data);
int32 count(void); int32 count(void);
void updateLTM(void);
}; };
struct Image struct Image