just wondering if anyone had or knew of a way to convert quakes 3d origin locations into 2d locations, its for a project im working on any help would be great thanks.
							
						
					Announcement
				
					Collapse
				
			
		
	
		
			
				No announcement yet.
				
			
				
	
need help with client coding
				
					Collapse
				
			
		
	X
- 
	
	
		
		
		
		
		
		
		
	
	
here is what ive made so far didnt test but still looking for help
Code:float WorldToScreen( vec3_t origin, float *ScreenX, float *ScreenY ) { float xzi, yzi; vec3_t local, transformed; vec3_t forward, right, up; #define xcenter ( r_refdef.vrect.width / 2.f ) #define ycenter ( r_refdef.vrect.height / 2.f ) AngleToVector (cl.viewangles , forward, right, up); VectorSubtract( origin, r_refdef.vieworg, local ); transformed[0] = DotProduct( local, right ); transformed[1] = DotProduct( local, up ); transformed[2] = DotProduct( local, forward ); if( transformed[2] < 0.01f ) return 0; xzi = xcenter / transformed[2] * ( 90.0f / (r_refdef.fov_x *100 )); yzi = ycenter / transformed[2] * ( 90.0f / (r_refdef.fov_y *100) ); *ScreenX = xcenter + ( xzi * transformed[0] ); *ScreenY = ycenter - ( yzi * transformed[1] ); return 1; }
Comment
 - 
	
	
		
		
		
		
		
		
		
	
	
I don't even understand the question. You ought to ask stuff like that at Inside3d.
x = x; y = y; z = 0 ?3d origin locations into 2d locationsQuakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.
So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...
Comment
 - 
	
	
		
		
		
		
		
		
		
	
	
i had the same idea as baker, the 1st thing came to mind was a radar.
get the azimuth, determine the distance, scale it, then render. but Z can be used in a 3d radar too
. I havent used this sort of math in 20 years so im not shy, just forgot what it smells like 
 BTW i searched the q3 source for WORLDTOSCREEN, none.
							
						
Comment
 - 
	
	
		
		
		
		
		
		
		
	
	
that is an converted WolrdtoScreen from the quake 3 sdk.
Code:int CG_WorldCoordToScreenCoordFloat( vec3_t worldCoord, FLOAT *XXX, FLOAT *YYY ) { int xcenter, ycenter; vec3_t local, transformed; vec3_t vfwd; vec3_t vright; vec3_t vup; float xzi; float yzi; xcenter = r_refdef.vrect.width / 2; ycenter = r_refdef.vrect.height / 2; AngleVectors (cl.viewangles , vfwd, vright, vup); VectorSubtract (worldCoord, r_refdef.vieworg, local); transformed[0] = DotProduct (local, vright); transformed[1] = DotProduct (local, vup); transformed[2] = DotProduct (local, vfwd); if (transformed[2] < 0.01) { return 0; } xzi = xcenter / transformed[2] * ( 90 / ( r_refdef.fov_x * 100.0f ) ); yzi = ycenter / transformed[2] * ( 90 / ( r_refdef.fov_y * 100.0f ) ); #define BOUND_VALUE( var, min, max ) if( ( var ) > ( max ) ) { ( var ) = ( max ); }; if( ( var ) < ( min ) ) { ( var ) =( min ); } BOUND_VALUE( *XXX, 0, 640 ); BOUND_VALUE( *YYY, 0, 480 ); *XXX = xcenter + xzi * transformed[0]; *YYY = ycenter - yzi * transformed[1]; return 1; }
Comment
 - 
	
	
		
		
		
		
		
		
		
	
	
Rich Whitehouse created a nifty lil radar in QuakeRoyale,
with a little tweaking could be converted to netQuake
might be usefull to ya..
While the radar is drawn client side, the server provides the entities that are shown on the radar, so for it to be useful the server mod/engine would have to be modified as well, ieCode://gl_screen.c extern float g_worldMins[3]; extern float g_worldMaxs[3]; void SCR_OrthographicWorldPoint(float *point, float *out, float w, float h, float d) { int i; float scales[3]; scales[0] = w; scales[1] = h; scales[2] = d; for (i = 0; i < 3; i++) { float ex; out[i] = point[i]; if (out[i] > g_worldMaxs[i]) { out[i] = g_worldMaxs[i]; } else if (out[i] < g_worldMins[i]) { out[i] = g_worldMins[i]; } ex = g_worldMaxs[i]-g_worldMins[i]; out[i] = ((out[i]-g_worldMins[i])/ex)*scales[i]; } out[1] = w-out[1]; } typedef struct radarObject_s { float pos[3]; float ang; double time; qboolean allied; qboolean valid; } radarObject_t; radarObject_t g_radarObjects[MAX_CLIENTS]; //rww void SCR_ClearRadar(void) { memset(g_radarObjects, 0, sizeof(g_radarObjects)); } //rww void SCR_AddRadarObject(int i, float *pos, float ang, qboolean allied) { radarObject_t *rad = &g_radarObjects[i]; float orthoWidth = scr_maporwidth.value; float orthoHeight = scr_maporheight.value; float orthoDepth = scr_mapordepth.value; //VectorCopy(pos, rad->pos); //put in automap coordinates now SCR_OrthographicWorldPoint(pos, rad->pos, orthoWidth, orthoHeight, orthoDepth); rad->ang = ang; rad->time = realtime+1.0; rad->valid = true; rad->allied = allied; } //rww void SCR_MapPosScaledOutput(float scale, float x, float y, float w, float h, float tx, float ty, float *in, float *out) { float orthoWidth = scr_maporwidth.value; float orthoHeight = scr_maporheight.value; float orthoDepth = scr_mapordepth.value; out[0] = ((in[0]-(tx*orthoWidth)) * (w/(orthoWidth*scale))) + x; out[1] = ((in[1]-(ty*orthoHeight)) * (h/(orthoHeight*scale))) + y; out[2] = in[2]; } //rww void SCR_DrawAngledMapTri(float scale, float x, float y, float w, float h, float tx, float ty, float tw, float th, float ang, float *pos, float *clr) { float transPos[3]; float triWidth = 32.0f*0.2f; float triHeight = 48.0f*0.2f; glPushMatrix(); SCR_MapPosScaledOutput(scale, x, y, w, h, tx, ty, pos, transPos); glTranslatef(transPos[0], transPos[1], transPos[2]); glRotatef((-ang)+90.0f, 0.0f, 0.0f, 1.0f); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDisable(GL_TEXTURE_2D); glBegin(GL_TRIANGLES); glColor4f(clr[0]*0.25f, clr[1]*0.25f, clr[2]*0.25f, clr[3]); glVertex3f(-(triWidth * 0.5f), (triHeight * 0.5f), 0.0f); glColor4f(clr[0]*1.0f, clr[1]*1.0f, clr[2]*1.0f, clr[3]); glVertex3f(0.0f, -(triHeight * 0.5f), 0.0f); glColor4f(clr[0]*0.6f, clr[1]*0.6f, clr[2]*0.6f, clr[3]); glVertex3f((triWidth * 0.5f), (triHeight * 0.5f), 0.0f); glEnd(); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glPopMatrix(); } //rww int g_automapState = 1; void SCR_AutomapToggle_f(void) { g_automapState++; if (g_automapState > 3) { g_automapState = 0; } } //rww float SCR_NudgeVal(float prev, float dest, float base) { if (prev == dest) { return prev; } if (fabsf(prev) < 0.001f) { if (prev < 0.0f) { prev = -0.001f; } else { prev = 0.001f; } } if (prev < dest) { prev += base*host_frametime; if (prev > dest) { prev = dest; } } else { prev -= base*host_frametime; if (prev < dest) { prev = dest; } } return prev; } //rww extern int window_width; extern int window_height; extern int hr_automap; extern qboolean g_hasAutomap; extern float Draw_ScaleBasedOnResW(float f); extern float Draw_ScaleBasedOnResH(float f); void SCR_DrawAutomap(void) { float fX, fY, fW, fH; float tX, tY, tW, tH; float orthoWidth = scr_maporwidth.value; float orthoHeight = scr_maporheight.value; float orthoDepth = scr_mapordepth.value; float mapPos[3]; float centerOffs; static float downScale = 0.15;//25f; static float mapWidth = 96.0f; static float mapHeight = 96.0f; float goalDS = 0.15f; float goalMW = 96.0f; float goalMH = 96.0f; float clr[4]; int i; if (g_automapState) { if (mapWidth < 8.0f) { mapWidth = 8.0f; } if (mapHeight < 8.0f) { mapHeight = 8.0f; } if (downScale < 0.01f) { downScale = 0.01f; } } else { if (mapWidth < 2.0f) { mapWidth = 0.0f; } if (mapHeight < 2.0f) { mapHeight = 0.0f; } if (downScale < 0.01f) { downScale = 0.01f; } } if (g_automapState == 0) { goalDS = 0.0f; goalMW = 0.0f; goalMH = 0.0f; } else if (g_automapState == 1) { goalDS = 0.15f; goalMW = 96.0f; goalMH = 96.0f; } else if (g_automapState == 2) { goalDS = 0.4f; goalMW = 200.0f; goalMH = 200.0f; } else { goalDS = 1.0f; goalMW = 400.0f; goalMH = 400.0f; } downScale = SCR_NudgeVal(downScale, goalDS, 0.4f); mapWidth = SCR_NudgeVal(mapWidth, goalMW, 256.0f); mapHeight = SCR_NudgeVal(mapHeight, goalMH, 256.0f); if (mapWidth < 0.1f || mapHeight < 0.1f) { return; } if (!g_hasAutomap) { return; } GL_Bind(hr_automap); SCR_OrthographicWorldPoint(cl.simorg, mapPos, orthoWidth, orthoHeight, orthoDepth); centerOffs = downScale*0.5f; tX = (mapPos[0]/orthoWidth)-centerOffs; tY = (mapPos[1]/orthoHeight)-centerOffs; tW = downScale; tH = downScale; if (tX < 0.0f) { tX = 0.0f; } if (tY < 0.0f) { tY = 0.0f; } if (tX+tW > 1.0f) { tX = 1.0f-tW; } if (tY+tH > 1.0f) { tY = 1.0f-tH; } if (gl_forceWideAspect.value) { fX = Draw_ScaleBasedOnResW((640.0f*(640.0f/480.0f))-(mapWidth+8.0f)); } else { fX = Draw_ScaleBasedOnResW(640.0f-(mapWidth+8.0f)); } fY = Draw_ScaleBasedOnResH(8.0f); fW = Draw_ScaleBasedOnResW(mapWidth); fH = Draw_ScaleBasedOnResH(mapHeight); if (gl_forceWideAspect.value) { float v = (480.0f/640.0f); glScissor(fX*((float)window_width/(float)vid.width)*v, ((float)vid.height-fY-fH)*((float)window_height/(float)vid.height), fW*((float)window_width/(float)vid.width)*v, fH*((float)window_height/(float)vid.height)); } else { glScissor(fX*((float)window_width/(float)vid.width), ((float)vid.height-fY-fH)*((float)window_height/(float)vid.height), fW*((float)window_width/(float)vid.width), fH*((float)window_height/(float)vid.height)); } glEnable(GL_SCISSOR_TEST); glShadeModel(GL_SMOOTH); glBegin(GL_QUADS); glTexCoord2f (tX, tY); glVertex2f (fX, fY); glTexCoord2f (tX + tW, tY); glVertex2f (fX+fW, fY); glTexCoord2f (tX + tW, tY + tH); glVertex2f (fX+fW, fY+fH); glTexCoord2f (tX, tY + tH); glVertex2f (fX, fY+fH); glEnd(); //self clr[0] = 0.0f; clr[1] = 1.0f; clr[2] = 0.0f; clr[3] = 1.0f; SCR_DrawAngledMapTri( downScale, fX, fY, fW, fH, tX, tY, tW, tH, cl.simangles[YAW], mapPos, clr); for (i = 0; i < MAX_CLIENTS; i++) { //other client blips radarObject_t *rad = &g_radarObjects[i]; if (rad->valid && rad->time > realtime) { glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); if (rad->allied) { clr[0] = 0.0f; clr[1] = 1.0f; clr[2] = 0.0f; } else { clr[0] = 1.0f; clr[1] = 0.0f; clr[2] = 0.0f; } clr[3] = rad->time-realtime; SCR_DrawAngledMapTri( downScale, fX, fY, fW, fH, tX, tY, tW, tH, rad->ang, rad->pos, clr); glEnable(GL_ALPHA_TEST); glDisable(GL_BLEND); } } //the outline glDisable(GL_TEXTURE_2D); glLineWidth(2.0f); glBegin(GL_LINES); glColor4f(0.0f, 0.15f, 0.0f, 1.0f); glVertex2f (fX, fY); glColor4f(0.0f, 0.45f, 0.0f, 1.0f); glVertex2f (fX+fW, fY); glVertex2f (fX+fW, fY); glColor4f(0.0f, 0.15f, 0.0f, 1.0f); glVertex2f (fX+fW, fY+fH); glVertex2f (fX+fW, fY+fH); glColor4f(0.0f, 0.45f, 0.0f, 1.0f); glVertex2f (fX, fY+fH); glVertex2f (fX, fY+fH); glColor4f(0.0f, 0.15f, 0.0f, 1.0f); glVertex2f (fX, fY); glEnd(); glEnable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glLineWidth(1.0f); glShadeModel(GL_FLAT); glDisable(GL_SCISSOR_TEST); } void SCR_UpdateScreen (void) { //... SCR_DrawTurtle (); SCR_DrawPause (); //radar here... SCR_DrawAutomap(); //rww SCR_CheckDrawCenterString (); Sbar_Draw (); //... //cl_parse.c// //entities's posistions come from the server...allied ents are on our team void CL_ParseRadar(qboolean allied) { int i = MSG_ReadByte(); while (i <= MAX_CLIENTS) { float pos[3]; float ang; pos[0] = MSG_ReadFloat(); pos[1] = MSG_ReadFloat(); pos[2] = MSG_ReadFloat(); ang = MSG_ReadFloat(); SCR_AddRadarObject(i-1, pos, ang, allied); i = MSG_ReadByte(); } }
//cl_parse.c
defs.qcCode:case svc_radar: CL_ParseRadar(false); break;
client.qc, void() PlayerPostThinkCode:void(entity self, entity other, float showall) updateradar = #90;
Code:if (self.radarUpdateTime < time) { if (royaleRoundState == RRSTATE_INPROGRESS && !self.kitanoCalled) { updateradar(self, world, 1); } else if (self.items & IT_RADAR) { updateradar(self, world, 0); } if (self.jointAlly != world) { updateradar(self, self.jointAlly, 1); if (self.jointAlly.jointAlly != self) { //they probably died or something self.jointAlly = world; updatealliance(self, self.jointAlly); } } self.radarUpdateTime = time + 1.0; }
Comment
 
Comment