From dc7b29fb37ae77e155dd82d9e6631df745fce99f Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 27 Jan 2010 20:46:36 +0000 Subject: [PATCH] model drawing from csqc git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8587 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/Main.qc | 24 ++++++++++++++++++++++++ data/qcsrc/client/csqc_builtins.qc | 11 +++++++++++ data/qcsrc/client/miscfunctions.qc | 25 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/data/qcsrc/client/Main.qc b/data/qcsrc/client/Main.qc index b685edb1a..3d2d93ff2 100644 --- a/data/qcsrc/client/Main.qc +++ b/data/qcsrc/client/Main.qc @@ -470,10 +470,24 @@ void ShotOrg_Spawn() debug_shotorg.view_ofs = '25 8 -8'; } +void DrawDebugModel() +{ + if(time - floor(time) > 0.5) + { + PolyDrawModel(self); + } + else + { + self.renderflags = 0; + R_AddEntity(self); + } +} + void GameCommand(string msg) { string s; float argc; + entity e; argc = tokenize_console(msg); if(argv(0) == "help" || argc == 0) @@ -566,6 +580,16 @@ void GameCommand(string msg) s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0); localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n"); } + else if(cmd == "spawn") { + s = argv(1); + e = spawn(); + precache_model(s); + setmodel(e, s); + setorigin(e, view_origin); + e.angles = view_angles; + e.draw = DrawDebugModel; + e.classname = "debugmodel"; + } else { print("Invalid command. For a list of supported commands, try cl_cmd help.\n"); diff --git a/data/qcsrc/client/csqc_builtins.qc b/data/qcsrc/client/csqc_builtins.qc index 6e2e53114..55dbe3f1c 100644 --- a/data/qcsrc/client/csqc_builtins.qc +++ b/data/qcsrc/client/csqc_builtins.qc @@ -155,12 +155,23 @@ float (float handle) search_getsize = #446; string (float handle, float num) search_getfilename = #447; +#define SPA_POSITION 0 +#define SPA_S_AXIS 1 +#define SPA_T_AXIS 2 +#define SPA_R_AXIS 3 +#define SPA_TEXCOORDS0 4 +#define SPA_LIGHTMAP0_TEXCOORDS 5 +#define SPA_LIGHTMAP_COLOR 6 float (entity e, float s) getsurfacenumpoints = #434; vector (entity e, float s, float n) getsurfacepoint = #435; vector (entity e, float s) getsurfacenormal = #436; string (entity e, float s) getsurfacetexture = #437; float (entity e, vector p) getsurfacenearpoint = #438; vector (entity e, float s, vector p) getsurfaceclippedpoint = #439; +vector(entity e, float s, float n, float a) getsurfacepointattribute = #486; +float(entity e, float s) getsurfacenumtriangles = #628; +vector(entity e, float s, float n) getsurfacetriangle = #629; + float (float a, float b) min = #94; float (float a, float b, float c) min3 = #94; diff --git a/data/qcsrc/client/miscfunctions.qc b/data/qcsrc/client/miscfunctions.qc index 432b5ebf0..d88af4203 100644 --- a/data/qcsrc/client/miscfunctions.qc +++ b/data/qcsrc/client/miscfunctions.qc @@ -473,3 +473,28 @@ void drawcolorcodedstring_expanding(vector position, string text, vector scale, if(cvar("menu_font_size_snapping_fix")) drawfontscale = '1 1 0'; } + +// this draws the triangles of a model DIRECTLY. Don't expect high performance, really... +void PolyDrawModel(entity e) +{ + float i_s, i_t; + float n_t; + vector tri; + string tex; + for(i_s = 0; ; ++i_s) + { + tex = getsurfacetexture(e, i_s); + if not(tex) + break; // this is beyond the last one + n_t = getsurfacenumtriangles(e, i_s); + for(i_t = 0; i_t < n_t; ++i_t) + { + tri = getsurfacetriangle(e, i_s, i_t); + R_BeginPolygon(tex, 0); + R_PolygonVertex(getsurfacepoint(e, i_s, tri_x), getsurfacepointattribute(e, i_s, tri_x, SPA_TEXCOORDS0), '1 1 1', 1); + R_PolygonVertex(getsurfacepoint(e, i_s, tri_y), getsurfacepointattribute(e, i_s, tri_y, SPA_TEXCOORDS0), '1 1 1', 1); + R_PolygonVertex(getsurfacepoint(e, i_s, tri_z), getsurfacepointattribute(e, i_s, tri_z, SPA_TEXCOORDS0), '1 1 1', 1); + R_EndPolygon(); + } + } +} -- 2.39.2