Exemplo n.º 1
0
 public RuneObject(int x, int y, int z, int type, object mainClass, int bX, int bY, int id, GameObject objects, GameObject animatedObjects)
 {
     localX = x / 128f;
     height = y / 128f;
     localY = z / 128f;
     if (mainClass is InteractiveObject)
     {
         if ((mainClass as InteractiveObject).renderable is Projectile)
         {
             isGfx = true;
         }
     }
     shouldMove = true;
     objectType = type;
     if (type == 1)
     {
         wallObj = (WallObject)mainClass;
     }
     if (type == 2)
     {
         obj2 = (WallDecoration)mainClass;
     }
     if (type == 3)
     {
         obj3 = (GroundDecoration)mainClass;
     }
     if (type == 4)
     {
         obj4 = (Object4)mainClass;
     }
     if (type == 5)
     {
         obj5 = (InteractiveObject)mainClass;
     }
     baseX   = bX;
     baseY   = bY;
     modelId = id;
     if (id > 0)
     {
         def = ObjectDef.forID(id);
         if (def != null)
         {
             if (def.animId != -1)
             {
                 isAnimated = true;
             }
         }
     }
     myRuneMesh               = new RuneMesh();
     this.objectRoot          = objects;
     this.animatedObjectsRoot = animatedObjects;
 }
Exemplo n.º 2
0
    public void convertTextureCoordinates(RuneMesh model)
    {
        textureCoordU = new Vector3[model.numTriangles];
        textureCoordV = new Vector3[model.numTriangles];
//		int[] faces = new int[model.numTriangles];
//		for (int triangle = 0; triangle < model.numTriangles; triangle++)
//			faces [triangle] = triangle;
//		ParticleGenerator particles = ParticleGenerator.generateParticles (model, faces, model.numTriangles);
        for (int triangle = 0; triangle < model.numTriangles; triangle++)
        {
            float[] U = new float[3];
            float[] V = new float[3];
//			long l_2242_ = 0;
//			long l_2241_ = 0;
//			long l = 0;
//			int i_2249_ = 0;
//			int i_2248_ = 0;
//			int i_2247_ = 0;
//			int face = faces [triangle];
//			int textureId = (model.faceTexture == null ? (int)-1
//                        : (model.faceTexture [face] & 0xffff));
//
//			if (textureId != -1) {
//				int coord = (model.textureCoords != null ? (int)model.textureCoords [triangle]
//				             : -1);
//				if (coord == 32766) {
//					int a = model.faceUVIndexA [triangle] & 0xff;
//					int b = model.faceUVIndexB [triangle] & 0xff;
//					int c = model.faceUVIndexC [triangle] & 0xff;
//					a += (model.uvVertexOffset [model.triangleViewspaceX [face]]);
//					l_2242_ = a;
//					b += (model.uvVertexOffset [model.triangleViewspaceY [face]]);
//					l_2241_ = a;
//					c += (model.uvVertexOffset [model.triangleViewspaceZ [face]]);
//					l = a;
//					U [0] = model.texCoordU [a];
//					V [0] = model.texCoordV [a];
//					U [1] = model.texCoordU [b];
//					V [1] = model.texCoordV [b];
//					U [2] = model.texCoordU [c];
//					V [2] = model.texCoordV [c];
//				} else if (coord == -1) {
//					U [0] = 0.0F;
//					V [0] = 1.0F;
//					l_2242_ = 65535L;
//					U [1] = 1.0F;
//					V [1] = 1.0F;
//					l_2241_ = 131071L;
//					U [2] = 0.0F;
//					V [2] = 0.0F;
//					l = 196607L;
//				} else {
//					if (model.newFormat)
//						coord &= 0xffff;
//					else
//						coord &= 0xff;
//					sbyte type = model.textureRenderTypes [coord];
//					if (type == 0) {
//						short viewspaceX = model.triangleViewspaceX [triangle];
//						short viewspaceY = model.triangleViewspaceY [triangle];
//						short viewspaceZ = model.triangleViewspaceZ [triangle];
//						short texA = (short)model.textureTrianglePIndex [coord];
//						short texB = (short)model.textureTriangleMIndex [coord];
//						short texC = (short)model.textureTriangleNIndex [coord];
//						float pX = (float)model.verticesX [texA];
//						float pY = (float)model.verticesY [texA];
//						float pZ = (float)model.verticesZ [texA];
//						float mX = ((float)model.verticesX [texB] - pX);
//						float mY = ((float)model.verticesY [texB] - pY);
//						float mZ = ((float)model.verticesZ [texB] - pZ);
//						float nX = ((float)model.verticesX [texC] - pX);
//						float nY = ((float)model.verticesY [texC] - pY);
//						float nZ = ((float)model.verticesZ [texC] - pZ);
//						float iA = ((float)model.verticesX [viewspaceX] - pX);
//						float jA = ((float)model.verticesY [viewspaceX] - pY);
//						float kA = ((float)model.verticesZ [viewspaceX] - pZ);
//						float iB = ((float)model.verticesX [viewspaceY] - pX);
//						float jB = ((float)model.verticesY [viewspaceY] - pY);
//						float kB = ((float)model.verticesZ [viewspaceY] - pZ);
//						float iC = ((float)model.verticesX [viewspaceZ] - pX);
//						float jC = ((float)model.verticesY [viewspaceZ] - pY);
//						float kC = ((float)model.verticesZ [viewspaceZ] - pZ);
//						float horizontal = mY * nZ - mZ * nY;
//						float origin = mZ * nX - mX * nZ;
//						float vertical = mX * nY - mY * nX;
//						float a = nY * vertical - nZ * origin;
//						float b = nZ * horizontal - nX * vertical;
//						float c = nX * origin - nY * horizontal;
//						float d = 1.0F / (a * mX + b * mY + c * mZ);
//						U [0] = (a * iA + b * jA + c * kA) * d;
//						U [1] = (a * iB + b * jB + c * kB) * d;
//						U [2] = (a * iC + b * jC + c * kC) * d;
//						a = mY * vertical - mZ * origin;
//						b = mZ * horizontal - mX * vertical;
//						c = mX * origin - mY * horizontal;
//						d = 1.0F / (a * nX + b * nY + c * nZ);
//						V [0] = (a * iA + b * jA + c * kA) * d;
//						V [1] = (a * iB + b * jB + c * kB) * d;
//						V [2] = (a * iC + b * jC + c * kC) * d;
////						if (U [0] < 0 || U [1] < 0 || U [2] < 0 || V [0] < 0 || V [1] < 0 || V [2] < 0 || U [0] > 1 || U [1] > 1 || U [2] > 1 || V [0] > 1 || V [1] > 1 || V [2] > 1) {
////							//	Debug.Log (type + " : " + U[0] + " : " + U[1] + " : " + U[2] + " : " + V[0] + " : " + V[1] + " : " + V[2]);
////						}
//
//					} else {
//						short faceA = model.triangleViewspaceX [triangle];
//						short faceB = model.triangleViewspaceY [triangle];
//						short faceC = model.triangleViewspaceZ [triangle];
//						int vertexX = particles.verticesX [coord];
//						int vertexY = particles.verticesY [coord];
//						int vertexZ = particles.verticesZ [coord];
//						float[] fs = particles.particles [coord];
//						float[] aFloatArray9098 = new float[2];
//						aFloatArray9098 [0] = 0;
//						aFloatArray9098 [1] = 0;
//						sbyte i_2288_ = model.particleLifespanY [coord];
//						float f_2289_ = (model.particleLifespanZ [coord] / 256.0F);
//						if (type == 1) {
//							float f_2290_ = (model.particleDirectionZ [coord] / 1024.0F);
//							method3208 (model.verticesX [faceA], model.verticesY [faceA],
//							           model.verticesZ [faceA], vertexX, vertexY,
//							           vertexZ, fs, f_2290_, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [0] = aFloatArray9098 [0];
//							V [0] = aFloatArray9098 [1];
//							method3208 (model.verticesX [faceB], model.verticesY [faceB],
//							           model.verticesZ [faceB], vertexX, vertexY,
//							           vertexZ, fs, f_2290_, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [1] = aFloatArray9098 [0];
//							V [1] = aFloatArray9098 [1];
//							method3208 (model.verticesX [faceC], model.verticesY [faceC],
//							           model.verticesZ [faceC], vertexX, vertexY,
//							           vertexZ, fs, f_2290_, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [2] = aFloatArray9098 [0];
//							V [2] = aFloatArray9098 [1];
//							float f_2291_ = f_2290_ / 2.0F;
//							if ((i_2288_ & 0x1) == 0) {
//								if (U [1] - U [0] > f_2291_) {
//									U [1] -= f_2290_;
//									i_2248_ = 1;
//								} else if (U [0] - U [1] > f_2291_) {
//									U [1] += f_2290_;
//									i_2248_ = 2;
//								}
//								if (U [2] - U [0] > f_2291_) {
//									U [2] -= f_2290_;
//									i_2249_ = 1;
//								} else if (U [0] - U [2] > f_2291_) {
//									U [2] += f_2290_;
//									i_2249_ = 2;
//								}
//							} else {
//								if (V [1] - V [0] > f_2291_) {
//									V [1] -= f_2290_;
//									i_2248_ = 1;
//								} else if (V [0] - V [1] > f_2291_) {
//									V [1] += f_2290_;
//									i_2248_ = 2;
//								}
//								if (V [2] - V [0] > f_2291_) {
//									V [2] -= f_2290_;
//									i_2249_ = 1;
//								} else if (V [0] - V [2] > f_2291_) {
//									V [2] += f_2290_;
//									i_2249_ = 2;
//								}
//							}
//						} else if (type == 2) {
//							float f_2292_ = (model.texturePrimaryColor [coord] / 256.0F);
//							float f_2293_ = (model.textureSecondaryColor [coord] / 256.0F);
//							int i_2294_ = (model.verticesX [faceB] - model.verticesX [faceA]);
//							int i_2295_ = (model.verticesY [faceB] - model.verticesY [faceA]);
//							int i_2296_ = (model.verticesZ [faceB] - model.verticesZ [faceA]);
//							int i_2297_ = (model.verticesX [faceC] - model.verticesX [faceA]);
//							int i_2298_ = (model.verticesY [faceC] - model.verticesY [faceA]);
//							int i_2299_ = (model.verticesZ [faceC] - model.verticesZ [faceA]);
//							int i_2300_ = i_2295_ * i_2299_ - i_2298_ * i_2296_;
//							int i_2301_ = i_2296_ * i_2297_ - i_2299_ * i_2294_;
//							int i_2302_ = i_2294_ * i_2298_ - i_2297_ * i_2295_;
//							float f_2303_ = (64.0F / model.particleDirectionX [coord]);
//							float f_2304_ = (64.0F / model.particleDirectionY [coord]);
//							float f_2305_ = (64.0F / model.particleDirectionZ [coord]);
//							float f_2306_ = ((i_2300_ * fs [0]
//								+ i_2301_ * fs [1] + i_2302_
//								* fs [2]) / f_2303_);
//							float f_2307_ = ((i_2300_ * fs [3]
//								+ i_2301_ * fs [4] + i_2302_
//								* fs [5]) / f_2304_);
//							float f_2308_ = ((i_2300_ * fs [6]
//								+ i_2301_ * fs [7] + i_2302_
//								* fs [8]) / f_2305_);
//							i_2247_ = method3051 (f_2306_, f_2307_, f_2308_);
//							method3053 (model.verticesX [faceA], model.verticesY [faceA],
//							           model.verticesZ [faceA], vertexX, vertexY,
//							           vertexZ, i_2247_, fs, i_2288_, f_2289_,
//							            f_2292_, f_2293_, aFloatArray9098);
//							U [0] = aFloatArray9098 [0];
//							V [0] = aFloatArray9098 [1];
//							method3053 (model.verticesX [faceB], model.verticesY [faceB],
//							           model.verticesZ [faceB], vertexX, vertexY,
//							           vertexZ, i_2247_, fs, i_2288_, f_2289_,
//							            f_2292_, f_2293_, aFloatArray9098);
//							U [1] = aFloatArray9098 [0];
//							V [1] = aFloatArray9098 [1];
//							method3053 (model.verticesX [faceC], model.verticesY [faceC],
//							           model.verticesZ [faceC], vertexX, vertexY,
//							           vertexZ, i_2247_, fs, i_2288_, f_2289_,
//							            f_2292_, f_2293_, aFloatArray9098);
//							U [2] = aFloatArray9098 [0];
//							V [2] = aFloatArray9098 [1];
//						} else if (type == 3) {
//							method3052 (model.verticesX [faceA], model.verticesY [faceA],
//							           model.verticesZ [faceA], vertexX, vertexY,
//							           vertexZ, fs, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [0] = aFloatArray9098 [0];
//							V [0] = aFloatArray9098 [1];
//							method3052 (model.verticesX [faceB], model.verticesY [faceB],
//							           model.verticesZ [faceB], vertexX, vertexY,
//							           vertexZ, fs, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [1] = aFloatArray9098 [0];
//							V [1] = aFloatArray9098 [1];
//							method3052 (model.verticesX [faceC], model.verticesY [faceC],
//							           model.verticesZ [faceC], vertexX, vertexY,
//							           vertexZ, fs, i_2288_, f_2289_,
//							            aFloatArray9098);
//							U [2] = aFloatArray9098 [0];
//							V [2] = aFloatArray9098 [1];
//							if ((i_2288_ & 0x1) == 0) {
//								if (U [1] - U [0] > 0.5F) {
//									U [1]--;
//									i_2248_ = 1;
//								} else if (U [0] - U [1] > 0.5F) {
//									U [1]++;
//									i_2248_ = 2;
//								}
//								if (U [2] - U [0] > 0.5F) {
//									U [2]--;
//									i_2249_ = 1;
//								} else if (U [0] - U [2] > 0.5F) {
//									U [2]++;
//									i_2249_ = 2;
//								}
//							} else {
//								if (V [1] - V [0] > 0.5F) {
//									V [1]--;
//									i_2248_ = 1;
//								} else if (V [0] - V [1] > 0.5F) {
//									V [1]++;
//									i_2248_ = 2;
//								}
//								if (V [2] - V [0] > 0.5F) {
//									V [2]--;
//									i_2249_ = 1;
//								} else if (V [0] - V [2] > 0.5F) {
//									V [2]++;
//									i_2249_ = 2;
//								}
//							}
//						}
//					}
//					l_2242_ = i_2247_ << 16 | coord;
//					l_2241_ = i_2248_ << 19 | l_2242_;
//					l = i_2249_ << 19 | l_2242_;
//				}
//			} else {
//				l = 0L;
//				l_2241_ = 0L;
//				l_2242_ = 0L;
//			}
//						if (U [0] < 0 || U [1] < 0 || U [2] < 0 || V [0] < 0|| V [1] < 0 || V [2] < 0 || U [0] > 1 || U [1] > 1 || U [2] > 1 || V [0] > 1 || V [1] > 1 || V [2] > 1)
//						{
            U [0] = 0.0F;
            V [0] = 1.0F;
            U [1] = 1.0F;
            V [1] = 1.0F;
            U [2] = 0.0F;
            V [2] = 0.0F;
//						}
            textureCoordU [triangle] = new Vector3(U [0], U [1], U [2]);
            textureCoordV [triangle] = new Vector3(V [0], V [1], V [2]);
//			if (textureId >= 0 && textureId < Engine.atlasInfo.Length) {
//				textureCoordU [triangle] *= float.Parse (Engine.atlasInfo [textureId, 3]);
//				textureCoordV [triangle] *= float.Parse (Engine.atlasInfo [textureId, 4]);
//				textureCoordU [triangle] += new Vector3(float.Parse (Engine.atlasInfo [textureId, 1]),float.Parse (Engine.atlasInfo [textureId, 1]),float.Parse (Engine.atlasInfo [textureId, 1]));
//				textureCoordV [triangle] += new Vector3(float.Parse (Engine.atlasInfo [textureId, 2]),float.Parse (Engine.atlasInfo [textureId, 2]),float.Parse (Engine.atlasInfo [textureId, 2]));
//			}
        }
    }
Exemplo n.º 3
0
 public RuneObject(Entity aPlayer)
 {
     player     = aPlayer;
     isAnimated = true;
     myRuneMesh = new RuneMesh();
 }
Exemplo n.º 4
0
    static void GenUnityMeshs()
    {
        Debug.Log("Generating Unity Mesh's");
        MapManager.InitializeSolo();
        RS2Sharp.Texture.anIntArray1468 = new int[512];
        RS2Sharp.Texture.anIntArray1469 = new int[2048];
        RS2Sharp.Texture.SINE           = new int[2048];
        RS2Sharp.Texture.COSINE         = new int[2048];
        for (int i = 1; i < 512; i++)
        {
            RS2Sharp.Texture.anIntArray1468[i] = 32768 / i;
        }

        for (int j = 1; j < 2048; j++)
        {
            RS2Sharp.Texture.anIntArray1469[j] = 0x10000 / j;
        }

        for (int k = 0; k < 2048; k++)
        {
            RS2Sharp.Texture.SINE[k]   = (int)(65536D * System.Math.Sin((double)k * 0.0030679614999999999D));
            RS2Sharp.Texture.COSINE[k] = (int)(65536D * System.Math.Cos((double)k * 0.0030679614999999999D));
        }
        RS2Sharp.Texture.method372(0.80000000000000004D);
        byte[] gzipInputBuffer = new byte[0];
        for (int modelId = 0; modelId < 1000; ++modelId)
        {
            byte[] modelData = UnityClient.decompressors[1].decompress(modelId);
            if (modelData != null)
            {
                gzipInputBuffer = new byte[modelData.Length * 100];
                int i2 = 0;
                try {
                    Ionic.Zlib.GZipStream gzipinputstream = new Ionic.Zlib.GZipStream(
                        new MemoryStream(modelData), Ionic.Zlib.CompressionMode.Decompress);
                    do
                    {
                        if (i2 == gzipInputBuffer.Length)
                        {
                            throw new Exception("buffer overflow!");
                        }
                        int k = gzipinputstream.Read(gzipInputBuffer, i2,
                                                     gzipInputBuffer.Length - i2);
                        if (k == 0)
                        {
                            break;
                        }
                        i2 += k;
                    } while (true);
                } catch (IOException _ex) {
                    throw new Exception("error unzipping");
                }
                modelData = new byte[i2];
                System.Array.Copy(gzipInputBuffer, 0, modelData, 0, i2);

                Model model = new Model(modelData, modelId);

                RuneMesh rMesh = new RuneMesh();
                rMesh.Fill(model, true);

                Mesh mesh = new Mesh();
                rMesh.Render(mesh, false);

                if (mesh.vertexCount > 0)
                {
                    AssetDatabase.CreateAsset(mesh, "Assets/Resources/Meshes/" + modelId + ".asset");
                }
            }
            AssetDatabase.SaveAssets();
        }
    }