[nexuiz-commits] r8587 - trunk/data/qcsrc/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jan 27 15:46:37 EST 2010


Author: div0
Date: 2010-01-27 15:46:36 -0500 (Wed, 27 Jan 2010)
New Revision: 8587

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/csqc_builtins.qc
   trunk/data/qcsrc/client/miscfunctions.qc
Log:
model drawing from csqc

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2010-01-27 20:44:41 UTC (rev 8586)
+++ trunk/data/qcsrc/client/Main.qc	2010-01-27 20:46:36 UTC (rev 8587)
@@ -470,10 +470,24 @@
 	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 @@
 			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");

Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc	2010-01-27 20:44:41 UTC (rev 8586)
+++ trunk/data/qcsrc/client/csqc_builtins.qc	2010-01-27 20:46:36 UTC (rev 8587)
@@ -155,13 +155,24 @@
 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;
 float (float a, float b, float c, float d) min4 = #94;

Modified: trunk/data/qcsrc/client/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/client/miscfunctions.qc	2010-01-27 20:44:41 UTC (rev 8586)
+++ trunk/data/qcsrc/client/miscfunctions.qc	2010-01-27 20:46:36 UTC (rev 8587)
@@ -473,3 +473,28 @@
 	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();
+		}
+	}
+}



More information about the nexuiz-commits mailing list