mirror of
https://github.com/aap/librw.git
synced 2025-02-21 11:45:54 +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
|
Clump
|
||||||
R* Collision 0x253F2FA
|
R* Collision 0x253F2FA
|
||||||
Animation (old III dffs)
|
Animation (old III dffs)
|
||||||
|
Frame
|
||||||
|
Animation (old III dffs)
|
||||||
Atomic
|
Atomic
|
||||||
((Particles)) 0x118
|
((Particles)) 0x118
|
||||||
R* Pipeline Set 0x253F2F3
|
R* Pipeline 0x253F2F3
|
||||||
Skin (old III dffs)
|
Skin (old III dffs)
|
||||||
Geometry
|
Geometry
|
||||||
((Morph)) 0x105
|
((Morph)) 0x105
|
||||||
R* 2dfx 0x253F2F8
|
R* 2dfx 0x253F2F8
|
||||||
|
R* mystery xbox plugin 0x253F2F2
|
||||||
Material
|
Material
|
||||||
UV Anim 0x135
|
UV Anim 0x135
|
||||||
Texture
|
Texture
|
||||||
(Sky Mipmap Val) 0x110
|
(Sky Mipmap Val) 0x110
|
||||||
|
|
||||||
|
UV Anim Dict
|
||||||
|
|
||||||
|
Texture Dictionary
|
||||||
|
|
||||||
|
.anm/.ska
|
||||||
|
|
||||||
|
- properly implement Skin plugin
|
||||||
|
|
||||||
- PDS Pipelines
|
- PDS Pipelines
|
||||||
|
|
||||||
- ADC
|
- ADC
|
||||||
|
|
||||||
- uninstance geometry
|
- uninstance geometry (PS2, Xbox; OpenGL done)
|
||||||
|
|
||||||
- UV Anim Dict
|
|
||||||
|
|
||||||
- Texture Dictionary
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ main(int argc, char *argv[])
|
|||||||
rw::registerAtomicRightsPlugin();
|
rw::registerAtomicRightsPlugin();
|
||||||
rw::registerHAnimPlugin();
|
rw::registerHAnimPlugin();
|
||||||
gta::registerNodeNamePlugin();
|
gta::registerNodeNamePlugin();
|
||||||
|
gta::registerExtraNormalsPlugin();
|
||||||
gta::registerBreakableModelPlugin();
|
gta::registerBreakableModelPlugin();
|
||||||
gta::registerExtraVertColorPlugin();
|
gta::registerExtraVertColorPlugin();
|
||||||
rw::ps2::registerADCPlugin();
|
rw::ps2::registerADCPlugin();
|
||||||
|
@ -62,7 +62,7 @@ const char *toolkitchunks1[] = {
|
|||||||
"UV Animation Linear", "UV Animation Parameter"
|
"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",
|
"Pipeline Set", "Unused 5", "Unused 6", "Specular Material",
|
||||||
"Unused 8", "2dfx", "Extra Colors", "Collision Model",
|
"Unused 8", "2dfx", "Extra Colors", "Collision Model",
|
||||||
"Unused 12", "Environment Material", "Breakable", "Node Name",
|
"Unused 12", "Environment Material", "Breakable", "Node Name",
|
||||||
|
@ -189,6 +189,78 @@ registerBreakableModelPlugin(void)
|
|||||||
getSizeBreakableModel);
|
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
|
// Extra colors
|
||||||
|
|
||||||
int32 extraVertColorOffset;
|
int32 extraVertColorOffset;
|
||||||
@ -228,6 +300,7 @@ readExtraVertColors(Stream *stream, int32, void *object, int32 offset, int32)
|
|||||||
colordata->dayColors = new uint8[geometry->numVertices*4];
|
colordata->dayColors = new uint8[geometry->numVertices*4];
|
||||||
colordata->balance = 1.0f;
|
colordata->balance = 1.0f;
|
||||||
stream->read(colordata->nightColors, geometry->numVertices*4);
|
stream->read(colordata->nightColors, geometry->numVertices*4);
|
||||||
|
printf("extra colors\n");
|
||||||
if(geometry->colors)
|
if(geometry->colors)
|
||||||
memcpy(colordata->dayColors, geometry->colors,
|
memcpy(colordata->dayColors, geometry->colors,
|
||||||
geometry->numVertices*4);
|
geometry->numVertices*4);
|
||||||
|
@ -3,6 +3,7 @@ using namespace rw;
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
ID_EXTRANORMALS = 0x253f2f2,
|
||||||
ID_SPECMAT = 0x253f2f6,
|
ID_SPECMAT = 0x253f2f6,
|
||||||
ID_EXTRAVERTCOLORS = 0x253f2f9,
|
ID_EXTRAVERTCOLORS = 0x253f2f9,
|
||||||
ID_ENVMAT = 0x253f2fc,
|
ID_ENVMAT = 0x253f2fc,
|
||||||
@ -37,7 +38,12 @@ struct Breakable
|
|||||||
extern int32 breakableOffset;
|
extern int32 breakableOffset;
|
||||||
void registerBreakableModelPlugin(void);
|
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
|
struct ExtraVertColors
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ extern char *debugFile;
|
|||||||
inline uint32
|
inline uint32
|
||||||
libraryIDPack(int version, int build)
|
libraryIDPack(int version, int build)
|
||||||
{
|
{
|
||||||
if(version < 0x32000)
|
if(version <= 0x31000)
|
||||||
return version>>8;
|
return version>>8;
|
||||||
return (version-0x30000 & 0x3FF00) << 14 | (version&0x3F) << 16 |
|
return (version-0x30000 & 0x3FF00) << 14 | (version&0x3F) << 16 |
|
||||||
(build & 0xFFFF);
|
(build & 0xFFFF);
|
||||||
|
@ -239,7 +239,7 @@ static void
|
|||||||
readVertexFmt(Stream *stream, int32, void *object, int32 offset, int32)
|
readVertexFmt(Stream *stream, int32, void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
uint32 fmt = stream->readU32();
|
uint32 fmt = stream->readU32();
|
||||||
printf("vertexfmt: %X\n", fmt);
|
// printf("vertexfmt: %X\n", fmt);
|
||||||
*PLUGINOFFSET(uint32, object, offset) = fmt;
|
*PLUGINOFFSET(uint32, object, offset) = fmt;
|
||||||
// TODO: create and attach "vertex shader"
|
// TODO: create and attach "vertex shader"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user