Improved Mass Object rendering
This commit is contained in:
		
							parent
							
								
									145fe35393
								
							
						
					
					
						commit
						9eaca6c30c
					
				| @ -129,11 +129,9 @@ final class MassObjectRenderer { | |||||||
| 			final int slices, final int stacks) { | 			final int slices, final int stacks) { | ||||||
| 		 | 		 | ||||||
| 		double da, r, dz; | 		double da, r, dz; | ||||||
| 		double x, y, z, nz, nsign; | 		double x, y, z; | ||||||
| 		int i, j; | 		int i, j; | ||||||
| 		 | 		 | ||||||
| 		nsign = 1.0f; |  | ||||||
| 		 |  | ||||||
| 		da = 2.0f * PI / slices; | 		da = 2.0f * PI / slices; | ||||||
| 		dz = o.getLength() / stacks; | 		dz = o.getLength() / stacks; | ||||||
| 		 | 		 | ||||||
| @ -144,15 +142,10 @@ final class MassObjectRenderer { | |||||||
| 		for (j = 0; j < stacks; j++) { | 		for (j = 0; j < stacks; j++) { | ||||||
| 			r = getRadius(o, z); | 			r = getRadius(o, z); | ||||||
| 			double rNext = getRadius(o, z + dz); | 			double rNext = getRadius(o, z + dz); | ||||||
| 			if (j == stacks - 1) |  | ||||||
| 				rNext = 0; |  | ||||||
| 			 | 			 | ||||||
| 			if (j == stacks - 1) | 			if (j == stacks - 1) | ||||||
| 				rNext = 0; | 				rNext = 0; | ||||||
| 			 | 			 | ||||||
| 			// Z component of normal vectors |  | ||||||
| 			nz = -(rNext - r) / dz; |  | ||||||
| 			 |  | ||||||
| 			double s = 0.0f; | 			double s = 0.0f; | ||||||
| 			glBegin(gl, GL2.GL_QUAD_STRIP); | 			glBegin(gl, GL2.GL_QUAD_STRIP); | ||||||
| 			for (i = 0; i <= slices; i++) { | 			for (i = 0; i <= slices; i++) { | ||||||
| @ -163,21 +156,21 @@ final class MassObjectRenderer { | |||||||
| 					x = sin((i * da)); | 					x = sin((i * da)); | ||||||
| 					y = cos((i * da)); | 					y = cos((i * da)); | ||||||
| 				} | 				} | ||||||
| 				if (nsign == 1.0f) { | 				 | ||||||
| 					normal3d(gl, (x * nsign), (y * nsign), (nz * nsign)); | 				if (r == 0) | ||||||
|  | 					normal3d(gl, 0, 0, 1); | ||||||
|  | 				else | ||||||
|  | 					normal3d(gl, x, y, z); | ||||||
| 				TXTR_COORD(gl, s, t); | 				TXTR_COORD(gl, s, t); | ||||||
| 				glVertex3d(gl, (x * r), (y * r), z); | 				glVertex3d(gl, (x * r), (y * r), z); | ||||||
| 					normal3d(gl, (x * nsign), (y * nsign), (nz * nsign)); | 				 | ||||||
|  | 				if (rNext == 0) | ||||||
|  | 					normal3d(gl, 0, 0, -1); | ||||||
|  | 				else | ||||||
|  | 					normal3d(gl, x, y, z); | ||||||
| 				TXTR_COORD(gl, s, t + dt); | 				TXTR_COORD(gl, s, t + dt); | ||||||
| 				glVertex3d(gl, (x * rNext), (y * rNext), (z + dz)); | 				glVertex3d(gl, (x * rNext), (y * rNext), (z + dz)); | ||||||
| 				} else { | 				 | ||||||
| 					normal3d(gl, x * nsign, y * nsign, nz * nsign); |  | ||||||
| 					TXTR_COORD(gl, s, t); |  | ||||||
| 					glVertex3d(gl, (x * r), (y * r), z); |  | ||||||
| 					normal3d(gl, x * nsign, y * nsign, nz * nsign); |  | ||||||
| 					TXTR_COORD(gl, s, t + dt); |  | ||||||
| 					glVertex3d(gl, (x * rNext), (y * rNext), (z + dz)); |  | ||||||
| 				} |  | ||||||
| 				s += ds; | 				s += ds; | ||||||
| 			} // for slices | 			} // for slices | ||||||
| 			glEnd(gl); | 			glEnd(gl); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user