model drawing from csqc
authordiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Wed, 27 Jan 2010 20:46:36 +0000 (20:46 +0000)
committerdiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Wed, 27 Jan 2010 20:46:36 +0000 (20:46 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8587 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

data/qcsrc/client/Main.qc
data/qcsrc/client/csqc_builtins.qc
data/qcsrc/client/miscfunctions.qc

index b685edb..3d2d93f 100644 (file)
@@ -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");
index 6e2e531..55dbe3f 100644 (file)
@@ -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;
index 432b5eb..d88af42 100644 (file)
@@ -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();
+               }
+       }
+}