2004-07-02 15:00:02 +02:00
|
|
|
#ifndef NXS_PATCH_H
|
|
|
|
#define NXS_PATCH_H
|
|
|
|
|
|
|
|
#include <vcg/space/point3.h>
|
2004-07-02 19:42:43 +02:00
|
|
|
#include <iostream>
|
2004-07-02 15:00:02 +02:00
|
|
|
namespace nxs {
|
|
|
|
|
2004-10-01 01:56:33 +02:00
|
|
|
enum Signature { NXS_FACES = 0x00000001,
|
2004-09-30 02:27:42 +02:00
|
|
|
NXS_STRIP = 0x00000002,
|
|
|
|
NXS_COLORS = 0x00000010,
|
|
|
|
NXS_NORMALS_SHORT = 0x00000100,
|
|
|
|
NXS_NORMALS_FLOAT = 0x00000200,
|
|
|
|
NXS_TEXTURES_SHORT = 0x00001000,
|
|
|
|
NXS_TEXTURES_FLOAT = 0x00002000,
|
|
|
|
NXS_DATA8 = 0x00010000,
|
|
|
|
NXS_DATA16 = 0x00020000,
|
|
|
|
NXS_DATA32 = 0x00040000,
|
|
|
|
NXS_DATA64 = 0x00080000,
|
|
|
|
NXS_COMPRESSED = 0x10000000};
|
2004-09-17 17:25:59 +02:00
|
|
|
|
2004-07-02 15:00:02 +02:00
|
|
|
struct Chunk {
|
|
|
|
unsigned char p[4096];
|
|
|
|
};
|
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
|
2004-07-02 15:00:02 +02:00
|
|
|
class Patch {
|
|
|
|
public:
|
2004-09-16 16:25:16 +02:00
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
Patch(Signature signature, Chunk *s,
|
|
|
|
unsigned short nv, unsigned short nf);
|
2004-07-02 19:42:43 +02:00
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
void Init(Signature signature, unsigned short nv, unsigned short nf);
|
2004-07-02 15:00:02 +02:00
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
inline vcg::Point3f *VertBegin();
|
|
|
|
inline unsigned short *FaceBegin();
|
|
|
|
|
|
|
|
inline vcg::Point3f &Vert(unsigned short v);
|
|
|
|
inline unsigned short *Face(unsigned short f);
|
2004-09-30 02:27:42 +02:00
|
|
|
|
|
|
|
inline unsigned int *ColorBegin();
|
|
|
|
inline short *Norm16Begin();
|
|
|
|
inline short *Norm16(unsigned short v);
|
2004-10-01 01:56:33 +02:00
|
|
|
inline vcg::Point3f *Norm32Begin();
|
|
|
|
inline vcg::Point3f &Norm32(unsigned short v);
|
2004-09-17 17:25:59 +02:00
|
|
|
|
2004-09-16 16:25:16 +02:00
|
|
|
static unsigned int ChunkSize(Signature signature,
|
2004-09-17 17:25:59 +02:00
|
|
|
unsigned short nvert,
|
|
|
|
unsigned short nface);
|
2004-07-02 15:00:02 +02:00
|
|
|
|
2004-09-16 16:25:16 +02:00
|
|
|
static unsigned int ByteSize(Signature signature,
|
2004-09-17 17:25:59 +02:00
|
|
|
unsigned short nvert,
|
|
|
|
unsigned short nface);
|
|
|
|
|
2004-09-16 16:25:16 +02:00
|
|
|
|
|
|
|
Chunk *start;
|
2004-07-02 15:00:02 +02:00
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
unsigned short nv;
|
|
|
|
unsigned short nf;
|
|
|
|
|
|
|
|
float *vstart;
|
2004-09-30 02:27:42 +02:00
|
|
|
//these offset are from vstart!
|
2004-09-17 17:25:59 +02:00
|
|
|
unsigned short cstart;
|
|
|
|
unsigned short nstart;
|
|
|
|
unsigned short tstart;
|
|
|
|
unsigned short dstart;
|
2004-07-02 15:00:02 +02:00
|
|
|
};
|
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
inline vcg::Point3f *Patch::VertBegin() {
|
|
|
|
return (vcg::Point3f *)vstart;
|
|
|
|
}
|
|
|
|
inline unsigned short *Patch::FaceBegin() {
|
|
|
|
return (unsigned short *)start;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline vcg::Point3f &Patch::Vert(unsigned short v) {
|
|
|
|
return VertBegin()[v];
|
|
|
|
}
|
|
|
|
inline unsigned short *Patch::Face(unsigned short f) {
|
|
|
|
return FaceBegin() + f * 3;
|
|
|
|
}
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
inline unsigned int *Patch::ColorBegin() {
|
|
|
|
return (unsigned int *)(((char *)vstart) + cstart);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline short *Patch::Norm16Begin() {
|
|
|
|
return (short *)(((char *)vstart) + nstart);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline short *Patch::Norm16(unsigned short v) {
|
|
|
|
return Norm16Begin() + 4 * v;
|
|
|
|
}
|
|
|
|
|
2004-10-01 01:56:33 +02:00
|
|
|
inline vcg::Point3f *Patch::Norm32Begin() {
|
|
|
|
return (vcg::Point3f *)(((char *)vstart) + nstart);
|
|
|
|
}
|
|
|
|
inline vcg::Point3f &Patch::Norm32(unsigned short v) {
|
|
|
|
return Norm32Begin()[v];
|
|
|
|
}
|
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
} //namespace
|
|
|
|
|
2004-07-02 15:00:02 +02:00
|
|
|
#endif
|