Mercurial > mm7
comparison Render.cpp @ 106:efece1632349
8.02.13
author | Ritor1 |
---|---|
date | Fri, 08 Feb 2013 18:33:54 +0600 |
parents | 56e11be29db1 |
children | 23b213c3f8e1 |
comparison
equal
deleted
inserted
replaced
105:56e11be29db1 | 106:efece1632349 |
---|---|
1564 } | 1564 } |
1565 v69 = v16 - 1; | 1565 v69 = v16 - 1; |
1566 ptr_801A08 = pVerticesSR_806210; | 1566 ptr_801A08 = pVerticesSR_806210; |
1567 ptr_801A04 = pVerticesSR_801A10; | 1567 ptr_801A04 = pVerticesSR_801A10; |
1568 v126 = v69; | 1568 v126 = v69; |
1569 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 ) | 1569 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
1570 { | 1570 { |
1571 for ( i = v69; i >= 1; --i ) | 1571 for ( i = v69; i >= 1; --i ) |
1572 { | 1572 { |
1573 //v70 = i; | 1573 //v70 = i; |
1574 v71 = terrain_76D7C8[i];//88 | 1574 v71 = terrain_76D7C8[i];//88 |
1597 //v116 = v77; | 1597 //v116 = v77; |
1598 //pHeight = v79; | 1598 //pHeight = v79; |
1599 v111 = v75 - uStartZ; | 1599 v111 = v75 - uStartZ; |
1600 for (int z = uStartZ; z < uEndZ; ++z) | 1600 for (int z = uStartZ; z < uEndZ; ++z) |
1601 { | 1601 { |
1602 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512; | 1602 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
1603 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; | 1603 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
1604 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); | 1604 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
1605 | |
1606 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; | 1605 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; |
1607 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; | 1606 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
1608 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); | 1607 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
1609 | |
1610 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) | 1608 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1611 { | 1609 { |
1612 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); | 1610 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1613 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | 1611 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); |
1614 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | 1612 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); |
1616 } | 1614 } |
1617 //v79 += 512; | 1615 //v79 += 512; |
1618 v127 ++; | 1616 v127 ++; |
1619 //++v116; | 1617 //++v116; |
1620 //pHeight = v79; | 1618 //pHeight = v79; |
1621 } | 1619 } |
1622 //while ( v116 < v107 ); | 1620 //while ( v116 < v107 ); |
1623 } | 1621 } |
1624 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); | 1622 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
1625 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); | 1623 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); |
1626 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test | 1624 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
1627 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); | 1625 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); |
1628 else | 1626 else |
1629 Render::DrawTerrainSW(v111, 0, (int)&v102); | 1627 Render::DrawTerrainSW(v111, 0, (int)&v102); |
1630 } | 1628 } |
1631 } | 1629 } |
1735 int v57; // [sp+38h] [bp-20h]@36 | 1733 int v57; // [sp+38h] [bp-20h]@36 |
1736 int v58; // [sp+3Ch] [bp-1Ch]@8 | 1734 int v58; // [sp+3Ch] [bp-1Ch]@8 |
1737 int v63; // [sp+50h] [bp-8h]@3 | 1735 int v63; // [sp+50h] [bp-8h]@3 |
1738 int v64; // [sp+57h] [bp-1h]@2 | 1736 int v64; // [sp+57h] [bp-1h]@2 |
1739 int v62; | 1737 int v62; |
1738 struct IndoorCameraD3D *pIndoorCameraD3D; | |
1740 | 1739 |
1741 v63 = 0; | 1740 v63 = 0; |
1742 | |
1743 // basic optimizations | 1741 // basic optimizations |
1744 unsigned int uStartX, uEndX, | 1742 unsigned int uStartX, uEndX, |
1745 uStartZ, uEndZ; | 1743 uStartZ, uEndZ; |
1746 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) | 1744 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1747 { | 1745 { |
1748 /* CAMERA | 1746 uStartX = 0, uEndX = 128; |
1749 ï/2 512 | 1747 uStartZ = 0, uEndZ = 64 + 16; |
1750 ^ | 1748 } |
1751 \ | / | 1749 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) |
1752 \ | / | 1750 { |
1753 ï _____\|/______ + 0 | 1751 uStartX = 0, uEndX = 64 + 16; |
1754 1024 | x 0 | 1752 uStartZ = 0, uEndZ = 128; |
1755 | | 1753 } |
1756 - y | 1754 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) |
1757 3ï/2 1536 | 1755 { |
1758 */ | 1756 uStartX = 64 - 16, uEndX = 128; |
1759 uStartX = 0, uEndX = 128; | 1757 uStartZ = 0, uEndZ = 128; |
1760 uStartZ = 0, uEndZ = 64 + 16; | 1758 } |
1761 } | 1759 else |
1762 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | 1760 { |
1763 { | 1761 uStartX = 0, uEndX = 128; |
1764 /* ï/2 512 | 1762 uStartZ = 64 - 16, uEndZ = 128; |
1765 + y | 1763 } |
1766 \ | | 1764 // uStartX = 0, uEndX = 128; |
1767 \ | | 1765 // uStartZ = 0, uEndZ = 128; |
1768 CAMERA ï _____\| ______ + 0 | 1766 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1769 1024 /| x 0 | 1767 for (unsigned int z = uStartZ; z < uEndZ; ++z) |
1770 / | | 1768 { |
1771 / - y | 1769 for (unsigned int x = uStartX; x < uEndX; ++x) |
1772 3ï/2 1536 | 1770 { |
1773 */ | 1771 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
1774 uStartX = 0, uEndX = 64 + 16; | 1772 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; |
1775 uStartZ = 0, uEndZ = 128; | 1773 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; |
1776 } | 1774 pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1777 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | 1775 pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
1778 { | 1776 pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); |
1779 /* ï/2 512 | 1777 } |
1780 + y | 1778 } |
1781 | / | 1779 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1782 | / | 1780 { |
1783 ï _____ |/______ + 0 CAMERA | 1781 for (unsigned int x = uStartX; x < uEndX - 1; ++x) |
1784 1024 |\ x 0 | 1782 { |
1785 | \ | 1783 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; |
1786 - y \ | 1784 v8->flags = 0; |
1787 3ï/2 1536 | 1785 v8->field_32 = 0; |
1788 */ | 1786 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; |
1789 uStartX = 64 - 16, uEndX = 128; | 1787 //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID); |
1790 uStartZ = 0, uEndZ = 128; | 1788 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
1791 } | 1789 v6 = v8->uTileBitmapID; |
1792 else | 1790 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6]; |
1793 { | 1791 if (v8->uTileBitmapID == 0xFFFF) |
1794 uStartX = 0, uEndX = 128; | 1792 continue; |
1795 uStartZ = 64 - 16, uEndZ = 128; | 1793 v8->sTextureDeltaU = 0; |
1796 } | 1794 v8->sTextureDeltaV = 0; |
1797 | 1795 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); |
1798 // uStartX = 0, uEndX = 128; | 1796 array_73D150[0].u = 0; |
1799 // uStartZ = 0, uEndZ = 128; | 1797 array_73D150[0].v = 0; |
1800 | 1798 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); |
1801 | 1799 array_73D150[1].u = 1; |
1802 static RenderVertexSoft pTerrainVertices[128 * 128]; | 1800 array_73D150[1].v = 0; |
1803 for (unsigned int z = uStartZ; z < uEndZ; ++z) | 1801 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); |
1804 for (unsigned int x = uStartX; x < uEndX; ++x) | 1802 array_73D150[2].u = 1; |
1805 { | 1803 array_73D150[2].v = 1; |
1806 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | 1804 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); |
1807 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | 1805 array_73D150[3].u = 0; |
1808 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | 1806 array_73D150[3].v = 1; |
1809 | |
1810 struct IndoorCameraD3D *pIndoorCameraD3D = pGame->pIndoorCameraD3D; | |
1811 pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1812 pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
1813 } | |
1814 | |
1815 | |
1816 | |
1817 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) | |
1818 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1819 { | |
1820 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1821 v8->flags = 0; | |
1822 v8->field_32 = 0; | |
1823 | |
1824 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
1825 //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID); | |
1826 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
1827 /*if (uTileID == 1 || //dirttyl BitmapID 88 | |
1828 uTileID == 2 || //dirt1 BitmapID 126 | |
1829 uTileID == 3 || //dirttyl BitmapID 88 | |
1830 uTileID == 4 || //dirt2 BitmapID 127 | |
1831 uTileID == 11 || //dirttyl BitmapID 127 | |
1832 | |
1833 uTileID == 90 || //grastyl BitmapID 110 | |
1834 uTileID == 92 || //grastyl BitmapID 110 | |
1835 | |
1836 uTileID == 102 || //grdrtNE BitmapID 128 | |
1837 uTileID == 104 || //grdrtNW BitmapID 130 | |
1838 uTileID == 105 || //grdrtSW BitmapID 131 | |
1839 uTileID == 106 || //grdrtE BitmapID 132 | |
1840 uTileID == 107 || //grdrtW BitmapID 133 | |
1841 uTileID == 108 || //grdrtN BitmapID 134 | |
1842 uTileID == 109 || //grdrtS BitmapID 135 | |
1843 uTileID == 110 || //grdrtXNE BitmapID 136 | |
1844 uTileID == 112 || //grdrtXNW BitmapID 138 | |
1845 uTileID == 113 || //grdrtXSW BitmapID 139 | |
1846 | |
1847 uTileID == 126 || uTileID == 127 || uTileID == 128 || uTileID == 129 || | |
1848 uTileID == 130 || //wtrtyl BitmapID 89 | |
1849 uTileID == 131 || //wtrtyl BitmapID 89 | |
1850 uTileID == 132 || //wtrtyl BitmapID 89 | |
1851 uTileID == 133 || //wtrtyl BitmapID 89 | |
1852 uTileID == 134 || //wtrtyl BitmapID 89 | |
1853 uTileID == 135 || //wtrtyl BitmapID 89 | |
1854 uTileID == 136 || //wtrtyl BitmapID 89 | |
1855 uTileID == 137 || //wtrtyl BitmapID 89 | |
1856 | |
1857 uTileID == 139 || //wtrdrSE BitmapID 141 | |
1858 uTileID == 141 || //wrtdrSW BitmapID 143 | |
1859 uTileID == 142 || //wrtdrE BitmapID 144 | |
1860 uTileID == 143 || //wrtdrW BitmapID 145 | |
1861 uTileID == 145 || //wtrdrS BitmapID 147 | |
1862 uTileID == 147 || //wtrdrXSE BitmapID 149 | |
1863 uTileID == 149 ) //wtrdrXSW BitmapID 151 | |
1864 continue;*/ | |
1865 | |
1866 /*if (uTileID == 199 || //dirttyl BitmapID 0 | |
1867 uTileID == 200 || //dirttyl BitmapID 0 | |
1868 uTileID == 201 || //dirttyl BitmapID 0 | |
1869 uTileID == 202 || //dirttyl BitmapID 0 | |
1870 uTileID == 203 || //dirttyl BitmapID 0 | |
1871 uTileID == 204 || //dirttyl BitmapID 0 | |
1872 uTileID == 212 || //dirttyl BitmapID 0 | |
1873 uTileID == 217) //dirttyl BitmapID 0 | |
1874 continue;*/ | |
1875 | |
1876 v6 = v8->uTileBitmapID; | |
1877 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6]; | |
1878 | |
1879 if (v8->uTileBitmapID == 0xFFFF) | |
1880 continue; | |
1881 | |
1882 v8->sTextureDeltaU = 0; | |
1883 v8->sTextureDeltaV = 0; | |
1884 | |
1885 | |
1886 /* world coordinates, z -> height | |
1887 32767 | |
1888 +y | |
1889 | |
1890 -32768 -x +x 32767 | |
1891 | |
1892 -y | |
1893 -32768 | |
1894 */ | |
1895 | |
1896 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1897 array_73D150[0].u = 0; | |
1898 array_73D150[0].v = 0; | |
1899 | |
1900 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1901 array_73D150[1].u = 1; | |
1902 array_73D150[1].v = 0; | |
1903 | |
1904 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1905 array_73D150[2].u = 1; | |
1906 array_73D150[2].v = 1; | |
1907 | |
1908 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1909 array_73D150[3].u = 0; | |
1910 array_73D150[3].v = 1; | |
1911 | |
1912 | |
1913 v55 = 0; | 1807 v55 = 0; |
1914 v54 = false; | 1808 v54 = false; |
1915 v58 = 0; | 1809 v58 = 0; |
1916 | |
1917 if (v58 == 4) // if all y == first y; primitive in xz plane | 1810 if (v58 == 4) // if all y == first y; primitive in xz plane |
1918 v8->field_32 |= 0x0001; | 1811 v8->field_32 |= 0x0001; |
1919 | |
1920 v8->pODMFace = nullptr; | 1812 v8->pODMFace = nullptr; |
1921 v8->uNumVertices = 4; | 1813 v8->uNumVertices = 4; |
1922 v8->field_59 = 5; | 1814 v8->field_59 = 5; |
1923 | |
1924 v8->field_58 = 0; | 1815 v8->field_58 = 0; |
1925 | |
1926 ++pOutdoorCamera->numStru148s; | 1816 ++pOutdoorCamera->numStru148s; |
1927 ++pOutdoorCamera->field_44; | 1817 ++pOutdoorCamera->field_44; |
1928 | 1818 v8->uBModelID = 0; |
1929 | 1819 v8->uBModelFaceID = 0; |
1930 | 1820 v31 = (8 * (0 | (0 << 6))); |
1931 v8->uBModelID = 0; | 1821 v8->field_50 = v31 | 6; |
1932 v8->uBModelFaceID = 0; | 1822 for (unsigned int k = 0; k < 4; ++k) |
1933 v31 = (8 * (0 | (0 << 6))); | 1823 { |
1934 v8->field_50 = v31 | 6; | 1824 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); |
1935 | 1825 array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
1936 for (unsigned int k = 0; k < 4; ++k) | 1826 } |
1937 { | 1827 pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); |
1938 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
1939 array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); | |
1940 } | |
1941 | |
1942 | |
1943 pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); | |
1944 | |
1945 --pOutdoorCamera->numStru148s; | 1828 --pOutdoorCamera->numStru148s; |
1946 --pOutdoorCamera->field_44; | 1829 --pOutdoorCamera->field_44; |
1947 | 1830 } |
1948 } | 1831 } |
1949 | 1832 } |
1950 } | |
1951 | 1833 |
1952 //----- (0048034E) -------------------------------------------------------- | 1834 //----- (0048034E) -------------------------------------------------------- |
1953 void Render::DrawTerrainD3D(int a1, int a2, int a3) | 1835 void Render::DrawTerrainD3D(int a1, int a2, int a3) |
1954 { | 1836 { |
1955 int v3; // esi@1 | 1837 int v3; // esi@1 |