mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 05:42:59 +05:30
Merge branch 'scuti/warnings' of scuti/lib3ddevil1 into master
This commit is contained in:
commit
6afa14c124
8
Makefile
8
Makefile
@ -3,17 +3,17 @@ TEX=demo-extracttexture
|
||||
MEX=demo-extractmesh
|
||||
|
||||
CC=gcc
|
||||
CFLAGS= -I"include"
|
||||
CFLAGS= -I"include" -Wall
|
||||
|
||||
all: pld texture mesh
|
||||
|
||||
pld: devil1pld.o devil1tex.o src/devil1geo.o
|
||||
pld: devil1pld.o devil1tex.o devil1geo.o
|
||||
$(CC) $^ demo/extractpld.c $(CFLAGS) -o $(PEX)
|
||||
|
||||
texture: devil1pld.o devil1tex.o src/devil1geo.o
|
||||
texture: devil1pld.o devil1tex.o devil1geo.o
|
||||
$(CC) $^ demo/extracttexture.c $(CFLAGS) -o $(TEX)
|
||||
|
||||
mesh: devil1pld.o devil1tex.o src/devil1geo.o
|
||||
mesh: devil1pld.o devil1tex.o devil1geo.o
|
||||
$(CC) $^ demo/extractmesh.c $(CFLAGS) -o $(MEX)
|
||||
|
||||
devil1pld.o: src/devil1pld.c
|
||||
|
@ -23,7 +23,7 @@ void extracttextures(const char *filedata,
|
||||
DEVIL1TEX.gettextures(t, i, filedata, filesize);
|
||||
for (j = 0; j < d -> texNumber; j++) {
|
||||
sprintf(fmt, "%s_%d.dds", filename, id);
|
||||
write(fmt, t[j].data, d -> textureSize);
|
||||
write(fmt, (char*)t[j].data, d -> textureSize);
|
||||
id++;
|
||||
}
|
||||
free(t);
|
||||
|
@ -73,39 +73,35 @@ struct Mesh {
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
// input: pointer to struct
|
||||
void (* const printheader) (struct Header*);
|
||||
|
||||
// input: pointer to struct
|
||||
void (* const printmeshheader)(struct MeshHeader*);
|
||||
|
||||
// input: pointer to struct
|
||||
void (* const printbatch) (struct Batch*);
|
||||
|
||||
// input: pointer to struct
|
||||
void (* const printcoordinate)(struct Coordinate*, unsigned int);
|
||||
|
||||
// input: pointer of pointer to struct, order, file data
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool (* const getmeshheader) (struct MeshHeader**,
|
||||
unsigned int i,
|
||||
const char * const);
|
||||
|
||||
// input: pointer to struct, offset of file data batch is at, file data
|
||||
bool (* const getbatch) (struct Batch*,
|
||||
unsigned int offset,
|
||||
const char * const);
|
||||
|
||||
// input: pointer to struct, order, file data
|
||||
bool (* const getmesh) (struct Mesh*,
|
||||
unsigned int i,
|
||||
const char* filename);
|
||||
const char*);
|
||||
} fn_devil1geo;
|
||||
extern fn_devil1geo const DEVIL1GEO;
|
||||
|
||||
static void printgheader(struct Header*);
|
||||
|
||||
static void printmeshheader(struct MeshHeader*);
|
||||
|
||||
static void printmeshbatch(struct Batch*);
|
||||
|
||||
static void printcoordinate(struct Coordinate*, unsigned int);
|
||||
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
|
||||
|
||||
static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const);
|
||||
|
||||
static bool getmesh(struct Mesh*, unsigned int i, const char* filename);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -14,23 +14,19 @@ struct PldHeader {
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
bool (* const getheader) (struct PldHeader*, const char*);
|
||||
int (* const sizeofsector)(struct PldHeader*, unsigned int, unsigned int);
|
||||
void (* const printheader) (struct PldHeader*);
|
||||
} fn_devil1pld;
|
||||
extern fn_devil1pld const DEVIL1PLD;
|
||||
|
||||
// input: pointer to a struct, contents of the .pld file.
|
||||
// * = pass by reference of a struct PldHeader
|
||||
static bool getpldh(struct PldHeader*, const char*);
|
||||
bool (* const getheader) (struct PldHeader*, const char*);
|
||||
|
||||
// input: pointer to header, index of offset, filesize
|
||||
// * = pass by reference of a struct PldHeader
|
||||
static int sizeofpldstruct(struct PldHeader*, unsigned int, unsigned int);
|
||||
int (* const sizeofsector)(struct PldHeader*, unsigned int, unsigned int);
|
||||
|
||||
// input: a pld header struct.
|
||||
// * = pass by reference of a struct PldHeader
|
||||
static void printpldh(struct PldHeader*);
|
||||
void (* const printheader) (struct PldHeader*);
|
||||
|
||||
} fn_devil1pld;
|
||||
extern fn_devil1pld const DEVIL1PLD;
|
||||
|
||||
#endif
|
||||
|
@ -39,16 +39,27 @@ struct TextureBatch {
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
// input: pointer to struct
|
||||
void (* const printheader) (struct TexturePack*);
|
||||
|
||||
// input: pointer to struct
|
||||
void (* const printbatchdesc)(struct TextureBatchDescriptor*);
|
||||
|
||||
// input: pointer of pointer to struct, order, file data, file size
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool (* const getbatchdesc) (struct TextureBatchDescriptor**,
|
||||
unsigned int,
|
||||
const char *,
|
||||
unsigned int);
|
||||
|
||||
// input: pointer of pointer to struct, order, file data, file size
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool (* const getbatch) (struct TextureBatch**,
|
||||
unsigned int,
|
||||
const char*,
|
||||
unsigned int);
|
||||
|
||||
// input: pointer to struct, order, file data, file size
|
||||
bool (* const gettextures) (struct Texture*,
|
||||
unsigned int,
|
||||
const char*,
|
||||
@ -56,34 +67,4 @@ typedef struct {
|
||||
} fn_devil1tex;
|
||||
extern fn_devil1tex const DEVIL1TEX;
|
||||
|
||||
// -------------------------------------------------------+
|
||||
// Functions
|
||||
// -------------------------------------------------------+
|
||||
|
||||
// Print Texture Pack Header.
|
||||
static void printtph(struct TexturePack*);
|
||||
|
||||
// Print Texture Batch Descriptor.
|
||||
static void printtbd(struct TextureBatchDescriptor*);
|
||||
|
||||
// Get Texture Batch Descriptor.
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
static bool gettexdescriptor(struct TextureBatchDescriptor**,
|
||||
unsigned int,
|
||||
const char *,
|
||||
unsigned int);
|
||||
|
||||
// Get Texture Batch.
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
static bool gettexbatch(struct TextureBatch**,
|
||||
unsigned int,
|
||||
const char*,
|
||||
unsigned int);
|
||||
|
||||
// Unpack Texture Batch
|
||||
static bool unpacktexbatch(struct Texture*,
|
||||
unsigned int,
|
||||
const char*,
|
||||
const unsigned int);
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,21 @@
|
||||
#include "devil1geo.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void printgheader(struct Header*);
|
||||
|
||||
static void printmeshheader(struct MeshHeader*);
|
||||
|
||||
static void printmeshbatch(struct Batch*);
|
||||
|
||||
static void printcoordinate(struct Coordinate*, unsigned int);
|
||||
|
||||
|
||||
static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
|
||||
|
||||
static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const);
|
||||
|
||||
static bool getmesh(struct Mesh*, unsigned int i, const char*);
|
||||
|
||||
fn_devil1geo const DEVIL1GEO = {printgheader,
|
||||
printmeshheader,
|
||||
printmeshbatch,
|
||||
@ -11,13 +26,13 @@ fn_devil1geo const DEVIL1GEO = {printgheader,
|
||||
|
||||
static void printgheader(struct Header *gh) {
|
||||
if (gh != NULL) {
|
||||
printf("pointer %x\n", gh);
|
||||
printf("pointer %p\n", gh);
|
||||
printf("number of meshes %x\n", gh -> numMesh);
|
||||
printf("unknown number B %x\n", gh -> unknownNumberB);
|
||||
printf("unknown number C %x\n", gh -> unknownNumberC);
|
||||
printf("unknown number D %x\n", gh -> unknownNumberD);
|
||||
printf("padding %x\n", gh -> padding);
|
||||
printf("unknown offset %x\n", gh -> unknownOffset);
|
||||
printf("padding %x\n", gh -> padding);
|
||||
printf("unknown offset %lx\n", gh -> unknownOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,11 +40,11 @@ static void printmeshheader(struct MeshHeader *mh) {
|
||||
if (mh == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("number of batches %x\n", mh -> numBatch);
|
||||
printf("number of batches %x\n", mh -> numBatch);
|
||||
printf("number of vertices %x\n", mh -> numVertex);
|
||||
printf("unknown %x\n", mh -> u);
|
||||
printf("batch offset %x\n", mh -> offsetBatches);
|
||||
printf("flags %x\n\n", mh -> flags);
|
||||
printf("unknown %x\n", mh -> u);
|
||||
printf("batch offset %lx\n", mh -> offsetBatches);
|
||||
printf("flags %lx\n\n", mh -> flags);
|
||||
}
|
||||
|
||||
static void printmeshbatch(struct Batch *b) {
|
||||
@ -40,12 +55,12 @@ static void printmeshbatch(struct Batch *b) {
|
||||
printf("number of vertices %x\n", bd -> numVertex);
|
||||
printf("unknown byte %x\n", bd -> uB);
|
||||
printf("padding %x\n", bd -> padding);
|
||||
printf("offsetPositions %x\n", bd -> offsetPositions);
|
||||
printf("offsetNormals %x\n", bd -> offsetNormals);
|
||||
printf("offsetUVs %x\n", bd -> offsetUVs);
|
||||
printf("offsetBoneIndexes %x\n", bd -> offsetBoneIndexes);
|
||||
printf("offsetBoneWeights %x\n", bd -> offsetBoneWeights);
|
||||
printf("offsets %x\n\n", bd -> offsets[0]);
|
||||
printf("offsetPositions %lx\n", bd -> offsetPositions);
|
||||
printf("offsetNormals %lx\n", bd -> offsetNormals);
|
||||
printf("offsetUVs %lx\n", bd -> offsetUVs);
|
||||
printf("offsetBoneIndexes %lx\n", bd -> offsetBoneIndexes);
|
||||
printf("offsetBoneWeights %lx\n", bd -> offsetBoneWeights);
|
||||
printf("offsets %lx\n\n", bd -> offsets[0]);
|
||||
printcoordinate(b -> vd.positions, 3);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
#include "devil1pld.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static bool getpldh(struct PldHeader*, const char*);
|
||||
|
||||
static int sizeofpldstruct(struct PldHeader*, unsigned int, unsigned int);
|
||||
|
||||
static void printpldh(struct PldHeader*);
|
||||
|
||||
fn_devil1pld const DEVIL1PLD = {getpldh, sizeofpldstruct, printpldh};
|
||||
|
||||
static bool getpldh(struct PldHeader *ph, const char *filedata) {
|
||||
@ -36,7 +42,7 @@ static void printpldh(struct PldHeader *ph) {
|
||||
return;
|
||||
}
|
||||
printf("number of offsets = %i\n", ph -> numOffset);
|
||||
printf("offsets = %x\n", ph -> offsets);
|
||||
printf("offsets = %p\n", ph -> offsets);
|
||||
unsigned int i;
|
||||
for (i = 0; i < ph -> numOffset; i++) {
|
||||
printf("offset %i = %x\n", i, ph -> offsets[i]);
|
||||
|
@ -2,6 +2,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// Print Texture Pack Header.
|
||||
static void printtph(struct TexturePack*);
|
||||
|
||||
// Print Texture Batch Descriptor.
|
||||
static void printtbd(struct TextureBatchDescriptor*);
|
||||
|
||||
// Get Texture Batch Descriptor.
|
||||
|
||||
static bool gettexdescriptor(struct TextureBatchDescriptor**,
|
||||
unsigned int,
|
||||
const char *,
|
||||
unsigned int);
|
||||
|
||||
// Get Texture Batch.
|
||||
|
||||
static bool gettexbatch(struct TextureBatch**,
|
||||
unsigned int,
|
||||
const char*,
|
||||
unsigned int);
|
||||
|
||||
// Unpack Texture Batch
|
||||
static bool unpacktexbatch(struct Texture*,
|
||||
unsigned int,
|
||||
const char*,
|
||||
const unsigned int);
|
||||
|
||||
fn_devil1tex const DEVIL1TEX = {printtph,
|
||||
printtbd,
|
||||
gettexdescriptor,
|
||||
|
Loading…
Reference in New Issue
Block a user