Jump to content

The RuneLocus forum has been archived and does not accept new registrations.
Click here for more information, and click here to join the community on Discord.

Convert Any Revision Textures to 317 Textures


Pois0n
 Share

Recommended Posts

This code will convert any revision texture code to 317 textures. Obviously does not support textures with alpha so it'll look crap with hd textures. Any hd models using old textures (or other flat ones) will look good though. Works with osrs as well.
 

Code:

public void convertTexturesTo317(short[] textureIds, int[] texa, int[] texb, int[] texc, boolean osrs) {
		int set = 0;
		int set2 = 0;
		int max = osrs ? TextureLoaderOSRS.TEXTURE_COUNT : 50;
		if(textureIds != null) {
			textures_face_a = new int[numberOfTriangleFaces];
			textures_face_b = new int[numberOfTriangleFaces];
			textures_face_c = new int[numberOfTriangleFaces];
			
			for(int i = 0; i < numberOfTriangleFaces; i++) {
				if(textureIds[i] == -1 && face_render_type[i] == 2) {
					face_color[i] = 65535;
					face_render_type[i] = 0;
				}
				if(textureIds[i] >= max || textureIds[i] < 0 || textureIds[i] == 39) {
					face_render_type[i] = 0;
					continue;
				}
				face_render_type[i] = 2+set2;
				set2 += 4;
				int a = face_a[i];
				int b = face_b[i];
				int c = face_c[i];
				face_color[i] = textureIds[i];
				
				int texture_type = -1;
				if(texture_coordinates != null) {
					texture_type = texture_coordinates[i] & 0xff;
					if(texture_type != 0xff)
						if(texa[texture_type] >= camera_vertex_x.length || texb[texture_type] >= camera_vertex_y.length
							|| texc[texture_type] >= camera_vertex_z.length)
						texture_type = -1;
				}
                if(texture_type == 0xff)
                        texture_type = -1;
                
				textures_face_a[set] = texture_type == -1 ? a : texa[texture_type];
				textures_face_b[set] = texture_type == -1 ? b : texb[texture_type];
				textures_face_c[set++] = texture_type == -1 ? c : texc[texture_type];

			}
			numberOfTexturesFaces = set;
		}
	}

Best way to use is to put it on the bottom of your model reading method (model header); example for read525Model that lots of clients have:

Code:

face_color = triangleColours2;
		numberOfVerticeCoordinates = numVertices;
		numberOfTriangleFaces = numTriangles;
		verticesXCoordinate = vertexX;
		verticesYCoordinate = vertexY;
		verticesZCoordinate = vertexZ;
		face_a = facePoint1;
		face_b = facePoint2;
		face_c = facePoint3;
		convertTexturesTo317(textureIds, texTrianglesPoint1, texTrianglesPoint2, texTrianglesPoint3, false);

The osrs Boolean is something personal, it's not required. The max value is your max texture id (because else you're gonna get weird behavior).

Result:

080fd0f1fc5803fbc49c455569371f16.png

Edited by Sylvanas
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...