comparison mm7_3.cpp @ 168:ee11772d0ad2

New sky (turn on -new_sky console command) cube textures are stored in /daata/skybox/%name%_xn.tga %name%%_xp.tga %name%_zn.tga etc
author Nomad
date Thu, 14 Feb 2013 13:58:34 +0200
parents 8ab4484c22e0
children d1dde383af89
comparison
equal deleted inserted replaced
144:8ab4484c22e0 168:ee11772d0ad2
6991 { 6991 {
6992 v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001); 6992 v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
6993 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); 6993 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28]));
6994 ++v28; 6994 ++v28;
6995 --v29; 6995 --v29;
6996 array_50A2B0[v28 + 49].flt_20 = v30; 6996 array_50A2B0[v28 + 49]._rhw = v30;
6997 } 6997 }
6998 while ( v29 ); 6998 while ( v29 );
6999 pFace = v46; 6999 pFace = v46;
7000 } 7000 }
7001 7001
7358 do 7358 do
7359 { 7359 {
7360 v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001); 7360 v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001);
7361 memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31])); 7361 memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31]));
7362 ++v31; 7362 ++v31;
7363 array_50A2B0[v31 + 49].flt_20 = v32; 7363 array_50A2B0[v31 + 49]._rhw = v32;
7364 v84 = v12->sTextureDeltaU + *(short *)(v30 - 40); 7364 v84 = v12->sTextureDeltaU + *(short *)(v30 - 40);
7365 array_50A2B0[v31 + 49].u = (double)v84 * v28; 7365 array_50A2B0[v31 + 49].u = (double)v84 * v28;
7366 v33 = v12->sTextureDeltaV + *(short *)v30; 7366 v33 = v12->sTextureDeltaV + *(short *)v30;
7367 v30 += 2; 7367 v30 += 2;
7368 v34 = v83-- == 1; 7368 v34 = v83-- == 1;
7721 goto LABEL_24; 7721 goto LABEL_24;
7722 } 7722 }
7723 return result; 7723 return result;
7724 } 7724 }
7725 7725
7726
7727
7728 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
7729 {
7730 #pragma pack(push, 1)
7731 struct TGAHeader
7732 {
7733 unsigned char tgaSkip;
7734 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette
7735 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
7736
7737 short colourmapstart; // first colour map entry in palette
7738 short colourmaplength; // number of colours in palette
7739 char colourmapbits; // number of bits per palette entry 15,16,24,32
7740
7741 //unsigned char tgaDontCare2[9];
7742 short xstart; // image x origin
7743 short ystart; // image y origin
7744
7745 unsigned short tgaWidth;
7746 unsigned short tgaHeight;
7747 unsigned char tgaBPP;
7748
7749 char descriptor; // image descriptor bits: 00vhaaaa
7750 // h horizontal flip
7751 // v vertical flip
7752 // a alpha bits
7753 };
7754 #pragma pack(pop)
7755
7756 if (out_width)
7757 *out_width = 0;
7758 if (out_height)
7759 *out_height = 0;
7760
7761 DWORD w;
7762 auto file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
7763 if (file == INVALID_HANDLE_VALUE)
7764 return nullptr;
7765
7766 TGAHeader header;
7767 ReadFile(file, &header, sizeof(header), &w, nullptr);
7768 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT);
7769
7770 if (header.tgaBPP != 24 || header.tgaType != 2)
7771 {
7772 CloseHandle(file);
7773 return nullptr;
7774 }
7775
7776 int imgSize = header.tgaWidth * header.tgaHeight * 3;
7777 auto pixels = new unsigned char[imgSize];
7778 ReadFile(file, pixels, imgSize, &w, nullptr);
7779 CloseHandle(file);
7780
7781 if (w != imgSize)
7782 {
7783 delete [] pixels;
7784 return nullptr;
7785 }
7786
7787 if (out_width)
7788 *out_width = header.tgaWidth;
7789 if (out_height)
7790 *out_height = header.tgaHeight;
7791
7792 auto pixels_16bit = new unsigned short[imgSize / 3];
7793 for (int i = 0; i < imgSize / 3; ++i)
7794 {
7795 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) |
7796 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) |
7797 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11);
7798 }
7799 delete [] pixels;
7800 return pixels_16bit;
7801 }
7802
7803 unsigned short *skybox_xn, *skybox_xp,
7804 *skybox_yn, *skybox_yp,
7805 *skybox_zn, *skybox_zp;
7806 int skybox_width, skybox_height;
7807 IDirect3DTexture2 *skybox_texture;
7808 IDirectDrawSurface4 *skybox_surface;
7809 bool Skybox_Initialize(const wchar_t *skybox_name)
7810 {
7811 wchar_t xn_filename[1024], xp_filename[1024],
7812 yn_filename[1024], yp_filename[1024],
7813 zn_filename[1024], zp_filename[1024];
7814 swprintf(xn_filename, L"%s_xn.tga", skybox_name); swprintf(xp_filename, L"%s_xp.tga", skybox_name);
7815 swprintf(yn_filename, L"%s_yn.tga", skybox_name); swprintf(yp_filename, L"%s_yp.tga", skybox_name);
7816 swprintf(zn_filename, L"%s_zn.tga", skybox_name); swprintf(zp_filename, L"%s_zp.tga", skybox_name);
7817
7818 int xn_width, xn_height;
7819 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height);
7820 if (!skybox_xn)
7821 return false;
7822
7823 int xp_width, xp_height;
7824 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height);
7825 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height)
7826 {
7827 delete [] skybox_xn;
7828 if (skybox_xp) delete [] skybox_xp;
7829 return false;
7830 }
7831
7832 int yn_width, yn_height;
7833 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height);
7834 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height)
7835 {
7836 delete [] skybox_xn;
7837 if (skybox_xp) delete [] skybox_xp;
7838 if (skybox_yn) delete [] skybox_yn;
7839 return false;
7840 }
7841
7842 int yp_width, yp_height;
7843 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height);
7844 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height)
7845 {
7846 delete [] skybox_xn;
7847 if (skybox_xp) delete [] skybox_xp;
7848 if (skybox_yn) delete [] skybox_yn;
7849 if (skybox_yp) delete [] skybox_yp;
7850 return false;
7851 }
7852
7853 int zn_width, zn_height;
7854 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height);
7855 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height)
7856 {
7857 delete [] skybox_xn;
7858 if (skybox_xp) delete [] skybox_xp;
7859 if (skybox_yn) delete [] skybox_yn;
7860 if (skybox_yp) delete [] skybox_yp;
7861 if (skybox_zn) delete [] skybox_zn;
7862 return false;
7863 }
7864
7865 int zp_width, zp_height;
7866 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height);
7867 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height)
7868 {
7869 delete [] skybox_xn;
7870 if (skybox_xp) delete [] skybox_xp;
7871 if (skybox_yn) delete [] skybox_yn;
7872 if (skybox_yp) delete [] skybox_yp;
7873 if (skybox_zn) delete [] skybox_zn;
7874 if (skybox_zp) delete [] skybox_zp;
7875 return false;
7876 }
7877
7878 skybox_width = xn_width;
7879 skybox_height = xn_height;
7880
7881
7882 if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture,
7883 false, false, pRenderer->uMinDeviceTextureDim))
7884 return false;
7885
7886 return true;
7887 }
7888
7889
7890 struct vector
7891 {
7892 float x, y, z;
7893 };
7894 struct matrix
7895 {
7896 float m[4][4];
7897 };
7898 void VectorNormalize(vector *v)
7899 {
7900 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z);
7901 v->x *= invmag;
7902 v->y *= invmag;
7903 v->z *= invmag;
7904 }
7905 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle)
7906 {
7907 memset(pout, 0, sizeof(matrix));
7908 pout->m[3][0] = 0;
7909 pout->m[3][1] = 0;
7910 pout->m[3][2] = 0;
7911 pout->m[3][3] = 1;
7912
7913 vector v;
7914 v.x = pv->x; v.y = pv->y; v.z = pv->z;
7915 VectorNormalize(&v);
7916
7917 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle);
7918 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z;
7919 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y;
7920 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z;
7921 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle);
7922 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x;
7923 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y;
7924 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x;
7925 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle);
7926 }
7927 void VectorTransform(const matrix *m, const vector *v, vector *out)
7928 {
7929 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0];
7930 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1];
7931 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2];
7932 }
7933
7934
7935 bool DrawSkyD3D_Skybox()
7936 {
7937 static bool initialized = false,
7938 initialization_failed = false;
7939 if (initialization_failed)
7940 return false;
7941
7942 static int last_camera_rot_y,
7943 last_camera_rot_x;
7944 if (!initialized)
7945 {
7946 if (!Skybox_Initialize(L"data/skybox/stars"))
7947 {
7948 initialization_failed = true;
7949 return false;
7950 }
7951 initialized = true;
7952
7953 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run
7954 last_camera_rot_x = pParty->sRotationX + 1;
7955 }
7956
7957 /*
7958 r(y) =
7959 cos y 0 sin y 0
7960 0 1 0 0
7961 -sin y 0 cos y 0
7962 0 0 0 1
7963
7964 x cos y - z sin y
7965 y
7966 x sin y + z cos y
7967 1
7968
7969
7970
7971 r(x) = // should be r(right) actually
7972 1 0 0 0
7973 0 cos x -sin x 0
7974 0 sin x cos x 0
7975 0 0 0 1
7976
7977
7978 x
7979 y cos x + z sin x
7980 -y sin x + z cos x
7981 1
7982
7983 */
7984
7985 if (last_camera_rot_y == pParty->sRotationY &&
7986 last_camera_rot_x == pParty->sRotationX)
7987 {
7988 draw:
7989 struct RenderVertexD3D3 v[6];
7990
7991 v[0].pos.x = pViewport->uScreenX;
7992 v[0].pos.y = pViewport->uScreenY;
7993 v[0].pos.z = 0.99989998;
7994 v[0].rhw = 1;
7995 v[0].diffuse = 0xFFFFFFFF;
7996 v[0].specular = 0;
7997 v[0].texcoord.x = 0;
7998 v[0].texcoord.y = 0;
7999
8000 v[1].pos.x = pViewport->uScreenX + pViewport->uScreenWidth;
8001 v[1].pos.y = pViewport->uScreenY + pViewport->uScreenHeight;
8002 v[1].pos.z = 0.99989998;
8003 v[1].rhw = 1;
8004 v[1].diffuse = 0xFFFFFFFF;
8005 v[1].specular = 0;
8006 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
8007 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
8008
8009 v[2].pos.x = pViewport->uScreenX + pViewport->uScreenWidth;
8010 v[2].pos.y = pViewport->uScreenY;
8011 v[2].pos.z = 0.99989998;
8012 v[2].rhw = 1;
8013 v[2].diffuse = 0xFFFFFFFF;
8014 v[2].specular = 0;
8015 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
8016 v[2].texcoord.y = 0;
8017
8018 memcpy(&v[3], &v[0], sizeof(*v));
8019
8020 v[4].pos.x = pViewport->uScreenX;
8021 v[4].pos.y = pViewport->uScreenY + pViewport->uScreenHeight;
8022 v[4].pos.z = 0.99989998;
8023 v[4].rhw = 1;
8024 v[4].diffuse = 0xFFFFFFFF;
8025 v[4].specular = 0;
8026 v[4].texcoord.x = 0;
8027 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
8028
8029 memcpy(&v[5], &v[1], sizeof(*v));
8030
8031 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
8032 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture);
8033 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
8034 //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
8035
8036 return true;
8037 }
8038
8039
8040 DDSURFACEDESC2 desc;
8041 desc.dwSize = sizeof(desc);
8042 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY))
8043 return false;
8044
8045 last_camera_rot_y = pParty->sRotationY;
8046 last_camera_rot_x = pParty->sRotationX;
8047
8048 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight;
8049 float fov_x = 3.141592f * (pOutdoorCamera->uCameraFovInDegrees + 0) / 360.0f;
8050 float fov_y = fov_x / aspect;
8051
8052 float ray_dx = fov_x / (float)pViewport->uScreenWidth,
8053 ray_dy = fov_y / (float)pViewport->uScreenHeight;
8054 float party_angle_x = 2 * 3.141592653589 * pParty->sRotationX / 2048.0,
8055 party_angle_y = 2 * 3.141592653589 * pParty->sRotationY / 2048.0;
8056 for (int y = 0; y < pViewport->uScreenHeight; ++y)
8057 for (int x = 0; x < pViewport->uScreenWidth; ++x)
8058 {
8059 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy;
8060 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx;
8061
8062 float _dir_x_ = 1,
8063 _dir_y_ = 0,
8064 _dir_z_ = 0;
8065
8066 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y
8067 //float dir_y_ = _dir_y_;
8068 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y);
8069
8070 //float dir_x = dir_x_; // rotation around x
8071 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x);
8072 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x);
8073
8074 vector right; // rotate around right actually to avoid space distortion
8075 right.x = /*dir_y * 0*/ - dir_z_ * 1;
8076 right.y = /*dir_z_ * 0 - dir_x_ * */0;
8077 right.z = dir_x_ * 1/* - dir_y_ * 0*/;
8078 //VectorNormalize(&right);
8079
8080 matrix rightMatrix;
8081 MatrixRotationAxis(&rightMatrix, &right, angle_x);
8082
8083 vector v1, v2;
8084 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_;
8085 VectorTransform(&rightMatrix, &v1, &v2);
8086
8087 float dir_x = v2.x,
8088 dir_y = v2.y,
8089 dir_z = v2.z;
8090
8091 float abs_dir_x = fabsf(dir_x),
8092 abs_dir_y = fabsf(dir_y),
8093 abs_dir_z = fabsf(dir_z);
8094
8095 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange
8096 if (abs_dir_x >= abs_dir_y)
8097 {
8098 if (abs_dir_x >= abs_dir_z)
8099 {
8100 if (dir_x >= 0)
8101 {
8102 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0
8103 float instersect_z = dir_z / (2.0f * dir_x);
8104
8105 float u = 1.0f - (instersect_z + 0.5f),
8106 v = 1.0f - (instersect_y + 0.5f);
8107
8108 int tx = u * (skybox_width - 1),
8109 ty = v * (skybox_height - 1);
8110
8111 color = skybox_xp[ty * skybox_width + tx];
8112 //color = ty * 0x1F / skybox_height;
8113 }
8114 else
8115 {
8116 float instersect_y = dir_y / (2.0f * dir_x);
8117 float instersect_z = dir_z / (2.0f * dir_x);
8118
8119 float u = 1.0f - (instersect_z + 0.5f),
8120 v = instersect_y + 0.5f;
8121
8122 int tx = u * (skybox_width - 1),
8123 ty = v * (skybox_height - 1);
8124
8125 color = skybox_xn[ty * skybox_width + tx];
8126 //color = tx * 0x1F / skybox_height;
8127 }
8128 }
8129 else if (dir_z >= 0)
8130 goto DIR_ZP;
8131 else
8132 goto DIR_ZN;
8133 }
8134 else if (abs_dir_y >= abs_dir_z)
8135 {
8136 if (dir_y >= 0)
8137 {
8138 float instersect_x = dir_x / (2.0f * dir_y);
8139 float instersect_z = dir_z / (2.0f * dir_y);
8140
8141 float u = instersect_x + 0.5f,
8142 v = instersect_z + 0.5f;
8143
8144 int tx = u * (skybox_width - 1),
8145 ty = v * (skybox_height - 1);
8146
8147 color = skybox_yp[ty * skybox_width + tx];
8148 //color = tx * 0x1F / skybox_height;
8149 }
8150 /*else should never be seen i guess
8151 {
8152 __debugbreak();
8153 // -y
8154 //Log::Warning(L"(%03u, %03u): -y", x, y);
8155 }*/
8156 }
8157 else if (dir_z >= 0)
8158 {
8159 DIR_ZP:
8160 // +z
8161 float instersect_x = dir_x / (2.0f * dir_z);
8162 float instersect_y = dir_y / (2.0f * dir_z);
8163 //float intersect_z = 0.5f;
8164
8165 float u = instersect_x + 0.5f,
8166 v = -instersect_y + 0.5f;
8167
8168 int tx = u * (skybox_width - 1),
8169 ty = v * (skybox_height - 1);
8170
8171 color = skybox_zp[ty * skybox_width + tx];
8172 }
8173 else
8174 {
8175 DIR_ZN:
8176 // -z
8177 float instersect_x = -dir_x / (2.0f * dir_z);
8178 float instersect_y = -dir_y / (2.0f * dir_z);
8179 //float intersect_z = -0.5f;
8180
8181 float u = 1.0f - instersect_x - 0.5f,
8182 v = -instersect_y + 0.5f;
8183
8184 int tx = u * (skybox_width - 1),
8185 ty = v * (skybox_height - 1);
8186
8187 color = skybox_zn[ty * skybox_width + tx];
8188 }
8189
8190 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color;
8191 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color;
8192 }
8193
8194 ErrD3D((skybox_surface)->Unlock(0));
8195 goto draw;
8196 }
8197
7726 //----- (00479543) -------------------------------------------------------- 8198 //----- (00479543) --------------------------------------------------------
7727 void Render::DrawSkyD3D() 8199 void Render::DrawSkyD3D()
7728 { 8200 {
7729 int v0; // esi@2 8201 int v0; // esi@2
7730 int v1; // eax@2 8202 int v1; // eax@2
7765 int v36; // [sp+14Ch] [bp-18h]@2 8237 int v36; // [sp+14Ch] [bp-18h]@2
7766 int v37; // [sp+154h] [bp-10h]@8 8238 int v37; // [sp+154h] [bp-10h]@8
7767 int v38; // [sp+158h] [bp-Ch]@1 8239 int v38; // [sp+158h] [bp-Ch]@1
7768 int v39; // [sp+15Ch] [bp-8h]@4 8240 int v39; // [sp+15Ch] [bp-8h]@4
7769 int v40; // [sp+160h] [bp-4h]@7 8241 int v40; // [sp+160h] [bp-4h]@7
8242
8243 extern bool new_sky;
8244 if (new_sky)
8245 {
8246 if (DrawSkyD3D_Skybox())
8247 return;
8248 }
7770 8249
7771 v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z) 8250 v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
7772 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY); 8251 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);
7773 v38 = pViewport->uScreenCenterY - 8252 v38 = pViewport->uScreenCenterY -
7774 pOutdoorCamera->int_fov_rad / (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) * 8253 pOutdoorCamera->int_fov_rad / (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) *
7775 (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z); 8254 (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);
7776 _this._48607B(&stru_8019C8); 8255 _this._48607B(&stru_8019C8);
7777 _this.ptr_38->_48694B(); 8256 _this.ptr_38->_48694B();
7778 _this.uTileBitmapID = pOutdoor->uSky_TextureID; 8257 _this.uTileBitmapID = pOutdoor->uSky_TextureID;
7779 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0); 8258 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? &pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
7780 if (pOutdoor->uSky_TextureID == -1) 8259 if (pOutdoor->uSky_TextureID == -1)
7781 return; 8260 return;
8261
7782 _this.field_58 = 0; 8262 _this.field_58 = 0;
7783 _this.uNumVertices = 4; 8263 _this.uNumVertices = 4;
7784 _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16); 8264 _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16);
7785 _this.v_18.y = 0; 8265 _this.v_18.y = 0;
7786 _this.v_18.z = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX + 16); 8266 _this.v_18.z = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX + 16);
7861 v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16); 8341 v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16);
7862 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8; 8342 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8;
7863 v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8; 8343 v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8;
7864 8344
7865 array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; 8345 array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
7866 array_50AC10[i].flt_20 = 1.0 / (double)(v17 / 65536); 8346 array_50AC10[i]._rhw = 1.0 / (double)(v17 / 65536);
7867 array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth); 8347 array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
7868 array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth); 8348 array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
7869 } 8349 }
7870 8350
7871 float t = (GetTickCount() % 96000) / 96000.0f; 8351 float t = (GetTickCount() % 96000) / 96000.0f;
7872 8352
7873 array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; 8353 array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
7874 array_50AC10[0].flt_20 = 1; 8354 array_50AC10[0]._rhw = 1;
7875 array_50AC10[0].u = 0; 8355 array_50AC10[0].u = 0;
7876 array_50AC10[0].v = 0 + t; 8356 array_50AC10[0].v = 0 + t;
7877 8357
7878 array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; 8358 array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
7879 array_50AC10[1].flt_20 = 1; 8359 array_50AC10[1]._rhw = 1;
7880 array_50AC10[1].u = 0; 8360 array_50AC10[1].u = 0;
7881 array_50AC10[1].v = 1 + t; 8361 array_50AC10[1].v = 1 + t;
7882 8362
7883 array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; 8363 array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
7884 array_50AC10[2].flt_20 = 1; 8364 array_50AC10[2]._rhw = 1;
7885 array_50AC10[2].u = 1; 8365 array_50AC10[2].u = 1;
7886 array_50AC10[2].v = 0 + t; 8366 array_50AC10[2].v = 0 + t;
7887 8367
7888 array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; 8368 array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
7889 array_50AC10[3].flt_20 = 1; 8369 array_50AC10[3]._rhw = 1;
7890 array_50AC10[3].u = 1; 8370 array_50AC10[3].u = 1;
7891 array_50AC10[3].v = 1 + t; 8371 array_50AC10[3].v = 1 + t;
7892 pRenderer->DrawStrip(_this.uNumVertices, &_this, 8372 pRenderer->DrawStrip(_this.uNumVertices, &_this,
7893 pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); 8373 pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]);
7894 return; 8374 return;
9292 v3 = (double)pViewport->uScreenCenterY; 9772 v3 = (double)pViewport->uScreenCenterY;
9293 v4 = 0; 9773 v4 = 0;
9294 v5 = uNumVertices; 9774 v5 = uNumVertices;
9295 do 9775 do
9296 { 9776 {
9297 v6 = v1 * array_507D30[v4].flt_20; 9777 v6 = v1 * array_507D30[v4]._rhw;
9298 v7 = v6 * array_507D30[v4].vWorldViewPosition.y; 9778 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
9299 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4])); 9779 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
9300 array_50AC10[v4].vWorldViewProjX = v2 - v7; 9780 array_50AC10[v4].vWorldViewProjX = v2 - v7;
9301 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z; 9781 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
9302 ++v4; 9782 ++v4;
18510 { 18990 {
18511 double v1; // st7@1 18991 double v1; // st7@1
18512 double v2; // st7@1 18992 double v2; // st7@1
18513 18993
18514 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001); 18994 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001);
18515 v->flt_20 = v1; 18995 v->_rhw = v1;
18516 v2 = v1 * (double)pOutdoorCamera->int_fov_rad; 18996 v2 = v1 * (double)pOutdoorCamera->int_fov_rad;
18517 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y; 18997 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y;
18518 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z; 18998 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z;
18519 } 18999 }
18520 19000