| 
		
	
		
			| 
					05-09-2010, 07:40 PM,  
				 |  
			| 
					
						|  | alex25   Senior Member
 
     
 | Posts: 531 Threads: 42
 Joined: Jun 2006
 |  |  
			| 
					but obviously the racing line doesn't represent the actual surface vdrift sees: ![[Image: suzuka-racingline.jpg]](http://caliban.lbl.gov/vdrift/suzuka-racingline.jpg) 
everything is red but the car still sinks in.
 
--alex--
				
				
				 |  
			|  |  
	
		
			| 
					05-09-2010, 09:11 PM,  
				 |  
			| 
					
						|  | NaN   Posting Freak
 
      
 | Posts: 2,024 Threads: 120
 Joined: Jan 2010
 |  |  
			| 
					OMG, hacking in real time. This is a quick and dirty draw mesh through patch control points implementation. You will see buggy patches if they are visible from the bottom. You can adjust the trackoffset to a height you like. 
Bug example:
 ![[Image: shot008fguzz.jpg]](http://e02.img-up.net/shot008fguzz.jpg)  
Code:
 Code: void ROADPATCH::AddRacinglineScenenode(SCENENODE & node, ROADPATCH * nextpatch,TEXTUREPTR racingline_texture, std::ostream & error_output)
 {
 if (!nextpatch)
 return;
 
 //Create racing line scenenode
 keyed_container <DRAWABLE>::handle drawhandle = node.GetDrawlist().normal_blend.insert(DRAWABLE());
 DRAWABLE & draw = node.GetDrawlist().normal_blend.get(drawhandle);
 
 draw.SetDiffuseMap(racingline_texture);
 draw.SetLit(false);
 draw.SetPartialTransparency(true);
 draw.SetColor(1, 1, 1, 0.5);
 draw.SetBlur(false);
 draw.SetCull(true, false);
 draw.SetVertArray(&racingline_vertexarray);
 
 float vcorners[3*16];
 float uvs[2*16];
 int bfaces[2*3*9];
 
 // vertices/uvs
 float trackoffset = 2;
 for(int y = 0, vi = 0, ui = 0; y < 4; y++)
 {
 for(int x = 0; x < 4; x++)
 {
 MATHVECTOR <float, 3> v = patch.GetPoint(x,y);
 v.Set(v[2],v[0],v[1]);
 vcorners[vi++] = v[0];
 vcorners[vi++] = v[1];
 vcorners[vi++] = v[2] + trackoffset;
 uvs[ui++] = x;
 uvs[ui++] = y;
 }
 }
 
 // faces
 int n = 3;
 int m = 4;
 for(int i = 0; i < n; i++)
 {
 for(int j = 0; j < n; j++)
 {
 bfaces[6*(i*n+j)+0] = (i+1)*m+j+1;
 bfaces[6*(i*n+j)+1] = (i+1)*m+j;
 bfaces[6*(i*n+j)+2] = i*m+j;
 bfaces[6*(i*n+j)+3] = i*m+j+1;
 bfaces[6*(i*n+j)+4] = (i+1)*m+j+1;
 bfaces[6*(i*n+j)+5] = i*m+j;
 }
 }
 
 racingline_vertexarray.SetFaces(bfaces, 2*3*9);
 racingline_vertexarray.SetVertices(vcorners, 3*16);
 racingline_vertexarray.SetTexCoordSets(1);
 racingline_vertexarray.SetTexCoords(0, uvs, 2*16);
 }
I'll try to write down the interpolated version tomorrow.
				
				
				 |  
			|  |  
	
		
			| 
					05-09-2010, 11:44 PM,  
				 |  
			| 
					
						|  | alex25   Senior Member
 
     
 | Posts: 531 Threads: 42
 Joined: Jun 2006
 |  |  
			| 
					awesome job, but it looks like it highlights the next good patch and not the bad one: ![[Image: badpatch.jpg]](http://caliban.lbl.gov/vdrift/badpatch.jpg)  
--alex--
				
				
				 |  
			|  |  
	
		
			| 
					05-10-2010, 05:50 AM,  
				 |  
			| 
					
						|  | NaN   Posting Freak
 
      
 | Posts: 2,024 Threads: 120
 Joined: Jan 2010
 |  |  
			| 
					Quote:highlights the next good patch 
The code simply draws the patches with 0.5 transparency. The highlighted section means there is some overlap(something wrong with the patches).
 
To visualize the patch segments:
 
Change uv-code to:
 Code: uvs[ui++] = y/3.0;uvs[ui++] = x/3.0;
Use this racingline.png:
 ![[Image: racinglinet87f.png]](http://s08.img-up.net/racinglinet87f.png) 
In game:
 ![[Image: shot0092hdj7.jpg]](http://j29.img-up.net/shot0092hdj7.jpg)  
				
				 |  
			|  |  |