⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelcanvas.h

📁 wowmodelview魔兽世界的模型查看工具。下了看看吧
💻 H
字号:
#ifndef MODELCANVAS_H
#define MODELCANVAS_H

#include "wx/wxprec.h"
#ifdef __BORLANDC__
    #pragma hdrstop
#endif
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

// wx
#include "wx/glcanvas.h"
#include "wx/window.h"
#include "wx/treectrl.h"

// stl
#include <string>

// project headers
#include "model.h"
#include "wmo.h"
#include "util.h"
#include "viewcontrol.h"


class AnimControl;
class GifExporter;

// 100 fps?
#define TIME_STEP 10

enum {
	TIMER_ID = 1
};

enum {
	LT_AMBIENT,
	LT_DIRECTIONAL,
	LT_MODEL_ONLY
};

enum ModelType {
	MT_NORMAL,
	MT_CHAR,
	MT_WMO,
	MT_NPC
};

//class ModelCanvas;

struct Attachment {
	Attachment *parent;
	Displayable *model;

	std::vector<Attachment*> children;

	int id;
	int slot;
	float scale;

	Attachment(Attachment *parent, Displayable *model, int id, int slot, float scale = 1.0f): parent(parent), model(model), id(id), slot(slot), scale(scale)
	{}

	~Attachment()
	{
		delChildren();
		//delete model;
	}
	
	void setup();
	Attachment* addChild(const char *fn, int id, int slot, float scale = 1.0f);
	Attachment* addChild(Displayable *disp, int id, int slot, float scale = 1.0f);
	void delSlot(int slot);
	void delChildren();

	void draw(ModelCanvas *c);
	void drawParticles(ModelCanvas *c);
	void tick(float dt);
};


#ifdef wxUSE_GLCANVAS

class ModelCanvas: public wxGLCanvas
{
private:
	DECLARE_CLASS(ModelCanvas)
    DECLARE_EVENT_TABLE()
	
	float time, aspect, modelsize;

public:
	ModelCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
        const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxDefaultSize, long style = 0,
        const wxString& name = _T("ModelCanvas"), int *attribList = 0,
        const wxPalette& palette = wxNullPalette);

    ~ModelCanvas();

	// GUI Control Panels
	ViewControl *viewControl;	AnimControl *animControl;
	GifExporter *gifExporter;
	
	// Event Handlers
    void OnPaint(wxPaintEvent& WXUNUSED(event));
    void OnSize(wxSizeEvent& event);
    void OnEraseBackground(wxEraseEvent& event);
    void OnMouse(wxMouseEvent& event);
	void OnKey(wxKeyEvent &event);

	void OnIdle(wxIdleEvent& event);
    void OnTimer(wxTimerEvent& event);
	void tick();
	wxTimer timer;

	// OGL related functions
	void InitGL();
	void InitView();
	void ResetView();
	void ResetViewWMO(int id);
	void SetupProjection(float scale = 10.0f);
	void Render();

	// view:
	float fov;
	Vec3D vRot, vRot0;
	Vec3D vPos, vPos0;
	wxCoord mx, my;
	void Zoom(float f, bool rel = false); // f = amount to zoom, rel = relative to model or not

	// Lighting and colour vectors
	Vec4D lPos, lDif, lAmb;
	Vec3D bgcolor;
	Vec3D ltColor;
	Vec3D baseTrans;

	void ClearModel();
	Attachment* LoadModel(const char* fn);
	Attachment* LoadCharModel(const char* fn);
	void LoadWMO(std::string fn);
	//void TogglePause();
	
	// Various toggles
	bool init;
	bool drawModel, drawMask, drawBones, drawBounds, drawParticles, drawLightDir, drawBackground, drawSky;
	bool useCamera; //, useLights;
	bool viewingModel; // true if we're rendering the model
	bool bMouseLight; // true if the mouse is set to control the light pos, instead of model
	bool bSaving;

	int lightType;
	int ignoreMouse;

	ModelType modelType;

	Model *model;
	Model *skyModel;
	WMO *wmo;

	Attachment *root;
	Attachment *sky;
	//std::vector<Attachment> atts;

	void clearAttachments();
	int addAttachment(const char *model, Attachment *parent, int id, int slot);
	void deleteSlot(int slot);
	//void deleteAttachment(size_t idx);

	//void resetTime() { fglobaltime = 0; }
	// 	GLuint bgTexture;
	void loadBackground(wxString filename);
};
#endif


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -