vcglib/apps/nexus/nexusmt.h

180 lines
3.7 KiB
C
Raw Normal View History

2004-09-17 17:25:59 +02:00
#ifndef NXS_NEXUS_MT_H
#define NXS_NEXUS_MT_H
2004-09-28 12:26:35 +02:00
#include <vector>
#include <queue>
#include <wrap/gui/frustum.h>
2004-09-17 17:25:59 +02:00
2004-12-13 01:44:48 +01:00
#include "nexusbase.h"
#include "queuepserver.h"
#include "borderserver.h"
#include "prefetch.h"
2004-09-17 17:25:59 +02:00
2004-09-28 12:26:35 +02:00
namespace nxs {
2004-09-17 17:25:59 +02:00
2004-10-14 15:42:33 +02:00
typedef std::vector<unsigned int> Frag;
2004-09-28 12:26:35 +02:00
struct Node {
std::vector<Node *> in;
std::vector<Node *> out;
std::vector<Frag> frags;
float error;
2004-12-15 09:46:16 +01:00
bool visited;
bool current;
2004-12-13 01:44:48 +01:00
// bool pushed;
2004-10-14 15:42:33 +02:00
};
struct TNode {
float error;
Node *node;
TNode(Node *n, float e): node(n), error(e) {}
bool operator<(const TNode &n) { return error < n.error; }
2004-09-28 12:26:35 +02:00
};
2004-10-15 18:45:27 +02:00
2004-10-14 15:42:33 +02:00
class Metric {
2004-09-28 12:26:35 +02:00
public:
2004-12-13 01:44:48 +01:00
std::vector<PatchInfo> *index;
2004-10-14 15:42:33 +02:00
2004-10-19 06:05:56 +02:00
float GetError(Node *node);
float GetError(Frag &frag);
virtual float GetError(unsigned int cell) = 0;
2004-10-14 15:42:33 +02:00
virtual void GetView() {}
2004-09-28 12:26:35 +02:00
};
2004-09-17 17:25:59 +02:00
2004-10-14 15:42:33 +02:00
class FlatMetric: public Metric {
2004-09-28 12:26:35 +02:00
public:
2004-10-14 15:42:33 +02:00
void GetView() {}
2004-10-19 06:05:56 +02:00
float GetError(unsigned int cell);
2004-10-14 15:42:33 +02:00
};
class DeltaMetric: public Metric {
public:
vcg::Point3f delta;
void GetView() {}
2004-10-19 06:05:56 +02:00
float GetError(unsigned int cell);
2004-10-14 15:42:33 +02:00
};
class FrustumMetric: public Metric {
public:
vcg::Frustumf frustum;
2004-09-30 02:27:42 +02:00
2004-09-28 12:26:35 +02:00
void GetView() { frustum.GetView(); }
2004-10-19 06:05:56 +02:00
float GetError(unsigned int cell);
2004-10-14 15:42:33 +02:00
};
2004-12-13 01:44:48 +01:00
/* class Policy {
2004-10-14 15:42:33 +02:00
public:
float error;
int ram_used;
int ram_size;
vector<PatchEntry> *entries;
void Init();
bool Expand(TNode &node);
void NodeVisited(Node *node);
2004-12-13 01:44:48 +01:00
};*/
2004-09-28 12:26:35 +02:00
2004-12-13 01:44:48 +01:00
class NexusMt: public NexusBase {
2004-09-17 17:25:59 +02:00
public:
2004-09-30 02:27:42 +02:00
//Vertex buffer object mode
2004-10-15 18:45:27 +02:00
enum Vbo { VBO_AUTO, //autodetect best size
2004-09-30 02:27:42 +02:00
VBO_OFF, //no vertex buffer object
VBO_FIXED }; //user supplied size
2004-10-14 15:42:33 +02:00
enum MetricKind { FRUSTUM, //screen error extraction
2004-11-28 02:23:26 +01:00
GEOMETRY, //geometry error extraction
2004-10-14 15:42:33 +02:00
DELTA }; //delta error
2004-09-30 02:27:42 +02:00
enum Mode { POINTS,
SMOOTH,
XRAY,
HIDDEN_LINE,
FLAT_WIRE,
2004-10-01 01:56:33 +02:00
FLAT,
2004-12-01 19:46:21 +01:00
PATCHES };
2004-09-30 02:27:42 +02:00
enum Component { COLOR = 0x1,
NORMAL = 0x2,
TEXTURE = 0x4,
DATA = 0x8};
2004-10-15 18:45:27 +02:00
Vbo vbo_mode;
2004-09-30 02:27:42 +02:00
2004-10-14 15:42:33 +02:00
Metric *metric;
2004-12-13 01:44:48 +01:00
float target_error;
2004-12-15 09:46:16 +01:00
vcg::Frustumf frustum;
unsigned int extraction_max; //total extraxtion (even culled parts)
unsigned int extraction_used;
unsigned int draw_max; //only visible parts
unsigned int draw_used;
unsigned int disk_max; //max not in ram loadable size
unsigned int disk_used;
2004-12-13 01:44:48 +01:00
2004-09-30 02:27:42 +02:00
Mode mode;
unsigned int components;
bool use_normals;
bool use_colors;
bool use_textures;
bool use_data;
2004-10-14 15:42:33 +02:00
//statistics:
unsigned int tri_rendered;
unsigned int tri_total;
2004-12-13 01:44:48 +01:00
2004-12-15 09:46:16 +01:00
vector<QueuePServer::Data *> todraw;
2004-12-13 01:44:48 +01:00
std::vector<PServer::Item> visited;
2004-12-15 09:46:16 +01:00
std::vector<Node *> sequence;
2004-12-14 15:10:22 +01:00
2004-12-13 01:44:48 +01:00
QueuePServer patches;
BorderServer borders;
2004-12-14 15:10:22 +01:00
Prefetch prefetch;
2004-09-30 02:27:42 +02:00
NexusMt();
~NexusMt();
2004-09-30 02:27:42 +02:00
2004-12-13 01:44:48 +01:00
bool Load(const std::string &filename);
void Close();
bool InitGL(Vbo mode = VBO_AUTO, unsigned int vbo_size = 64000000);
2004-09-30 02:27:42 +02:00
void Render();
2004-10-15 18:45:27 +02:00
2004-10-14 15:42:33 +02:00
void SetMetric(MetricKind kind);
void SetError(float error);
2004-12-13 01:44:48 +01:00
void SetExtractionSize(unsigned int ram_size);
void SetPrefetchSize(unsigned int size);
2004-10-15 18:45:27 +02:00
void SetVboSize(unsigned int vbo_size);
2004-10-14 15:42:33 +02:00
2004-11-28 02:23:26 +01:00
2004-09-30 02:27:42 +02:00
bool SetMode(Mode mode);
bool SetComponent(Component c, bool on);
bool SetComponents(unsigned int mask);
2004-10-30 22:17:03 +02:00
void Draw(std::vector<unsigned int> &selected);
2004-12-14 15:10:22 +01:00
void Draw(unsigned int cell, QueuePServer::Data &data);
2004-10-14 15:42:33 +02:00
void Extract(std::vector<unsigned int> &selected);
2004-09-17 17:25:59 +02:00
2004-09-28 12:26:35 +02:00
protected:
2004-12-13 01:44:48 +01:00
std::vector<Node> nodes;
bool Expand(TNode &node);
void NodeVisited(Node *node);
2004-09-30 02:27:42 +02:00
void LoadHistory();
void ClearHistory();
2004-10-14 15:42:33 +02:00
void VisitNode(Node *node, std::vector<TNode> &heap);
2004-12-15 09:46:16 +01:00
void UnvisitNode(Node *node, std::vector<TNode> &heap);
2004-09-28 12:26:35 +02:00
void Select(std::vector<unsigned int> &selected);
Patch &LoadPatch(unsigned int p);
2004-09-17 17:25:59 +02:00
};
}
2004-09-28 12:26:35 +02:00
2004-09-17 17:25:59 +02:00
#endif