mirror of
https://github.com/aap/librw.git
synced 2025-12-20 17:39:49 +00:00
implemented MaterialList struct
This commit is contained in:
@@ -129,7 +129,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
inst->numVertices = *(uint32*)p; p += 4;
|
||||
inst->numIndices = *(uint32*)p; p += 4;
|
||||
uint32 matid = *(uint32*)p; p += 4;
|
||||
inst->material = geometry->materialList[matid];
|
||||
inst->material = geometry->matList.materials[matid];
|
||||
inst->vertexShader = *(uint32*)p; p += 4;
|
||||
inst->primType = *(uint32*)p; p += 4;
|
||||
inst->indexBuffer = nil; p += 4;
|
||||
@@ -184,7 +184,7 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||
*(uint32*)p = inst->stride; p += 4;
|
||||
*(uint32*)p = inst->numVertices; p += 4;
|
||||
*(uint32*)p = inst->numIndices; p += 4;
|
||||
int32 matid = findPointer(inst->material, (void**)geometry->materialList, geometry->numMaterials);
|
||||
int32 matid = geometry->matList.findIndex(inst->material);
|
||||
*(int32*)p = matid; p += 4;
|
||||
*(uint32*)p = inst->vertexShader; p += 4;
|
||||
*(uint32*)p = inst->primType; p += 4;
|
||||
@@ -248,9 +248,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if(geo->geoflags & Geometry::NATIVE)
|
||||
if(geo->flags & Geometry::NATIVE)
|
||||
return;
|
||||
geo->geoflags |= Geometry::NATIVE;
|
||||
geo->flags |= Geometry::NATIVE;
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
MeshHeader *meshh = geo->meshHeader;
|
||||
geo->instData = header;
|
||||
@@ -295,11 +295,11 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if((geo->geoflags & Geometry::NATIVE) == 0)
|
||||
if((geo->flags & Geometry::NATIVE) == 0)
|
||||
return;
|
||||
assert(geo->instData != nil);
|
||||
assert(geo->instData->platform == PLATFORM_D3D8);
|
||||
geo->geoflags &= ~Geometry::NATIVE;
|
||||
geo->flags &= ~Geometry::NATIVE;
|
||||
geo->allocateData();
|
||||
geo->meshHeader->allocateIndices();
|
||||
|
||||
@@ -328,7 +328,7 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if((geo->geoflags & Geometry::NATIVE) == 0)
|
||||
if((geo->flags & Geometry::NATIVE) == 0)
|
||||
pipe->instance(atomic);
|
||||
assert(geo->instData != nil);
|
||||
assert(geo->instData->platform == PLATFORM_D3D8);
|
||||
@@ -350,8 +350,8 @@ ObjPipeline::ObjPipeline(uint32 platform)
|
||||
void
|
||||
defaultInstanceCB(Geometry *geo, InstanceData *inst)
|
||||
{
|
||||
inst->vertexShader = makeFVFDeclaration(geo->geoflags, geo->numTexCoordSets);
|
||||
inst->stride = getStride(geo->geoflags, geo->numTexCoordSets);
|
||||
inst->vertexShader = makeFVFDeclaration(geo->flags, geo->numTexCoordSets);
|
||||
inst->stride = getStride(geo->flags, geo->numTexCoordSets);
|
||||
|
||||
inst->vertexBuffer = createVertexBuffer(inst->numVertices*inst->stride,
|
||||
inst->vertexShader, D3DPOOL_MANAGED);
|
||||
@@ -363,7 +363,7 @@ defaultInstanceCB(Geometry *geo, InstanceData *inst)
|
||||
inst->numVertices, inst->stride);
|
||||
dst += 12;
|
||||
|
||||
if(geo->geoflags & Geometry::NORMALS){
|
||||
if(geo->flags & Geometry::NORMALS){
|
||||
instV3d(VERT_FLOAT3, dst,
|
||||
&geo->morphTargets[0].normals[3*inst->minVert],
|
||||
inst->numVertices, inst->stride);
|
||||
@@ -371,7 +371,7 @@ defaultInstanceCB(Geometry *geo, InstanceData *inst)
|
||||
}
|
||||
|
||||
inst->vertexAlpha = 0;
|
||||
if(geo->geoflags & Geometry::PRELIT){
|
||||
if(geo->flags & Geometry::PRELIT){
|
||||
inst->vertexAlpha = instColor(VERT_ARGB, dst, &geo->colors[4*inst->minVert],
|
||||
inst->numVertices, inst->stride);
|
||||
dst += 4;
|
||||
@@ -394,7 +394,7 @@ defaultUninstanceCB(Geometry *geo, InstanceData *inst)
|
||||
src, inst->numVertices, inst->stride);
|
||||
src += 12;
|
||||
|
||||
if(geo->geoflags & Geometry::NORMALS){
|
||||
if(geo->flags & Geometry::NORMALS){
|
||||
uninstV3d(VERT_FLOAT3,
|
||||
&geo->morphTargets[0].normals[3*inst->minVert],
|
||||
src, inst->numVertices, inst->stride);
|
||||
@@ -402,7 +402,7 @@ defaultUninstanceCB(Geometry *geo, InstanceData *inst)
|
||||
}
|
||||
|
||||
inst->vertexAlpha = 0;
|
||||
if(geo->geoflags & Geometry::PRELIT){
|
||||
if(geo->flags & Geometry::PRELIT){
|
||||
uninstColor(VERT_ARGB, &geo->colors[4*inst->minVert], src,
|
||||
inst->numVertices, inst->stride);
|
||||
src += 4;
|
||||
|
||||
@@ -32,7 +32,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
d3d::setRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(0xFF, 0x40, 0x40, 0x40));
|
||||
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
d3d::setRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
if(geo->geoflags & Geometry::PRELIT)
|
||||
if(geo->flags & Geometry::PRELIT)
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
|
||||
device->SetFVF(inst->vertexShader);
|
||||
|
||||
@@ -153,7 +153,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
inst->numIndex = *(uint32*)p; p += 4;
|
||||
inst->minVert = *(uint32*)p; p += 4;
|
||||
uint32 matid = *(uint32*)p; p += 4;
|
||||
inst->material = geometry->materialList[matid];
|
||||
inst->material = geometry->matList.materials[matid];
|
||||
inst->vertexAlpha = *(bool32*)p; p += 4;
|
||||
inst->vertexShader = nil; p += 4;
|
||||
inst->baseIndex = 0; p += 4;
|
||||
@@ -235,7 +235,7 @@ writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||
*(uint32*)p = inst->numIndex; p += 4;
|
||||
*(uint32*)p = inst->minVert; p += 4;
|
||||
int32 matid = findPointer(inst->material, (void**)geometry->materialList, geometry->numMaterials);
|
||||
int32 matid = geometry->matList.findIndex(inst->material);
|
||||
*(int32*)p = matid; p += 4;
|
||||
*(bool32*)p = inst->vertexAlpha; p += 4;
|
||||
*(uint32*)p = 0; p += 4; // vertex shader
|
||||
@@ -312,9 +312,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if(geo->geoflags & Geometry::NATIVE)
|
||||
if(geo->flags & Geometry::NATIVE)
|
||||
return;
|
||||
geo->geoflags |= Geometry::NATIVE;
|
||||
geo->flags |= Geometry::NATIVE;
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
MeshHeader *meshh = geo->meshHeader;
|
||||
geo->instData = header;
|
||||
@@ -365,11 +365,11 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if((geo->geoflags & Geometry::NATIVE) == 0)
|
||||
if((geo->flags & Geometry::NATIVE) == 0)
|
||||
return;
|
||||
assert(geo->instData != nil);
|
||||
assert(geo->instData->platform == PLATFORM_D3D9);
|
||||
geo->geoflags &= ~Geometry::NATIVE;
|
||||
geo->flags &= ~Geometry::NATIVE;
|
||||
geo->allocateData();
|
||||
geo->meshHeader->allocateIndices();
|
||||
|
||||
@@ -398,7 +398,7 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if((geo->geoflags & Geometry::NATIVE) == 0)
|
||||
if((geo->flags & Geometry::NATIVE) == 0)
|
||||
pipe->instance(atomic);
|
||||
assert(geo->instData != nil);
|
||||
assert(geo->instData->platform == PLATFORM_D3D9);
|
||||
@@ -439,7 +439,7 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
uint16 stride = 12;
|
||||
s->geometryFlags |= 0x2;
|
||||
|
||||
bool isPrelit = (geo->geoflags & Geometry::PRELIT) != 0;
|
||||
bool isPrelit = (geo->flags & Geometry::PRELIT) != 0;
|
||||
if(isPrelit){
|
||||
dcl[i].stream = 0;
|
||||
dcl[i].offset = stride;
|
||||
@@ -464,7 +464,7 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
stride += 8;
|
||||
}
|
||||
|
||||
bool hasNormals = (geo->geoflags & Geometry::NORMALS) != 0;
|
||||
bool hasNormals = (geo->flags & Geometry::NORMALS) != 0;
|
||||
if(hasNormals){
|
||||
dcl[i].stream = 0;
|
||||
dcl[i].offset = stride;
|
||||
@@ -540,7 +540,7 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
header->totalNumVertex,
|
||||
header->vertexStream[dcl[i].stream].stride);
|
||||
|
||||
if(geo->geoflags & Geometry::PRELIT){
|
||||
if(geo->flags & Geometry::PRELIT){
|
||||
for(i = 0; dcl[i].usage != D3DDECLUSAGE_COLOR || dcl[i].usageIndex != 0; i++)
|
||||
;
|
||||
uninstColor(vertFormatMap[dcl[i].type],
|
||||
@@ -560,7 +560,7 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
header->vertexStream[dcl[i].stream].stride);
|
||||
}
|
||||
|
||||
if(geo->geoflags & Geometry::NORMALS){
|
||||
if(geo->flags & Geometry::NORMALS){
|
||||
for(i = 0; dcl[i].usage != D3DDECLUSAGE_NORMAL || dcl[i].usageIndex != 0; i++)
|
||||
;
|
||||
uninstV3d(vertFormatMap[dcl[i].type],
|
||||
|
||||
@@ -37,7 +37,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
d3d::setRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(0xFF, 0x40, 0x40, 0x40));
|
||||
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
d3d::setRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
if(geo->geoflags & Geometry::PRELIT)
|
||||
if(geo->flags & Geometry::PRELIT)
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
d3d::flushCache();
|
||||
device->DrawIndexedPrimitive((D3DPRIMITIVETYPE)header->primType, inst->baseIndex,
|
||||
|
||||
@@ -197,9 +197,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if(geo->geoflags & Geometry::NATIVE)
|
||||
if(geo->flags & Geometry::NATIVE)
|
||||
return;
|
||||
geo->geoflags |= Geometry::NATIVE;
|
||||
geo->flags |= Geometry::NATIVE;
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
MeshHeader *meshh = geo->meshHeader;
|
||||
geo->instData = header;
|
||||
@@ -247,11 +247,11 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
{
|
||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||
Geometry *geo = atomic->geometry;
|
||||
if((geo->geoflags & Geometry::NATIVE) == 0)
|
||||
if((geo->flags & Geometry::NATIVE) == 0)
|
||||
return;
|
||||
assert(geo->instData != nil);
|
||||
assert(geo->instData->platform == PLATFORM_XBOX);
|
||||
geo->geoflags &= ~Geometry::NATIVE;
|
||||
geo->flags &= ~Geometry::NATIVE;
|
||||
geo->allocateData();
|
||||
geo->meshHeader->allocateIndices();
|
||||
|
||||
@@ -293,7 +293,7 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
{
|
||||
uint32 *vertexFmt = getVertexFmt(geo);
|
||||
if(*vertexFmt == 0)
|
||||
*vertexFmt = makeVertexFmt(geo->geoflags, geo->numTexCoordSets);
|
||||
*vertexFmt = makeVertexFmt(geo->flags, geo->numTexCoordSets);
|
||||
header->stride = getVertexFmtStride(*vertexFmt);
|
||||
header->vertexBuffer = new uint8[header->stride*header->numVertices];
|
||||
uint8 *dst = (uint8*)header->vertexBuffer;
|
||||
|
||||
Reference in New Issue
Block a user