mirror of
https://github.com/aap/librw.git
synced 2025-02-16 17:26:18 +00:00
implemented xbox extra normals plugin
This commit is contained in:
parent
3698d97c50
commit
c99e045e8d
19
TODO
19
TODO
@ -16,25 +16,32 @@ Clump & related:
|
||||
Clump
|
||||
R* Collision 0x253F2FA
|
||||
Animation (old III dffs)
|
||||
Frame
|
||||
Animation (old III dffs)
|
||||
Atomic
|
||||
((Particles)) 0x118
|
||||
R* Pipeline Set 0x253F2F3
|
||||
R* Pipeline 0x253F2F3
|
||||
Skin (old III dffs)
|
||||
Geometry
|
||||
((Morph)) 0x105
|
||||
R* 2dfx 0x253F2F8
|
||||
R* mystery xbox plugin 0x253F2F2
|
||||
Material
|
||||
UV Anim 0x135
|
||||
Texture
|
||||
(Sky Mipmap Val) 0x110
|
||||
|
||||
UV Anim Dict
|
||||
|
||||
Texture Dictionary
|
||||
|
||||
.anm/.ska
|
||||
|
||||
- properly implement Skin plugin
|
||||
|
||||
- PDS Pipelines
|
||||
|
||||
- ADC
|
||||
|
||||
- uninstance geometry
|
||||
|
||||
- UV Anim Dict
|
||||
|
||||
- Texture Dictionary
|
||||
- uninstance geometry (PS2, Xbox; OpenGL done)
|
||||
|
||||
|
@ -24,6 +24,7 @@ main(int argc, char *argv[])
|
||||
rw::registerAtomicRightsPlugin();
|
||||
rw::registerHAnimPlugin();
|
||||
gta::registerNodeNamePlugin();
|
||||
gta::registerExtraNormalsPlugin();
|
||||
gta::registerBreakableModelPlugin();
|
||||
gta::registerExtraVertColorPlugin();
|
||||
rw::ps2::registerADCPlugin();
|
||||
|
@ -62,7 +62,7 @@ const char *toolkitchunks1[] = {
|
||||
"UV Animation Linear", "UV Animation Parameter"
|
||||
};
|
||||
|
||||
const char *RSchunks[] = { "Unused 1", "Unused 2", "Unused 3",
|
||||
const char *RSchunks[] = { "Unused 1", "Unused 2", "Extra Normals",
|
||||
"Pipeline Set", "Unused 5", "Unused 6", "Specular Material",
|
||||
"Unused 8", "2dfx", "Extra Colors", "Collision Model",
|
||||
"Unused 12", "Environment Material", "Breakable", "Node Name",
|
||||
|
@ -189,6 +189,78 @@ registerBreakableModelPlugin(void)
|
||||
getSizeBreakableModel);
|
||||
}
|
||||
|
||||
// Extra normals
|
||||
|
||||
int32 extraNormalsOffset;
|
||||
|
||||
static void*
|
||||
createExtraNormals(void *object, int32 offset, int32)
|
||||
{
|
||||
*PLUGINOFFSET(float*, object, offset) = NULL;
|
||||
return object;
|
||||
}
|
||||
|
||||
static void*
|
||||
destroyExtraNormals(void *object, int32 offset, int32)
|
||||
{
|
||||
float *extranormals = *PLUGINOFFSET(float*, object, offset);
|
||||
delete[] extranormals;
|
||||
*PLUGINOFFSET(float*, object, offset) = NULL;
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
readExtraNormals(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
{
|
||||
Geometry *geo = (Geometry*)object;
|
||||
float **plgp = PLUGINOFFSET(float*, object, offset);
|
||||
if(*plgp)
|
||||
delete[] *plgp;
|
||||
float *extranormals = *plgp = new float[geo->numVertices*3];
|
||||
stream->read(extranormals, geo->numVertices*3*4);
|
||||
|
||||
// for(int i = 0; i < geo->numVertices; i++){
|
||||
// float *nx = extranormals+i*3;
|
||||
// float *n = geo->morphTargets[0].normals;
|
||||
// float len = n[0]*n[0] + n[1]*n[1] + n[2]*n[2];
|
||||
// printf("%f %f %f %f\n", n[0], n[1], n[2], len);
|
||||
// printf("%f %f %f\n", nx[0], nx[1], nx[2]);
|
||||
// }
|
||||
}
|
||||
|
||||
static void
|
||||
writeExtraNormals(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
{
|
||||
Geometry *geo = (Geometry*)object;
|
||||
float *extranormals = *PLUGINOFFSET(float*, object, offset);
|
||||
assert(extranormals != NULL);
|
||||
stream->write(extranormals, geo->numVertices*3*4);
|
||||
}
|
||||
|
||||
static int32
|
||||
getSizeExtraNormals(void *object, int32 offset, int32)
|
||||
{
|
||||
Geometry *geo = (Geometry*)object;
|
||||
if(*PLUGINOFFSET(float*, object, offset))
|
||||
return geo->numVertices*3*4;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
registerExtraNormalsPlugin(void)
|
||||
{
|
||||
extraNormalsOffset = Geometry::registerPlugin(sizeof(void*),
|
||||
ID_EXTRANORMALS,
|
||||
createExtraNormals,
|
||||
destroyExtraNormals,
|
||||
NULL);
|
||||
Geometry::registerPluginStream(ID_EXTRANORMALS,
|
||||
readExtraNormals,
|
||||
writeExtraNormals,
|
||||
getSizeExtraNormals);
|
||||
}
|
||||
|
||||
|
||||
// Extra colors
|
||||
|
||||
int32 extraVertColorOffset;
|
||||
@ -228,6 +300,7 @@ readExtraVertColors(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
colordata->dayColors = new uint8[geometry->numVertices*4];
|
||||
colordata->balance = 1.0f;
|
||||
stream->read(colordata->nightColors, geometry->numVertices*4);
|
||||
printf("extra colors\n");
|
||||
if(geometry->colors)
|
||||
memcpy(colordata->dayColors, geometry->colors,
|
||||
geometry->numVertices*4);
|
||||
|
@ -3,6 +3,7 @@ using namespace rw;
|
||||
|
||||
enum
|
||||
{
|
||||
ID_EXTRANORMALS = 0x253f2f2,
|
||||
ID_SPECMAT = 0x253f2f6,
|
||||
ID_EXTRAVERTCOLORS = 0x253f2f9,
|
||||
ID_ENVMAT = 0x253f2fc,
|
||||
@ -37,7 +38,12 @@ struct Breakable
|
||||
extern int32 breakableOffset;
|
||||
void registerBreakableModelPlugin(void);
|
||||
|
||||
// Extra vert colors
|
||||
// Extra normals (only on Xbox)
|
||||
|
||||
extern int32 extraNormalsOffset;
|
||||
void registerExtraNormalsPlugin(void);
|
||||
|
||||
// Extra vert colors (not on Xbox)
|
||||
|
||||
struct ExtraVertColors
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ extern char *debugFile;
|
||||
inline uint32
|
||||
libraryIDPack(int version, int build)
|
||||
{
|
||||
if(version < 0x32000)
|
||||
if(version <= 0x31000)
|
||||
return version>>8;
|
||||
return (version-0x30000 & 0x3FF00) << 14 | (version&0x3F) << 16 |
|
||||
(build & 0xFFFF);
|
||||
|
@ -239,7 +239,7 @@ static void
|
||||
readVertexFmt(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
{
|
||||
uint32 fmt = stream->readU32();
|
||||
printf("vertexfmt: %X\n", fmt);
|
||||
// printf("vertexfmt: %X\n", fmt);
|
||||
*PLUGINOFFSET(uint32, object, offset) = fmt;
|
||||
// TODO: create and attach "vertex shader"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user