mirror of
https://github.com/aap/librw.git
synced 2025-12-18 16:39:51 +00:00
implemented leeds dff stream read
This commit is contained in:
@@ -400,7 +400,9 @@ Material::Material(void)
|
||||
{
|
||||
this->texture = NULL;
|
||||
memset(this->color, 0xFF, 4);
|
||||
surfaceProps[0] = surfaceProps[1] = surfaceProps[2] = 1.0f;
|
||||
surfaceProps.ambient = 1.0f;
|
||||
surfaceProps.specular = 1.0f;
|
||||
surfaceProps.diffuse = 1.0f;
|
||||
this->pipeline = NULL;
|
||||
this->refCount = 1;
|
||||
this->constructPlugins();
|
||||
@@ -412,9 +414,9 @@ Material::Material(Material *m)
|
||||
this->color[1] = m->color[1];
|
||||
this->color[2] = m->color[2];
|
||||
this->color[3] = m->color[3];
|
||||
this->surfaceProps[0] = m->surfaceProps[0];
|
||||
this->surfaceProps[1] = m->surfaceProps[1];
|
||||
this->surfaceProps[2] = m->surfaceProps[2];
|
||||
this->surfaceProps.ambient = m->surfaceProps.ambient;
|
||||
this->surfaceProps.specular = m->surfaceProps.specular;
|
||||
this->surfaceProps.diffuse = m->surfaceProps.diffuse;
|
||||
this->texture = m->texture;
|
||||
if(this->texture)
|
||||
this->texture->refCount++;
|
||||
@@ -463,15 +465,15 @@ Material::streamRead(Stream *stream)
|
||||
mat->color[2] = buf.color[2];
|
||||
mat->color[3] = buf.color[3];
|
||||
if(version < 0x30400){
|
||||
mat->surfaceProps[0] = 1.0f;
|
||||
mat->surfaceProps[1] = 1.0f;
|
||||
mat->surfaceProps[2] = 1.0f;
|
||||
mat->surfaceProps.ambient = 1.0f;
|
||||
mat->surfaceProps.specular = 1.0f;
|
||||
mat->surfaceProps.diffuse = 1.0f;
|
||||
}else{
|
||||
float32 surfaceProps[3];
|
||||
stream->read(surfaceProps, sizeof(surfaceProps));
|
||||
mat->surfaceProps[0] = surfaceProps[0];
|
||||
mat->surfaceProps[1] = surfaceProps[1];
|
||||
mat->surfaceProps[2] = surfaceProps[2];
|
||||
mat->surfaceProps.ambient = surfaceProps[0];
|
||||
mat->surfaceProps.specular = surfaceProps[1];
|
||||
mat->surfaceProps.diffuse = surfaceProps[2];
|
||||
}
|
||||
if(buf.textured){
|
||||
assert(findChunk(stream, ID_TEXTURE, &length, NULL));
|
||||
@@ -505,9 +507,9 @@ Material::streamWrite(Stream *stream)
|
||||
|
||||
if(rw::version >= 0x30400){
|
||||
float32 surfaceProps[3];
|
||||
surfaceProps[0] = this->surfaceProps[0];
|
||||
surfaceProps[1] = this->surfaceProps[1];
|
||||
surfaceProps[2] = this->surfaceProps[2];
|
||||
surfaceProps[0] = this->surfaceProps.ambient;
|
||||
surfaceProps[1] = this->surfaceProps.specular;
|
||||
surfaceProps[2] = this->surfaceProps.diffuse;
|
||||
stream->write(surfaceProps, sizeof(surfaceProps));
|
||||
}
|
||||
|
||||
|
||||
@@ -374,10 +374,10 @@ geometryStreamReadRsl(Stream *stream)
|
||||
for(int32 i = 0; i < g->numMaterials; i++){
|
||||
assert(findChunk(stream, ID_MATERIAL, NULL, NULL));
|
||||
g->materialList[i] = Material::streamRead(stream);
|
||||
// fucked somehow
|
||||
g->materialList[i]->surfaceProps[0] = 1.0f;
|
||||
g->materialList[i]->surfaceProps[1] = 1.0f;
|
||||
g->materialList[i]->surfaceProps[2] = 1.0f;
|
||||
// unimplemented by Rsl
|
||||
g->materialList[i]->surfaceProps.ambient = 1.0f;
|
||||
g->materialList[i]->surfaceProps.specular = 1.0f;
|
||||
g->materialList[i]->surfaceProps.diffuse = 1.0f;
|
||||
}
|
||||
|
||||
g->streamReadPlugins(stream);
|
||||
|
||||
@@ -791,17 +791,17 @@ clearMatFX(MatFX *matfx)
|
||||
}
|
||||
|
||||
void
|
||||
MatFX::setEffects(uint32 flags)
|
||||
MatFX::setEffects(uint32 type)
|
||||
{
|
||||
if(this->flags != 0 && this->flags != flags)
|
||||
if(this->type != 0 && this->type != type)
|
||||
clearMatFX(this);
|
||||
this->flags = flags;
|
||||
switch(flags){
|
||||
this->type = type;
|
||||
switch(type){
|
||||
case BUMPMAP:
|
||||
case ENVMAP:
|
||||
case DUAL:
|
||||
case UVTRANSFORM:
|
||||
this->fx[0].type = flags;
|
||||
this->fx[0].type = type;
|
||||
this->fx[1].type = NOTHING;
|
||||
break;
|
||||
|
||||
@@ -889,7 +889,7 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
*PLUGINOFFSET(MatFX*, object, offset) = matfx;
|
||||
matfx->setEffects(stream->readU32());
|
||||
|
||||
if(matfx->flags == MatFX::BUMPMAP && matFXGlobals.hack){
|
||||
if(matfx->type == MatFX::BUMPMAP && matFXGlobals.hack){
|
||||
stream->seek(12);
|
||||
return;
|
||||
}
|
||||
@@ -961,7 +961,7 @@ writeMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
{
|
||||
MatFX *matfx = *PLUGINOFFSET(MatFX*, object, offset);
|
||||
|
||||
stream->writeU32(matfx->flags);
|
||||
stream->writeU32(matfx->type);
|
||||
for(int i = 0; i < 2; i++){
|
||||
stream->writeU32(matfx->fx[i].type);
|
||||
switch(matfx->fx[i].type){
|
||||
|
||||
66
src/ps2.cpp
66
src/ps2.cpp
@@ -1515,24 +1515,24 @@ ps2MinSize(int32 psm, int32 flags, int32 *minw, int32 *minh)
|
||||
{
|
||||
*minh = 1;
|
||||
switch(psm){
|
||||
case 0x00:
|
||||
case 0x30:
|
||||
*minw = 2; // 32 bit
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x0A:
|
||||
case 0x32:
|
||||
case 0x3A:
|
||||
*minw = 4; // 16 bit
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
case 0x1B:
|
||||
case 0x24:
|
||||
case 0x2C:
|
||||
case 0x31:
|
||||
*minw = 8; // everything else
|
||||
case 0x00:
|
||||
case 0x30:
|
||||
*minw = 2; // 32 bit
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x0A:
|
||||
case 0x32:
|
||||
case 0x3A:
|
||||
*minw = 4; // 16 bit
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
case 0x1B:
|
||||
case 0x24:
|
||||
case 0x2C:
|
||||
case 0x31:
|
||||
*minw = 8; // everything else
|
||||
break;
|
||||
}
|
||||
if(flags & 0x2 && psm == 0x13){ // PSMT8
|
||||
@@ -1896,21 +1896,21 @@ registerNativeRaster(void)
|
||||
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);
|
||||
}
|
||||
|
||||
struct StreamRasterExt
|
||||
{
|
||||
int32 width;
|
||||
int32 height;
|
||||
int32 depth;
|
||||
uint16 rasterFormat;
|
||||
int16 type;
|
||||
uint32 tex0[2];
|
||||
uint32 tex1[2];
|
||||
uint32 miptbp1[2];
|
||||
uint32 miptbp2[2];
|
||||
uint32 texelSize;
|
||||
uint32 paletteSize;
|
||||
uint32 gsSize;
|
||||
uint32 mipmapVal;
|
||||
struct StreamRasterExt
|
||||
{
|
||||
int32 width;
|
||||
int32 height;
|
||||
int32 depth;
|
||||
uint16 rasterFormat;
|
||||
int16 type;
|
||||
uint32 tex0[2];
|
||||
uint32 tex1[2];
|
||||
uint32 miptbp1[2];
|
||||
uint32 miptbp2[2];
|
||||
uint32 texelSize;
|
||||
uint32 paletteSize;
|
||||
uint32 gsSize;
|
||||
uint32 mipmapVal;
|
||||
};
|
||||
|
||||
Texture*
|
||||
|
||||
@@ -199,11 +199,18 @@ struct Texture : PluginBase<Texture>
|
||||
};
|
||||
};
|
||||
|
||||
struct SurfaceProperties
|
||||
{
|
||||
float32 ambient;
|
||||
float32 specular;
|
||||
float32 diffuse;
|
||||
};
|
||||
|
||||
struct Material : PluginBase<Material>
|
||||
{
|
||||
Texture *texture;
|
||||
uint8 color[4];
|
||||
float32 surfaceProps[3];
|
||||
SurfaceProperties surfaceProps;
|
||||
Pipeline *pipeline;
|
||||
int32 refCount;
|
||||
|
||||
@@ -220,7 +227,7 @@ void registerMaterialRightsPlugin(void);
|
||||
|
||||
struct MatFX
|
||||
{
|
||||
enum Flags {
|
||||
enum {
|
||||
NOTHING = 0,
|
||||
BUMPMAP,
|
||||
ENVMAP,
|
||||
@@ -259,7 +266,7 @@ struct MatFX
|
||||
UVtransform uvtransform;
|
||||
};
|
||||
} fx[2];
|
||||
uint32 flags;
|
||||
uint32 type;
|
||||
|
||||
void setEffects(uint32 flags);
|
||||
int32 getEffectIndex(uint32 type);
|
||||
|
||||
Reference in New Issue
Block a user