diff --git a/2DFXDataGrabber/2DFXDataGrabber.cpp b/2DFXDataGrabber/2DFXDataGrabber.cpp index 49e07bb..42e4a80 100644 --- a/2DFXDataGrabber/2DFXDataGrabber.cpp +++ b/2DFXDataGrabber/2DFXDataGrabber.cpp @@ -1,5 +1,7 @@ -#include "stdafx.h" -#include "windows.h" +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include #include #include #include @@ -7,6 +9,18 @@ #include using namespace std; +enum BlinkTypes +{ + DEFAULT, + RANDOM_FLASHING, + T_1S_ON_1S_OFF, + T_2S_ON_2S_OFF, + T_3S_ON_3S_OFF, + T_4S_ON_4S_OFF, + T_5S_ON_5S_OFF, + T_6S_ON_4S_OFF +}; + string Filename; void ConvertDFFTo2DFX() @@ -78,14 +92,8 @@ void ConvertDFFTo2DFX() LodLights.open(Filename, fstream::trunc); LodLights << "#%modelname" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, vecOffset.x, vecOffset.y, vecOffset.z, fCustomSize" << endl; - LodLights << "#coronaColour2.r, coronaColour2.g, coronaColour2.b, vecOffset2.x, vecOffset2.y, vecOffset2.z, fCustomSize2" << endl; - LodLights << "#%modelname2" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, vecOffset.x, vecOffset.y, vecOffset.z, fCustomSize" << endl; - LodLights << "#%additional_coronas" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, position.x, position.y, position.z, fCustomSize, 1" << endl; - LodLights << "#place you coronas here" << endl; - LodLights << "#0.45 - reserved for traffic lights" << endl; + LodLights << "#Red, Green, Blue, Alpha, OffsetX, OffsetY, OffsetZ, CustomSize, BlinkType, NoDistance, DrawSearchlight" << endl; + LodLights << "#0.45 - custom size reserved for traffic lights" << endl; LodLights << endl; SetCurrentDirectory(".\\2dfx\\"); @@ -108,12 +116,12 @@ void ConvertDFFTo2DFX() string ext = fd.cFileName; ext.replace(ext.find(".txt"), 4, "\0"); LodLights << "%" << ext.c_str() << endl; - string EntryName; float offsetX, offsetY, offsetZ, CoronaSize; int R, G, B; + string EntryName; float offsetX, offsetY, offsetZ, CoronaSize; int R = 0, G = 0, B = 0, A = 255; int BlinkType = 0; int nNoDistance = 0; int nDrawSearchlight = 0; while (getline(TXTFileContent, buf)) { if (buf[0] != '#') { - if (sscanf(buf.c_str(), "%s", &EntryName)) + if (sscanf(buf.c_str(), "%s", &EntryName[0])) { if (buf.find("Position") != std::string::npos) { @@ -127,20 +135,115 @@ void ConvertDFFTo2DFX() { sscanf(buf.c_str(), "%*s %f", &CoronaSize); + if (ext.find("lamppost1") != std::string::npos || ext.find("lamppost2") != std::string::npos || + ext.find("lamppost3") != std::string::npos || ext.find("mlamppost") != std::string::npos || + ext.find("vegaslampost") != std::string::npos || ext.find("vegaslampost2") != std::string::npos || + ext.find("streetlamp1") != std::string::npos || ext.find("streetlamp2") != std::string::npos || + ext.find("ce_radarmast3") != std::string::npos || ext.find("radarmast1_lawn") != std::string::npos || + ext.find("radarmast1_lawn01") != std::string::npos || ext.find("bollardlight") != std::string::npos || + ext.find("sub_floodlite") != std::string::npos || ext.find("cj_traffic_light5") != std::string::npos || + ext.find("lamppost_coast") != std::string::npos || ext.find("airuntest_las") != std::string::npos || + ext.find("vegasairportlight") != std::string::npos || ext.find("gay_lamppost") != std::string::npos || + ext.find("gay_traffic_light") != std::string::npos || ext.find("cj_traffic_light4") != std::string::npos || + ext.find("lodnsmitter_sfs01") != std::string::npos || ext.find("lodrailbge01_sfse") != std::string::npos || + ext.find("lodrailbge02_sfse") != std::string::npos || ext.find("lodrailbge04_sfse") != std::string::npos || + ext.find("lodrailbge09_sfse") != std::string::npos || ext.find("lodtainercrane_04") != std::string::npos || + ext.find("lod_refchimny01") != std::string::npos || ext.find("mtraffic1") != std::string::npos || + ext.find("mtraffic2") != std::string::npos || ext.find("mtraffic3") != std::string::npos || + ext.find("mtraffic4") != std::string::npos || ext.find("trafficlight1") != std::string::npos || + ext.find("vgsstriptlights1") != std::string::npos || ext.find("circuslampost03") != std::string::npos) + { + nDrawSearchlight = 1; + } + if (ext.find("cj_traffic_light3") != std::string::npos || ext.find("cj_traffic_light4") != std::string::npos || - ext.find("cj_traffic_light5") != std::string::npos || ext.find("gay_traffic_light") != std::string::npos || - ext.find("mtraffic1") != std::string::npos || ext.find("mtraffic2") != std::string::npos || - ext.find("mtraffic4") != std::string::npos || ext.find("trafficlight1") != std::string::npos || - ext.find("vgsstriptlights1") != std::string::npos) + ext.find("cj_traffic_light5") != std::string::npos || ext.find("gay_traffic_light") != std::string::npos || + ext.find("mtraffic1") != std::string::npos || ext.find("mtraffic2") != std::string::npos || + ext.find("mtraffic4") != std::string::npos || ext.find("trafficlight1") != std::string::npos || + ext.find("vgsstriptlights1") != std::string::npos || ext.find("traincross1") != std::string::npos) { CoronaSize = 0.45f; - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << CoronaSize << std::setprecision(-1) << endl; - break; + nDrawSearchlight = 0; + if ((R == 255 && G == 148 && B == 52) || (R == 255 && G == 255 && B == 221)) + CoronaSize = 1.0f; } if (CoronaSize > 1.0f) CoronaSize = 1.2f; - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << CoronaSize << std::setprecision(-1) << endl; + + (offsetX == -0.0f) ? offsetX = 0.0f : offsetX; + (offsetY == -0.0f) ? offsetY = 0.0f : offsetY; + (offsetZ == -0.0f) ? offsetZ = 0.0f : offsetZ; + } + else if (buf.find("CoronaShowMode") != std::string::npos) + { + if (buf.find("DEFAULT") != std::string::npos || buf.find("TRAFFICLIGHT") != std::string::npos || + buf.find("TRAINCROSSLIGHT") != std::string::npos || buf.find("AT_RAIN_ONLY") != std::string::npos) + { + BlinkType = BlinkTypes::DEFAULT; + } + else if (buf.find("RANDOM_FLASHING") != std::string::npos || buf.find("RANDOM_FLASHIN_ALWAYS_AT_WET_WEATHER") != std::string::npos || + buf.find("ALWAYS_AT_WET_WEATHER") != std::string::npos) + { + BlinkType = BlinkTypes::DEFAULT; //BlinkType = BlinkTypes::RANDOM_FLASHING; + } + else if (buf.find("LIGHTS_ANIM_SPEED_4X") != std::string::npos) + { + BlinkType = BlinkTypes::T_1S_ON_1S_OFF; + } + else if (buf.find("LIGHTS_ANIM_SPEED_2X") != std::string::npos) + { + BlinkType = BlinkTypes::T_2S_ON_2S_OFF; + } + else if (buf.find("LIGHTS_ANIM_SPEED_1X") != std::string::npos) + { + BlinkType = BlinkTypes::T_4S_ON_4S_OFF; + } + else if (buf.find("5S_ON_5S_OFF") != std::string::npos) + { + BlinkType = BlinkTypes::T_5S_ON_5S_OFF; + } + else if (buf.find("6S_ON_4S_OFF") != std::string::npos || buf.find("6S_ON_4S_OFF_2") != std::string::npos) + { + BlinkType = BlinkTypes::T_6S_ON_4S_OFF; + } + + if (CoronaSize > 0.0f) + { + auto GetPrecison = [](float value) -> int + { + int width = 10; + int digits = 0; + + if (value < 0.0f) + { + value *= -1.0f; + digits++; + } + digits += ((value<1) ? 1 : int(1 + log10(float(abs(value))))); + int precision = (((width - digits - 1) >= 0) ? (width - digits - 1) : 0); + return precision; + }; + + LodLights << std::right + << std::setfill('0') + << std::setw(3) << R << " " + << std::setw(3) << G << " " + << std::setw(3) << B << " " + << std::setw(3) << A << " " + << std::setfill(' ') + << std::left + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetX)) << offsetX << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetY)) << offsetY << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetZ)) << offsetZ << " " + << std::setw(4) << std::fixed << std::setprecision(2) << CoronaSize << " " + << std::right << std::setfill('0') + << std::setw(2) << BlinkType << " " + << std::left << std::setfill(' ') + << std::setw(1) << nNoDistance << " " + << std::setw(1) << nDrawSearchlight + << std::endl; + } } } } @@ -155,159 +258,331 @@ void ConvertDFFTo2DFX() } LodLights << "%lodnsmitter_sfs01" << endl; - LodLights << "255 0 0 -9.298000 -11.402000 -68.624001 1.0 1" << endl; - LodLights << "255 0 0 10.505000 -0.040000 -68.624001 1.0 1" << endl; - LodLights << "255 0 0 -9.212000 11.244000 -68.624001 1.0 1" << endl; - LodLights << "255 0 0 -7.926000 9.126000 -33.070000 1.0 1" << endl; - LodLights << "255 0 0 7.932000 -0.002000 -33.070000 1.0 1" << endl; - LodLights << "255 0 0 -7.974000 -9.203000 -33.070000 1.0 1" << endl; - LodLights << "255 0 0 -6.840000 7.285000 0.826000 1.0 1" << endl; - LodLights << "255 0 0 -6.812000 -7.408000 0.826000 1.0 1" << endl; - LodLights << "255 0 0 5.768000 -0.097000 0.826000 1.0 1" << endl; - LodLights << "255 0 0 7.377000 0.061000 24.687000 1.0 1" << endl; - LodLights << "255 0 0 -7.586000 -8.599000 24.687000 1.0 1" << endl; - LodLights << "255 0 0 -7.906000 8.648000 24.687000 1.0 1" << endl; - LodLights << "255 0 0 -7.893000 15.860000 51.548000 1.0 1" << endl; - LodLights << "255 0 0 -13.689000 12.518000 51.548000 1.0 1" << endl; - LodLights << "255 0 0 13.900000 3.256000 51.797001 1.0 1" << endl; - LodLights << "255 0 0 13.674000 -3.285000 51.797001 1.0 1" << endl; - LodLights << "255 0 0 -7.933000 -15.856000 51.616001 1.0 1" << endl; - LodLights << "255 0 0 -13.234000 -12.272000 51.548000 1.0 1" << endl; - LodLights << "255 0 0 -8.114000 -9.256000 89.308998 1.0 1" << endl; - LodLights << "255 0 0 8.037000 -0.015000 89.308998 1.0 1" << endl; + LodLights << "255 000 000 255 -9.2980000 -11.402000 -68.624001 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 10.5050000 -0.0400000 -68.624001 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -9.2120000 11.2440000 -68.624001 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.9260000 9.12600000 -33.070000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 7.93200000 -0.0020000 -33.070000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.9740000 -9.2030000 -33.070000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -6.8400000 7.28500000 0.82600000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -6.8120000 -7.4080000 0.82600000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 5.76800000 -0.0970000 0.82600000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 7.37700000 0.06100000 24.6870000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.5860000 -8.5990000 24.6870000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.9060000 8.64800000 24.6870000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.8930000 15.8600000 51.5480000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -13.689000 12.5180000 51.5480000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 13.9000000 3.25600000 51.7970010 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 13.6740000 -3.2850000 51.7970010 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -7.9330000 -15.856000 51.6160010 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -13.234000 -12.272000 51.5480000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -8.1140000 -9.2560000 89.3089980 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 8.03700000 -0.0150000 89.3089980 1.00 00 1 0" << endl; LodLights << "%radarmast1_lawn" << endl; - LodLights << "255 0 0 0.091 0.053 24.62 0.1 1" << endl; + LodLights << "255 000 000 0.091000000000 0.05300000 24.6200000 0.10 00 1 0" << endl; LodLights << "%radarmast1_lawn01" << endl; - LodLights << "255 0 0 0.130000 -0.008000 24.490000 1.0 1" << endl; + LodLights << "255 000 000 255 0.13000000 -0.0080000 24.4900000 1.00 00 1 0" << endl; LodLights << "%ce_radarmast3" << endl; - LodLights << "255 0 0 0.001 0.033 32.657 0.5 1" << endl; + LodLights << "255 000 000 255 0.00100000 0.03300000 32.6570000 0.50 00 1 0" << endl; LodLights << "%ws_ref_bollard" << endl; - LodLights << "255 0 0 0.009 0.001 0.469 0.7 1" << endl; + LodLights << "255 000 000 255 0.00900000 0.00100000 0.46900000 0.70 00 1 0" << endl; LodLights << "%baybridge1_sfse" << endl; - LodLights << "0 111 255 -76.679 -16.446 -8.721 1.2 1" << endl; - LodLights << "0 111 255 -53.127 -16.434 -5.59 1.2 1" << endl; - LodLights << "0 111 255 -29.32 -16.434 -0.143 1.2 1" << endl; - LodLights << "0 111 255 -6.182 -16.434 7.343 1.2 1" << endl; - LodLights << "0 111 255 16.348 -16.434 16.761 1.2 1" << endl; - LodLights << "0 111 255 37.866 -16.434 28.076 1.2 1" << endl; - LodLights << "0 111 255 58.783 -16.434 41.432 1.2 1" << endl; - LodLights << "0 111 255 -76.679 16.468 -8.721 1.2 1" << endl; - LodLights << "0 111 255 -53.127 16.468 -5.59 1.2 1" << endl; - LodLights << "0 111 255 -29.32 16.49 -0.143 1.2 1" << endl; - LodLights << "0 111 255 -6.182 16.49 7.343 1.2 1" << endl; - LodLights << "0 111 255 16.348 16.49 16.761 1.2 1" << endl; - LodLights << "0 111 255 37.866 16.49 28.076 1.2 1" << endl; - LodLights << "0 111 255 58.783 16.49 41.432 1.2 1" << endl; + LodLights << "000 111 255 255 -76.679000 -16.446000 -8.7210000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -53.127000 -16.434000 -5.5900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -29.320000 -16.434000 -0.1430000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -6.1820000 -16.434000 7.34300000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 16.3480000 -16.434000 16.7610000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 37.8660000 -16.434000 28.0760000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 58.7830000 -16.434000 41.4320000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -76.679000 16.4680000 -8.7210000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -53.127000 16.4680000 -5.5900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -29.320000 16.4900000 -0.1430000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -6.1820000 16.4900000 7.34300000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 16.3480000 16.4900000 16.7610000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 37.8660000 16.4900000 28.0760000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 58.7830000 16.4900000 41.4320000 1.20 00 1 0" << endl; LodLights << "%baybridge2_sfse" << endl; - LodLights << "255 0 0 38.4845 -18.2165 83.4015 1.0 1" << endl; - LodLights << "255 0 0 38.479 18.3384 83.4015 1.0 1" << endl; - LodLights << "0 111 255 74.872 16.408 39.921 1.2 1" << endl; - LodLights << "0 111 255 74.872 -16.476 39.921 1.2 1" << endl; - LodLights << "0 111 255 56.636 -16.476 56.243 1.2 1" << endl; - LodLights << "0 111 255 56.636 16.408 56.243 1.2 1" << endl; - LodLights << "0 111 255 17.591 -16.476 53.324 1.2 1" << endl; - LodLights << "0 111 255 17.591 16.408 53.324 1.2 1" << endl; - LodLights << "0 111 255 -0.551 -16.476 37.625 1.2 1" << endl; - LodLights << "0 111 255 -0.551 16.408 37.625 1.2 1" << endl; - LodLights << "0 111 255 -19.959 -16.476 24.133 1.2 1" << endl; - LodLights << "0 111 255 -19.959 16.408 24.133 1.2 1" << endl; - LodLights << "0 111 255 -40.829 -16.476 12.153 1.2 1" << endl; - LodLights << "0 111 255 -62.489 16.408 2.284 1.2 1" << endl; - LodLights << "0 111 255 -62.489 -16.476 2.269 1.2 1" << endl; - LodLights << "0 111 255 -84.947 -16.476 -5.715 1.2 1" << endl; - LodLights << "0 111 255 -84.947 16.408 -5.701 1.2 1" << endl; + LodLights << "255 000 000 255 38.4845000 -18.216500 83.4015000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 38.4790000 18.3384000 83.4015000 1.00 00 1 0" << endl; + LodLights << "000 111 255 255 74.8720000 16.4080000 39.9210000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 74.8720000 -16.476000 39.9210000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 56.6360000 -16.476000 56.2430000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 56.6360000 16.4080000 56.2430000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 17.5910000 -16.476000 53.3240000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 17.5910000 16.4080000 53.3240000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -0.5510000 -16.476000 37.6250000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -0.5510000 16.4080000 37.6250000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -19.959000 -16.476000 24.1330000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -19.959000 16.4080000 24.1330000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -40.829000 -16.476000 12.1530000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -62.489000 16.4080000 2.28400000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -62.489000 -16.476000 2.26900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -84.947000 -16.476000 -5.7150000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -84.947000 16.4080000 -5.7010000 1.20 00 1 0" << endl; LodLights << "%baybridge3_sfse" << endl; - LodLights << "255 0 0 -100.83 18.3671 89.5265 1.0 1" << endl; - LodLights << "255 0 0 -100.87 -18.1406 89.5265 1.0 1" << endl; - LodLights << "0 111 255 136.609 -16.542 -5.215 1.2 1" << endl; - LodLights << "0 111 255 136.609 16.383 -5.215 1.2 1" << endl; - LodLights << "0 111 255 112.756 16.383 -8.19 1.2 1" << endl; - LodLights << "0 111 255 112.756 -16.542 -8.19 1.2 1" << endl; - LodLights << "0 111 255 69.149 16.383 -8.19 1.2 1" << endl; - LodLights << "0 111 255 69.149 -16.542 -8.19 1.2 1" << endl; - LodLights << "0 111 255 45.419 -16.542 -4.999 1.2 1" << endl; - LodLights << "0 111 255 45.419 16.383 -4.999 1.2 1" << endl; - LodLights << "0 111 255 22.189 -16.542 0.429 1.2 1" << endl; - LodLights << "0 111 255 22.189 16.383 0.429 1.2 1" << endl; - LodLights << "0 111 255 -0.257 -16.542 8.424 1.2 1" << endl; - LodLights << "0 111 255 -0.257 16.383 8.424 1.2 1" << endl; - LodLights << "0 111 255 -21.66 16.383 18.381 1.2 1" << endl; - LodLights << "0 111 255 -21.66 -16.542 18.381 1.2 1" << endl; - LodLights << "0 111 255 -42.686 -16.542 30.249 1.2 1" << endl; - LodLights << "0 111 255 -42.686 16.383 30.249 1.2 1" << endl; - LodLights << "0 111 255 -62.074 -16.421 43.898 1.2 1" << endl; - LodLights << "0 111 255 -62.074 16.504 43.898 1.2 1" << endl; - LodLights << "0 111 255 -80.451 -16.463 59.17 1.2 1" << endl; - LodLights << "0 111 255 -80.451 16.462 59.17 1.2 1" << endl; + LodLights << "255 000 000 255 -100.83000 18.3671000 89.5265000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 -100.87000 -18.140600 89.5265000 1.00 00 1 0" << endl; + LodLights << "000 111 255 255 136.609000 -16.542000 -5.2150000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 136.609000 16.3830000 -5.2150000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 112.756000 16.3830000 -8.1900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 112.756000 -16.542000 -8.1900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 69.1490000 16.3830000 -8.1900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 69.1490000 -16.542000 -8.1900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 45.4190000 -16.542000 -4.9990000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 45.4190000 16.3830000 -4.9990000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 22.1890000 -16.542000 0.42900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 22.1890000 16.3830000 0.42900000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -0.2570000 -16.542000 8.42400000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -0.2570000 16.3830000 8.42400000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -21.660000 16.3830000 18.3810000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -21.660000 -16.542000 18.3810000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -42.686000 -16.542000 30.2490000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -42.686000 16.3830000 30.2490000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -62.074000 -16.421000 43.8980000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -62.074000 16.5040000 43.8980000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -80.451000 -16.463000 59.1700000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -80.451000 16.4620000 59.1700000 1.20 00 1 0" << endl; LodLights << "%baybridge4_sfse" << endl; - LodLights << "0 111 255 73.96 16.419 66.576 1.2 1" << endl; - LodLights << "0 111 255 73.96 -16.496 66.576 1.2 1" << endl; - LodLights << "0 111 255 55.538 16.419 50.292 1.2 1" << endl; - LodLights << "0 111 255 55.538 -16.496 50.292 1.2 1" << endl; - LodLights << "0 111 255 36.283 16.419 35.603 1.2 1" << endl; - LodLights << "0 111 255 36.283 -16.496 35.603 1.2 1" << endl; - LodLights << "0 111 255 15.391 16.419 22.126 1.2 1" << endl; - LodLights << "0 111 255 15.391 -16.496 22.126 1.2 1" << endl; - LodLights << "0 111 255 -6.209 16.419 10.828 1.2 1" << endl; - LodLights << "0 111 255 -6.209 -16.496 10.828 1.2 1" << endl; - LodLights << "0 111 255 -28.574 16.419 1.465 1.2 1" << endl; - LodLights << "0 111 255 -28.574 -16.496 1.465 1.2 1" << endl; - LodLights << "0 111 255 -51.905 16.419 -5.869 1.2 1" << endl; - LodLights << "0 111 255 -51.905 -16.496 -5.869 1.2 1" << endl; - LodLights << "0 111 255 -75.652 16.419 -11.285 1.2 1" << endl; - LodLights << "0 111 255 -75.652 -16.496 -11.285 1.2 1" << endl; - LodLights << "0 111 255 -99.5 16.419 -14.214 1.2 1" << endl; - LodLights << "0 111 255 -99.5 -16.496 -14.214 1.2 1" << endl; + LodLights << "000 111 255 255 73.9600000 16.4190000 66.5760000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 73.9600000 -16.496000 66.5760000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 55.5380000 16.4190000 50.2920000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 55.5380000 -16.496000 50.2920000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 36.2830000 16.4190000 35.6030000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 36.2830000 -16.496000 35.6030000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 15.3910000 16.4190000 22.1260000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 15.3910000 -16.496000 22.1260000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -6.2090000 16.4190000 10.8280000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -6.2090000 -16.496000 10.8280000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -28.574000 16.4190000 1.46500000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -28.574000 -16.496000 1.46500000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -51.905000 16.4190000 -5.8690000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -51.905000 -16.496000 -5.8690000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -75.652000 16.4190000 -11.285000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -75.652000 -16.496000 -11.285000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -99.500000 16.4190000 -14.214000 1.20 00 1 0" << endl; + LodLights << "000 111 255 255 -99.500000 -16.496000 -14.214000 1.20 00 1 0" << endl; LodLights << "%ggbrig_06_sfw" << endl; - LodLights << "255 0 0 19.097 0.128 115.89 2.0 1" << endl; + LodLights << "255 000 000 255 19.0970000 0.12800000 115.890000 2.00 00 1 0" << endl; LodLights << "%ggbrig_01_sfw" << endl; - LodLights << "255 0 0 19.097 0.128 115.89 2.0 1" << endl; + LodLights << "255 000 000 255 19.0970000 0.12800000 115.890000 2.00 00 1 0" << endl; LodLights << "%ggbrig_03_sfw" << endl; - LodLights << "255 0 0 19.385 55.76 19.433 1.2 1" << endl; - LodLights << "255 0 0 -19.136 55.76 19.433 1.2 1" << endl; - LodLights << "255 0 0 -19.136 -5.989 -30.831 1.2 1" << endl; - LodLights << "255 0 0 19.385 -5.989 -30.831 1.2 1" << endl; + LodLights << "255 000 000 255 19.3850000 55.7600000 19.4330000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 -19.136000 55.7600000 19.4330000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 -19.136000 -5.9890000 -30.831000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 19.3850000 -5.9890000 -30.831000 1.20 00 1 0" << endl; LodLights << "%ggbrig_05_sfw" << endl; - LodLights << "255 0 0 -19.308 -59.193 17.728 1.2 1" << endl; - LodLights << "255 0 0 19.136 -59.193 17.728 1.2 1" << endl; - LodLights << "255 0 0 19.136 2.375 -31.452 1.2 1" << endl; - LodLights << "255 0 0 -19.308 2.375 -31.452 1.2 1" << endl; + LodLights << "255 000 000 255 -19.308000 -59.193000 17.7280000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 19.1360000 -59.193000 17.7280000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 19.1360000 2.37500000 -31.452000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 -19.308000 2.37500000 -31.452000 1.20 00 1 0" << endl; LodLights << "%cxrf_whitebrig" << endl; - LodLights << "249 145 34 -0.118 -29.064 5.175 1.2 1" << endl; - LodLights << "249 145 34 16.632 -29.064 5.175 1.2 1" << endl; - LodLights << "249 145 34 16.632 28.92 5.175 1.2 1" << endl; - LodLights << "249 145 34 -0.118 28.92 5.175 1.2 1" << endl; + LodLights << "249 145 34 255 -0.11800000 -29.064000 5.17500000 1.20 00 1 0" << endl; + LodLights << "249 145 34 255 16.63200000 -29.064000 5.17500000 1.20 00 1 0" << endl; + LodLights << "249 145 34 255 16.63200000 28.9200000 5.17500000 1.20 00 1 0" << endl; + LodLights << "249 145 34 255 -0.11800000 28.9200000 5.17500000 1.20 00 1 0" << endl; LodLights << "%des_bigtelescope" << endl; - LodLights << "255 0 0 24.051 24.258 53.915 3.0 1" << endl; + LodLights << "255 000 000 255 24.0510000 24.2580000 53.9150000 3.00 00 1 0" << endl; LodLights << "%pylon_big1_" << endl; - LodLights << "255 0 0 4.671 0.134 36.003 1.2 1" << endl; - LodLights << "255 0 0 -4.356 0.134 36.003 1.2 1" << endl; + LodLights << "255 000 000 255 4.67100000 0.13400000 36.0030000 1.20 00 1 0" << endl; + LodLights << "255 000 000 255 -4.3560000 0.13400000 36.0030000 1.20 00 1 0" << endl; LodLights << "%additional_coronas" << endl; - LodLights << "255 255 255 -651.287 2145.91 74.7152 0.7 1" << endl; - LodLights << "255 255 255 -781.256 2140.42 74.7152 0.7 1" << endl; - LodLights << "255 255 255 -811.168 2015.78 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -794.209 2024.26 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -776.244 2031.43 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -733.823 2041.57 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -714.854 2043.3 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -695.276 2043.66 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -653.376 2038.31 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -635.249 2032.18 57.1071 0.7 1" << endl; - LodLights << "255 255 255 -617.319 2024.71 57.1071 0.7 1" << endl; - LodLights << "255 0 0 -750.894 2036.27 76.7071 0.7 1" << endl; - LodLights << "255 0 0 -678.849 2040.47 76.7071 0.7 1" << endl; + LodLights << "255 255 255 255 -651.28700 2145.91000 74.7152000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -781.25600 2140.42000 74.7152000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -811.16800 2015.78000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -794.20900 2024.26000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -776.24400 2031.43000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -733.82300 2041.57000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -714.85400 2043.30000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -695.27600 2043.66000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -653.37600 2038.31000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -635.24900 2032.18000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 -617.31900 2024.71000 57.1071000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 -750.89400 2036.27000 76.7071000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 -678.84900 2040.47000 76.7071000 0.70 00 1 0" << endl; LodLights << "#place you coronas here" << endl; LodLights.close(); SetCurrentDirectory("..\\"); } +void ConvertLightTo2DFX() +{ + ofstream LodLights; + LodLights.open(Filename, fstream::trunc); + + LodLights << "#%modelname" << endl; + LodLights << "#Red, Green, Blue, Alpha, OffsetX, OffsetY, OffsetZ, CustomSize, BlinkType, NoDistance, DrawSearchlight" << endl; + LodLights << "#0.45 - custom size reserved for traffic lights" << endl; + LodLights << endl; + + SetCurrentDirectory(".\\iv\\"); + WIN32_FIND_DATA fd; + HANDLE TXTFile = FindFirstFile("*.light", &fd); + if (TXTFile != INVALID_HANDLE_VALUE) + { + do { + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + + ifstream TXTFileContent(fd.cFileName); string buf; + string ext = fd.cFileName; ext.replace(ext.find(".light"), 6, "\0"); + string ext2 = ext; + //LodLights << "%" << ext.c_str() << endl; + bool mdlname = false; + + if (ext2.find("bm_nylamp110b") != std::string::npos || ext2.find("bm_nylamp1b") != std::string::npos || ext2.find("bm_nylamp2b") != std::string::npos || + ext2.find("cj_nylamp2b") != std::string::npos) + continue; + + string EntryName; float offsetX, offsetY, offsetZ, CoronaSize; int R = 0, G = 0, B = 0, A = 255; int BlinkType = 0; int nNoDistance = 0; int nDrawSearchlight = 0; + while (getline(TXTFileContent, buf)) + { + if (buf[0] != '#') + { + if (sscanf(buf.c_str(), "%s", &EntryName[0])) + { + if (buf.find("Position") != std::string::npos) + { + sscanf(buf.c_str(), "%*s %f %f %f", &offsetX, &offsetY, &offsetZ); + } + else if (buf.find("Color") != std::string::npos) + { + sscanf(buf.c_str(), "%*s %d %d %d %*d", &R, &G, &B); + } + else if (buf.find("CoronaSize") != std::string::npos) + { + sscanf(buf.c_str(), "%*s %f", &CoronaSize); + + if (CoronaSize > 1.0f) + CoronaSize = 1.2f; + + if (ext.find("traf") != std::string::npos) + CoronaSize = 0.45f; + + (offsetX == -0.0f) ? offsetX = 0.0f : offsetX; + (offsetY == -0.0f) ? offsetY = 0.0f : offsetY; + (offsetZ == -0.0f) ? offsetZ = 0.0f : offsetZ; + } + else if (buf.find("Type Spot") != std::string::npos || buf.find("Type Omni") != std::string::npos) + { + ext = ext2 + ".skel"; + ifstream TXTFileContent2(ext); string buf2; + bool br = false; + if (TXTFileContent2.is_open()) + { + while (getline(TXTFileContent2, buf2)) + { + if (offsetZ >= 21.0f) + break; + if (buf2.find("LocalOffset") != std::string::npos) + { + float offsetX2, offsetY2, offsetZ2; + sscanf(buf2.c_str(), "%*s %f %f %f", &offsetX2, &offsetY2, &offsetZ2); + offsetX += offsetX2; + offsetY += offsetY2; + offsetZ += offsetZ2; + } + + //if (buf2.find("NumBones 0") != std::string::npos || buf2.find("NumBones 1") != std::string::npos) + //{ + // br = true; + // break; + //} + } + TXTFileContent2.close(); + } + //else + // continue; + + //if (br) + // continue; + + if (CoronaSize > 0.0f) + { + auto GetPrecison = [](float value) -> int + { + int width = 10; + int digits = 0; + + if (value < 0.0f) + { + value *= -1.0f; + digits++; + } + digits += ((value<1) ? 1 : int(1 + log10(float(abs(value))))); + int precision = (((width - digits - 1) >= 0) ? (width - digits - 1) : 0); + return precision; + }; + + if (!mdlname) + { + LodLights << "%" << ext2.c_str() << endl; + mdlname = true; + } + + LodLights << std::right + << std::setfill('0') + << std::setw(3) << R << " " + << std::setw(3) << G << " " + << std::setw(3) << B << " " + << std::setw(3) << ((buf.find("Type Omni") != std::string::npos) ? 128 : A) << " " + << std::setfill(' ') + << std::left + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetX)) << offsetX << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetY)) << offsetY << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetZ)) << offsetZ << " " + << std::setw(4) << std::fixed << std::setprecision(2) << CoronaSize << " " + << std::right << std::setfill('0') + << std::setw(2) << BlinkType << " " + << std::left << std::setfill(' ') + << std::setw(1) << nNoDistance << " " + << std::setw(1) << nDrawSearchlight + << std::endl; + } + } + + } + } + } + TXTFileContent.close(); + } + + } while (FindNextFile(TXTFile, &fd)); + FindClose(TXTFile); + } + + LodLights << "%bm_nylamp110b" << endl; + LodLights << "255 219 155 255 -1.1508710 -0.0219250 6.95975000 0.80 00 0 0" << endl; + LodLights << "255 219 155 255 1.10668200 -0.0219260 6.95970100 0.80 00 0 0" << endl; + LodLights << "%bm_nylamp1b" << endl; + LodLights << "255 221 163 255 -1.6176590 -0.0347459 7.78166600 0.80 00 0 0" << endl; + LodLights << "255 221 163 255 1.58855900 -0.0347870 7.78166800 0.80 00 0 0" << endl; + LodLights << "%bm_nylamp2b" << endl; + LodLights << "255 221 163 255 -2.5801490 -0.0306550 7.68636900 0.80 00 0 0" << endl; + LodLights << "255 221 163 255 2.56053300 -0.0384880 7.68502200 0.80 00 0 0" << endl; + LodLights << "%cj_nylamp2b" << endl; + LodLights << "255 221 163 255 -2.1766780 0.12343800 8.0072020 0.80 00 0 0" << endl; + LodLights << "255 221 163 255 2.21655300 0.12538500 8.0055760 0.80 00 0 0" << endl; + + LodLights.close(); + SetCurrentDirectory("..\\"); +} + int _tmain(int argc, _TCHAR* argv[]) { string line, line2; ifstream GTAData; + GTAData.open(".\\gta4.dat", std::ifstream::in); + if (GTAData.is_open()) + { + GTAData.close(); + Filename = "IVLodLights.dat"; + ConvertLightTo2DFX(); + return 0; + } + GTAData.open(".\\gta3.dat", std::ifstream::in); Filename = "IIILodLights.dat"; if (!GTAData.is_open()) @@ -346,7 +621,7 @@ int _tmain(int argc, _TCHAR* argv[]) { int ID; string ModelName; IDEline.erase(std::remove(IDEline.begin(), IDEline.end(), ','), IDEline.end()); - if (sscanf(IDEline.c_str(), "%d %s %*s %*d %*s", &ID, &ModelName)) + if (sscanf(IDEline.c_str(), "%d %s %*s %*d %*s", &ID, &ModelName[0])) { if (IDEline.find("coronastar") == std::string::npos) { @@ -375,30 +650,61 @@ int _tmain(int argc, _TCHAR* argv[]) if (FX2DData.is_open()) { LodLights << "#%modelname" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, vecOffset.x, vecOffset.y, vecOffset.z, fCustomSize" << endl; - LodLights << "#coronaColour2.r, coronaColour2.g, coronaColour2.b, vecOffset2.x, vecOffset2.y, vecOffset2.z, fCustomSize2" << endl; - LodLights << "#%modelname2" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, vecOffset.x, vecOffset.y, vecOffset.z, fCustomSize" << endl; - LodLights << "#%additional_coronas" << endl; - LodLights << "#coronaColour.r, coronaColour.g, coronaColour.b, position.x, position.y, position.z, fCustomSize, 1" << endl; - LodLights << "#place you coronas here" << endl; - LodLights << "#0.45 - reserved for traffic lights" << endl; + LodLights << "#Red, Green, Blue, Alpha, OffsetX, OffsetY, OffsetZ, CustomSize, BlinkType, NoDistance, DrawSearchlight" << endl; + LodLights << "#0.45 - custom size reserved for traffic lights" << endl; LodLights << endl; static int PrevID; + static int TrafficLCount; while (getline(FX2DData, line)) { - int ID; float offsetX, offsetY, offsetZ; int R, G, B; int unk1, type; string Corona, Shadow; float Distance, OuterRange, Size, InnerRange; int ShadowIntensity, Flash, Wet, Flare, Dust; + int ID; float offsetX, offsetY, offsetZ; int R = 0, G = 0, B = 0, A = 255; int BlinkType = 0; int nNoDistance = 0; int nDrawSearchlight = 0; int unk1, type; string Corona, Shadow; float Distance, OuterRange, CoronaSize, InnerRange; int ShadowIntensity, Wet, Flare, Dust; line.erase(std::remove(line.begin(), line.end(), ','), line.end()); if (sscanf(line.c_str(), "%d %f %f %f %d %d %d %d %d %s %s %f %f %f %f %d %d %d %d %d", - &ID, &offsetX, &offsetY, &offsetZ, &R, &G, &B, &unk1, &type, &Corona, &Shadow, &Distance, &OuterRange, &Size, &InnerRange, &ShadowIntensity, &Flash, &Wet, &Flare, &Dust)) + &ID, &offsetX, &offsetY, &offsetZ, &R, &G, &B, &unk1, &type, &Corona[0], &Shadow[0], &Distance, &OuterRange, &CoronaSize, &InnerRange, &ShadowIntensity, &BlinkType, &Wet, &Flare, &Dust)) { - if (Size > 1.0f) - Size = 1.2f; + if (BlinkType == 0 || BlinkType == 1 || BlinkType == 12) + { + BlinkType = BlinkTypes::DEFAULT; + } + else if (BlinkType == 2 || BlinkType == 3 || BlinkType == 10 || BlinkType == 11) + { + BlinkType = BlinkTypes::DEFAULT; //BlinkType = BlinkTypes::RANDOM_FLASHING; + } + else if (BlinkType == 4 || BlinkType == 5 || BlinkType == 13) + { + BlinkType = BlinkTypes::T_1S_ON_1S_OFF; + } + else if (BlinkType == 6 || BlinkType == 7) + { + BlinkType = BlinkTypes::T_2S_ON_2S_OFF; + } + else if (BlinkType == 8 || BlinkType == 9) + { + BlinkType = BlinkTypes::T_3S_ON_3S_OFF; + } - if (!Size || ID == 4481 || ID == 4483) //destruct2 destruct03 + if (CoronaSize > 1.0f) + CoronaSize = 1.2f; + + if (!CoronaSize || ID == 4481 || ID == 4483) //destruct2 destruct03 continue; + auto GetPrecison = [](float value) -> int + { + int width = 10; + int digits = 0; + + if (value < 0.0f) + { + value *= -1.0f; + digits++; + } + digits += ((value<1) ? 1 : int(1 + log10(float(abs(value))))); + int precision = (((width - digits - 1) >= 0) ? (width - digits - 1) : 0); + return precision; + }; + if (PrevID != ID) { IDEData.clear(); @@ -407,7 +713,7 @@ int _tmain(int argc, _TCHAR* argv[]) { line2.erase(std::remove(line2.begin(), line2.end(), ','), line2.end()); int IdeID; string ModelName2; - if (sscanf(line2.c_str(), "%d %s %*s %*d %*s", &IdeID, &ModelName2)) + if (sscanf(line2.c_str(), "%d %s %*s %*d %*s", &IdeID, &ModelName2[0])) { if (IdeID == ID) { @@ -417,35 +723,124 @@ int _tmain(int argc, _TCHAR* argv[]) } } std::transform(line2.begin(), line2.end(), line2.begin(), ::tolower); + + if (line2.find("lamppost1") != std::string::npos || line2.find("lamppost2") != std::string::npos || + line2.find("lamppost3") != std::string::npos || line2.find("sub_floodlite") != std::string::npos || + line2.find("mlamppost") != std::string::npos || line2.find("doublestreetlght1") != std::string::npos || + line2.find("bollardlight") != std::string::npos || line2.find("lampost_coast") != std::string::npos) + { + nDrawSearchlight = 1; + } + if (line2.find("mtraffic1") != std::string::npos || line2.find("mtraffic2") != std::string::npos || - line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos) + line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos) { - Size = 0.45f; - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); - PrevID = ID; - continue; + CoronaSize = 0.45f; + nDrawSearchlight = 0; + R = 255; + G = 0; + B = 0; + TrafficLCount = 0; } + + (offsetX == -0.0f) ? offsetX = 0.0f : offsetX; + (offsetY == -0.0f) ? offsetY = 0.0f : offsetY; + (offsetZ == -0.0f) ? offsetZ = 0.0f : offsetZ; + + LodLights << std::right + << std::setfill('0') + << std::setw(3) << R << " " + << std::setw(3) << G << " " + << std::setw(3) << B << " " + << std::setw(3) << A << " " + << std::setfill(' ') + << std::left + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetX)) << offsetX << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetY)) << offsetY << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetZ)) << offsetZ << " " + << std::setw(4) << std::fixed << std::setprecision(2) << CoronaSize << " " + << std::right << std::setfill('0') + << std::setw(2) << BlinkType << " " + << std::left << std::setfill(' ') + << std::setw(1) << nNoDistance << " " + << std::setw(1) << nDrawSearchlight + << std::endl; - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); PrevID = ID; } else { std::transform(line2.begin(), line2.end(), line2.begin(), ::tolower); - if (!(line2.find("mtraffic1") != std::string::npos || line2.find("mtraffic2") != std::string::npos || - line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos)) - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); - } - if (line2.find("lamppost1") != std::string::npos || line2.find("lamppost2") != std::string::npos || - line2.find("lamppost3") != std::string::npos || line2.find("sub_floodlite") != std::string::npos || - line2.find("mlamppost") != std::string::npos || line2.find("doublestreetlght1") != std::string::npos || - line2.find("bollardlight") != std::string::npos || line2.find("lampost_coast") != std::string::npos) - { - LodLights << " " << "0" << " " << "1" << endl; - } - else - { - LodLights << endl; + + if (line2.find("lamppost1") != std::string::npos || line2.find("lamppost2") != std::string::npos || + line2.find("lamppost3") != std::string::npos || line2.find("sub_floodlite") != std::string::npos || + line2.find("mlamppost") != std::string::npos || line2.find("doublestreetlght1") != std::string::npos || + line2.find("bollardlight") != std::string::npos || line2.find("lampost_coast") != std::string::npos) + { + nDrawSearchlight = 1; + } + + if (line2.find("mtraffic1") != std::string::npos || line2.find("mtraffic2") != std::string::npos || + line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos) + { + CoronaSize = 0.45f; + nDrawSearchlight = 0; + + TrafficLCount++; + switch (TrafficLCount) + { + case 1: + R = 255; + G = 128; + B = 0; + break; + case 2: + R = 0; + G = 255; + B = 0; + break; + case 3: + R = 255; + G = 0; + B = 0; + break; + case 4: + R = 255; + G = 128; + B = 0; + break; + case 5: + R = 0; + G = 255; + B = 0; + break; + default: + break; + } + } + + (offsetX == -0.0f) ? offsetX = 0.0f : offsetX; + (offsetY == -0.0f) ? offsetY = 0.0f : offsetY; + (offsetZ == -0.0f) ? offsetZ = 0.0f : offsetZ; + + LodLights << std::right + << std::setfill('0') + << std::setw(3) << R << " " + << std::setw(3) << G << " " + << std::setw(3) << B << " " + << std::setw(3) << A << " " + << std::setfill(' ') + << std::left + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetX)) << offsetX << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetY)) << offsetY << " " + << std::setw(10) << std::fixed << std::setprecision(GetPrecison(offsetZ)) << offsetZ << " " + << std::setw(4) << std::fixed << std::setprecision(2) << CoronaSize << " " + << std::right << std::setfill('0') + << std::setw(2) << BlinkType << " " + << std::left << std::setfill(' ') + << std::setw(1) << nNoDistance << " " + << std::setw(1) << nDrawSearchlight + << std::endl; } } } @@ -454,98 +849,98 @@ int _tmain(int argc, _TCHAR* argv[]) LodLights << "%additional_coronas" << endl; if (Filename == "IIILodLights.dat") { - LodLights << "255 0 0 225.823 -1554.6 461.855 0.7 1" << endl; - LodLights << "255 0 0 277.323 -1530.9 461.855 0.7 1" << endl; - LodLights << "255 0 0 289.423 -1434.6 461.855 0.7 1" << endl; - LodLights << "255 0 0 276.523 -1411.9 461.855 0.7 1" << endl; - LodLights << "255 0 0 216.623 -1411.9 461.855 0.7 1" << endl; - LodLights << "255 0 0 206.723 -1429.2 461.855 0.7 1" << endl; - LodLights << "255 0 0 207.223 -1475.6 461.855 0.7 1" << endl; - LodLights << "255 0 0 262.954 -1353.97 298.755 0.7 1" << endl; - LodLights << "255 0 0 262.958 -1303.72 298.755 0.7 1" << endl; - LodLights << "255 0 0 223.264 -1303.67 298.755 0.7 1" << endl; - LodLights << "255 0 0 223.256 -1353.92 298.755 0.7 1" << endl; - LodLights << "255 145 0 100.484 -1365 416.956 2.0 1" << endl; - LodLights << "255 0 0 400.353 -328.015 187.855 1.0 1" << endl; - LodLights << "255 0 0 26.6703 -1161.49 177.355 0.7 1" << endl; - LodLights << "255 0 0 - 5.41379 -1146.4 176.955 0.7 1" << endl; - LodLights << "255 0 0 - 39.8296 -1216 176.955 0.7 1" << endl; - LodLights << "255 0 0 26.5036 -1247.63 177.355 0.7 1" << endl; - LodLights << "255 255 255 460.366 -951.669 48.3555 1.2 1" << endl; - LodLights << "255 255 255 460.366 -908.269 48.3555 1.2 1" << endl; - LodLights << "255 255 255 486.166 -908.369 56.2555 1.2 1" << endl; - LodLights << "255 255 255 486.166 -951.769 56.2555 1.2 1" << endl; - LodLights << "255 255 255 509.166 -908.369 66.2555 1.2 1" << endl; - LodLights << "255 255 255 509.166 -951.769 66.2555 1.2 1" << endl; - LodLights << "255 255 255 531.566 -908.369 77.7555 1.2 1" << endl; - LodLights << "255 255 255 531.566 -951.769 77.7555 1.2 1" << endl; - LodLights << "255 255 255 554.466 -908.369 93.9555 1.2 1" << endl; - LodLights << "255 255 255 554.466 -951.769 93.9555 1.2 1" << endl; - LodLights << "255 255 255 577.366 -908.369 114.356 1.2 1" << endl; - LodLights << "255 255 255 577.366 -951.769 114.356 1.2 1" << endl; - LodLights << "255 255 255 599.566 -951.769 139.155 1.2 1" << endl; - LodLights << "255 255 255 599.566 -908.369 139.155 1.2 1" << endl; - LodLights << "255 255 255 771.866 -952.669 48.3555 1.2 1" << endl; - LodLights << "255 255 255 771.366 -909.269 48.3555 1.2 1" << endl; - LodLights << "255 255 255 744.966 -909.369 56.7555 1.2 1" << endl; - LodLights << "255 255 255 745.466 -952.769 56.7555 1.2 1" << endl; - LodLights << "255 255 255 722.666 -952.569 65.6555 1.2 1" << endl; - LodLights << "255 255 255 722.166 -909.169 65.6555 1.2 1" << endl; - LodLights << "255 255 255 700.166 -952.569 78.2555 1.2 1" << endl; - LodLights << "255 255 255 699.666 -909.169 78.2555 1.2 1" << endl; - LodLights << "255 255 255 678.066 -952.469 93.7555 1.2 1" << endl; - LodLights << "255 255 255 677.566 -909.069 93.7555 1.2 1" << endl; - LodLights << "255 255 255 654.466 -952.269 113.856 1.2 1" << endl; - LodLights << "255 255 255 653.966 -908.869 113.855 1.2 1" << endl; - LodLights << "255 255 255 632.466 -952.469 139.155 1.2 1" << endl; - LodLights << "255 255 255 631.966 -909.069 139.155 1.2 1" << endl; - LodLights << "#place you coronas here" << endl; + LodLights << "255 000 000 255 225.823000 -1554.6000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 277.323000 -1530.9000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 289.423000 -1434.6000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 276.523000 -1411.9000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 216.623000 -1411.9000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 206.723000 -1429.2000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 207.223000 -1475.6000 461.855000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 262.954000 -1353.9700 298.755000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 262.958000 -1303.7200 298.755000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 223.264000 -1303.6700 298.755000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 223.256000 -1353.9200 298.755000 0.70 00 1 0" << endl; + LodLights << "255 145 000 255 100.484000 -1365.0000 416.956000 2.00 00 1 0" << endl; + LodLights << "255 000 000 255 400.353000 -328.01500 187.855000 1.00 00 1 0" << endl; + LodLights << "255 000 000 255 26.6703000 -1161.4900 177.355000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 -5.4137900 -1146.4000 176.955000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 -39.829600 -1216.0000 176.955000 0.70 00 1 0" << endl; + LodLights << "255 000 000 255 26.5036000 -1247.6300 177.355000 0.70 00 1 0" << endl; + LodLights << "255 255 255 255 460.366000 -951.66900 48.3555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 460.366000 -908.26900 48.3555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 486.166000 -908.36900 56.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 486.166000 -951.76900 56.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 509.166000 -908.36900 66.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 509.166000 -951.76900 66.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 531.566000 -908.36900 77.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 531.566000 -951.76900 77.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 554.466000 -908.36900 93.9555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 554.466000 -951.76900 93.9555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 577.366000 -908.36900 114.356000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 577.366000 -951.76900 114.356000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 599.566000 -951.76900 139.155000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 599.566000 -908.36900 139.155000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 771.866000 -952.66900 48.3555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 771.366000 -909.26900 48.3555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 744.966000 -909.36900 56.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 745.466000 -952.76900 56.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 722.666000 -952.56900 65.6555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 722.166000 -909.16900 65.6555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 700.166000 -952.56900 78.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 699.666000 -909.16900 78.2555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 678.066000 -952.46900 93.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 677.566000 -909.06900 93.7555000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 654.466000 -952.26900 113.856000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 653.966000 -908.86900 113.855000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 632.466000 -952.46900 139.155000 1.20 00 1 0" << endl; + LodLights << "255 255 255 255 631.966000 -909.06900 139.155000 1.20 00 1 0" << endl; + LodLights << "#place you coronas here" << endl; } else { - LodLights << "255 0 255 -682.821 -919.102 12.5548 0.7 1" << endl; - LodLights << "255 0 255 -662.821 -920.202 13.7548 0.7 1" << endl; - LodLights << "255 0 255 -642.821 -920.802 15.2548 0.7 1" << endl; - LodLights << "255 0 255 -622.821 -921.002 16.8548 0.7 1" << endl; - LodLights << "255 0 255 -682.821 -939.702 12.5548 0.7 1" << endl; - LodLights << "255 0 255 -662.821 -940.602 13.7548 0.7 1" << endl; - LodLights << "255 0 255 -642.821 -941.202 15.2548 0.7 1" << endl; - LodLights << "255 0 255 -622.821 -941.402 16.8548 0.7 1" << endl; - LodLights << "255 0 255 -602.821 -921.102 18.2548 0.7 1" << endl; - LodLights << "255 0 255 -602.821 -941.502 18.2548 0.7 1" << endl; - LodLights << "255 0 255 -582.821 -921.202 19.7548 0.7 1" << endl; - LodLights << "255 0 255 -582.821 -941.602 19.7548 0.7 1" << endl; - LodLights << "255 0 255 -562.821 -921.202 21.5548 0.7 1" << endl; - LodLights << "255 0 255 -562.821 -941.602 21.5548 0.7 1" << endl; - LodLights << "255 0 255 -542.821 -921.202 22.6548 0.7 1" << endl; - LodLights << "255 0 255 -542.821 -941.602 22.6548 0.7 1" << endl; - LodLights << "255 0 255 -522.821 -921.202 23.3548 0.7 1" << endl; - LodLights << "255 0 255 -522.821 -941.602 23.3548 0.7 1" << endl; - LodLights << "255 0 255 -502.821 -941.602 24.1548 0.7 1" << endl; - LodLights << "255 0 255 -502.821 -921.202 24.1548 0.7 1" << endl; - LodLights << "255 0 255 -482.821 -921.602 24.4548 0.7 1" << endl; - LodLights << "255 0 255 -482.821 -942.002 24.4548 0.7 1" << endl; - LodLights << "255 0 255 -462.821 -922.102 24.4548 0.7 1" << endl; - LodLights << "255 0 255 -462.821 -942.502 24.4548 0.7 1" << endl; - LodLights << "255 0 255 -442.821 -922.402 23.9548 0.7 1" << endl; - LodLights << "255 0 255 -442.821 -942.802 23.9548 0.7 1" << endl; - LodLights << "255 0 255 -422.821 -922.702 23.3548 0.7 1" << endl; - LodLights << "255 0 255 -422.821 -943.102 23.3548 0.7 1" << endl; - LodLights << "255 0 255 -402.821 -943.502 22.4548 0.7 1" << endl; - LodLights << "255 0 255 -402.821 -923.102 22.4548 0.7 1" << endl; - LodLights << "255 0 255 -382.821 -944.002 21.1548 0.7 1" << endl; - LodLights << "255 0 255 -382.821 -923.602 21.1548 0.7 1" << endl; - LodLights << "255 0 255 -362.821 -944.702 19.5548 0.7 1" << endl; - LodLights << "255 0 255 -362.821 -924.302 19.5548 0.7 1" << endl; - LodLights << "255 0 255 -342.821 -945.202 18.2548 0.7 1" << endl; - LodLights << "255 0 255 -342.821 -924.802 18.2548 0.7 1" << endl; - LodLights << "255 0 255 -322.821 -925.902 17.0548 0.7 1" << endl; - LodLights << "255 0 255 -322.821 -946.402 17.0548 0.7 1" << endl; - LodLights << "255 0 255 -302.821 -927.002 15.9548 0.7 1" << endl; - LodLights << "255 0 255 -302.821 -947.502 15.9548 0.7 1" << endl; - LodLights << "255 0 255 -282.821 -948.302 15.2548 0.7 1" << endl; - LodLights << "255 0 255 -282.821 -927.902 15.2548 0.7 1" << endl; - LodLights << "#place you coronas here" << endl; + LodLights << "255 000 255 255 -682.82100 -919.10200 12.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -662.82100 -920.20200 13.7548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -642.82100 -920.80200 15.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -622.82100 -921.00200 16.8548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -682.82100 -939.70200 12.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -662.82100 -940.60200 13.7548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -642.82100 -941.20200 15.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -622.82100 -941.40200 16.8548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -602.82100 -921.10200 18.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -602.82100 -941.50200 18.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -582.82100 -921.20200 19.7548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -582.82100 -941.60200 19.7548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -562.82100 -921.20200 21.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -562.82100 -941.60200 21.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -542.82100 -921.20200 22.6548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -542.82100 -941.60200 22.6548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -522.82100 -921.20200 23.3548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -522.82100 -941.60200 23.3548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -502.82100 -941.60200 24.1548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -502.82100 -921.20200 24.1548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -482.82100 -921.60200 24.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -482.82100 -942.00200 24.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -462.82100 -922.10200 24.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -462.82100 -942.50200 24.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -442.82100 -922.40200 23.9548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -442.82100 -942.80200 23.9548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -422.82100 -922.70200 23.3548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -422.82100 -943.10200 23.3548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -402.82100 -943.50200 22.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -402.82100 -923.10200 22.4548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -382.82100 -944.00200 21.1548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -382.82100 -923.60200 21.1548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -362.82100 -944.70200 19.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -362.82100 -924.30200 19.5548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -342.82100 -945.20200 18.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -342.82100 -924.80200 18.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -322.82100 -925.90200 17.0548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -322.82100 -946.40200 17.0548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -302.82100 -927.00200 15.9548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -302.82100 -947.50200 15.9548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -282.82100 -948.30200 15.2548000 0.70 00 1 0" << endl; + LodLights << "255 000 255 255 -282.82100 -927.90200 15.2548000 0.70 00 1 0" << endl; + LodLights << "#place you coronas here" << endl; } LodLights.close(); diff --git a/2DFXDataGrabber/2DFXDataGrabber.vcxproj b/2DFXDataGrabber/2DFXDataGrabber.vcxproj index 702178d..f1a7ce0 100644 --- a/2DFXDataGrabber/2DFXDataGrabber.vcxproj +++ b/2DFXDataGrabber/2DFXDataGrabber.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,17 @@ Release Win32 + + Debug + x64 + + + Release + x64 + - {8862820A-5A13-49D6-A4D1-0E44F1AA1C49} + {F8B89DD3-F127-474B-8CA8-81D276F651AD} Win32Proj My2DFXDataGrabber 8.1 @@ -20,7 +28,7 @@ Application true - v120 + v140 Unicode @@ -30,29 +38,70 @@ true MultiByte + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + true + + true + false $(SolutionDir)$(Configuration)\$(ProjectName)\ + + false + - Use + + Level3 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) Console @@ -62,30 +111,46 @@ Level3 - Use + + MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded Console + true + true true + + + copy /y "$(TargetPath)" "Z:\WGTA\P2DFXData\2dfxsa\2DFXDataGrabber.exe" +copy /y "$(TargetPath)" "Z:\WGTA\P2DFXData\2dfxvc\2DFXDataGrabber.exe" +copy /y "$(TargetPath)" "Z:\WGTA\P2DFXData\2dfx3\2DFXDataGrabber.exe" +copy /y "$(TargetPath)" "Z:\WGTA\P2DFXData\2dfxiv\2DFXDataGrabber.exe" + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console true true + true - - - - - - Create - Create - diff --git a/2DFXDataGrabber/2DFXDataGrabber.vcxproj.filters b/2DFXDataGrabber/2DFXDataGrabber.vcxproj.filters index 3062c57..9d296a9 100644 --- a/2DFXDataGrabber/2DFXDataGrabber.vcxproj.filters +++ b/2DFXDataGrabber/2DFXDataGrabber.vcxproj.filters @@ -15,17 +15,6 @@ - - Header Files - - - Header Files - - - - - Source Files - Source Files diff --git a/2DFXDataGrabber/stdafx.cpp b/2DFXDataGrabber/stdafx.cpp deleted file mode 100644 index 11c7921..0000000 --- a/2DFXDataGrabber/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// 2DFXDataGrabber.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/2DFXDataGrabber/stdafx.h b/2DFXDataGrabber/stdafx.h deleted file mode 100644 index b005a83..0000000 --- a/2DFXDataGrabber/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/2DFXDataGrabber/targetver.h b/2DFXDataGrabber/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/2DFXDataGrabber/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/III.VC.SA.IV.Project2DFX.VC.db b/III.VC.SA.IV.Project2DFX.VC.db new file mode 100644 index 0000000..8b5f9a9 Binary files /dev/null and b/III.VC.SA.IV.Project2DFX.VC.db differ diff --git a/III.VC.SA.IV.Project2DFX.sln b/III.VC.SA.IV.Project2DFX.sln index d4cd85e..cdf3d36 100644 --- a/III.VC.SA.IV.Project2DFX.sln +++ b/III.VC.SA.IV.Project2DFX.sln @@ -1,74 +1,68 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IIILodLights", "IIILodLights\IIILodLights.vcxproj", "{B42AC8DF-B9B8-4B39-852B-259C71EFDA35}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SALodLights", "SALodLights\SALodLights.vcxproj", "{7929C620-829C-4A98-9AC7-9578D8009C30}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCLodLights", "VCLodLights\VCLodLights.vcxproj", "{4304D8B7-2551-42BA-B62F-B898C42EABF2}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCLodLights", "VCLodLights\VCLodLights.vcxproj", "{EA7315B9-C110-4B2D-98D2-955D65CC4C20}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SALodLights", "SALodLights\SALodLights.vcxproj", "{32E8A22B-F9D9-4A3C-B524-9632BEC56A51}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IIILodLights", "IIILodLights\IIILodLights.vcxproj", "{6ED8D974-2933-4DF0-9E64-4A6656BD29AE}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IVLodLights", "IVLodLights\IVLodLights.vcxproj", "{586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IVLodLights", "IVLodLights\IVLodLights.vcxproj", "{C6635A78-06E3-45B6-B2F8-47557753A614}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "includes", "includes", "{C3D6CE2B-BA5B-4F07-BB5D-DA6361526A8A}" - ProjectSection(SolutionItems) = preProject - includes\Camera.h = includes\Camera.h - includes\CLODLightManager.h = includes\CLODLightManager.h - includes\General.cpp = includes\General.cpp - includes\General.h = includes\General.h - includes\IniReader.h = includes\IniReader.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "injector", "injector", "{AA98E65A-C4CF-484F-A2E0-68D2C3BBABBE}" - ProjectSection(SolutionItems) = preProject - includes\injector\assembly.hpp = includes\injector\assembly.hpp - includes\injector\calling.hpp = includes\injector\calling.hpp - includes\injector\hooking.hpp = includes\injector\hooking.hpp - includes\injector\injector.hpp = includes\injector\injector.hpp - includes\injector\utility.hpp = includes\injector\utility.hpp - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gvm", "gvm", "{2201EC13-514E-440A-A4D2-7D6640D24D6C}" - ProjectSection(SolutionItems) = preProject - includes\injector\gvm\gvm.hpp = includes\injector\gvm\gvm.hpp - includes\injector\gvm\translator.hpp = includes\injector\gvm\translator.hpp - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2DFXDataGrabber", "2DFXDataGrabber\2DFXDataGrabber.vcxproj", "{8862820A-5A13-49D6-A4D1-0E44F1AA1C49}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2DFXDataGrabber", "2DFXDataGrabber\2DFXDataGrabber.vcxproj", "{F8B89DD3-F127-474B-8CA8-81D276F651AD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B42AC8DF-B9B8-4B39-852B-259C71EFDA35}.Debug|Win32.ActiveCfg = Debug|Win32 - {B42AC8DF-B9B8-4B39-852B-259C71EFDA35}.Debug|Win32.Build.0 = Debug|Win32 - {B42AC8DF-B9B8-4B39-852B-259C71EFDA35}.Release|Win32.ActiveCfg = Release|Win32 - {B42AC8DF-B9B8-4B39-852B-259C71EFDA35}.Release|Win32.Build.0 = Release|Win32 - {4304D8B7-2551-42BA-B62F-B898C42EABF2}.Debug|Win32.ActiveCfg = Debug|Win32 - {4304D8B7-2551-42BA-B62F-B898C42EABF2}.Debug|Win32.Build.0 = Debug|Win32 - {4304D8B7-2551-42BA-B62F-B898C42EABF2}.Release|Win32.ActiveCfg = Release|Win32 - {4304D8B7-2551-42BA-B62F-B898C42EABF2}.Release|Win32.Build.0 = Release|Win32 - {32E8A22B-F9D9-4A3C-B524-9632BEC56A51}.Debug|Win32.ActiveCfg = Debug|Win32 - {32E8A22B-F9D9-4A3C-B524-9632BEC56A51}.Debug|Win32.Build.0 = Debug|Win32 - {32E8A22B-F9D9-4A3C-B524-9632BEC56A51}.Release|Win32.ActiveCfg = Release|Win32 - {32E8A22B-F9D9-4A3C-B524-9632BEC56A51}.Release|Win32.Build.0 = Release|Win32 - {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}.Debug|Win32.ActiveCfg = Debug|Win32 - {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}.Debug|Win32.Build.0 = Debug|Win32 - {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}.Release|Win32.ActiveCfg = Release|Win32 - {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}.Release|Win32.Build.0 = Release|Win32 - {8862820A-5A13-49D6-A4D1-0E44F1AA1C49}.Debug|Win32.ActiveCfg = Debug|Win32 - {8862820A-5A13-49D6-A4D1-0E44F1AA1C49}.Debug|Win32.Build.0 = Debug|Win32 - {8862820A-5A13-49D6-A4D1-0E44F1AA1C49}.Release|Win32.ActiveCfg = Release|Win32 - {8862820A-5A13-49D6-A4D1-0E44F1AA1C49}.Release|Win32.Build.0 = Release|Win32 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Debug|x64.ActiveCfg = Debug|x64 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Debug|x64.Build.0 = Debug|x64 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Debug|x86.ActiveCfg = Debug|Win32 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Debug|x86.Build.0 = Debug|Win32 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Release|x64.ActiveCfg = Release|x64 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Release|x64.Build.0 = Release|x64 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Release|x86.ActiveCfg = Release|Win32 + {7929C620-829C-4A98-9AC7-9578D8009C30}.Release|x86.Build.0 = Release|Win32 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Debug|x64.ActiveCfg = Debug|x64 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Debug|x64.Build.0 = Debug|x64 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Debug|x86.ActiveCfg = Debug|Win32 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Debug|x86.Build.0 = Debug|Win32 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Release|x64.ActiveCfg = Release|x64 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Release|x64.Build.0 = Release|x64 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Release|x86.ActiveCfg = Release|Win32 + {EA7315B9-C110-4B2D-98D2-955D65CC4C20}.Release|x86.Build.0 = Release|Win32 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Debug|x64.ActiveCfg = Debug|x64 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Debug|x64.Build.0 = Debug|x64 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Debug|x86.ActiveCfg = Debug|Win32 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Debug|x86.Build.0 = Debug|Win32 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Release|x64.ActiveCfg = Release|x64 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Release|x64.Build.0 = Release|x64 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Release|x86.ActiveCfg = Release|Win32 + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE}.Release|x86.Build.0 = Release|Win32 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Debug|x64.ActiveCfg = Debug|x64 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Debug|x64.Build.0 = Debug|x64 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Debug|x86.ActiveCfg = Debug|Win32 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Debug|x86.Build.0 = Debug|Win32 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Release|x64.ActiveCfg = Release|x64 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Release|x64.Build.0 = Release|x64 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Release|x86.ActiveCfg = Release|Win32 + {C6635A78-06E3-45B6-B2F8-47557753A614}.Release|x86.Build.0 = Release|Win32 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Debug|x64.ActiveCfg = Debug|x64 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Debug|x64.Build.0 = Debug|x64 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Debug|x86.ActiveCfg = Debug|Win32 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Debug|x86.Build.0 = Debug|Win32 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Release|x64.ActiveCfg = Release|x64 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Release|x64.Build.0 = Release|x64 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Release|x86.ActiveCfg = Release|Win32 + {F8B89DD3-F127-474B-8CA8-81D276F651AD}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {AA98E65A-C4CF-484F-A2E0-68D2C3BBABBE} = {C3D6CE2B-BA5B-4F07-BB5D-DA6361526A8A} - {2201EC13-514E-440A-A4D2-7D6640D24D6C} = {AA98E65A-C4CF-484F-A2E0-68D2C3BBABBE} - EndGlobalSection EndGlobal diff --git a/IIILodLights/CSearchlights.cpp b/IIILodLights/CSearchlights.cpp new file mode 100644 index 0000000..573d3a2 --- /dev/null +++ b/IIILodLights/CSearchlights.cpp @@ -0,0 +1,429 @@ +#include "CSearchlights.h" + +extern float* CWeatherFoggyness; +extern CVector* GetCamPos(); + +struct CHeliIII +{ + char pad[0x34]; + RwV3D pos; + char pad2[0x26C]; + RwV3D shadowPos; + char pad3[0x4C]; + float unk; + char pad4[0x30]; +}; + +void CSearchlights::RenderHeliSearchLightsIII() +{ + static CHeliIII ***pPoliceHelis = (CHeliIII ***)0x54AE16; + CHeliIII* HeliInst = nullptr; + int nOffset = 0; + short NumOfHelisRequired = *(short*)0x95CCAA; + if (NumOfHelisRequired > 0) + { + nOffset = 0; + do + { + HeliInst = *(nOffset + (*pPoliceHelis)); + if (HeliInst) + { + if (HeliInst->unk > 0.0f) + { + RwV3D EndPoint = HeliInst->shadowPos; + + if (EndPoint.x && EndPoint.y) + { + EndPoint.z = CLODLightManager::III::FindGroundZFor3DCoord(HeliInst->shadowPos.x, HeliInst->shadowPos.y, HeliInst->pos.z, 0, 0); + drawCustomSpotLightIII(HeliInst->pos, EndPoint, 13.0f, 1.0f, 255.0f, 8, 0.8f); //white + } + } + } + nOffset++; + --NumOfHelisRequired; + } while (NumOfHelisRequired > 0); + } +} + +void CSearchlights::RenderSearchLightsIII() +{ + if ((CLODLightManager::III::bRenderOnlyDuringFoggyWeather && *CWeatherFoggyness) || !CLODLightManager::III::bRenderOnlyDuringFoggyWeather) + { + if (CLODLightManager::III::GetIsTimeInRange(20, 7)) + { + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEZWRITEENABLE, (void*)0); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEZTESTENABLE, (void*)1); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATESRCBLEND, (void*)2); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEDESTBLEND, (void*)2); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEVERTEXALPHAENABLE, (void*)1); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATETEXTURERASTER, (void*)0); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEFOGENABLE, (void*)0); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATESHADEMODE, (void*)2); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEALPHATESTFUNCTION, (void*)7); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)0); + + for (auto it = CLODLightManager::III::m_pLampposts->cbegin(); it != CLODLightManager::III::m_pLampposts->cend(); ++it) + { + if (it->nDrawSearchlight) + { + CVector* pCamPos = GetCamPos(); + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + + if ((fDistSqr > 50.0f*50.0f) && (fDistSqr < 300.0f*300.0f)) + { + float fVisibility = CLODLightManager::III::fSearchlightEffectVisibilityFactor * ((0.0233333f)*sqrt(fDistSqr) - 1.16667f); + //if (*CWeatherFoggyness) + // fVisibility *= 0.5f; + + RwV3D EndPoint = *(RwV3D*)&it->vecPos; + EndPoint.z = CLODLightManager::III::FindGroundZFor3DCoord(it->vecPos.x, it->vecPos.y, it->vecPos.z, 0, 0); + + if (!(it->colour.r == 255 && it->colour.g == 255 && it->colour.b == 255)) + { + //yellow + drawCustomSpotLightIII(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 5.0f, 8, fVisibility); + } + else //if (!(it->colour.r == 254 && it->colour.g == 117 && it->colour.b == 134)) + { + //white + drawCustomSpotLightIII(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 255.0f, 8, fVisibility); + } + //else + //{ + // //pink + // drawCustomSpotLightVC(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 200.0f, 18, fVisibility); + //} + } + } + } + + CLODLightManager::III::bRenderHeliSearchlights ? RenderHeliSearchLightsIII() : nullptr; + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEZWRITEENABLE, (void*)1); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEZTESTENABLE, (void*)1); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATESRCBLEND, (void*)5); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEDESTBLEND, (void*)6); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATECULLMODE, (void*)2); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEALPHATESTFUNCTION, (void*)5); + CLODLightManager::III::RwRenderStateSetIII(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)2); + } + } +} + +void __cdecl CSearchlights::drawCustomSpotLightIII(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) +{ + static short TempBufferRenderIndexList[4096]; + static RxObjSpace3dVertex TempVertexBuffer[500]; + static int TempBufferIndicesStored = 0; + static unsigned int TempBufferVerticesStored = 0; + + RwMatrix *v12; // ebx@1 + RwV3D *v13; // eax@4 + signed int v19; // esi@8 + float v20; // fst7@9 + float v21; // ST7C_4@9 + float v22; // ST60_4@9 + float v23; // fst7@9 + float v24; // fst6@9 + float v25; // fst4@9 + float v26; // ST7C_4@9 + float v27; // ST68_4@9 + float v28; // ST6C_4@9 + float v29; // fst4@9 + float v30; // fst3@9 + float v31; // ST80_4@9 + float v32; // fst2@9 + float v33; // ST60_4@9 + float v34; // ST74_4@9 + float v35; // ST78_4@9 + float v36; // ST78_4@9 + float v37; // ST60_4@9 + float v38; // fst7@15 + float v39; // fst5@15 + float v40; // ST80_4@16 + float v41; // fst4@15 + float v42; // fst7@17 + unsigned int v43; // eax@17 + float v44; // fst7@17 + float v45; // fst7@17 + float v46; // fst7@17 + float v47; // fst7@19 + int v49; // ebp@21 + float v50; // fst7@22 + unsigned int v51; // edi@24 + signed int v52; // esi@25 + float v53; // fst7@26 + unsigned char *v54; // ebp@26 + float v55; // fst6@27 + int v56; // ebx@27 + unsigned __int64 v57; // qax@27 + float v59; // fst6@27 + int v60; // ebx@27 + unsigned __int64 v61; // qax@27 + float v63; // fst6@27 + int v64; // ebx@27 + unsigned __int64 v65; // qax@27 + float v66; // fst6@27 + float v67; // fst7@30 + float v68; // fst6@31 + signed int v88; // [sp+44h] [bp-424h]@8 + signed int v89; // [sp+44h] [bp-424h]@26 + void *v90; // [sp+44h] [bp-424h]@30 + float a4; // [sp+48h] [bp-420h]@9 + float EndPointa; // [sp+4Ch] [bp-41Ch]@9 + float v97; // [sp+50h] [bp-418h]@9 + float a6; // [sp+54h] [bp-414h]@9 + float a7; // [sp+58h] [bp-410h]@9 + float v104; // [sp+5Ch] [bp-40Ch]@9 + float v105; // [sp+64h] [bp-404h]@17 + RwV3D a; // [sp+68h] [bp-400h]@1 + float v107; // [sp+74h] [bp-3F4h]@8 + RwV3D v108; // [sp+78h] [bp-3F0h]@1 + float v109; // [sp+84h] [bp-3E4h]@9 + RwV3D v110; // [sp+88h] [bp-3E0h]@6 + RwV3D v111; // [sp+94h] [bp-3D4h]@9 + float v112; // [sp+A0h] [bp-3C8h]@9 + float v113; // [sp+A4h] [bp-3C4h]@9 + RwV3D v115; // [sp+ACh] [bp-3BCh]@16 + float v116; // [sp+B8h] [bp-3B0h]@9 + float v117; // [sp+BCh] [bp-3ACh]@9 + float v118; // [sp+C0h] [bp-3TargetRadiush]@9 + RwV3D out; // [sp+C4h] [bp-3A4h]@9 + float v120; // [sp+D0h] [bp-398h]@16 + float v121; // [sp+D4h] [bp-394h]@16 + float v122; // [sp+D8h] [bp-390h]@16 + float v123; // [sp+DCh] [bp-38Ch]@3 + float v124; // [sp+E0h] [bp-388h]@3 + float v125; // [sp+E4h] [bp-384h]@3 + float v126; // [sp+E8h] [bp-380h]@9 + float v127; // [sp+ECh] [bp-37Ch]@9 + float v128; // [sp+F0h] [bp-378h]@9 + RwV3D v132; // [sp+100h] [bp-368h]@9 + float v133; // [sp+10Ch] [bp-35Ch]@9 + float v134; // [sp+110h] [bp-358h]@9 + float v135; // [sp+118h] [bp-350h]@9 + float v136; // [sp+11Ch] [bp-34Ch]@9 + RwV3D b; // [sp+124h] [bp-344h]@9 + RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 + RwV3D v140; // [sp+158h] [bp-310h]@14 + float v141; // [sp+164h] [bp-304h]@9 + float v142; // [sp+178h] [bp-2F0h]@16 + float v143; // [sp+17Ch] [bp-2ECh]@9 + float v144; // [sp+188h] [bp-2E0h]@9 + float v145; // [sp+19Ch] [bp-2CCh]@9 + float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 + RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 + RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 + + v108.x = EndPoint.x - StartPoint.x; + a.x = v108.x; + v108.y = EndPoint.y - StartPoint.y; + a.y = v108.y; + v108.z = EndPoint.z - StartPoint.z; + a.z = v108.z; + CLODLightManager::III::CVectorNormalize(&a); + v12 = 0; + EndPoint.x = a.x * 3.0f + EndPoint.x; + EndPoint.y = a.y * 3.0f + EndPoint.y; + EndPoint.z = a.z * 3.0f + EndPoint.z; + v123 = a.x * 100.0f + StartPoint.x; + v124 = a.y * 100.0f + StartPoint.y; + v125 = a.z * 100.0f + StartPoint.z; + v13 = (RwV3D*)GetCamPos(); + v110.x = v13->x - StartPoint.x; + v110.y = v13->y - StartPoint.y; + v110.z = v13->z - StartPoint.z; + CLODLightManager::III::CVectorNormalize(&v110); + v19 = 0; + v107 = 0.0f; + TempBufferIndicesStored = 0; + TempBufferVerticesStored = 0; + v88 = 0; + do + { + b.x = 0; + b.y = 0; + b.z = 1.0f; + CLODLightManager::III::CrossProduct(&out, &a, &b); + CLODLightManager::III::CVectorNormalize(&out); + CLODLightManager::III::CrossProduct(&v132, &out, &a); + CLODLightManager::III::CVectorNormalize(&v132); + v20 = (float)v88 * 0.15707964f; + v21 = sin(v20); + v22 = cos(v20); + v23 = out.x * v21; + v141 = v23; + v24 = out.y * v21; + v25 = out.z * v21; + v26 = v25; + v133 = v141 * baseRadius; + v134 = v24 * baseRadius; + v27 = v134 + StartPoint.y; + v28 = v25 * baseRadius + StartPoint.z; + v29 = v132.x * v22; + v109 = v29; + v30 = v132.y * v22; + v31 = v30; + v32 = v132.z * v22; + v33 = v32; + v145 = v32; + v126 = v29 * baseRadius; + v127 = v30 * baseRadius; + v128 = v145 * baseRadius; + v146 = v33; + a4 = v126 + v133 + StartPoint.x; + EndPointa = v127 + v27; + v97 = v128 + v28; + v144 = v23; + v135 = v144 * TargetRadius; + v136 = v24 * TargetRadius; + v34 = v136 + v124; + v35 = v26 * TargetRadius + v125; + v116 = v109 * TargetRadius; + v117 = v31 * TargetRadius; + v118 = v33 * TargetRadius; + v36 = v118 + v35; + v37 = (v97 - EndPoint.z) / (v97 - v36); + v143 = v135 + v123 + v116 - a4; + v112 = v143 * v37; + v113 = (v117 + v34 - EndPointa) * v37; + v111.x = v112 + a4; + v111.y = v113 + EndPointa; + a6 = v111.x; + a7 = v111.y; + v111.z = (v36 - v97) * v37 + v97; + v104 = v111.z; + if (v19 && v19 != 10) + { + if (v19 == 20) + { + v139.x = v111.x; + v139.y = v111.y; + v139.z = v111.z; + } + else + { + if (v19 == 30) + { + v140.x = v111.x; + v140.y = v111.y; + v140.z = v111.z; + } + } + } + v38 = v111.x - a4; + v39 = v111.y - EndPointa; + v41 = v111.z - v97; + v109 = v41; + if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) + { + v115.x = v38; + v40 = v39; + v115.y = v40; + v115.z = v109; + CLODLightManager::III::CVectorNormalize(&v115); + v142 = v115.z * 100.0f; + v120 = v115.x * 100.0f + a4; + a6 = v120; + v121 = v115.y * 100.0f + EndPointa; + a7 = v121; + v122 = v142 + v97; + v104 = v122; + } + v42 = slAlpha * 0.15000001f + 0.1f; + v43 = TempBufferVerticesStored; + TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; + v105 = v42; + TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; + v44 = a4 - StartPoint.x; + TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; + v108.x = v44; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; + v45 = EndPointa - StartPoint.y; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; + v108.y = v45; + v108.z = v97 - StartPoint.z; + CLODLightManager::III::CVectorNormalize(&v108); + v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; + if (v46 < 0.0f) + v46 = -v46; + v47 = v46 * v46; + if (v47 > v107) + v107 = v47; + v49 = TempBufferIndicesStored; + *(&v149[0].red + TempBufferVerticesStored) = v105; + *(&v149[0].green + TempBufferVerticesStored) = 0; + *(&v148[0].red + TempBufferVerticesStored) = v47; + *(&v148[0].green + TempBufferVerticesStored) = v47; + if (v19 != 40) + { + v50 = baseRadius; + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); + v49 += 3; + TempBufferIndicesStored = v49; + if (v50 > 0.0f) + { + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); + v49 += 3; + TempBufferIndicesStored = v49; + } + } + v51 = TempBufferVerticesStored + 2; + ++v19; + TempBufferVerticesStored = v51; + v88 = v19; + } while (v19 <= 40); + v52 = 0; + if ((signed int)v51 >= 4) + { + v89 = 3; + v53 = CLODLightManager::III::fSearchlightEffectVisibilityFactor / v107; + v54 = (unsigned char *)&TempVertexBuffer[1 + CLODLightManager::III::nSmoothEffect].color; + do + { + v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; + v56 = (((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v57 = (unsigned __int64)(v55 * slColorFactor1); + *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); + v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; + v60 = (((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v61 = (unsigned __int64)(v59 * slColorFactor1); + *(DWORD *)v54 = (DWORD)(v61 | v60); + v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; + v64 = (((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v65 = (unsigned __int64)(v63 * slColorFactor1); + *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); + v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); + *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v52 += 4; + v54 = (unsigned char *)v54 + 144; + v89 += 4; + } while (v89 < (signed int)v51); + v49 = TempBufferIndicesStored; + v12 = 0; + } + if (v52 < (signed int)v51) + { + v67 = CLODLightManager::III::fSearchlightEffectVisibilityFactor / v107; + v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + CLODLightManager::III::nSmoothEffect].color); + do + { + v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; + *(unsigned __int64 *)v90 = ((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)) + 0x80000000u; + ++v52; + v90 = (char *)v90 + 0x24; + } while (v52 < (signed int)v51); + v12 = 0; + } + + if (v49 >(signed int)v12 && CLODLightManager::III::RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) + { + CLODLightManager::III::RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); + CLODLightManager::III::RwIm3DEnd(); + } +} \ No newline at end of file diff --git a/IIILodLights/CSearchlights.h b/IIILodLights/CSearchlights.h new file mode 100644 index 0000000..333dccf --- /dev/null +++ b/IIILodLights/CSearchlights.h @@ -0,0 +1,14 @@ +#ifndef __SEARCHLIGHTS +#define __SEARCHLIGHTS +#include "..\includes\stdafx.h" +#include "..\includes\CLODLightManager.h" + +class CSearchlights +{ +public: + static void (__cdecl drawCustomSpotLightIII)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); + static void RenderHeliSearchLightsIII(); + static void RenderSearchLightsIII(); +}; + +#endif \ No newline at end of file diff --git a/IIILodLights/IIILodLights.vcxproj b/IIILodLights/IIILodLights.vcxproj index fdc4990..df14808 100644 --- a/IIILodLights/IIILodLights.vcxproj +++ b/IIILodLights/IIILodLights.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,17 @@ Release Win32 + + Debug + x64 + + + Release + x64 + - {B42AC8DF-B9B8-4B39-852B-259C71EFDA35} + {6ED8D974-2933-4DF0-9E64-4A6656BD29AE} Win32Proj IIILodLights 8.1 @@ -20,7 +28,7 @@ DynamicLibrary true - v120 + v140 Unicode @@ -30,27 +38,55 @@ true MultiByte + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + true + + true + false .asi $(SolutionDir)$(Configuration)\$(ProjectName)\ + + false + - Use + + Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;IIILODLIGHTS_EXPORTS;%(PreprocessorDefinitions) @@ -60,10 +96,24 @@ true + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;IIILODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + - Level4 - Use + Level3 + + MaxSpeed true true @@ -72,34 +122,43 @@ Windows + true + true true + + + copy /y "$(TargetPath)" "Z:\WGTA\Modloader\Grand Theft Auto III\modloader\mods\III.Project2DFXv4\IIILodLights.asi" + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;IIILODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows true true + true - - cd $(TargetDir) -del *.iobj - - - - + + + + + - - - false - - - false - - - - - Create - Create - + + + + diff --git a/IIILodLights/IIILodLights.vcxproj.filters b/IIILodLights/IIILodLights.vcxproj.filters index 63c8950..d85964a 100644 --- a/IIILodLights/IIILodLights.vcxproj.filters +++ b/IIILodLights/IIILodLights.vcxproj.filters @@ -15,25 +15,34 @@ - - Header Files - - - Header Files - - - Header Files - - - - + Source Files - + + Source Files + + Source Files - + Source Files + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/IIILodLights/SearchlightsIII.h b/IIILodLights/SearchlightsIII.h deleted file mode 100644 index 31e03dc..0000000 --- a/IIILodLights/SearchlightsIII.h +++ /dev/null @@ -1,616 +0,0 @@ -enum RwRenderState -{ - rwRENDERSTATENARENDERSTATE = 0, - - rwRENDERSTATETEXTURERASTER, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: FALSE. - */ - rwRENDERSTATESTENCILFAIL, - /**<\ref RwStencilOperation used when the stencil test passes. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILZFAIL, - /**<\ref RwStencilOperation used when the stencil test passes and - * the depth test (z-test) fails. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILPASS, - /**<\ref RwStencilOperation used when both the stencil and the depth - * (z) tests pass. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILFUNCTION, - /**<\ref RwStencilFunction for the stencil test. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILFUNCTIONALWAYS. - */ - rwRENDERSTATESTENCILFUNCTIONREF, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0. - */ - rwRENDERSTATESTENCILFUNCTIONMASK, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0xffffffff. - */ - rwRENDERSTATESTENCILFUNCTIONWRITEMASK, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0xffffffff. - */ - rwRENDERSTATEALPHATESTFUNCTION, - /**<\ref RwAlphaTestFunction for the alpha test. When a pixel fails, - * neither the frame buffer nor the Z-buffer are updated. - * Default: rwALPHATESTFUNCTIONGREATER (GameCube, Xbox, D3D8, D3D9 - * and OpenGL). The default PS2 behaviour is to always update the - * frame buffer and update the Z-buffer only if a greater than or - * equal test passes. - */ - rwRENDERSTATEALPHATESTFUNCTIONREF, - /** Range is 0 to 255, mapped to the platform's actual range - * Default: 128 (PS2) 0 (GameCube, Xbox, D3D8, D3D9 and OpenGL). - */ - - -}; - -unsigned short mi_lamppost1; -unsigned short mi_lamppost2; -unsigned short mi_lamppost3; -unsigned short mi_sub_floodlite; -unsigned short mi_Streetlamp1; -unsigned short mi_mlamppost; -unsigned short mi_doublestreetlght1; -unsigned short mi_Streetlamp2; -unsigned short mi_bollardlight; -unsigned short mi_lampost_coast; -unsigned short mi_doc_floodlite; - -struct CHeliIII -{ - char pad[0x34]; - RwV3D pos; - char pad2[0x26C]; - RwV3D shadowPos; - char pad3[0x4C]; - float unk; - char pad4[0x30]; -}; - -void CLODLightManager::III::RenderHeliSearchLights() -{ - static CHeliIII ***pPoliceHelis = (CHeliIII ***)0x54AE16; - CHeliIII* HeliInst; - int nOffset = 0; - short NumOfHelisRequired = *(short*)0x95CCAA; - if (NumOfHelisRequired > 0) - { - nOffset = 0; - do - { - HeliInst = *(nOffset + (*pPoliceHelis)); - if (HeliInst) - { - if (HeliInst->unk > 0.0f || true) - { - RwV3D StartPoint; - RwV3D EndPoint; - StartPoint.x = HeliInst->pos.x; - EndPoint.x = HeliInst->shadowPos.x; - - if (EndPoint.x && EndPoint.y) - { - StartPoint.y = HeliInst->pos.y; - StartPoint.z = HeliInst->pos.z; - - EndPoint.y = HeliInst->shadowPos.y; - EndPoint.z = FindGroundZFor3DCoord(HeliInst->shadowPos.x, HeliInst->shadowPos.y, HeliInst->pos.z, 0, 0); - - //white - drawCustomSpotLight(StartPoint, EndPoint, 6.0f, 1.0f, 255.0f, 8, fSearchlightEffectVisibilityFactor); - } - } - } - nOffset++; - --NumOfHelisRequired; - } while (NumOfHelisRequired > 0); - } -} - -void CLODLightManager::III::RenderSearchLights() -{ - static CPool **pObjectPool = (CPool **)0x880E28; - CEntityIII *ObjectInst; - int nObjectPoolSize = (*pObjectPool)->size; - - if (nObjectPoolSize && GetIsTimeInRange(20, 7)) - { - int nOffset = 0x19C * nObjectPoolSize; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); - RwRenderStateSet(rwRENDERSTATESRCBLEND, 2); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, 2); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 1); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, 0); - RwRenderStateSet(rwRENDERSTATEFOGENABLE, 0); - RwRenderStateSet(rwRENDERSTATESHADEMODE, 2); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, 7); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, 0); - do - { - --nObjectPoolSize; - nOffset -= 0x19C; - if (*(BYTE *)(nObjectPoolSize + (*pObjectPool)->flags) >= 0) - { - ObjectInst = (CEntityIII *)(nOffset + (*pObjectPool)->objects); - if (ObjectInst) - { - int IsObjectDamaged = (ObjectInst->m_bRenderDamaged); - if (!IsObjectDamaged) - { - auto itEnd = pFileContent->upper_bound(PackKey(ObjectInst->m_nModelIndex, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(ObjectInst->m_nModelIndex, 0)); it != itEnd; it++) - { - if (it->second.nDrawSearchlight) - { - RwV3D StartPoint; - RwV3D EndPoint; - RwV3D zeroCoords; zeroCoords.x = zeroCoords.y = zeroCoords.z = 0.0f; - CVector result = ObjectInst->matrix * it->second.vecPos; - StartPoint.x = result.x; StartPoint.y = result.y; StartPoint.z = result.z; - - if (GetDistance(GetCamPos(), &StartPoint) < 1000.0f && GetDistance(&zeroCoords, &StartPoint) > 100.0f) - { - EndPoint = StartPoint; - float grZ = FindGroundZFor3DCoord(StartPoint.x, StartPoint.y, StartPoint.z, 0, 0); - EndPoint.z = grZ; - - if (!(it->second.colour.r == 255u && it->second.colour.g == 255u && it->second.colour.b == 255u)) - { - //yellow - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), it->second.fCustomSizeMult / 6.0f, 5.0f, 8, fSearchlightEffectVisibilityFactor); - - } - else //if (ObjectInst->m_nModelIndex != GetModelInfoUInt16("Gay_lamppost")) - { - //white - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), it->second.fCustomSizeMult / 6.0f, 255.0f, 8, fSearchlightEffectVisibilityFactor); - } - /*else - { - //pink - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), it->second.fCustomSizeMult / 6.0f, 200.0f, 18, fSearchlightEffectVisibilityFactor); - }*/ - } - } - } - } - } - } - } while (nObjectPoolSize); - true ? RenderHeliSearchLights() : nullptr; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 1); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); - RwRenderStateSet(rwRENDERSTATESRCBLEND, 5); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, 6); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 0); - RwRenderStateSet(rwRENDERSTATECULLMODE, 2); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, 5); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, 2); - } -} - - -void __cdecl CLODLightManager::III::drawCustomSpotLight(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) -{ - RwMatrix *v12; // ebx@1 - RwV3D *v13; // eax@4 - signed int v19; // esi@8 - float v20; // fst7@9 - float v21; // ST7C_4@9 - float v22; // ST60_4@9 - float v23; // fst7@9 - float v24; // fst6@9 - float v25; // fst4@9 - float v26; // ST7C_4@9 - float v27; // ST68_4@9 - float v28; // ST6C_4@9 - float v29; // fst4@9 - float v30; // fst3@9 - float v31; // ST80_4@9 - float v32; // fst2@9 - float v33; // ST60_4@9 - float v34; // ST74_4@9 - float v35; // ST78_4@9 - float v36; // ST78_4@9 - float v37; // ST60_4@9 - float v38; // fst7@15 - float v39; // fst5@15 - float v40; // ST80_4@16 - float v41; // fst4@15 - float v42; // fst7@17 - unsigned int v43; // eax@17 - float v44; // fst7@17 - float v45; // fst7@17 - float v46; // fst7@17 - float v47; // fst7@19 - int v49; // ebp@21 - float v50; // fst7@22 - unsigned int v51; // edi@24 - signed int v52; // esi@25 - float v53; // fst7@26 - unsigned char *v54; // ebp@26 - float v55; // fst6@27 - int v56; // ebx@27 - unsigned __int64 v57; // qax@27 - float v59; // fst6@27 - int v60; // ebx@27 - unsigned __int64 v61; // qax@27 - float v63; // fst6@27 - int v64; // ebx@27 - unsigned __int64 v65; // qax@27 - float v66; // fst6@27 - float v67; // fst7@30 - float v68; // fst6@31 - signed int v88; // [sp+44h] [bp-424h]@8 - signed int v89; // [sp+44h] [bp-424h]@26 - void *v90; // [sp+44h] [bp-424h]@30 - float a4; // [sp+48h] [bp-420h]@9 - float EndPointa; // [sp+4Ch] [bp-41Ch]@9 - float v97; // [sp+50h] [bp-418h]@9 - float a6; // [sp+54h] [bp-414h]@9 - float a7; // [sp+58h] [bp-410h]@9 - float v104; // [sp+5Ch] [bp-40Ch]@9 - float v105; // [sp+64h] [bp-404h]@17 - RwV3D a; // [sp+68h] [bp-400h]@1 - float v107; // [sp+74h] [bp-3F4h]@8 - RwV3D v108; // [sp+78h] [bp-3F0h]@1 - float v109; // [sp+84h] [bp-3E4h]@9 - RwV3D v110; // [sp+88h] [bp-3E0h]@6 - RwV3D v111; // [sp+94h] [bp-3D4h]@9 - float v112; // [sp+A0h] [bp-3C8h]@9 - float v113; // [sp+A4h] [bp-3C4h]@9 - RwV3D v115; // [sp+ACh] [bp-3BCh]@16 - float v116; // [sp+B8h] [bp-3B0h]@9 - float v117; // [sp+BCh] [bp-3ACh]@9 - float v118; // [sp+C0h] [bp-3TargetRadiush]@9 - RwV3D out; // [sp+C4h] [bp-3A4h]@9 - float v120; // [sp+D0h] [bp-398h]@16 - float v121; // [sp+D4h] [bp-394h]@16 - float v122; // [sp+D8h] [bp-390h]@16 - float v123; // [sp+DCh] [bp-38Ch]@3 - float v124; // [sp+E0h] [bp-388h]@3 - float v125; // [sp+E4h] [bp-384h]@3 - float v126; // [sp+E8h] [bp-380h]@9 - float v127; // [sp+ECh] [bp-37Ch]@9 - float v128; // [sp+F0h] [bp-378h]@9 - RwV3D v132; // [sp+100h] [bp-368h]@9 - float v133; // [sp+10Ch] [bp-35Ch]@9 - float v134; // [sp+110h] [bp-358h]@9 - float v135; // [sp+118h] [bp-350h]@9 - float v136; // [sp+11Ch] [bp-34Ch]@9 - RwV3D b; // [sp+124h] [bp-344h]@9 - RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 - RwV3D v140; // [sp+158h] [bp-310h]@14 - float v141; // [sp+164h] [bp-304h]@9 - float v142; // [sp+178h] [bp-2F0h]@16 - float v143; // [sp+17Ch] [bp-2ECh]@9 - float v144; // [sp+188h] [bp-2E0h]@9 - float v145; // [sp+19Ch] [bp-2CCh]@9 - float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 - RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 - RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 - - v108.x = EndPoint.x - StartPoint.x; - a.x = v108.x; - v108.y = EndPoint.y - StartPoint.y; - a.y = v108.y; - v108.z = EndPoint.z - StartPoint.z; - a.z = v108.z; - CVectorNormalize(&a); - v12 = 0; - EndPoint.x = a.x * 3.0f + EndPoint.x; - EndPoint.y = a.y * 3.0f + EndPoint.y; - EndPoint.z = a.z * 3.0f + EndPoint.z; - v123 = a.x * 100.0f + StartPoint.x; - v124 = a.y * 100.0f + StartPoint.y; - v125 = a.z * 100.0f + StartPoint.z; - v13 = GetCamPos(); - v110.x = v13->x - StartPoint.x; - v110.y = v13->y - StartPoint.y; - v110.z = v13->z - StartPoint.z; - CVectorNormalize(&v110); - v19 = 0; - v107 = 0.0f; - TempBufferIndicesStored = 0; - TempBufferVerticesStored = 0; - v88 = 0; - do - { - b.x = 0; - b.y = 0; - b.z = 1.0f; - CrossProduct(&out, &a, &b); - CVectorNormalize(&out); - CrossProduct(&v132, &out, &a); - CVectorNormalize(&v132); - v20 = (float)v88 * 0.15707964f; - v21 = sin(v20); - v22 = cos(v20); - v23 = out.x * v21; - v141 = v23; - v24 = out.y * v21; - v25 = out.z * v21; - v26 = v25; - v133 = v141 * baseRadius; - v134 = v24 * baseRadius; - v27 = v134 + StartPoint.y; - v28 = v25 * baseRadius + StartPoint.z; - v29 = v132.x * v22; - v109 = v29; - v30 = v132.y * v22; - v31 = v30; - v32 = v132.z * v22; - v33 = v32; - v145 = v32; - v126 = v29 * baseRadius; - v127 = v30 * baseRadius; - v128 = v145 * baseRadius; - v146 = v33; - a4 = v126 + v133 + StartPoint.x; - EndPointa = v127 + v27; - v97 = v128 + v28; - v144 = v23; - v135 = v144 * TargetRadius; - v136 = v24 * TargetRadius; - v34 = v136 + v124; - v35 = v26 * TargetRadius + v125; - v116 = v109 * TargetRadius; - v117 = v31 * TargetRadius; - v118 = v33 * TargetRadius; - v36 = v118 + v35; - v37 = (v97 - EndPoint.z) / (v97 - v36); - v143 = v135 + v123 + v116 - a4; - v112 = v143 * v37; - v113 = (v117 + v34 - EndPointa) * v37; - v111.x = v112 + a4; - v111.y = v113 + EndPointa; - a6 = v111.x; - a7 = v111.y; - v111.z = (v36 - v97) * v37 + v97; - v104 = v111.z; - if (v19 && v19 != 10) - { - if (v19 == 20) - { - v139.x = v111.x; - v139.y = v111.y; - v139.z = v111.z; - } - else - { - if (v19 == 30) - { - v140.x = v111.x; - v140.y = v111.y; - v140.z = v111.z; - } - } - } - v38 = v111.x - a4; - v39 = v111.y - EndPointa; - v41 = v111.z - v97; - v109 = v41; - if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) - { - v115.x = v38; - v40 = v39; - v115.y = v40; - v115.z = v109; - CVectorNormalize(&v115); - v142 = v115.z * 100.0f; - v120 = v115.x * 100.0f + a4; - a6 = v120; - v121 = v115.y * 100.0f + EndPointa; - a7 = v121; - v122 = v142 + v97; - v104 = v122; - } - v42 = slAlpha * 0.15000001f + 0.1f; - v43 = TempBufferVerticesStored; - TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; - v105 = v42; - TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; - v44 = a4 - StartPoint.x; - TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; - v108.x = v44; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; - v45 = EndPointa - StartPoint.y; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; - v108.y = v45; - v108.z = v97 - StartPoint.z; - CVectorNormalize(&v108); - v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; - if (v46 < 0.0f) - v46 = -v46; - v47 = v46 * v46; - if (v47 > v107) - v107 = v47; - v49 = TempBufferIndicesStored; - *(&v149[0].red + TempBufferVerticesStored) = v105; - *(&v149[0].green + TempBufferVerticesStored) = 0; - *(&v148[0].red + TempBufferVerticesStored) = v47; - *(&v148[0].green + TempBufferVerticesStored) = v47; - if (v19 != 40) - { - v50 = baseRadius; - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); - v49 += 3; - TempBufferIndicesStored = v49; - if (v50 > 0.0f) - { - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); - v49 += 3; - TempBufferIndicesStored = v49; - } - } - v51 = TempBufferVerticesStored + 2; - ++v19; - TempBufferVerticesStored = v51; - v88 = v19; - } while (v19 <= 40); - v52 = 0; - if ((signed int)v51 >= 4) - { - v89 = 3; - v53 = fSearchlightEffectVisibilityFactor / v107; - v54 = (unsigned char *)&TempVertexBuffer[1 + SmoothEffect].color; - do - { - v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; - v56 = (((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v57 = (unsigned __int64)(v55 * slColorFactor1); - *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); - v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; - v60 = (((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v61 = (unsigned __int64)(v59 * slColorFactor1); - *(DWORD *)v54 = (DWORD)(v61 | v60); - v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; - v64 = (((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v65 = (unsigned __int64)(v63 * slColorFactor1); - *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); - v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); - *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v52 += 4; - v54 = (unsigned char *)v54 + 144; - v89 += 4; - } while (v89 < (signed int)v51); - v49 = TempBufferIndicesStored; - v12 = 0; - } - if (v52 < (signed int)v51) - { - v67 = fSearchlightEffectVisibilityFactor / v107; - v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + SmoothEffect].color); - do - { - v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; - *(unsigned __int64 *)v90 = ((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)) + 0x80000000u; - ++v52; - v90 = (char *)v90 + 0x24; - } while (v52 < (signed int)v51); - v12 = 0; - } - - if (v49 >(signed int)v12 && RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) - { - RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); - RwIm3DEnd(); - } -} \ No newline at end of file diff --git a/IIILodLights/dllmain.cpp b/IIILodLights/dllmain.cpp index 81e8144..bb192b9 100644 --- a/IIILodLights/dllmain.cpp +++ b/IIILodLights/dllmain.cpp @@ -1,247 +1,279 @@ -#include "stdafx.h" +#include "..\includes\stdafx.h" #include "..\includes\CLODLightManager.h" -#include "SearchlightsIII.h" +#include "..\includes\CLODLights.h" +#include "CSearchlights.h" + +int numCoronas; +std::vector VecEntities; +std::vector ExplosionTypes = { 0,2,6,7,8,9 }; //1,3,4,5 - barrel crash +RwCamera*& Camera = *(RwCamera**)0x72676C; +int& CTimer::m_snTimeInMillisecondsPauseMode = *(int*)0x885B48; +float& CTimer::ms_fTimeStep = *(float*)0x8E2CB4; + +char* CLODLightManager::III::CurrentTimeHours = (char*)0x95CDA6; +char* CLODLightManager::III::CurrentTimeMinutes = (char*)0x95CDC8; +float** CLODLightManager::III::fCurrentFarClip = (float**)0x48E5DC; +char(__cdecl *CLODLightManager::III::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x473420; +int* (__cdecl *CLODLightManager::III::GetModelInfo)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x50B860; +bool(__cdecl *const CLODLightManager::III::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CLODLightManager::III::CShadowsStoreStaticShadow))0x5130A0; +float(__cdecl *CLODLightManager::III::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x4B3AE0; +RwV3D* (__cdecl *CLODLightManager::III::TransformPoint)(RwV3D *, RwMatrix *, RwV3D *) = (RwV3D *(__cdecl *)(RwV3D *, RwMatrix *, RwV3D *)) 0x4BA4D0; +bool(__thiscall *CLODLightManager::III::CCameraIsSphereVisible)(int *camera, RwV3D *origin, float radius) = (bool(__thiscall *)(int *, RwV3D *, float)) 0x0043D3B0; +void(__cdecl *CLODLightManager::III::RegisterCorona)(int coronaID, char r, char g, char b, char a, RwV3D *pos, float size, float farClip, char type, char flare, char reflection, char obstacles, char notUsed, float normalAngle) = (void(__cdecl *)(int, char, char, char, char, RwV3D *, float, float, char, char, char, char, char, float)) 0x4FA080; +void(__fastcall *CLODLightManager::III::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x4BA560; +RwV3D *(__cdecl *CLODLightManager::III::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x4BA350; +int(__cdecl *CLODLightManager::III::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x5B6720; +int(__cdecl *CLODLightManager::III::RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices) = (int(__cdecl *)(int primType, short *indices, int numIndices)) 0x5B6820; +int(__cdecl *CLODLightManager::III::RwIm3DEnd)() = (int(__cdecl *)()) 0x5B67F0; +int(__cdecl *CLODLightManager::III::RwRenderStateSetIII)(RwRenderState nState, void *pParam) = (int(__cdecl *)(RwRenderState nState, void *pParam)) 0x5A43C0; +void RwRenderStateSetIII(RwRenderState nState, void *pParam) +{ + CLODLightManager::III::RwRenderStateSetIII(nState, pParam); +} +void(*_RwRenderStateSet)(RwRenderState nState, void *pParam) = &RwRenderStateSetIII; + -void CLODLightManager::III::RenderLODLights() +CVector* GetCamPos() { - if (GetIsTimeInRange(19, 7)) - { - unsigned char bAlpha; - float fRadius; - unsigned int nTime = (char)*CurrentTimeHours * 60 + (char)*CurrentTimeMinutes; - unsigned int curMin = (char)*CurrentTimeMinutes; - CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip; - - if (nTime >= 19 * 60) - bAlpha = static_cast((1.0f / 2.0f)*nTime - 570.0f); // http://goo.gl/3rI2tc - else if (nTime < 3 * 60) - bAlpha = 150; - else - bAlpha = static_cast((-5.0f / 8.0f)*nTime + 262.5f); // http://goo.gl/M8Dev9 + return (CVector*)(0x006FACF8 + 0x770); +} - for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) - { - if (GetDistance((RwV3d*)&it->vecPos, GetCamPos()) <= CoronaFarClip) - { - if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) - { - if (CCameraIsSphereVisible((int *)0x6FACF8, (RwV3d*)&it->vecPos, 5.0f)) - { - RwV3D* pCamPos = GetCamPos(); - float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); +void CLODLightManager::III::Init() +{ + CIniReader iniReader(""); + bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1) != 0; + numCoronas = iniReader.ReadInteger("LodLights", "MaxNumberOfLodLights", 25000); + fCoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); + bSlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; + if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) + fCoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); + else + autoFarClip = true; + szCustomCoronaTexturePath = iniReader.ReadString("LodLights", "CustomCoronaTexturePath", ".\\corona.png"); - if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance) - { - if (!it->nNoDistance) - fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; - else - fRadius = 3.5f; + bRenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0) != 0; + bIncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreaseCarsShadowsDrawDistance", 0) != 0; + fStaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); + fStaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); + fTrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); + fTrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); - if (SlightlyIncreaseRadiusWithDistance) - fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC + bRenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1) != 0; + bRenderHeliSearchlights = iniReader.ReadInteger("SearchLights", "RenderHeliSearchlights", 1) != 0; + fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); + nSmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); - if (it->fCustomSizeMult != 0.45f) - { - RegisterCorona(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f); - RenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), 2, *(RwTexture **)0x8F2A00, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, it->colour.r, it->colour.g, it->colour.b, 15.0f, 1.0f, CoronaFarClip, false, 0.0f) : nullptr; - } - else - { - if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50)) - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f); - else - RegisterCorona(reinterpret_cast(&*it), 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f); - } - else - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f); - else - RegisterCorona(reinterpret_cast(&*it), 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f); - } - } - } - } - } - } - } - } -} + bEnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0) != 0; + fMinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); + fFactor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); + fFactor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); + fStaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); -Fps _fps; -void CLODLightManager::III::DrawDistanceChanger() -{ - if (AdaptiveDrawDistanceEnabled) - { - _fps.update(); - int FPScount = _fps.get(); - if (FPScount < MinFPSValue) - { - MinDrawDistanceOnTheGround -= 2.0f; - } - else if (FPScount >= MaxFPSValue) - { - MinDrawDistanceOnTheGround += 2.0f; - } - if (MinDrawDistanceOnTheGround < 800.0f) - MinDrawDistanceOnTheGround = 800.0f; - else - if (MinDrawDistanceOnTheGround > MaxPossibleDrawDistance) - MinDrawDistanceOnTheGround = MaxPossibleDrawDistance; - } - fNewFarClip = (Factor1 / Factor2) * (GetCamPos()->z) + MinDrawDistanceOnTheGround; -} + bAdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0) != 0; + nMinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); + nMaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); + fMaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); -void CLODLightManager::III::RegisterLamppost(CEntityIII* entity) -{ - auto itEnd = pFileContent->upper_bound(PackKey(entity->m_nModelIndex, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(entity->m_nModelIndex, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(entity->matrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); + fMaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0); + fDrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0f); + bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) != 0; + + bRandomExplosionEffects = iniReader.ReadInteger("Misc", "RandomExplosionEffects", 0) != 0; + bReplaceSmokeTrailWithBulletTrail = iniReader.ReadInteger("Misc", "ReplaceSmokeTrailWithBulletTrail", 0) != 0; + + ApplyMemoryPatches(); } -void CLODLightManager::III::RegisterAllLampposts() +template +void CWorldAddHook() { - for (auto i : VecEntities) + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type CWorldAdd, CEntityIII* EntityIII) { - if (IsModelALamppost(i.m_nModelIndex)) + if (CLODLightManager::III::bPreloadLODs) { - RegisterLamppost(&i); + if (EntityIII->m_nModelIndex == 404 || EntityIII->m_nModelIndex == 405 || EntityIII->m_nModelIndex == 416 || EntityIII->m_nModelIndex == 402 || EntityIII->m_nModelIndex == 403) + { + EntityIII->m_bIsVisible = 0; + } } - } + VecEntities.push_back(*EntityIII); + + CWorldAdd(EntityIII); + }); } -void CLODLightManager::III::RegisterCustomCoronas() +template +void CBulletTracesAddTrace() { - unsigned short nModelID = 65534; - - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddTrace, CVector* start, CVector* end) + { + CVector endPoint = CVector(); + endPoint.x = (end->x - start->x) * 0.07f; + endPoint.y = (end->y - start->y) * 0.07f; + endPoint.z = (end->z - start->z) * 0.07f; + injector::cstd::call<0x50D140>(47, *start, endPoint, 0, 0.0f, 0, 0, 0, 0); + }); } template void CExplosionAddModifiedExplosion() { - using func_hook = injector::function_hooker; - injector::make_static_hook([](func_hook::func_type AddExplosion, int a1, int a2, int eExplosionType, int a4, int a5) + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddExplosion, CEntity* pTarget, CEntity* pSource, int nType, CVector* pVector, uint32_t uTimer) { std::random_shuffle(ExplosionTypes.begin(), ExplosionTypes.end()); injector::MakeNOP(0x559FD3, 5, true); for (auto it = ExplosionTypes.begin(); it != ExplosionTypes.end(); ++it) { - if (*it == eExplosionType) + if (*it == nType) break; - AddExplosion(a1, a2, *it, a4, a5); + AddExplosion(pTarget, pSource, *it, pVector, uTimer); } injector::MakeCALL(0x559FD3, 0x4B1140, true); - AddExplosion(a1, a2, eExplosionType, a4, a5); - return; - }); -} -template -void CBulletTracesAddTrace() -{ - using func_hook = injector::function_hooker; - injector::make_static_hook([](func_hook::func_type AddTrace, CVector* start, CVector* end) - { - injector::MakeNOP(0x563B56, 5); // sub_50D140 - injector::MakeNOP(0x563BBB, 5); // sub_510790 - injector::MakeNOP(0x563BDD, 5); // sub_4AF970 - //injector::MakeNOP(0x563C43, 5); // sub_50D140 - injector::MakeNOP(0x563CB6, 5); // sub_4CCE20 - injector::MakeNOP(0x563CC1, 5); // sub_4E67F0 - injector::MakeNOP(0x563CD4, 5); // sub_403620 - injector::MakeNOP(0x563D0C, 5); // sub_4EA420 - injector::MakeNOP(0x563D23, 5); // sub_474CC0 - injector::MakeNOP(0x563D40, 5); // sub_5A41D0 - injector::MakeNOP(0x563D68, 5); // sub_5A41D0 - injector::MakeNOP(0x563D90, 5); // sub_5A41D0 - injector::MakeNOP(0x563DD4, 5); // sub_50D140 - injector::MakeNOP(0x563E0D, 5); // sub_551950 - injector::MakeNOP(0x563E37, 5); // sub_57C5F0 - injector::MakeNOP(0x563E7E, 5); // sub_50D140 - injector::MakeNOP(0x563EA0, 5); // sub_57C840 - injector::MakeNOP(0x563EBF, 5); // sub_57C840 - injector::MakeNOP(0x563ECA, 5); // sub_4E5A10 - injector::MakeNOP(0x563F0B, 5); // sub_5552C0 - injector::MakeNOP(0x563F73, 5); // sub_50D140 - injector::MakeNOP(0x563F85, 5); // sub_57C5F0 - injector::cstd::call<0x563B00>(start, end, 0); - injector::MakeCALL(0x563B56, 0x50D140, true); - injector::MakeCALL(0x563BBB, 0x510790, true); - injector::MakeCALL(0x563BDD, 0x4AF970, true); - injector::MakeCALL(0x563C43, 0x50D140, true); - injector::MakeCALL(0x563CB6, 0x4CCE20, true); - injector::MakeCALL(0x563CC1, 0x4E67F0, true); - injector::MakeCALL(0x563CD4, 0x403620, true); - injector::MakeCALL(0x563D0C, 0x4EA420, true); - injector::MakeCALL(0x563D23, 0x474CC0, true); - injector::MakeCALL(0x563D40, 0x5A41D0, true); - injector::MakeCALL(0x563D68, 0x5A41D0, true); - injector::MakeCALL(0x563D90, 0x5A41D0, true); - injector::MakeCALL(0x563DD4, 0x50D140, true); - injector::MakeCALL(0x563E0D, 0x551950, true); - injector::MakeCALL(0x563E37, 0x57C5F0, true); - injector::MakeCALL(0x563E7E, 0x50D140, true); - injector::MakeCALL(0x563EA0, 0x57C840, true); - injector::MakeCALL(0x563EBF, 0x57C840, true); - injector::MakeCALL(0x563ECA, 0x4E5A10, true); - injector::MakeCALL(0x563F0B, 0x5552C0, true); - injector::MakeCALL(0x563F73, 0x50D140, true); - injector::MakeCALL(0x563F85, 0x57C5F0, true); - return; + return AddExplosion(pTarget, pSource, nType, pVector, uTimer); }); } void CLODLightManager::III::ApplyMemoryPatches() { - if (bRenderLodLights) + injector::WriteMemory(0x5F00BC, 300.0f, true); // Traffic lights coronas draw distance DOUBLE CHECK + struct GenericIDEHook { - injector::MakeCALL(0x48D440, RenderLODLights, true); + void operator()(injector::reg_pack& regs) + { + *(uint8_t*)(regs.ebx + 0x6ED4E0) = 32; - injector::MakeNOP(0x4F8E82, 6, true); //disable ambientBrightness change - injector::MakeNOP(0x4F8F16, 6, true); - } + static char* buffer = (char *)0x6ED4E0; + unsigned int modelID = 0, IDEDrawDistance = 0; + + auto tempptr = strchr(buffer, ','); + auto tempptr2 = strchr(buffer, '.'); + + if (!tempptr && !tempptr2) + { + sscanf(buffer, "%d %*s %*s %*d %d %*s %*s %*s", &modelID, &IDEDrawDistance); + if ((modelID >= 1100 && modelID <= 1438) || modelID == 887) + { + if (IDEDrawDistance >= 10 && IDEDrawDistance < 300) + { + char sIDEDrawDistance[5] = { 0 }, Flags2[20] = { 0 }; + sprintf(sIDEDrawDistance, "%d", IDEDrawDistance); + tempptr = strstr(buffer + 10, sIDEDrawDistance); + + if (IDEDrawDistance >= 100) + strncpy(Flags2, tempptr + 4, 15); + else + strncpy(Flags2, tempptr + 3, 15); - if (RenderSearchlightEffects) + strncpy(tempptr, "300 ", 5); + strncpy(tempptr + 5, Flags2, 15); + } + } + } + else + { + tempptr2 = strstr(buffer, "shad_exp"); + if (!tempptr && tempptr2) + { + sscanf(tempptr2 + 11, "%d", &IDEDrawDistance); + + if (IDEDrawDistance >= 100 && IDEDrawDistance < 300) + { + strncpy(tempptr2 + 11, "300", 3); + } + } + } + } + }; injector::MakeInline(0x476208, 0x476208+7); + + struct Render { - injector::MakeJMP(0x48E085, RenderSearchLights, true); - } + void operator()(injector::reg_pack&) + { + ((void(__cdecl *)())0x4F8FB0)(); //CCoronas::Render(); + + if (bRenderLodLights) + CLODLights::RenderBuffered(); + + if (bRenderSearchlightEffects) + CSearchlights::RenderSearchLightsIII(); + } + }; injector::MakeInline(0x48E0B8); + - if (SmoothEffect) + if (bRenderLodLights) { - SmoothEffect = 1; + CLODLights::Inject(); + + //injector::MakeNOP(0x4F8E82, 6, true); //disable ambientBrightness change + //injector::MakeNOP(0x4F8F16, 6, true); + + CWorldAddHook<(0x4787FE)>(); + CWorldAddHook<(0x47899C)>(); + + struct asmInit + { + void operator()(injector::reg_pack& regs) + { + LoadDatFile(); + + for (auto i : VecEntities) { + if (m_bCatchLamppostsNow && IsModelALamppost(i.m_nModelIndex)) + { + RegisterLamppost(&i); + } + } + + RegisterCustomCoronas(); + m_bCatchLamppostsNow = false; + m_pLampposts->shrink_to_fit(); + VecEntities.clear(); + pFileContent->clear(); + + injector::MakeCALL(0x48D440, RegisterLODLights, true); + + if (fDrawDistance) + { + injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (fDrawDistance / 1.8f), true); + injector::WriteMemory(0x487629 + 6, 1.2f * (fDrawDistance / 1.8f), true); + } + } + }; injector::MakeInline(0x48C09F); } - if (TrafficLightsShadowsDrawDistance) + if (nSmoothEffect) + { + nSmoothEffect = 1; + } + + if (fTrafficLightsShadowsDrawDistance) { - injector::WriteMemory(0x455E3F + 0x2, &TrafficLightsShadowsDrawDistance, true); - injector::WriteMemory(0x455F2D + 0x2, &TrafficLightsShadowsDrawDistance, true); + injector::WriteMemory(0x455E3F + 0x2, &fTrafficLightsShadowsDrawDistance, true); + injector::WriteMemory(0x455F2D + 0x2, &fTrafficLightsShadowsDrawDistance, true); } - if (StaticShadowsDrawDistance) + if (fStaticShadowsDrawDistance) { - injector::WriteMemory(0x5F00E0, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x5EDF3C, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x5FB214, StaticShadowsDrawDistance, true); + injector::WriteMemory(0x5F00E0, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x5EDF3C, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x5FB214, fStaticShadowsDrawDistance, true); } - if (StaticShadowsIntensity) + if (fStaticShadowsIntensity) { - injector::WriteMemory(0x5FB304, StaticShadowsIntensity, true); + injector::WriteMemory(0x5FB304, fStaticShadowsIntensity, true); injector::WriteMemory(0x4FACE6, 255, true); } - if (TrafficLightsShadowsIntensity) + if (fTrafficLightsShadowsIntensity) { - injector::WriteMemory(0x5F00EC, TrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x5F00EC, fTrafficLightsShadowsIntensity, true); } - //Car Shadows - if (IncreasePedsCarsShadowsDrawDistance) + if (bIncreasePedsCarsShadowsDrawDistance) { injector::WriteMemory(0x00513AC2, 0x75u, true); //headlight on far distance injector::WriteMemory(0x0051388F, 0x75u, true); //shadow on far distance @@ -252,59 +284,59 @@ void CLODLightManager::III::ApplyMemoryPatches() injector::MakeNOP(0x518DCA, 5, true); injector::MakeJMP(0x513CFF, 0x513D92); //ped shadows draw distance } - - if (DrawDistance) + + if (fDrawDistance) { - injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (fDrawDistance / 1.8f), true); injector::MakeInline<0x486AF2>([](injector::reg_pack&) { injector::thiscall::call<0x488CC0>(); - injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (fDrawDistance / 1.8f), true); }); injector::MakeInline<0x486B3A>([](injector::reg_pack& regs) { *(uintptr_t*)regs.esp = 0x486D16; - injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (fDrawDistance / 1.8f), true); }); injector::MakeInline<0x48B314>([](injector::reg_pack& regs) { *(uintptr_t*)regs.esp = 0x48B42C; - injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x5F726C, *(float*)0x5F726C * (fDrawDistance / 1.8f), true); }); - injector::WriteMemory(0x487629 + 6, 1.2f * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x487629 + 6, 1.2f * (fDrawDistance / 1.8f), true); } - - if (MaxDrawDistanceForNormalObjects) + + if (fMaxDrawDistanceForNormalObjects) { - //injector::WriteMemory(0x5F72A4, MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8AB1, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8AC6, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8AD9, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8B0E, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8B21, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8B34, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8B82, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8B97, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8BAA, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8BDF, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8BF2, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8C05, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4A8DA6, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA391, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA3A6, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA3B9, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA3EE, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA401, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA414, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA462, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA477, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA48A, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA4BF, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA4D2, &MaxDrawDistanceForNormalObjects, true); - injector::WriteMemory(0x4AA4E5, &MaxDrawDistanceForNormalObjects, true); + //injector::WriteMemory(0x5F72A4, fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8AB1, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8AC6, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8AD9, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8B0E, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8B21, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8B34, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8B82, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8B97, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8BAA, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8BDF, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8BF2, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8C05, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4A8DA6, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA391, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA3A6, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA3B9, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA3EE, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA401, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA414, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA462, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA477, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA48A, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA4BF, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA4D2, &fMaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x4AA4E5, &fMaxDrawDistanceForNormalObjects, true); } - if (EnableDrawDistanceChanger) + if (bEnableDrawDistanceChanger) { injector::MakeJMP(0x48E072, DrawDistanceChanger, true); @@ -314,255 +346,192 @@ void CLODLightManager::III::ApplyMemoryPatches() if (bRandomExplosionEffects) { - for (int i = 0; i < 10; ++i) - { - if (i != 1) - ExplosionTypes.push_back(i); - } - - CExplosionAddModifiedExplosion<(0x4309EB)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x442E65)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x53BF2A)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x53DA3C)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x541DAB)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x549773)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x549F90)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x54A349)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x54C265)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x54C6C0)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x54C7AD)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x54CC04)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - //CExplosionAddModifiedExplosion<(0x55B743)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) molotov/grenade expl - CExplosionAddModifiedExplosion<(0x55B7A9)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - //CExplosionAddModifiedExplosion<(0x564ADE)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) barrels + CExplosionAddModifiedExplosion<(0x4309EB)>(); + CExplosionAddModifiedExplosion<(0x442E65)>(); + CExplosionAddModifiedExplosion<(0x53BF2A)>(); + CExplosionAddModifiedExplosion<(0x53DA3C)>(); + CExplosionAddModifiedExplosion<(0x541DAB)>(); + CExplosionAddModifiedExplosion<(0x549773)>(); + CExplosionAddModifiedExplosion<(0x549F90)>(); + CExplosionAddModifiedExplosion<(0x54A349)>(); + CExplosionAddModifiedExplosion<(0x54C265)>(); + CExplosionAddModifiedExplosion<(0x54C6C0)>(); + CExplosionAddModifiedExplosion<(0x54C7AD)>(); + CExplosionAddModifiedExplosion<(0x54CC04)>(); + //CExplosionAddModifiedExplosion<(0x55B743)>(); // molotov/grenade expl + CExplosionAddModifiedExplosion<(0x55B7A9)>(); + CExplosionAddModifiedExplosion<(0x564ADE)>(); //barrels } if (bReplaceSmokeTrailWithBulletTrail) { CBulletTracesAddTrace<(0x55F9C7)>(); // = 0x518E90 + 0x0 -> call sub_518E90 - CBulletTracesAddTrace<(0x560599)>(); // = 0x518E90 + 0x0 -> call sub_518E90 - CBulletTracesAddTrace<(0x560F21)>(); // = 0x518E90 + 0x0 -> call sub_518E90 + //CBulletTracesAddTrace<(0x560599)>(); // = 0x518E90 + 0x0 -> call sub_518E90 + //CBulletTracesAddTrace<(0x560F21)>(); // = 0x518E90 + 0x0 -> call sub_518E90 CBulletTracesAddTrace<(0x56186B)>(); // = 0x518E90 + 0x0 -> call sub_518E90 - CBulletTracesAddTrace<(0x562B07)>(); // = 0x518E90 + 0x0 -> call sub_518E90 - CBulletTracesAddTrace<(0x562E4F)>(); // = 0x518E90 + 0x0 -> call sub_518E90 + //CBulletTracesAddTrace<(0x562B07)>(); // = 0x518E90 + 0x0 -> call sub_518E90 + //CBulletTracesAddTrace<(0x562E4F)>(); // = 0x518E90 + 0x0 -> call sub_518E90 + } + + if (bPreloadLODs) + { + injector::WriteMemory(0x47561F, 0xEB, true); + injector::MakeNOP(0x475615, 9, true); + injector::WriteMemory(0x475615, 0x005E43C7, true); + injector::WriteMemory(0x475615 + 4, 0x90000000, true); + + injector::MakeInline<0x40B7DA, 0x40B8F4>([](injector::reg_pack& regs) + { + static auto CPopulationDealWithZoneChange = injector::cstd::call<0x4F6200>; + static auto LoadCollisionFile1 = injector::cstd::call<0x476520>; + static auto sub_595BD0 = injector::cstd::call<0x595BD0>; + CPopulationDealWithZoneChange(0x8F6250, *(char*)0x941514, 0); + LoadCollisionFile1(*(char*)0x941514); + *(DWORD*)0x8F6250 = *(char*)0x941514; + sub_595BD0(); + }); } } -void CLODLightManager::III::LoadDatFile() +void CLODLightManager::III::RegisterCustomCoronas() { - CIniReader iniReader(""); - DataFilePath = iniReader.GetIniPath(); - char* tempPointer; - tempPointer = strrchr(DataFilePath, '.'); - *tempPointer = '\0'; - strcat(DataFilePath, ".dat"); + unsigned short nModelID = 65534; + + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, 0.0f)); +} - if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) +void CLODLightManager::III::RegisterLamppost(CEntityIII* entity) +{ + auto itEnd = pFileContent->upper_bound(PackKey(entity->m_nModelIndex, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(entity->m_nModelIndex, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(entity->matrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, atan2(entity->matrix.GetUp()->y, -entity->matrix.GetUp()->x))); +} + +void CLODLightManager::III::RegisterLODLights() +{ + if (GetIsTimeInRange(20, 7)) { - unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; + unsigned char bAlpha = 0; + float fRadius = 0.0f; + unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; + unsigned int curMin = *CurrentTimeMinutes; + fCoronaFarClip = autoFarClip ? **fCurrentFarClip : fCoronaFarClip; + + if (nTime >= 20 * 60) + bAlpha = static_cast((15.0f / 16.0f)*nTime - 1095.0f); // http://goo.gl/O03RpE {(20*60)a + y = 30, (24*60)a + y = 255} + else if (nTime < 3 * 60) + bAlpha = 255; + else + bAlpha = static_cast((-15.0f / 16.0f)*nTime + 424.0f); // http://goo.gl/M8Dev9 {(7*60)a + y = 30, (3*60)a + y = 150} - while (const char* pLine = CFileMgr::LoadLine(hFile)) + for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) { - if (pLine[0] && pLine[0] != '#') + if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) { - if (pLine[0] == '%') + CVector* pCamPos = (CVector*)GetCamPos(); + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + + if ((fDistSqr > 250.0f*250.0f && fDistSqr < fCoronaFarClip*fCoronaFarClip) || it->nNoDistance) { - nCurIndexForModel = 0; - if (strcmp(pLine, "%additional_coronas") != 0) - nModel = GetModelInfoUInt16(pLine + 1); + if (it->nNoDistance) + fRadius = 3.5f; else - nModel = 65534; - } - else - { - float fOffsetX, fOffsetY, fOffsetZ; - unsigned int nRed, nGreen, nBlue; - float fCustomSize = 1.0f; - int nNoDistance = 0; - int nDrawSearchlight = 0; - sscanf(pLine, "%d %d %d %f %f %f %f %d %d", &nRed, &nGreen, &nBlue, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nNoDistance, &nDrawSearchlight); - pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast(nRed), static_cast(nGreen), static_cast(nBlue)), fCustomSize, nNoDistance, nDrawSearchlight))); - } - } - } - - m_pLampposts = new std::vector; + fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - CFileMgr::CloseFile(hFile); - } - else - { - RenderSearchlightEffects = 0; - bRenderLodLights = 0; - } + if (bSlightlyIncreaseRadiusWithDistance) + fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC - if (RenderSearchlightEffects) - { - mi_lamppost1 = GetModelInfoUInt16("lamppost1"); - mi_lamppost2 = GetModelInfoUInt16("lamppost2"); - mi_lamppost3 = GetModelInfoUInt16("lamppost3"); - mi_sub_floodlite = GetModelInfoUInt16("sub_floodlite"); - mi_Streetlamp1 = GetModelInfoUInt16("Streetlamp1"); - mi_mlamppost = GetModelInfoUInt16("mlamppost"); - mi_doublestreetlght1 = GetModelInfoUInt16("doublestreetlght1"); - mi_Streetlamp2 = GetModelInfoUInt16("Streetlamp2"); - mi_bollardlight = GetModelInfoUInt16("bollardlight"); - mi_lampost_coast = GetModelInfoUInt16("lampost_coast"); - mi_doc_floodlite = GetModelInfoUInt16("doc_floodlite"); - } -} + if (it->fCustomSizeMult != 0.45f) + { + if (!it->nCoronaShowMode) + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + bRenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), 2, *(RwTexture **)0x8F2A00, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, it->colour.r, it->colour.g, it->colour.b, 15.0f, 1.0f, fCoronaFarClip, false, 0.0f) : nullptr; + } + else + { + static float blinking; + if (IsBlinkingNeeded(it->nCoronaShowMode)) + blinking -= CTimer::ms_fTimeStep / 1000.0f; + else + blinking += CTimer::ms_fTimeStep / 1000.0f; -DWORD jmpAddress = 0x47620F; -char* buffer = (char *)0x6ED4E0; -char* tempptr; -char* tempptr2; -unsigned int modelID, IDEDrawDistance; -char sIDEDrawDistance[5], Flags2[20]; -void __declspec(naked) CLODLightManager::III::GenericIDEHook() -{ - __asm MOV BYTE PTR DS : [EBX + 6ED4E0h], 20h + (blinking > 1.0f) ? blinking = 1.0f : (blinking < 0.0f) ? blinking = 0.0f : 0.0f; - tempptr = strchr(buffer, ','); - tempptr2 = strchr(buffer, '.'); - if (!tempptr && !tempptr2) - { - sscanf(buffer, "%d %*s %*s %*d %d %*s %*s %*s", &modelID, &IDEDrawDistance); - if ((modelID >= 1100 && modelID <= 1438) || modelID == 887) - { - if (IDEDrawDistance >= 10 && IDEDrawDistance < 300) - { - sprintf(sIDEDrawDistance, "%d", IDEDrawDistance); - tempptr = strstr(buffer + 10, sIDEDrawDistance); - //MessageBox(0, buffer, "0", 0); - - if (IDEDrawDistance >= 100) - strncpy(Flags2, tempptr + 4, 15); - else - strncpy(Flags2, tempptr + 3, 15); - - strncpy(tempptr, "300 ", 5); - strncpy(tempptr + 5, Flags2, 15); - //MessageBox(0, buffer, "0", 0); - } - } - } - else - { - tempptr2 = strstr(buffer, "shad_exp"); - if (!tempptr && tempptr2) - { - sscanf(tempptr2 + 11, "%d", &IDEDrawDistance); - - if (IDEDrawDistance >= 100 && IDEDrawDistance < 300) - { - //MessageBox(0, tempptr2 + 11, "0", 0); - strncpy(tempptr2 + 11, "3", 1); - //MessageBox(0, buffer, "0", 0); + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, blinking * (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + else + { + if ((it->colour.r >= 250 && it->colour.g >= 100 && it->colour.b <= 100) && ((curMin == 9 || curMin == 19 || curMin == 29 || curMin == 39 || curMin == 49 || curMin == 59))) //yellow + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((abs(it->fHeading) >= (3.1415f / 6.0f) && abs(it->fHeading) <= (5.0f * 3.1415f / 6.0f))) + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + } + } + } + } } } } - __asm jmp jmpAddress - + CLODLights::Update(); } -DWORD ipljmpAddress1 = 0x4787FE; -DWORD ipljmpAddress2 = 0x4789A1; -DWORD _EAX; -CEntityIII* EntityIII; -void __declspec(naked) CLODLightManager::III::IPLDataHook1() -{ - _asm - { - mov _EAX, eax - mov eax, 0x4B8DB0 - call eax - mov eax, _EAX - push ebp - mov EntityIII, ebp - } - - VecEntities.push_back(*EntityIII); - __asm jmp ipljmpAddress1 -} - -void __declspec(naked) CLODLightManager::III::IPLDataHook2() +void CLODLightManager::III::DrawDistanceChanger() { - _asm - { - push ebp - mov EntityIII, ebp - } - if (bPreloadLODs) + static Fps _fps; + if (bAdaptiveDrawDistanceEnabled) { - if (EntityIII->m_nModelIndex == 404 || EntityIII->m_nModelIndex == 405 || EntityIII->m_nModelIndex == 416 || EntityIII->m_nModelIndex == 402 || EntityIII->m_nModelIndex == 403) + _fps.update(); + int FPScount = _fps.get(); + if (FPScount < nMinFPSValue) { - EntityIII->m_bIsVisible = 0; + fMinDrawDistanceOnTheGround -= 2.0f; } + else if (FPScount >= nMaxFPSValue) + { + fMinDrawDistanceOnTheGround += 2.0f; + } + if (fMinDrawDistanceOnTheGround < 800.0f) + fMinDrawDistanceOnTheGround = 800.0f; + else + if (fMinDrawDistanceOnTheGround > fMaxPossibleDrawDistance) + fMinDrawDistanceOnTheGround = fMaxPossibleDrawDistance; } - VecEntities.push_back(*EntityIII); - _asm - { - mov _EAX, eax - mov eax, 0x4AE930 - call eax - mov eax, _EAX - jmp ipljmpAddress2 - } + fNewFarClip = (fFactor1 / fFactor2) * (GetCamPos()->z) + fMinDrawDistanceOnTheGround; } -void CLODLightManager::III::Init() -{ - CIniReader iniReader(""); - bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1); - CoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 0.0f); - SlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; - if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) - CoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); - else - autoFarClip = true; - - RenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0); - IncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreasePedsCarsShadowsDrawDistance", 0); - StaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); - StaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); - TrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); - TrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); - - RenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1); - fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); - SmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); - - EnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0); - MinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); - Factor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); - Factor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); - StaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); - - AdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0); - MinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); - MaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); - MaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); - - MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0f); - DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0f); - bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1; - - bRandomExplosionEffects = iniReader.ReadInteger("Misc", "RandomExplosionEffects", 0) == 1; - bReplaceSmokeTrailWithBulletTrail = iniReader.ReadInteger("Misc", "ReplaceSmokeTrailWithBulletTrail", 0) == 1; - - LoadDatFile(); - - if (bRenderLodLights) - { - RegisterAllLampposts(); - RegisterCustomCoronas(); - } - ApplyMemoryPatches(); - - //delete pFileContent; - VecEntities.clear(); -} BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { @@ -572,41 +541,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { if (injector::address_manager::singleton().GetMajorVersion() == 1 && injector::address_manager::singleton().GetMinorVersion() == 0) { - injector::MakeJMP(0x476208, CLODLightManager::III::GenericIDEHook); - injector::MakeJMP(0x4787F8, CLODLightManager::III::IPLDataHook1); - injector::MakeJMP(0x47899B, CLODLightManager::III::IPLDataHook2); - injector::MakeCALL(0x48C09F, CLODLightManager::III::Init); - - CIniReader iniReader(""); - if ((bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0)) == 1) - { - /*injector::WriteMemory(0x591E0B, &nLevelPortland, true); - injector::WriteMemory(0x591E16, &nLevelPortland, true); - injector::WriteMemory(0x591E28, &nLevelPortland, true); - injector::WriteMemory(0x591E3B, &nLevelPortland, true);*/ - - injector::WriteMemory(0x40A6E6, 0xBD, true); //mov ebp - injector::WriteMemory(0x40A6E6 + 0x1, nLevelPortland, true); - - //opcode - injector::MakeNOP(0x5887FD, 5, true); - injector::MakeNOP(0x588809, 5, true); - injector::MakeNOP(0x58881A, 5, true); - - injector::WriteMemory(0x4A8F79 + 0x1, &nLevelPortland, true); - - injector::WriteMemory(0x4B61BC, nLevelPortland, true); - - injector::MakeInline<0x40B7DA, 0x40B8F4>([](injector::reg_pack& regs) - { - CPopulationDealWithZoneChange(0x8F6250, *(char*)0x941514, 0); - LoadCollisionFile1(*(char*)0x941514); - *(DWORD*)0x8F6250 = *(char*)0x941514; - sub_595BD0(); - }); - - injector::MakeNOP(0x4764AF, 5, true); //CFileLoader::LoadMapZones((char const *)) - } + CLODLightManager::III::Init(); } } } diff --git a/IIILodLights/stdafx.cpp b/IIILodLights/stdafx.cpp deleted file mode 100644 index 29c1b08..0000000 --- a/IIILodLights/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// IIILodLights.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/IIILodLights/stdafx.h b/IIILodLights/stdafx.h deleted file mode 100644 index f3a0737..0000000 --- a/IIILodLights/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/IIILodLights/targetver.h b/IIILodLights/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/IIILodLights/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/IVLodLights/IVLodLights.vcxproj b/IVLodLights/IVLodLights.vcxproj index efb415f..b2540f0 100644 --- a/IVLodLights/IVLodLights.vcxproj +++ b/IVLodLights/IVLodLights.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,17 @@ Release Win32 + + Debug + x64 + + + Release + x64 + - {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D} + {C6635A78-06E3-45B6-B2F8-47557753A614} Win32Proj IVLodLights 8.1 @@ -20,7 +28,7 @@ DynamicLibrary true - v120 + v140 Unicode @@ -30,32 +38,71 @@ true MultiByte + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + true - .asi + + + true false .asi $(SolutionDir)$(Configuration)\$(ProjectName)\ + + false + - Use + + Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;IVLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDebug + + + Windows + true + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;IVLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) Windows @@ -64,8 +111,9 @@ - Level4 - Use + Level3 + + MaxSpeed true true @@ -74,29 +122,38 @@ Windows + true + true true + + + copy /y "$(TargetPath)" "Z:\WGTA\IV\Grand Theft Auto IV\plugins\IVLodLights.asi" +copy /y "$(TargetPath)" "Z:\WGTA\IV\Episodes from Liberty City\plugins\IVLodLights.asi" + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;IVLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows true true + true - - + + - - - false - - - false - - - - - Create - Create - + diff --git a/IVLodLights/IVLodLights.vcxproj.filters b/IVLodLights/IVLodLights.vcxproj.filters index fcfcac1..3532174 100644 --- a/IVLodLights/IVLodLights.vcxproj.filters +++ b/IVLodLights/IVLodLights.vcxproj.filters @@ -15,22 +15,16 @@ - - Header Files - - - Header Files - - - - - Source Files - Source Files - + Source Files + + + Header Files + + \ No newline at end of file diff --git a/IVLodLights/dllmain.cpp b/IVLodLights/dllmain.cpp index e18fef4..41cf7a1 100644 --- a/IVLodLights/dllmain.cpp +++ b/IVLodLights/dllmain.cpp @@ -1,17 +1,160 @@ -#include "stdafx.h" +#include "..\includes\stdafx.h" #include "..\includes\CLODLightManager.h" using namespace injector; + #define NewLimitExponent 14 -std::vector aCoronas; -std::vector aCoronas2; +char* CLODLightManager::IV::CurrentTimeHours; +char* CLODLightManager::IV::CurrentTimeMinutes; +int(__cdecl *CLODLightManager::IV::DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); +int(__cdecl *CLODLightManager::IV::DrawCorona2)(int id, char r, char g, char b, float a5, CVector* pos, float radius, float a8, float a9, int a10, float a11, char a12, char a13, int a14); +void(__stdcall *CLODLightManager::IV::GetRootCam)(int *camera); +void(__stdcall *CLODLightManager::IV::GetGameCam)(int *camera); +bool(__cdecl *CLODLightManager::IV::CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); +void(__cdecl *CLODLightManager::IV::GetCamPos)(int camera, float *pX, float *pY, float *pZ); +int& CTimer::m_snTimeInMillisecondsPauseMode = *(int*)0xBADDEAD; + +void CLODLightManager::IV::Init() +{ + CIniReader iniReader(""); + bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1) != 0; + fCoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); + bSlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; + fCoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); + bool DisableDefaultLodLights = iniReader.ReadInteger("LodLights", "DisableDefaultLodLights", 0) == 1; + bool DisableCoronasWaterReflection = iniReader.ReadInteger("LodLights", "DisableCoronasWaterReflection", 0) == 1; + fGenericObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "LamppostsDrawDistance", 0.0f); + bool SkipIntro = iniReader.ReadInteger("Misc", "SkipIntro", 0) == 1; + bool DoNotPauseOnMinimize = iniReader.ReadInteger("Misc", "DoNotPauseOnMinimize", 0) == 1; + + struct LoadObjectInstanceHook + { + void operator()(injector::reg_pack& regs) + { + regs.ebx = *(uintptr_t*)(regs.ebp + 0x8); + regs.ecx = *(uintptr_t*)(regs.ebx + 0x1C); + + PossiblyAddThisEntity((WplInstance*)regs.ebx); + } + }; + + struct ParseIdeObjsHook + { + void operator()(injector::reg_pack& regs) + { + auto xmmZero = *(float*)(regs.esp + 0x1C); + if (xmmZero == 50.0f || xmmZero == 100.0f || xmmZero == 150.0f || xmmZero == 80.0f) //lampposts draw distances + { + xmmZero = fGenericObjectsDrawDistance; + } + _asm movss xmm0, xmmZero + } + }; + + if (bRenderLodLights) + { + GetMemoryAddresses(); + IncreaseCoronaLimit(); + LoadDatFile(); + RegisterCustomCoronas(); + + if (injector::address_manager::singleton().IsIV()) + { + injector::MakeCALL(aslr_ptr(0x00402D6C), RegisterLODLights, true); + injector::MakeInline(aslr_ptr(0x008D63A1), aslr_ptr(0x008D63A7)); + injector::MakeInline(aslr_ptr(0x008D2311), aslr_ptr(0x8D2317)); + } + else + { + injector::MakeCALL(aslr_ptr(0x0047361F), RegisterLODLights, true); + injector::MakeInline(aslr_ptr(0x0091C851), aslr_ptr(0x0091C857)); + injector::MakeInline(aslr_ptr(0x00918891), aslr_ptr(0x918897)); + } + } + + if (injector::address_manager::singleton().IsIV()) + { + if (SkipIntro) { injector::WriteMemory(aslr_ptr(0x402B49), 0xEB, true); } + if (DoNotPauseOnMinimize) { injector::MakeNOP(aslr_ptr(0x61D06A), 2, true); } + + if (DisableDefaultLodLights) { injector::WriteMemory(aslr_ptr(0x00903300), 0xC3u, true); } + if (DisableCoronasWaterReflection) { injector::MakeNOP(aslr_ptr(0xB54373), 5, true); } + } + else + { + injector::WriteMemory(aslr_ptr(0x7FE12C), 0xEB, true); + struct RegPatch + { + void operator()(injector::reg_pack& regs) + { + HMODULE hModule = GetModuleHandle(NULL); + if (hModule != NULL) + { + GetModuleFileName(hModule, (char*)regs.esi, 260); + auto ptr = strrchr((char*)regs.esi, '\\'); + *(ptr+1) = '\0'; + } + } + }; injector::MakeInline(aslr_ptr(0x7FE1B8), aslr_ptr(0x7FE1B8 + 6)); + + injector::WriteMemory(aslr_ptr(0x8B329C), 0xEB, true); + struct RegPatch2 + { + void operator()(injector::reg_pack& regs) + { + regs.ecx = *(uintptr_t*)(regs.esp + 0x4); + HMODULE hModule = GetModuleHandle(NULL); + if (hModule != NULL) + { + GetModuleFileName(hModule, (char*)regs.esi, 260); + auto ptr = strrchr((char*)regs.esi, '\\'); + *(ptr + 1) = '\0'; + } + } + }; injector::MakeInline(aslr_ptr(0x8B3315), aslr_ptr(0x8B331B)); + if (SkipIntro) { injector::WriteMemory(aslr_ptr(0x473439), 0xEB, true); } + if (DoNotPauseOnMinimize) { injector::MakeNOP(aslr_ptr(0x402D5A), 2, true); } + + if (DisableDefaultLodLights) { injector::WriteMemory(aslr_ptr(0x00975860), 0xC3u, true); } + if (DisableCoronasWaterReflection) { injector::MakeNOP(aslr_ptr(0xC8E183), 5, true); } + } +} + +void CLODLightManager::IV::GetMemoryAddresses() +{ + if (injector::address_manager::singleton().IsIV()) + { + CLODLightManager::IV::CurrentTimeHours = aslr_ptr(0x11D5300).get(); + CLODLightManager::IV::CurrentTimeMinutes = aslr_ptr(0x11D52FC).get(); + CLODLightManager::IV::DrawCorona = (int(__cdecl *)(float, float, float, float, unsigned int, float, unsigned char, unsigned char, unsigned char))(aslr_ptr(0xA6E240).get()); + CLODLightManager::IV::DrawCorona2 = (int(__cdecl *)(int id, char r, char g, char b, float a5, CVector* pos, float radius, float a8, float a9, int a10, float a11, char a12, char a13, int a14))(aslr_ptr(0x7E1970).get()); + CLODLightManager::IV::GetRootCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xB006C0).get()); + CLODLightManager::IV::GetGameCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xB006E0).get()); + CLODLightManager::IV::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xBB9340).get()); + CLODLightManager::IV::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xBB8510).get()); + } + else + { + CLODLightManager::EFLC::CurrentTimeHours = injector::aslr_ptr(0x10C9398).get(); + CLODLightManager::EFLC::CurrentTimeMinutes = injector::aslr_ptr(0x10C9394).get(); + CLODLightManager::EFLC::DrawCorona = (int(__cdecl *)(float, float, float, float, unsigned int, float, unsigned char, unsigned char, unsigned char))(aslr_ptr(0xAA3100).get()); + CLODLightManager::EFLC::DrawCorona2 = (int(__cdecl *)(int id, char r, char g, char b, float a5, CVector* pos, float radius, float a8, float a9, int a10, float a11, char a12, char a13, int a14))(aslr_ptr(0x89A080).get()); + CLODLightManager::EFLC::GetRootCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xAFA7E0).get()); + CLODLightManager::EFLC::GetGameCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xAFA800).get()); + CLODLightManager::EFLC::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xC27DD0).get()); + CLODLightManager::EFLC::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xC26FA0).get()); + } +} + void CLODLightManager::IV::IncreaseCoronaLimit() { - nCoronasLimit = static_cast(3 * pow(2.0, NewLimitExponent)); // 49152, default 3 * pow(2, 8) = 768 + auto nCoronasLimit = static_cast(3 * pow(2.0, NewLimitExponent)); // 49152, default 3 * pow(2, 8) = 768 + static std::vector aCoronas; + static std::vector aCoronas2; aCoronas.resize(nCoronasLimit * 0x3C * 4); aCoronas2.resize(nCoronasLimit * 0x3C * 4); @@ -126,136 +269,163 @@ void CLODLightManager::IV::IncreaseCoronaLimit() } -void CLODLightManager::IV::RenderLODLights() +void CLODLightManager::IV::RegisterCustomCoronas() { - if (*CurrentTimeHours > 19 || *CurrentTimeHours < 7) - { - unsigned char bAlpha; - float fRadius; - unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; - unsigned int curMin = *CurrentTimeMinutes; - //CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip; - GetRootCam(¤tCamera); + unsigned short nModelID = 65534; - if (nTime >= 20 * 60) - bAlpha = static_cast((5.0f / 6.0f)*nTime - 1000.0f); - else if (nTime < 3 * 60) - bAlpha = 200; - else - bAlpha = static_cast((-5.0f / 6.0f)*nTime + 350.0f); - - for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) - { - Vector3 pCamPos; - GetCamPos(currentCamera, &pCamPos.X, &pCamPos.Y, &pCamPos.Z); - - if (GetDistance((RwV3d*)&it->vecPos, (RwV3d*)&pCamPos) <= CoronaFarClip) - { - if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) - { - if (CamIsSphereVisible(currentCamera, it->vecPos.x, it->vecPos.y, it->vecPos.z, 5.0f)) - { - float fDistSqr = (pCamPos.X - it->vecPos.x)*(pCamPos.X - it->vecPos.x) + (pCamPos.Y - it->vecPos.y)*(pCamPos.Y - it->vecPos.y) + (pCamPos.Z - it->vecPos.z)*(pCamPos.Z - it->vecPos.z); + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, 0.0f)); +} - if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance) - { - if (!it->nNoDistance) - fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - else - fRadius = 3.5f; +WplInstance* CLODLightManager::IV::PossiblyAddThisEntity(WplInstance* pInstance) +{ + if (m_bCatchLamppostsNow && IsModelALamppost(pInstance->ModelNameHash)) + RegisterLamppost(pInstance); - if (SlightlyIncreaseRadiusWithDistance) - fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC + return pInstance; +} - if (it->fCustomSizeMult != 0.45f) - { - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * it->colour.r, (bAlpha / 500.0f) * it->colour.g, (bAlpha / 500.0f) * it->colour.b); - } - else - { - if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50)) - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0); - else - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0); - } - else - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0); - else - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0); - } - } - } - } - } - } - } - } +void CLODLightManager::IV::RegisterLamppost(WplInstance* pObj) +{ + DWORD nModelID = pObj->ModelNameHash; + CMatrix dummyMatrix; + + float qw = pObj->RotationW; + float qx = pObj->RotationX; + float qy = pObj->RotationY; + float qz = pObj->RotationZ; + + float n = 1.0f / sqrt(qx*qx + qy*qy + qz*qz + qw*qw); + qx *= n; + qy *= n; + qz *= n; + qw *= n; + + dummyMatrix.matrix.right.x = 1.0f - 2.0f*qy*qy - 2.0f*qz*qz; + dummyMatrix.matrix.right.y = 2.0f*qx*qy - 2.0f*qz*qw; + dummyMatrix.matrix.right.z = 2.0f*qx*qz + 2.0f*qy*qw; + + dummyMatrix.matrix.up.x = 2.0f*qx*qy + 2.0f*qz*qw; + dummyMatrix.matrix.up.y = 1.0f - 2.0f*qx*qx - 2.0f*qz*qz; + dummyMatrix.matrix.up.z = 2.0f*qy*qz - 2.0f*qx*qw; + + dummyMatrix.matrix.at.x = 2.0f*qx*qz - 2.0f*qy*qw; + dummyMatrix.matrix.at.y = 2.0f*qy*qz + 2.0f*qx*qw; + dummyMatrix.matrix.at.z = 1.0f - 2.0f*qx*qx - 2.0f*qy*qy; + + dummyMatrix.matrix.pos.x = pObj->PositionX; + dummyMatrix.matrix.pos.y = pObj->PositionY; + dummyMatrix.matrix.pos.z = pObj->PositionZ; + + if (GetDistance((RwV3d*)&CVector(pObj->PositionX, pObj->PositionY, pObj->PositionZ), (RwV3d*)&CVector(-278.37f, -1377.48f, 90.98f)) <= 300.0f) + return; + + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(dummyMatrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, atan2(dummyMatrix.GetUp()->y, -dummyMatrix.GetUp()->x))); } -void CLODLightManager::EFLC::RenderLODLights() +void CLODLightManager::IV::RegisterLODLights() { + if (m_bCatchLamppostsNow) + m_bCatchLamppostsNow = false; + if (*CurrentTimeHours > 19 || *CurrentTimeHours < 7) { - unsigned char bAlpha; - float fRadius; + unsigned char bAlpha = 0; + float fRadius = 0.0f; unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; unsigned int curMin = *CurrentTimeMinutes; - //CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip; - GetRootCam(¤tCamera); - if (nTime >= 20 * 60) - bAlpha = static_cast((5.0f / 6.0f)*nTime - 1000.0f); + if (nTime >= 19 * 60) + bAlpha = static_cast((3.0f / 4.0f)*nTime - 825.0f); // http://goo.gl/O03RpE {(19*60)a + y = 30, (24*60)a + y = 255} else if (nTime < 3 * 60) - bAlpha = 200; + bAlpha = 255; else - bAlpha = static_cast((-5.0f / 6.0f)*nTime + 350.0f); + bAlpha = static_cast((-15.0f / 16.0f)*nTime + 424.0f); // http://goo.gl/M8Dev9 {(7*60)a + y = 30, (3*60)a + y = 255} for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) { - Vector3 pCamPos; - GetCamPos(currentCamera, &pCamPos.X, &pCamPos.Y, &pCamPos.Z); - - if (GetDistance((RwV3d*)&it->vecPos, (RwV3d*)&pCamPos) <= CoronaFarClip) + static int currentCamera; + GetRootCam(¤tCamera); + if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f) /*&& CamIsSphereVisible(currentCamera, it->vecPos.x, it->vecPos.y, it->vecPos.z, 3.0f)*/) { - if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) - { - if (CamIsSphereVisible(currentCamera, it->vecPos.x, it->vecPos.y, it->vecPos.z, 5.0f)) - { - float fDistSqr = (pCamPos.X - it->vecPos.x)*(pCamPos.X - it->vecPos.x) + (pCamPos.Y - it->vecPos.y)*(pCamPos.Y - it->vecPos.y) + (pCamPos.Z - it->vecPos.z)*(pCamPos.Z - it->vecPos.z); + CVector CamPos = CVector(); + GetCamPos(currentCamera, &CamPos.x, &CamPos.y, &CamPos.z); + CVector* pCamPos = &CamPos; + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); - if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance) - { - if (!it->nNoDistance) - fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - else - fRadius = 3.5f; + if ((fDistSqr > 250.0f*250.0f && fDistSqr < fCoronaFarClip*fCoronaFarClip) || it->nNoDistance) + { + if (it->nNoDistance) + fRadius = 3.5f; + else + fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - if (SlightlyIncreaseRadiusWithDistance) - fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC + if (bSlightlyIncreaseRadiusWithDistance) + fRadius *= min((0.00136364f)*sqrt(fDistSqr) + 0.590909f, 3.0f); // http://goo.gl/3kDpnC {(300)a + y = 1.0, (2500)a + y = 4} - if (it->fCustomSizeMult != 0.45f) + if (it->fCustomSizeMult != 0.45f) + { + if (!it->nCoronaShowMode) + { + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); + } + //else + //{ + // static float blinking = 1.0f; + // if (IsBlinkingNeeded(it->nCoronaShowMode)) + // blinking -= CTimer::ms_fTimeStep / 1000.0f; + // else + // blinking += CTimer::ms_fTimeStep / 1000.0f; + // + // (blinking > 1.0f) ? blinking = 1.0f : (blinking < 0.0f) ? blinking = 0.0f : 0.0f; + // + // CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, blinking * (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + //} + } + else + { + fRadius *= 1.3f; + if ((it->colour.r >= 250 && it->colour.g >= 100 && it->colour.b <= 100) && ((curMin == 9 || curMin == 19 || curMin == 29 || curMin == 39 || curMin == 49 || curMin == 59))) //yellow + { + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); + } + else + { + if ((abs(it->fHeading) >= (3.1415f / 6.0f) && abs(it->fHeading) <= (5.0f * 3.1415f / 6.0f))) { - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * it->colour.r, (bAlpha / 500.0f) * it->colour.g, (bAlpha / 500.0f) * it->colour.b); + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 100 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); + } + } } else { - if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50)) + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0); - else - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0); + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); } else { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0); - else - DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0); + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + //DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 127.5f, 0, 0.0f, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.r, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.g, ((bAlpha * (it->colour.a / 255.0f)) / 500.0f) * it->colour.b); + DrawCorona2(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)) / 10.0f, (CVector*)&it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier) * 1270.5f, 0.0, 0.0, 0, 0.0, 0, 0, 0); + } } } } @@ -266,123 +436,6 @@ void CLODLightManager::EFLC::RenderLODLights() } } -void __declspec(naked) CLODLightManager::IV::LoadObjectInstanceHook() -{ - _asm - { - mov ebx, [ebp + 8] - mov pInstance, ebx - } - PossiblyAddThisEntity(pInstance); - _asm - { - //mov ebx, [ebp + 8] - mov ecx, [ebx + 1Ch] - jmp hookJmpAddr - } -} - -void __declspec(naked) ParseIdeObjsHook() -{ - _asm - { - movss xmm0, [esp + 0x1C] - movss AllNormalObjectsDrawDistance, xmm0 - //mov pModelName, esp - //add pModelName, 0x54 - } - if (AllNormalObjectsDrawDistance == 50.0f || AllNormalObjectsDrawDistance == 100.0f || AllNormalObjectsDrawDistance == 150.0f || AllNormalObjectsDrawDistance == 80.0f) //lampposts draw distances - { - AllNormalObjectsDrawDistance = GenericObjectsDrawDistance; - } - _asm - { - movss xmm0, AllNormalObjectsDrawDistance - jmp hookJmpAddr2 - } -} - -void CLODLightManager::IV::GetMemoryAddresses() -{ - if (injector::address_manager::singleton().IsIV()) - { - CLODLightManager::IV::CurrentTimeHours = aslr_ptr(0x11D5300).get(); - CLODLightManager::IV::CurrentTimeMinutes = aslr_ptr(0x11D52FC).get(); - CLODLightManager::IV::DrawCorona = (int(__cdecl *)(float, float, float, float, unsigned int, float, unsigned char, unsigned char, unsigned char))(aslr_ptr(0xA6E240).get()); - CLODLightManager::IV::GetRootCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xB006C0).get()); - CLODLightManager::IV::GetGameCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xB006E0).get()); - CLODLightManager::IV::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xBB9340).get()); - CLODLightManager::IV::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xBB8510).get()); - } - else - { - CLODLightManager::EFLC::CurrentTimeHours = injector::aslr_ptr(0x10C9398).get(); - CLODLightManager::EFLC::CurrentTimeMinutes = injector::aslr_ptr(0x10C9394).get(); - CLODLightManager::EFLC::DrawCorona = (int(__cdecl *)(float, float, float, float, unsigned int, float, unsigned char, unsigned char, unsigned char))(aslr_ptr(0xAA3100).get()); - CLODLightManager::EFLC::GetRootCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xAFA7E0).get()); - CLODLightManager::EFLC::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xC27DD0).get()); - CLODLightManager::EFLC::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xC26FA0).get()); - } -} - -void CLODLightManager::IV::Init() -{ - CIniReader iniReader(""); - bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1); - CoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); - SlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; - CoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); - bool DisableDefaultLodLights = iniReader.ReadInteger("LodLights", "DisableDefaultLodLights", 0) == 1; - bool DisableCoronasWaterReflection = iniReader.ReadInteger("LodLights", "DisableCoronasWaterReflection", 0) == 1; - GenericObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "LamppostsDrawDistance", 0.0f); - bool SkipIntro = iniReader.ReadInteger("Misc", "SkipIntro", 0) == 1; - bool DoNotPauseOnMinimize = iniReader.ReadInteger("Misc", "DoNotPauseOnMinimize", 0) == 1; - - if (bRenderLodLights) - { - GetMemoryAddresses(); - - IncreaseCoronaLimit(); - LoadDatFile(); - RegisterCustomCoronas(); - - if (injector::address_manager::singleton().IsIV()) - { - if (SkipIntro) { injector::WriteMemory(aslr_ptr(0x402B49), 0xEB, true); } - if (DoNotPauseOnMinimize) { injector::MakeNOP(aslr_ptr(0x61D06A), 2, true); } - - if (DisableDefaultLodLights) { injector::WriteMemory(aslr_ptr(0x00903300), 0xC3u, true); } - if (DisableCoronasWaterReflection) { injector::MakeNOP(aslr_ptr(0xB54373), 5, true); } - - injector::MakeJMP(aslr_ptr(0x008D63A1), LoadObjectInstanceHook, true); - hookJmpAddr = (uintptr_t)injector::aslr_ptr(0x8D63A7).get(); - - injector::MakeJMP(aslr_ptr(0x008D2311), ParseIdeObjsHook, true); - hookJmpAddr2 = (uintptr_t)injector::aslr_ptr(0x8D2317).get(); - - injector::MakeCALL(aslr_ptr(0x00402D6C), RenderLODLights, true); - } - else - { - if (SkipIntro) { injector::WriteMemory(aslr_ptr(0x473439), 0xEB, true); } - if (DoNotPauseOnMinimize) { injector::MakeNOP(aslr_ptr(0x402D5A), 2, true); } - - if (DisableDefaultLodLights) { injector::WriteMemory(aslr_ptr(0x00975860), 0xC3u, true); } - if (DisableCoronasWaterReflection) { injector::MakeNOP(aslr_ptr(0xC8E183), 5, true); } - - injector::MakeJMP(aslr_ptr(0x0091C851), LoadObjectInstanceHook, true); - hookJmpAddr = (uintptr_t)injector::aslr_ptr(0x91C857).get(); - - injector::MakeJMP(aslr_ptr(0x00918891), ParseIdeObjsHook, true); - hookJmpAddr2 = (uintptr_t)injector::aslr_ptr(0x918897).get(); - - injector::MakeCALL(aslr_ptr(0x0047361F), CLODLightManager::EFLC::RenderLODLights); - } - } -} - - - BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { if (reason == DLL_PROCESS_ATTACH) diff --git a/IVLodLights/stdafx.cpp b/IVLodLights/stdafx.cpp deleted file mode 100644 index 862d1f5..0000000 --- a/IVLodLights/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// IVLodLights.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/IVLodLights/stdafx.h b/IVLodLights/stdafx.h deleted file mode 100644 index f3a0737..0000000 --- a/IVLodLights/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/IVLodLights/targetver.h b/IVLodLights/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/IVLodLights/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/SALodLights/CSearchlights.cpp b/SALodLights/CSearchlights.cpp new file mode 100644 index 0000000..91be940 --- /dev/null +++ b/SALodLights/CSearchlights.cpp @@ -0,0 +1,373 @@ +#include "CSearchlights.h" + +extern float* CWeatherFoggyness; + +void CSearchlights::RenderSearchLightsSA() +{ + if ((CLODLightManager::SA::bRenderOnlyDuringFoggyWeather && *CWeatherFoggyness) || !CLODLightManager::SA::bRenderOnlyDuringFoggyWeather) + { + if (CLODLightManager::SA::GetIsTimeInRange(20, 7) && *CLODLightManager::SA::ActiveInterior == 0) + { + static auto SetRenderStatesForSpotLights = (void(__cdecl *)()) 0x6C4650; + SetRenderStatesForSpotLights(); + + for (auto it = CLODLightManager::SA::m_pLampposts->cbegin(); it != CLODLightManager::SA::m_pLampposts->cend(); ++it) + { + if (it->nDrawSearchlight) + { + CVector* pCamPos = &TheCamera.Cams[TheCamera.ActiveCam].Source; + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + + if ((fDistSqr > 50.0f*50.0f) && (fDistSqr < 300.0f*300.0f)) + { + float fVisibility = CLODLightManager::SA::fSearchlightEffectVisibilityFactor * ((0.0233333f)*sqrt(fDistSqr) - 1.16667f); + //if (*CWeatherFoggyness) + // fVisibility *= 0.5f; + + RwV3D EndPoint = *(RwV3D*)&it->vecPos; + EndPoint.z = CLODLightManager::SA::FindGroundZFor3DCoord(it->vecPos.x, it->vecPos.y, it->vecPos.z, 0, 0); + + if (!(it->colour.r == 255 && it->colour.g == 255 && it->colour.b == 255) && !(it->colour.r == 254 && it->colour.g == 117 && it->colour.b == 134)) + { + //yellow + drawCustomSpotLightSA(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 5.0f, 8, fVisibility); + } + else if (!(it->colour.r == 254 && it->colour.g == 117 && it->colour.b == 134)) + { + //white + drawCustomSpotLightSA(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 255.0f, 8, fVisibility); + } + else + { + //pink + drawCustomSpotLightSA(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 200.0f, 18, fVisibility); + } + } + } + } + + static auto ResetRenderStatesForSpotLights = (void(__cdecl *)()) 0x6C46E0; + ResetRenderStatesForSpotLights(); + } + } +} + + + +void __cdecl CSearchlights::drawCustomSpotLightSA(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) +{ + static short TempBufferRenderIndexList[4096]; + static RxObjSpace3dVertex TempVertexBuffer[500]; + static int TempBufferIndicesStored = 0; + static unsigned int TempBufferVerticesStored = 0; + + RwMatrix *v12; // ebx@1 + RwV3D *v13; // eax@4 + signed int v19; // esi@8 + float v20; // fst7@9 + float v21; // ST7C_4@9 + float v22; // ST60_4@9 + float v23; // fst7@9 + float v24; // fst6@9 + float v25; // fst4@9 + float v26; // ST7C_4@9 + float v27; // ST68_4@9 + float v28; // ST6C_4@9 + float v29; // fst4@9 + float v30; // fst3@9 + float v31; // ST80_4@9 + float v32; // fst2@9 + float v33; // ST60_4@9 + float v34; // ST74_4@9 + float v35; // ST78_4@9 + float v36; // ST78_4@9 + float v37; // ST60_4@9 + float v38; // fst7@15 + float v39; // fst5@15 + float v40; // ST80_4@16 + float v41; // fst4@15 + float v42; // fst7@17 + unsigned int v43; // eax@17 + float v44; // fst7@17 + float v45; // fst7@17 + float v46; // fst7@17 + float v47; // fst7@19 + int v49; // ebp@21 + float v50; // fst7@22 + unsigned int v51; // edi@24 + signed int v52; // esi@25 + float v53; // fst7@26 + unsigned char *v54; // ebp@26 + float v55; // fst6@27 + int v56; // ebx@27 + unsigned __int64 v57; // qax@27 + float v59; // fst6@27 + int v60; // ebx@27 + unsigned __int64 v61; // qax@27 + float v63; // fst6@27 + int v64; // ebx@27 + unsigned __int64 v65; // qax@27 + float v66; // fst6@27 + float v67; // fst7@30 + float v68; // fst6@31 + signed int v88; // [sp+44h] [bp-424h]@8 + signed int v89; // [sp+44h] [bp-424h]@26 + void *v90; // [sp+44h] [bp-424h]@30 + float a4; // [sp+48h] [bp-420h]@9 + float EndPointa; // [sp+4Ch] [bp-41Ch]@9 + float v97; // [sp+50h] [bp-418h]@9 + float a6; // [sp+54h] [bp-414h]@9 + float a7; // [sp+58h] [bp-410h]@9 + float v104; // [sp+5Ch] [bp-40Ch]@9 + float v105; // [sp+64h] [bp-404h]@17 + RwV3D a; // [sp+68h] [bp-400h]@1 + float v107; // [sp+74h] [bp-3F4h]@8 + RwV3D v108; // [sp+78h] [bp-3F0h]@1 + float v109; // [sp+84h] [bp-3E4h]@9 + RwV3D v110; // [sp+88h] [bp-3E0h]@6 + RwV3D v111; // [sp+94h] [bp-3D4h]@9 + float v112; // [sp+A0h] [bp-3C8h]@9 + float v113; // [sp+A4h] [bp-3C4h]@9 + RwV3D v115; // [sp+ACh] [bp-3BCh]@16 + float v116; // [sp+B8h] [bp-3B0h]@9 + float v117; // [sp+BCh] [bp-3ACh]@9 + float v118; // [sp+C0h] [bp-3TargetRadiush]@9 + RwV3D out; // [sp+C4h] [bp-3A4h]@9 + float v120; // [sp+D0h] [bp-398h]@16 + float v121; // [sp+D4h] [bp-394h]@16 + float v122; // [sp+D8h] [bp-390h]@16 + float v123; // [sp+DCh] [bp-38Ch]@3 + float v124; // [sp+E0h] [bp-388h]@3 + float v125; // [sp+E4h] [bp-384h]@3 + float v126; // [sp+E8h] [bp-380h]@9 + float v127; // [sp+ECh] [bp-37Ch]@9 + float v128; // [sp+F0h] [bp-378h]@9 + RwV3D v132; // [sp+100h] [bp-368h]@9 + float v133; // [sp+10Ch] [bp-35Ch]@9 + float v134; // [sp+110h] [bp-358h]@9 + float v135; // [sp+118h] [bp-350h]@9 + float v136; // [sp+11Ch] [bp-34Ch]@9 + RwV3D b; // [sp+124h] [bp-344h]@9 + RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 + RwV3D v140; // [sp+158h] [bp-310h]@14 + float v141; // [sp+164h] [bp-304h]@9 + float v142; // [sp+178h] [bp-2F0h]@16 + float v143; // [sp+17Ch] [bp-2ECh]@9 + float v144; // [sp+188h] [bp-2E0h]@9 + float v145; // [sp+19Ch] [bp-2CCh]@9 + float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 + RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 + RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 + + v108.x = EndPoint.x - StartPoint.x; + a.x = v108.x; + v108.y = EndPoint.y - StartPoint.y; + a.y = v108.y; + v108.z = EndPoint.z - StartPoint.z; + a.z = v108.z; + CLODLightManager::SA::CVectorNormalize(&a); + v12 = 0; + EndPoint.x = a.x * 3.0f + EndPoint.x; + EndPoint.y = a.y * 3.0f + EndPoint.y; + EndPoint.z = a.z * 3.0f + EndPoint.z; + v123 = a.x * 100.0f + StartPoint.x; + v124 = a.y * 100.0f + StartPoint.y; + v125 = a.z * 100.0f + StartPoint.z; + v13 = &TheCamera.GetMatrix()->matrix.pos; + v110.x = v13->x - StartPoint.x; + v110.y = v13->y - StartPoint.y; + v110.z = v13->z - StartPoint.z; + CLODLightManager::SA::CVectorNormalize(&v110); + v19 = 0; + v107 = 0.0f; + TempBufferIndicesStored = 0; + TempBufferVerticesStored = 0; + v88 = 0; + do + { + b.x = 0; + b.y = 0; + b.z = 1.0f; + CLODLightManager::SA::CrossProduct(&out, &a, &b); + CLODLightManager::SA::CVectorNormalize(&out); + CLODLightManager::SA::CrossProduct(&v132, &out, &a); + CLODLightManager::SA::CVectorNormalize(&v132); + v20 = (float)v88 * 0.15707964f; + v21 = sin(v20); + v22 = cos(v20); + v23 = out.x * v21; + v141 = v23; + v24 = out.y * v21; + v25 = out.z * v21; + v26 = v25; + v133 = v141 * baseRadius; + v134 = v24 * baseRadius; + v27 = v134 + StartPoint.y; + v28 = v25 * baseRadius + StartPoint.z; + v29 = v132.x * v22; + v109 = v29; + v30 = v132.y * v22; + v31 = v30; + v32 = v132.z * v22; + v33 = v32; + v145 = v32; + v126 = v29 * baseRadius; + v127 = v30 * baseRadius; + v128 = v145 * baseRadius; + v146 = v33; + a4 = v126 + v133 + StartPoint.x; + EndPointa = v127 + v27; + v97 = v128 + v28; + v144 = v23; + v135 = v144 * TargetRadius; + v136 = v24 * TargetRadius; + v34 = v136 + v124; + v35 = v26 * TargetRadius + v125; + v116 = v109 * TargetRadius; + v117 = v31 * TargetRadius; + v118 = v33 * TargetRadius; + v36 = v118 + v35; + v37 = (v97 - EndPoint.z) / (v97 - v36); + v143 = v135 + v123 + v116 - a4; + v112 = v143 * v37; + v113 = (v117 + v34 - EndPointa) * v37; + v111.x = v112 + a4; + v111.y = v113 + EndPointa; + a6 = v111.x; + a7 = v111.y; + v111.z = (v36 - v97) * v37 + v97; + v104 = v111.z; + if (v19 && v19 != 10) + { + if (v19 == 20) + { + v139.x = v111.x; + v139.y = v111.y; + v139.z = v111.z; + } + else + { + if (v19 == 30) + { + v140.x = v111.x; + v140.y = v111.y; + v140.z = v111.z; + } + } + } + v38 = v111.x - a4; + v39 = v111.y - EndPointa; + v41 = v111.z - v97; + v109 = v41; + if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) + { + v115.x = v38; + v40 = v39; + v115.y = v40; + v115.z = v109; + CLODLightManager::SA::CVectorNormalize(&v115); + v142 = v115.z * 100.0f; + v120 = v115.x * 100.0f + a4; + a6 = v120; + v121 = v115.y * 100.0f + EndPointa; + a7 = v121; + v122 = v142 + v97; + v104 = v122; + } + v42 = slAlpha * 0.15000001f + 0.1f; + v43 = TempBufferVerticesStored; + TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; + v105 = v42; + TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; + v44 = a4 - StartPoint.x; + TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; + v108.x = v44; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; + v45 = EndPointa - StartPoint.y; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; + v108.y = v45; + v108.z = v97 - StartPoint.z; + CLODLightManager::SA::CVectorNormalize(&v108); + v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; + if (v46 < 0.0f) + v46 = -v46; + v47 = v46 * v46; + if (v47 > v107) + v107 = v47; + v49 = TempBufferIndicesStored; + *(&v149[0].red + TempBufferVerticesStored) = v105; + *(&v149[0].green + TempBufferVerticesStored) = 0; + *(&v148[0].red + TempBufferVerticesStored) = v47; + *(&v148[0].green + TempBufferVerticesStored) = v47; + if (v19 != 40) + { + v50 = baseRadius; + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); + v49 += 3; + TempBufferIndicesStored = v49; + if (v50 > 0.0f) + { + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); + v49 += 3; + TempBufferIndicesStored = v49; + } + } + v51 = TempBufferVerticesStored + 2; + ++v19; + TempBufferVerticesStored = v51; + v88 = v19; + } while (v19 <= 40); + v52 = 0; + if ((signed int)v51 >= 4) + { + v89 = 3; + v53 = CLODLightManager::SA::fSearchlightEffectVisibilityFactor / v107; + v54 = (unsigned char *)&TempVertexBuffer[1 + CLODLightManager::SA::nSmoothEffect].color; + do + { + v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; + v56 = ((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2; + v57 = (unsigned __int64)(v55 * slColorFactor1); + *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); + v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; + v60 = ((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2; + v61 = (unsigned __int64)(v59 * slColorFactor1); + *(DWORD *)v54 = (DWORD)(v61 | v60); + v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; + v64 = ((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2; + v65 = (unsigned __int64)(v63 * slColorFactor1); + *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); + v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); + *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2); + v52 += 4; + v54 = (unsigned char *)v54 + 144; + v89 += 4; + } while (v89 < (signed int)v51); + v49 = TempBufferIndicesStored; + v12 = 0; + } + if (v52 < (signed int)v51) + { + v67 = CLODLightManager::SA::fSearchlightEffectVisibilityFactor / v107; + v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + CLODLightManager::SA::nSmoothEffect].color); + do + { + v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; + *(DWORD *)v90 = (DWORD)((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)); + ++v52; + v90 = (char *)v90 + 0x24; + } while (v52 < (signed int)v51); + v12 = 0; + } + + if (v49 >(signed int)v12 && CLODLightManager::SA::RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) + { + CLODLightManager::SA::RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); + CLODLightManager::SA::RwIm3DEnd(); + } +} \ No newline at end of file diff --git a/SALodLights/CSearchlights.h b/SALodLights/CSearchlights.h new file mode 100644 index 0000000..8d6c072 --- /dev/null +++ b/SALodLights/CSearchlights.h @@ -0,0 +1,13 @@ +#ifndef __SEARCHLIGHTS +#define __SEARCHLIGHTS +#include "..\includes\stdafx.h" +#include "..\includes\CLODLightManager.h" + +class CSearchlights +{ +public: + static void (__cdecl drawCustomSpotLightSA)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); + static void RenderSearchLightsSA(); +}; + +#endif \ No newline at end of file diff --git a/SALodLights/SALodLights.vcxproj b/SALodLights/SALodLights.vcxproj index 96ed064..58f1074 100644 --- a/SALodLights/SALodLights.vcxproj +++ b/SALodLights/SALodLights.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,17 @@ Release Win32 + + Debug + x64 + + + Release + x64 + - {32E8A22B-F9D9-4A3C-B524-9632BEC56A51} + {7929C620-829C-4A98-9AC7-9578D8009C30} Win32Proj SALodLights 8.1 @@ -20,7 +28,7 @@ DynamicLibrary true - v120 + v140 Unicode @@ -30,27 +38,55 @@ true MultiByte + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + true + + true + false .asi $(SolutionDir)$(Configuration)\$(ProjectName)\ + + false + - Use + + Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;SALODLIGHTS_EXPORTS;%(PreprocessorDefinitions) @@ -60,10 +96,24 @@ true + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;SALODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + - Level4 - Use + Level3 + + MaxSpeed true true @@ -72,30 +122,43 @@ Windows + true + true true + + + copy /y "$(TargetPath)" "Z:\WGTA\Modloader\Grand Theft Auto San Andreas\modloader\mods\SA.Project2DFXv4.0\SALodLights.asi" + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;SALODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows true true + true - - - + + + + + - - - false - - - false - - - - - Create - Create - + + + + diff --git a/SALodLights/SALodLights.vcxproj.filters b/SALodLights/SALodLights.vcxproj.filters index afc4980..d85964a 100644 --- a/SALodLights/SALodLights.vcxproj.filters +++ b/SALodLights/SALodLights.vcxproj.filters @@ -15,25 +15,34 @@ - - Header Files - - - Header Files - - - Header Files - - - - + Source Files - + + Source Files + + Source Files - + Source Files + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/SALodLights/SearchlightsSA.h b/SALodLights/SearchlightsSA.h deleted file mode 100644 index 08c297c..0000000 --- a/SALodLights/SearchlightsSA.h +++ /dev/null @@ -1,389 +0,0 @@ - -void CLODLightManager::SA::RenderSearchLights() -{ - static CPool **pObjectPool = (CPool **)0xB7449C; - static DWORD *pModelPointers = (DWORD *)0xA9B0C8; - CObject *ObjectInst; - int nObjectPoolSize = (*pObjectPool)->size; - - if (nObjectPoolSize && GetIsTimeInRange(20, 7)) - { - int nOffset = 412 * nObjectPoolSize; - static auto SetRenderStatesForSpotLights = (void(__cdecl *)()) 0x6C4650; - SetRenderStatesForSpotLights(); - do - { - --nObjectPoolSize; - nOffset -= 412; - if (*(BYTE *)(nObjectPoolSize + (*pObjectPool)->flags) >= 0) - { - ObjectInst = (CObject *)(nOffset + (*pObjectPool)->objects); - if (ObjectInst) - { - if (!CObjectIsDamaged(ObjectInst) && IsModelALamppostNotTrafficLight(ObjectInst->m_nModelIndex) && ((CBaseModelInfo *)pModelPointers[ObjectInst->m_nModelIndex])->m_nbCount2dfx > 0) - { - for (auto i = 0; i < ((CBaseModelInfo *)pModelPointers[ObjectInst->m_nModelIndex])->m_nbCount2dfx; i++) - { - C2dfx* C2dfxData = Get2dfx((CBaseModelInfo *)pModelPointers[ObjectInst->m_nModelIndex], 0, i); - - //if (!C2dfxData->type) - //{ - if (!(C2dfxData->color.r == 255 && C2dfxData->color.g == 0 && C2dfxData->color.b == 0) - && !(C2dfxData->color.r == 0 && C2dfxData->color.g == 255 && C2dfxData->color.b == 0) - && !(C2dfxData->color.r == 255 && (C2dfxData->color.g == 128 || C2dfxData->color.g == 142) && C2dfxData->color.b == 0 && (ObjectInst->m_nModelIndex == CJ_TRAFFIC_LIGHT4 || ObjectInst->m_nModelIndex == GAY_TRAFFIC_LIGHT)) - && !(C2dfxData->coronaSize == 0.0f)) - { - RwV3D StartPoint; - RwV3D EndPoint; - RwV3D zeroCoords; zeroCoords.x = zeroCoords.y = zeroCoords.z = 0.0f; - TransformPoint(&StartPoint, (CMatrix *)ObjectInst->m_pCoords, &C2dfxData->offset); - - if (GetDistance(GetCamPos(), &StartPoint) < 1000.0f && GetDistance(&zeroCoords, &StartPoint) > 100.0f) - { - - EndPoint = StartPoint; - float grZ = FindGroundZFor3DCoord(StartPoint.x, StartPoint.y, StartPoint.z, 0, 0); - EndPoint.z = grZ; - - if (ObjectInst->m_nModelIndex != Streetlamp1 && ObjectInst->m_nModelIndex != Streetlamp2 - && ObjectInst->m_nModelIndex != bollardlight && ObjectInst->m_nModelIndex != Gay_lamppost) - { - //yellow - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), C2dfxData->coronaSize / 6.0f, 5.0f, 8, fSearchlightEffectVisibilityFactor); - - } - else if (ObjectInst->m_nModelIndex != Gay_lamppost) - { - //white - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), C2dfxData->coronaSize / 6.0f, 255.0f, 8, fSearchlightEffectVisibilityFactor); - } - else - { - //pink - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), C2dfxData->coronaSize / 6.0f, 200.0f, 18, fSearchlightEffectVisibilityFactor); - } - } - } - //} - } - } - } - } - } while (nObjectPoolSize); - static auto ResetRenderStatesForSpotLights = (void(__cdecl *)()) 0x6C46E0; - ResetRenderStatesForSpotLights(); - } -} - -void __cdecl CLODLightManager::SA::drawCustomSpotLight(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) -{ - RwMatrix *v12; // ebx@1 - RwV3D *v13; // eax@4 - signed int v19; // esi@8 - float v20; // fst7@9 - float v21; // ST7C_4@9 - float v22; // ST60_4@9 - float v23; // fst7@9 - float v24; // fst6@9 - float v25; // fst4@9 - float v26; // ST7C_4@9 - float v27; // ST68_4@9 - float v28; // ST6C_4@9 - float v29; // fst4@9 - float v30; // fst3@9 - float v31; // ST80_4@9 - float v32; // fst2@9 - float v33; // ST60_4@9 - float v34; // ST74_4@9 - float v35; // ST78_4@9 - float v36; // ST78_4@9 - float v37; // ST60_4@9 - float v38; // fst7@15 - float v39; // fst5@15 - float v40; // ST80_4@16 - float v41; // fst4@15 - float v42; // fst7@17 - unsigned int v43; // eax@17 - float v44; // fst7@17 - float v45; // fst7@17 - float v46; // fst7@17 - float v47; // fst7@19 - int v49; // ebp@21 - float v50; // fst7@22 - unsigned int v51; // edi@24 - signed int v52; // esi@25 - float v53; // fst7@26 - unsigned char *v54; // ebp@26 - float v55; // fst6@27 - int v56; // ebx@27 - unsigned __int64 v57; // qax@27 - float v59; // fst6@27 - int v60; // ebx@27 - unsigned __int64 v61; // qax@27 - float v63; // fst6@27 - int v64; // ebx@27 - unsigned __int64 v65; // qax@27 - float v66; // fst6@27 - float v67; // fst7@30 - float v68; // fst6@31 - signed int v88; // [sp+44h] [bp-424h]@8 - signed int v89; // [sp+44h] [bp-424h]@26 - void *v90; // [sp+44h] [bp-424h]@30 - float a4; // [sp+48h] [bp-420h]@9 - float EndPointa; // [sp+4Ch] [bp-41Ch]@9 - float v97; // [sp+50h] [bp-418h]@9 - float a6; // [sp+54h] [bp-414h]@9 - float a7; // [sp+58h] [bp-410h]@9 - float v104; // [sp+5Ch] [bp-40Ch]@9 - float v105; // [sp+64h] [bp-404h]@17 - RwV3D a; // [sp+68h] [bp-400h]@1 - float v107; // [sp+74h] [bp-3F4h]@8 - RwV3D v108; // [sp+78h] [bp-3F0h]@1 - float v109; // [sp+84h] [bp-3E4h]@9 - RwV3D v110; // [sp+88h] [bp-3E0h]@6 - RwV3D v111; // [sp+94h] [bp-3D4h]@9 - float v112; // [sp+A0h] [bp-3C8h]@9 - float v113; // [sp+A4h] [bp-3C4h]@9 - RwV3D v115; // [sp+ACh] [bp-3BCh]@16 - float v116; // [sp+B8h] [bp-3B0h]@9 - float v117; // [sp+BCh] [bp-3ACh]@9 - float v118; // [sp+C0h] [bp-3TargetRadiush]@9 - RwV3D out; // [sp+C4h] [bp-3A4h]@9 - float v120; // [sp+D0h] [bp-398h]@16 - float v121; // [sp+D4h] [bp-394h]@16 - float v122; // [sp+D8h] [bp-390h]@16 - float v123; // [sp+DCh] [bp-38Ch]@3 - float v124; // [sp+E0h] [bp-388h]@3 - float v125; // [sp+E4h] [bp-384h]@3 - float v126; // [sp+E8h] [bp-380h]@9 - float v127; // [sp+ECh] [bp-37Ch]@9 - float v128; // [sp+F0h] [bp-378h]@9 - RwV3D v132; // [sp+100h] [bp-368h]@9 - float v133; // [sp+10Ch] [bp-35Ch]@9 - float v134; // [sp+110h] [bp-358h]@9 - float v135; // [sp+118h] [bp-350h]@9 - float v136; // [sp+11Ch] [bp-34Ch]@9 - RwV3D b; // [sp+124h] [bp-344h]@9 - RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 - RwV3D v140; // [sp+158h] [bp-310h]@14 - float v141; // [sp+164h] [bp-304h]@9 - float v142; // [sp+178h] [bp-2F0h]@16 - float v143; // [sp+17Ch] [bp-2ECh]@9 - float v144; // [sp+188h] [bp-2E0h]@9 - float v145; // [sp+19Ch] [bp-2CCh]@9 - float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 - RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 - RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 - - v108.x = EndPoint.x - StartPoint.x; - a.x = v108.x; - v108.y = EndPoint.y - StartPoint.y; - a.y = v108.y; - v108.z = EndPoint.z - StartPoint.z; - a.z = v108.z; - CVectorNormalize(&a); - v12 = 0; - EndPoint.x = a.x * 3.0f + EndPoint.x; - EndPoint.y = a.y * 3.0f + EndPoint.y; - EndPoint.z = a.z * 3.0f + EndPoint.z; - v123 = a.x * 100.0f + StartPoint.x; - v124 = a.y * 100.0f + StartPoint.y; - v125 = a.z * 100.0f + StartPoint.z; - v13 = &TheCamera.m_pCoords->matrix.pos; - v110.x = v13->x - StartPoint.x; - v110.y = v13->y - StartPoint.y; - v110.z = v13->z - StartPoint.z; - CVectorNormalize(&v110); - v19 = 0; - v107 = 0.0f; - TempBufferIndicesStored = 0; - TempBufferVerticesStored = 0; - v88 = 0; - do - { - b.x = 0; - b.y = 0; - b.z = 1.0f; - CrossProduct(&out, &a, &b); - CVectorNormalize(&out); - CrossProduct(&v132, &out, &a); - CVectorNormalize(&v132); - v20 = (float)v88 * 0.15707964f; - v21 = sin(v20); - v22 = cos(v20); - v23 = out.x * v21; - v141 = v23; - v24 = out.y * v21; - v25 = out.z * v21; - v26 = v25; - v133 = v141 * baseRadius; - v134 = v24 * baseRadius; - v27 = v134 + StartPoint.y; - v28 = v25 * baseRadius + StartPoint.z; - v29 = v132.x * v22; - v109 = v29; - v30 = v132.y * v22; - v31 = v30; - v32 = v132.z * v22; - v33 = v32; - v145 = v32; - v126 = v29 * baseRadius; - v127 = v30 * baseRadius; - v128 = v145 * baseRadius; - v146 = v33; - a4 = v126 + v133 + StartPoint.x; - EndPointa = v127 + v27; - v97 = v128 + v28; - v144 = v23; - v135 = v144 * TargetRadius; - v136 = v24 * TargetRadius; - v34 = v136 + v124; - v35 = v26 * TargetRadius + v125; - v116 = v109 * TargetRadius; - v117 = v31 * TargetRadius; - v118 = v33 * TargetRadius; - v36 = v118 + v35; - v37 = (v97 - EndPoint.z) / (v97 - v36); - v143 = v135 + v123 + v116 - a4; - v112 = v143 * v37; - v113 = (v117 + v34 - EndPointa) * v37; - v111.x = v112 + a4; - v111.y = v113 + EndPointa; - a6 = v111.x; - a7 = v111.y; - v111.z = (v36 - v97) * v37 + v97; - v104 = v111.z; - if (v19 && v19 != 10) - { - if (v19 == 20) - { - v139.x = v111.x; - v139.y = v111.y; - v139.z = v111.z; - } - else - { - if (v19 == 30) - { - v140.x = v111.x; - v140.y = v111.y; - v140.z = v111.z; - } - } - } - v38 = v111.x - a4; - v39 = v111.y - EndPointa; - v41 = v111.z - v97; - v109 = v41; - if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) - { - v115.x = v38; - v40 = v39; - v115.y = v40; - v115.z = v109; - CVectorNormalize(&v115); - v142 = v115.z * 100.0f; - v120 = v115.x * 100.0f + a4; - a6 = v120; - v121 = v115.y * 100.0f + EndPointa; - a7 = v121; - v122 = v142 + v97; - v104 = v122; - } - v42 = slAlpha * 0.15000001f + 0.1f; - v43 = TempBufferVerticesStored; - TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; - v105 = v42; - TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; - v44 = a4 - StartPoint.x; - TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; - v108.x = v44; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; - v45 = EndPointa - StartPoint.y; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; - v108.y = v45; - v108.z = v97 - StartPoint.z; - CVectorNormalize(&v108); - v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; - if (v46 < 0.0f) - v46 = -v46; - v47 = v46 * v46; - if (v47 > v107) - v107 = v47; - v49 = TempBufferIndicesStored; - *(&v149[0].red + TempBufferVerticesStored) = v105; - *(&v149[0].green + TempBufferVerticesStored) = 0; - *(&v148[0].red + TempBufferVerticesStored) = v47; - *(&v148[0].green + TempBufferVerticesStored) = v47; - if (v19 != 40) - { - v50 = baseRadius; - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); - v49 += 3; - TempBufferIndicesStored = v49; - if (v50 > 0.0f) - { - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); - v49 += 3; - TempBufferIndicesStored = v49; - } - } - v51 = TempBufferVerticesStored + 2; - ++v19; - TempBufferVerticesStored = v51; - v88 = v19; - } while (v19 <= 40); - v52 = 0; - if ((signed int)v51 >= 4) - { - v89 = 3; - v53 = fSearchlightEffectVisibilityFactor / v107; - v54 = (unsigned char *)&TempVertexBuffer[1 + SmoothEffect].color; - do - { - v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; - v56 = ((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2; - v57 = (unsigned __int64)(v55 * slColorFactor1); - *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); - v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; - v60 = ((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2; - v61 = (unsigned __int64)(v59 * slColorFactor1); - *(DWORD *)v54 = (DWORD)(v61 | v60); - v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; - v64 = ((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2; - v65 = (unsigned __int64)(v63 * slColorFactor1); - *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); - v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); - *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2); - v52 += 4; - v54 = (unsigned char *)v54 + 144; - v89 += 4; - } while (v89 < (signed int)v51); - v49 = TempBufferIndicesStored; - v12 = 0; - } - if (v52 < (signed int)v51) - { - v67 = fSearchlightEffectVisibilityFactor / v107; - v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + SmoothEffect].color); - do - { - v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; - *(DWORD *)v90 = (DWORD)((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)); - ++v52; - v90 = (char *)v90 + 0x24; - } while (v52 < (signed int)v51); - v12 = 0; - } - - if (v49 >(signed int)v12 && RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) - { - RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); - RwIm3DEnd(); - } -} \ No newline at end of file diff --git a/SALodLights/dllmain.cpp b/SALodLights/dllmain.cpp index 4a722e3..865b297 100644 --- a/SALodLights/dllmain.cpp +++ b/SALodLights/dllmain.cpp @@ -1,441 +1,182 @@ -#include "stdafx.h" +#include "..\includes\stdafx.h" #include "..\includes\CLODLightManager.h" -#include "SearchlightsSA.h" - -void CLODLightManager::SA::RenderLODLights() +#include "..\includes\CLODLights.h" +#include "CSearchlights.h" + +int numCoronas; +CCamera& TheCamera = *(CCamera*)0xB6F028; +RwCamera*& Camera = *(RwCamera**)0xC1703C; +int& CTimer::m_snTimeInMillisecondsPauseMode = *(int*)0xB7CB7C; +float& CTimer::ms_fTimeStep = *(float*)0xB7CB5C; + +char* CLODLightManager::SA::CurrentTimeHours = (char*)0xB70153; +char* CLODLightManager::SA::CurrentTimeMinutes = (char*)0xB70152; +float** CLODLightManager::SA::fCurrentFarClip = (float**)0x53EA95; +int* CLODLightManager::SA::ActiveInterior = (int*)0xB72914; +char(__cdecl *CLODLightManager::SA::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x52CEE0; +int* (__cdecl *CLODLightManager::SA::GetModelInfo)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x4C5940; +void(__cdecl *const CLODLightManager::SA::CShadowsUpdateStaticShadows)() = (decltype(CShadowsUpdateStaticShadows))0x707F40; +bool(__cdecl *const CLODLightManager::SA::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CShadowsStoreStaticShadow))0x70BA00; +float(__cdecl *CLODLightManager::SA::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x5696C0; +RwV3D *(__cdecl *CLODLightManager::SA::TransformPoint)(RwV3D *outPoint, CMatrix *m, RwV3D *point) = (RwV3D *(__cdecl *)(RwV3D *, CMatrix *, RwV3D *)) 0x59C890; +bool(__thiscall *CLODLightManager::SA::CCameraIsSphereVisible)(int *camera, RwV3d *origin, float radius) = (bool(__thiscall *)(int *, RwV3d *, float)) 0x00420D40; +void(__cdecl *CLODLightManager::SA::RegisterCorona)(int id, int *vehicle, char r, char g, char b, char alpha, RwV3d *pos, float radius, float farClip, char type, char flareType, char enableReflection, char checkObstacles, int notUsed, float normalAngle, char longDistance, float nearClip, char someFadeFlag, float flashInertia, char onlyFromBelow, char flag) = (void(__cdecl *)(int, int *, char, char, char, char, RwV3d *, float, float, char, char, char, char, int, float, char, float, char, float, char, char)) 0x6FC580; +void(__fastcall *CLODLightManager::SA::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x59C910; +RwV3D *(__cdecl *CLODLightManager::SA::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x59C730; +int(__cdecl *CLODLightManager::SA::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x7EF450; +int(__cdecl *CLODLightManager::SA::RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices) = (int(__cdecl *)(int primType, short *indices, int numIndices)) 0x7EF550; +int(__cdecl *CLODLightManager::SA::RwIm3DEnd)() = (int(__cdecl *)()) 0x7EF520; +C2dfx *(__fastcall *CLODLightManager::SA::Get2dfx)(CBaseModelInfo *model, int edx0, int number) = (C2dfx *(__fastcall *)(CBaseModelInfo *, int, int)) 0x4C4C70; +void(__cdecl *CLODLightManager::SA::drawSpotLight)(int coronaIndex, float StartX, float StartY, float StartZ, float EndX, float EndY, float EndZ, float TargetRadius, float intensity, char flag1, char drawShadow, RwV3D *pVec1, RwV3D *pVec2, RwV3D *pVec3, char unkTrue, float BaseRadius) = (void(cdecl *)(int, float, float, float, float, float, float, float, float, char, char, RwV3D *, RwV3D *, RwV3D *, char, float)) 0x6C58E0; +bool(__thiscall *CLODLightManager::SA::CObjectIsDamaged)(CObject *pclObject) = (bool(__thiscall *)(CObject *))0x0046A2F0; + +RwTexture* CLODLightManager::SA::gpCustomCoronaTexture = nullptr; +RwImage*(__cdecl *const RtPNGImageReadSA)(const char* imageName) = (decltype(RtPNGImageReadSA))0x7CF9B0; +RwImage*(__cdecl *const RwImageFindRasterFormatSA)(RwImage* ipImage, int nRasterType, int* npWidth, int* npHeight, int* npDepth, int* npFormat) = (decltype(RwImageFindRasterFormatSA))0x8042C0; +RwRaster*(__cdecl *const RwRasterCreateSA)(int width, int height, int depth, int flags) = (decltype(RwRasterCreateSA))0x7FB230; +RwRaster*(__cdecl *const RwRasterSetFromImageSA)(RwRaster* raster, RwImage* image) = (decltype(RwRasterSetFromImageSA))0x804290; +RwTexture*(__cdecl *const RwTextureCreateSA)(RwRaster* raster) = (decltype(RwTextureCreateSA))0x7F37C0; +bool*(__cdecl *const RwImageDestroySA)(RwImage* image) = (decltype(RwImageDestroySA))0x802740; +RwTexture* CPNGFileReadFromFile(const char* pFileName) { - if (GetIsTimeInRange(20, 7) && *ActiveInterior == 0) - { - unsigned char bAlpha; - float fRadius; - unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; - unsigned int curMin = *CurrentTimeMinutes; - CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip; - - if (nTime >= 20 * 60) - bAlpha = static_cast((5.0f / 8.0f)*nTime - 750.0f); //http://goo.gl/O03RpE - else if (nTime < 3 * 60) - bAlpha = 150; - else - bAlpha = static_cast((-5.0f / 8.0f)*nTime + 262.5f); // http://goo.gl/M8Dev9 - - for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) - { - if (GetDistance((RwV3d*)&it->vecPos, GetCamPos()) <= CoronaFarClip) - { - if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) - { - if (CCameraIsSphereVisible((int *)0xB6F028, (RwV3d*)&it->vecPos, 5.0f)) - { - CVector* pCamPos = &TheCamera.Cams[TheCamera.ActiveCam].Source; - float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); - - if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance) - { - if (!it->nNoDistance) - fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - else - fRadius = 3.5f; - - if (SlightlyIncreaseRadiusWithDistance) - fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC - - if (it->fCustomSizeMult != 0.45f) - { - RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 0, 0, 0, 0.0f, false, 1.5f, false, bAlpha, false, true); - RenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), SSHADT_INTENSIVE, *(RwTexture **)0xC403F4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, (it->colour.r / 3), (it->colour.g / 3), (it->colour.b / 3), 15.0f, 1.0f, CoronaFarClip, false, 0.0f) : nullptr; - } - else - { - if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50)) - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), nullptr, 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 0, 0, 0, 0.0f, false, 1.5f, false, bAlpha, false, true); - else - RegisterCorona(reinterpret_cast(&*it), nullptr, 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 0, 0, 0, 0.0f, false, 1.5f, false, bAlpha, false, true); - } - else - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), nullptr, 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 0, 0, 0, 0.0f, false, 1.5f, false, bAlpha, false, true); - else - RegisterCorona(reinterpret_cast(&*it), nullptr, 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 0, 0, 0, 0.0f, false, 1.5f, false, bAlpha, false, true); - } - } - } - } - } - } - } - } -} - + RwTexture* pTexture = nullptr; -void CLODLightManager::SA::StoreCustomStaticShadows() -{ - if (GetIsTimeInRange(20, 7) && *ActiveInterior == 0) + if (RwImage* pImage = RtPNGImageReadSA(pFileName)) { - unsigned char bAlpha; - unsigned int nTime = (char)*CurrentTimeHours * 60 + (char)*CurrentTimeMinutes; - - if (nTime >= 20 * 60) - bAlpha = static_cast((5.0f / 6.0f)*nTime - 1000.0f); - else if (nTime < 3 * 60) - bAlpha = 200; - else - bAlpha = static_cast((-5.0f / 6.0f)*nTime + 350.0f); - - for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) + int dwWidth, dwHeight, dwDepth, dwFlags; + RwImageFindRasterFormatSA(pImage, 4/*rwRASTERTYPETEXTURE*/, &dwWidth, &dwHeight, &dwDepth, &dwFlags); + if (RwRaster* pRaster = RwRasterCreateSA(dwWidth, dwHeight, dwDepth, dwFlags)) { - if (CCameraIsSphereVisible((int *)0xB6F028, (RwV3d*)&it->vecPos, 5.0f)) - { - CVector* pCamPos = &TheCamera.Cams[TheCamera.ActiveCam].Source; - float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + RwRasterSetFromImageSA(pRaster, pImage); - if (fDistSqr > 280.0f*280.0f && fDistSqr < CoronaFarClip*CoronaFarClip) - { - //float fRadius = min((fDistSqr < 290.0f*290.0f) ? (1.0f / 4.0f)*sqrt(fDistSqr) - 70.0f : (3.0f / 164.0f)*sqrt(fDistSqr) - (5.0f / 41.0f), 20.0f); - CShadowsStoreStaticShadow(reinterpret_cast(&*it), SSHADT_INTENSIVE, *(RwTexture **)0xC403F4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, (it->colour.r / 2), (it->colour.g / 2), (it->colour.b / 2), 15.0f, 1.0f, CoronaFarClip, false, 0.0f); - } else { - CShadowsStoreStaticShadow(reinterpret_cast(&*it), SSHADT_INTENSIVE, *(RwTexture **)0xC403F4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, (it->colour.r / 3), (it->colour.g / 3), (it->colour.b / 3), 15.0f, 1.0f, CoronaFarClip, false, 0.0f); - } - } + pTexture = RwTextureCreateSA(pRaster); } + RwImageDestroySA(pImage); } - CShadowsUpdateStaticShadows(); + return pTexture; } -Fps _fps; -void CLODLightManager::SA::DrawDistanceChanger() +void RwRenderStateSetSA(RwRenderState nState, void *pParam) { - fNewFarClip = 500.0f; - static DWORD* pPlayerPed = (DWORD*)0xB6F5F0; - - if (*pPlayerPed) - { - if (*(BYTE*)((*pPlayerPed) + 0x2F) != 8) //[byte] Location status - { - if (*ActiveInterior == 0) - { - if (AdaptiveDrawDistanceEnabled) - { - _fps.update(); - int FPScount = _fps.get(); - if (FPScount < MinFPSValue) - { - MinDrawDistanceOnTheGround -= 2.0f; - } - else if (FPScount >= MaxFPSValue) - { - MinDrawDistanceOnTheGround += 2.0f; - } - if (MinDrawDistanceOnTheGround < 800.0f) - MinDrawDistanceOnTheGround = 800.0f; - else - if (MinDrawDistanceOnTheGround > MaxPossibleDrawDistance) - MinDrawDistanceOnTheGround = MaxPossibleDrawDistance; - } - fNewFarClip = (Factor1 / Factor2) * (GetCamPos()->z) + MinDrawDistanceOnTheGround; - } - } - } + RwEngineInstance = *(void**)0xC97B24; + RwRenderStateSet(nState, pParam); } +void(*_RwRenderStateSet)(RwRenderState nState, void *pParam) = &RwRenderStateSetSA; -void CLODLightManager::SA::RegisterLamppost(CEntity* pObj) +CVector* GetCamPos() { - unsigned short nModelID = pObj->GetModelIndex(); - CMatrix dummyMatrix; - CSimpleTransform& objTransform = pObj->GetTransform(); - - if (objTransform.m_translate.x == 0.0f && objTransform.m_translate.y == 0.0f) - return; - - dummyMatrix.SetTranslateOnly(objTransform.m_translate.x, objTransform.m_translate.y, objTransform.m_translate.z); - dummyMatrix.SetRotateZOnly(objTransform.m_heading); - - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(dummyMatrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); + return &TheCamera.GetCoords(); } -void CLODLightManager::SA::RegisterCustomCoronas() -{ - unsigned short nModelID = 65534; - - gpCustomCoronaTexture = CPNGFileReadFromFile(szCustomCoronaTexturePath); - if (gpCustomCoronaTexture) - injector::WriteMemory(0xC3E004, *(unsigned int*)gpCustomCoronaTexture); - - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); -} - -void CLODLightManager::SA::LoadDatFile() +void CLODLightManager::SA::Init() { CIniReader iniReader(""); - DataFilePath = iniReader.GetIniPath(); - char* tempPointer; - tempPointer = strrchr(DataFilePath, '.'); - *tempPointer = '\0'; - strcat(DataFilePath, ".dat"); - - if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) - { - unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; - - while (const char* pLine = CFileMgr::LoadLine(hFile)) - { - if (pLine[0] && pLine[0] != '#') - { - if (pLine[0] == '%') - { - nCurIndexForModel = 0; - if (strcmp(pLine, "%additional_coronas") != 0) - nModel = GetModelInfoUInt16(pLine + 1); - else - nModel = 65534; - } - else - { - float fOffsetX, fOffsetY, fOffsetZ; - unsigned int nRed, nGreen, nBlue; - float fCustomSize = 1.0f; - int nNoDistance = 0; - int nDrawSearchlight = 0; - sscanf(pLine, "%d %d %d %f %f %f %f %d %d", &nRed, &nGreen, &nBlue, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nNoDistance, &nDrawSearchlight); - pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast(nRed), static_cast(nGreen), static_cast(nBlue)), fCustomSize, nNoDistance, nDrawSearchlight))); - } - } - } - - m_pLampposts = new std::vector; - m_bCatchLamppostsNow = true; - - CFileMgr::CloseFile(hFile); - } + bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1) != 0; + numCoronas = iniReader.ReadInteger("LodLights", "MaxNumberOfLodLights", 25000); + fCoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); + bSlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; + if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) + fCoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); else - { - //RenderSearchlightEffects = 0; - bRenderLodLights = 0; - injector::MakeNOP(0x53C131, 5); - } -} - -CEntity* CLODLightManager::SA::PossiblyAddThisEntity(CEntity* pEntity) -{ - if (m_bCatchLamppostsNow && IsModelALamppost(pEntity->GetModelIndex())) - RegisterLamppost(pEntity); - - // Saves some hacking - return pEntity; -} - -static void __declspec(naked) LoadObjectInstHook() -{ - _asm - { - push eax - call CLODLightManager::SA::PossiblyAddThisEntity - add esp, 34h - retn - } -} - -DWORD jmpAddress; -static void __declspec(naked) asmInit() -{ - _asm - { - call CLODLightManager::SA::LoadDatFile - push 0x869B30 - mov jmpAddress, 0x5B9253 - jmp jmpAddress - } -} - -static void __declspec(naked) asmEnd() -{ - _asm - { - cmp bRenderLodLights, 0 - jz label1 - call CLODLightManager::SA::RegisterCustomCoronas - call CLODLightManager::SA::EndRegistering - label1: - push 0 - push 0x863A80 - push 0x863A6C - mov jmpAddress, 0x53BCBC - jmp jmpAddress - } -} + autoFarClip = true; + szCustomCoronaTexturePath = iniReader.ReadString("LodLights", "CustomCoronaTexturePath", ".\\corona.png"); -DWORD jmpAddress2; -static void __declspec(naked) LamppostsCoronaFarclpHook() -{ - _asm - { - //mov ecx, [esi + 14h] - mov jmpAddress2, 0x42BDF5 - mov ecx, [jmpAddress2] - mov ecx, [ecx] - mov ecx, [ecx] - push edx - push eax - mov jmpAddress2, 0x6FCFC9 - jmp jmpAddress2 - } -} + bRenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0) != 0; + bIncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreaseCarsShadowsDrawDistance", 0) != 0; + fStaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); + fStaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); + fTrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); + fTrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); -float drawDist; DWORD modelID; -void __declspec(naked) IncreaseDrawDistanceForTimedObjects() -{ - if (TimedObjectsDrawDistance <= 10.0f) - drawDist *= TimedObjectsDrawDistance; - else - drawDist = TimedObjectsDrawDistance; + bRenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1) != 0; + bRenderOnlyDuringFoggyWeather = iniReader.ReadInteger("SearchLights", "RenderOnlyDuringFoggyWeather", 0) != 0; + fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); + nSmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); + + bEnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0) != 0; + fMinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); + fFactor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); + fFactor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); + fStaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); + + bAdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0) != 0; + nMinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); + nMaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); + fMaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); + + fMaxDrawDistanceForNormalObjects = iniReader.ReadFloat("IDETweaker", "MaxDrawDistanceForNormalObjects", 300.0f); + fTimedObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "TimedObjectsDrawDistance", 0.0f); + fNeonsDrawDistance = iniReader.ReadFloat("IDETweaker", "NeonsDrawDistance", 0.0f); + fLODObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "LODObjectsDrawDistance", 0.0f); + fGenericObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "GenericObjectsDrawDistance", 0.0f); + fAllNormalObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "AllNormalObjectsDrawDistance", 0.0f); + fVegetationDrawDistance = iniReader.ReadFloat("IDETweaker", "VegetationDrawDistance", 0.0f); + bLoadAllBinaryIPLs = iniReader.ReadInteger("IDETweaker", "LoadAllBinaryIPLs", 0) != 0; + bPreloadLODs = iniReader.ReadInteger("IDETweaker", "PreloadLODs", 0) != 0; - __asm ret + ApplyMemoryPatches(); } -void IncreaseDrawDistanceForObjects() +void CLODLightManager::SA::ApplyMemoryPatches() { - if (VegetationDrawDistance) + struct asmInit { - if (modelID >= 615 && modelID <= 792 && drawDist <= 300.0f) + void operator()(injector::reg_pack& regs) { - if (VegetationDrawDistance <= 10.0f) - drawDist *= VegetationDrawDistance; - else - drawDist = VegetationDrawDistance; - - if (drawDist > MaxDrawDistanceForNormalObjects) - MaxDrawDistanceForNormalObjects = drawDist; - __asm ret + injector::cstd::call(0x5B3680, (char*)0x869B30); + CLODLightManager::SA::LoadDatFile(); } - } + }; injector::MakeInline(0x5B9253, 0x5B9258); - if (drawDist > 300.0f) + struct Render { - if (LODObjectsDrawDistance) + void operator()(injector::reg_pack&) { - if (LODObjectsDrawDistance <= 10.0f) - drawDist *= LODObjectsDrawDistance; - else - if (LODObjectsDrawDistance > drawDist) - drawDist = LODObjectsDrawDistance; + if (bRenderLodLights) + CLODLights::RenderBuffered(); + + if (bRenderSearchlightEffects) + CSearchlights::RenderSearchLightsSA(); } - } - else + }; injector::MakeInline(0x53E184); + + if (bRenderLodLights) { - if (GenericObjectsDrawDistance) + //injector::MakeNOP(0x6FAD78, 10, true); //disable ambientBrightness change + //injector::MakeNOP(0x6FAD84, 6, true); + //injector::MakeNOP(0x6FAE13, 10, true); + //injector::MakeNOP(0x6FAE1F, 6, true); + + CLODLights::Inject(); + + struct asmEnd { - if (modelID >= 615 && modelID <= 1572) - { - if (GenericObjectsDrawDistance <= 10.0f) - drawDist *= GenericObjectsDrawDistance; - else - drawDist = GenericObjectsDrawDistance; - } - else + void operator()(injector::reg_pack& regs) { - if (AllNormalObjectsDrawDistance) - { - if (AllNormalObjectsDrawDistance <= 10.0f) - drawDist *= AllNormalObjectsDrawDistance; - else - drawDist = AllNormalObjectsDrawDistance; - } + injector::cstd::call(0x53DED0, (char*)0x869B30, (char*)0x863A80); + CLODLightManager::SA::RegisterCustomCoronas(); + m_bCatchLamppostsNow = false; + m_pLampposts->shrink_to_fit(); + pFileContent->clear(); } - } - else + }; injector::MakeInline(0x53BCBC); + + struct LoadObjectInstHook { - if (AllNormalObjectsDrawDistance) + void operator()(injector::reg_pack& regs) { - if (AllNormalObjectsDrawDistance <= 10.0f) - drawDist *= AllNormalObjectsDrawDistance; - else - drawDist = AllNormalObjectsDrawDistance; - } - } - if (drawDist > MaxDrawDistanceForNormalObjects) - MaxDrawDistanceForNormalObjects = drawDist; - } - __asm ret -} - -void __declspec(naked) asm_IncreaseDrawDistanceForTimedObjects() -{ - __asm mov ecx, [esp + 0x0C] - __asm lea edx, [esp + 0x28] - __asm mov drawDist, ecx - __asm call IncreaseDrawDistanceForTimedObjects - __asm mov ecx, drawDist - __asm mov hookJmpAddr, 0x5B3F4B - __asm jmp hookJmpAddr -} - -void __declspec(naked) asm_IncreaseDrawDistanceForObjects() -{ - __asm lea eax, [esp + 0x20] - __asm add esp, 0x4 - __asm push eax - __asm mov modelID, ecx - __asm mov drawDist, edx - __asm call IncreaseDrawDistanceForObjects - __asm mov edx, drawDist - __asm mov hookJmpAddr, 0x5B3DAD - __asm jmp hookJmpAddr -} - -void __cdecl CIplStoreLoadAll() -{ - static auto IplFilePoolLocate = (int (__cdecl *)(const char *name)) 0x404AC0; - static auto CIplStoreRequestIplAndIgnore = (char *(__cdecl *)(int a1)) 0x405850; - - injector::address_manager::singleton().IsHoodlum() ? - injector::WriteMemory(0x015651C1 + 3, 0, true) : - injector::WriteMemory(0x405881 + 3, 0, true); + uint32_t _ecx = regs.ecx; + __asm mov ecx, _ecx + __asm mov fs : [00000000], ecx - for (auto it = IPLStreamNames.cbegin(); it != IPLStreamNames.cend(); it++) - { - CIplStoreRequestIplAndIgnore(IplFilePoolLocate(it->c_str())); - } - - injector::address_manager::singleton().IsHoodlum() ? - injector::WriteMemory(0x015651C1 + 3, 1, true) : - injector::WriteMemory(0x405881 + 3, 1, true); -} - -void LoadAllBinaryIPLs() -{ - static auto CIplStoreLoad = (char *(__cdecl *)()) 0x5D54A0; - CIplStoreLoad(); - CIplStoreLoadAll(); -} - -static std::vector lods; // CEntity* -static auto RequestModel = injector::cstd::call<0x4087E0>; -static auto LoadAllRequestedModels = injector::cstd::call<0x40EA10>; -static void RequestLod(uint16_t id) -{ - return RequestModel(id, 2); // STREAMING_CANNOT_DELETE -} - -void CLODLightManager::SA::ApplyMemoryPatches() -{ - if (bRenderLodLights) - { - injector::MakeJMP(0x5B924E, asmInit, true); - injector::MakeJMP(0x53BCB0, asmEnd, true); + CLODLightManager::SA::PossiblyAddThisEntity((CEntity*)regs.eax); + } + }; injector::MakeInline(0x538432, 0x538439); - injector::MakeJMP(0x538439, LoadObjectInstHook, true); - injector::MakeCALL(0x53C131, RenderLODLights, true); + injector::MakeCALL(0x53C131, RegisterLODLights, true); } - if (EnableDrawDistanceChanger) + if (bEnableDrawDistanceChanger) { injector::MakeCALL(0x53EBE4, DrawDistanceChanger, true); @@ -450,121 +191,242 @@ void CLODLightManager::SA::ApplyMemoryPatches() injector::WriteMemory(0x53EA95, &fNewFarClip, true); } - if (StaticSunSize) - { - injector::WriteMemory(0x6FC656, &StaticSunSize, true); - injector::WriteMemory(0x6FC6E2, &StaticSunSize, true); - } - - //Searchlight effect - if (RenderSearchlightEffects) + if (fStaticSunSize) { - injector::MakeCALL(0x53E184, RenderSearchLights, true); + injector::WriteMemory(0x6FC656, &fStaticSunSize, true); + injector::WriteMemory(0x6FC6E2, &fStaticSunSize, true); } - /*if (SmoothEffect) + /*if (nSmoothEffect) { - SmoothEffect = 1; + nSmoothEffect = 1; injector::WriteMemory(0x6C60F2 + 1, 0xC4D994 + 0x24, true); injector::WriteMemory(0x6C6222 + 3, 0xC4D970 + 0x24, true); }*/ //CPatch::RedirectCall(0x53E0BE, StoreCustomStaticShadows); - if (bRenderLodLights) - { - injector::MakeNOP(0x6FAD78, 10, true); //disable ambientBrightness change - injector::MakeNOP(0x6FAD84, 6, true); - injector::MakeNOP(0x6FAE13, 10, true); - injector::MakeNOP(0x6FAE1F, 6, true); - } - injector::WriteMemory(0x6FC051 + 0x2, 0x7080 * 0xA, true); // sun reflection injector::WriteMemory(0x49DCF4, 550.0f, true); //Traffic lights corona draw distance - injector::MakeJMP(0x6FCFC4, LamppostsCoronaFarclpHook, true); - if (StaticShadowsDrawDistance) + struct LamppostsCoronaFarclpHook + { + void operator()(injector::reg_pack& regs) + { + regs.eax &= 1; + + *(float*)(regs.esi + 0x14) = 3000.0f; + } + }; injector::MakeInline(0x6FCFBA); + + + if (fStaticShadowsDrawDistance) { - injector::WriteMemory(0x6FD3A6, StaticShadowsDrawDistance, true); // Lampposts shadows draw distance - injector::WriteMemory(0x6FD44F, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x455EF3, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x4561B3, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x49DF7A, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x53B5E2, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x70C88B, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x70C9F4, StaticShadowsDrawDistance, true); + injector::WriteMemory(0x6FD3A6, fStaticShadowsDrawDistance, true); // Lampposts shadows draw distance + injector::WriteMemory(0x6FD44F, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x455EF3, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x4561B3, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x49DF7A, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x53B5E2, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x70C88B, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x70C9F4, fStaticShadowsDrawDistance, true); } - if (StaticShadowsIntensity) + if (fStaticShadowsIntensity) { - StaticShadowsIntensity *= 0.00390625f; - injector::WriteMemory(0x6FD13C, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD16E, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD17C, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD1CE, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD2C0, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD301, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD30F, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD3BC, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD3DA, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 - injector::WriteMemory(0x6FD3F8, &StaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + fStaticShadowsIntensity *= 0.00390625f; + injector::WriteMemory(0x6FD13C, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD16E, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD17C, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD1CE, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD2C0, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD301, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD30F, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD3BC, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD3DA, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 + injector::WriteMemory(0x6FD3F8, &fStaticShadowsIntensity, true); // = 0x859AA0 + 0x0->fmul ds : flt_859AA0 } - if (TimedObjectsDrawDistance) + if (fTimedObjectsDrawDistance || fNeonsDrawDistance) { - injector::MakeJMP(0x5B3F43, asm_IncreaseDrawDistanceForTimedObjects, true); - if ((TimedObjectsDrawDistance > 2.0f && TimedObjectsDrawDistance <= 10.0f) || (TimedObjectsDrawDistance > 300.0f)) + struct IncreaseDrawDistanceForTimedObjectsHook { - injector::MakeInline<0x53C9B7>([](injector::reg_pack& regs) + void operator()(injector::reg_pack& regs) { - injector::WriteMemory(0x5D95B0, 0xC3u, true); - injector::WriteMemory(0x810CA0, 0xC3u, true); - injector::WriteMemory(0x5D9730, 0xC3u, true); - }); - injector::WriteMemory(0x56420F, 0xB83074, true); - } + *(float*)®s.ecx = *(float*)(regs.esp + 0xC); + regs.edx = (regs.esp + 0x28); + + if ((fNeonsDrawDistance && strstr((char*)(regs.esp + 0x28), "neon") != NULL) || fTimedObjectsDrawDistance) + { + if (fTimedObjectsDrawDistance <= 10.0f) + *(float*)®s.ecx *= fTimedObjectsDrawDistance; + else + *(float*)®s.ecx = fTimedObjectsDrawDistance; + } + } + }; injector::MakeInline(0x5B3F43, 0x5B3F43+8); } - if (LODObjectsDrawDistance || GenericObjectsDrawDistance || AllNormalObjectsDrawDistance || VegetationDrawDistance) + if (fLODObjectsDrawDistance || fGenericObjectsDrawDistance || fAllNormalObjectsDrawDistance || fVegetationDrawDistance) { - injector::MakeJMP(0x5B3DA5, asm_IncreaseDrawDistanceForObjects, true); //multiply dist + struct IncreaseDrawDistanceForObjectsHook + { + void operator()(injector::reg_pack& regs) + { + *(float*)®s.edx = *(float*)(regs.esp + 0xC); + regs.esi = regs.eax; + + auto modelID = regs.ecx; + float drawDist = *(float*)(regs.esp + 0xC); + + if (fVegetationDrawDistance) + { + if (modelID >= 615 && modelID <= 792 && drawDist <= 300.0f) + { + if (fVegetationDrawDistance <= 10.0f) + drawDist *= fVegetationDrawDistance; + else + drawDist = fVegetationDrawDistance; + + if (drawDist > fMaxDrawDistanceForNormalObjects) + fMaxDrawDistanceForNormalObjects = drawDist; + + *(float*)®s.edx = drawDist; + return; + } + } + + if (drawDist > 300.0f) + { + if (fLODObjectsDrawDistance) + { + if (fLODObjectsDrawDistance <= 10.0f) + drawDist *= fLODObjectsDrawDistance; + else + if (fLODObjectsDrawDistance > drawDist) + drawDist = fLODObjectsDrawDistance; + } + } + else + { + if (fGenericObjectsDrawDistance) + { + if (modelID >= 615 && modelID <= 1572) + { + if (fGenericObjectsDrawDistance <= 10.0f) + drawDist *= fGenericObjectsDrawDistance; + else + drawDist = fGenericObjectsDrawDistance; + } + else + { + if (fAllNormalObjectsDrawDistance) + { + if (fAllNormalObjectsDrawDistance <= 10.0f) + drawDist *= fAllNormalObjectsDrawDistance; + else + drawDist = fAllNormalObjectsDrawDistance; + } + } + } + else + { + if (fAllNormalObjectsDrawDistance) + { + if (fAllNormalObjectsDrawDistance <= 10.0f) + drawDist *= fAllNormalObjectsDrawDistance; + else + drawDist = fAllNormalObjectsDrawDistance; + } + } + if (drawDist > fMaxDrawDistanceForNormalObjects) + fMaxDrawDistanceForNormalObjects = drawDist; + } + *(float*)®s.edx = drawDist; + } + }; injector::MakeInline(0x5B3D9F, 0x5B3D9F + 6); - if (GenericObjectsDrawDistance || AllNormalObjectsDrawDistance || VegetationDrawDistance) + if (fGenericObjectsDrawDistance || fAllNormalObjectsDrawDistance || fVegetationDrawDistance) { - injector::WriteMemory(0x554230 + 0x3FA + 0x2, &MaxDrawDistanceForNormalObjects, true); //fsub ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x192 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x1B8 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x1DB + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x24E + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x258 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x262 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x314 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x31E + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x328 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x382 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x39A + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x554FE0 + 0x3A8 + 0x2, &MaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 - injector::WriteMemory(0x5B51E0 + 0x09A + 0x2, &MaxDrawDistanceForNormalObjects, true); // fcomp ds:flt_858FD8 - injector::WriteMemory(0x554230 + 0x3B6 + 0x2, &MaxDrawDistanceForNormalObjects, true); // fcomp ds:flt_858FD8 - injector::WriteMemory(0x554230 + 0x3D0 + 0x2, &MaxDrawDistanceForNormalObjects, true); // fld ds:flt_858FD8 - injector::WriteMemory(0x554230 + 0x3FA + 0x2, &MaxDrawDistanceForNormalObjects, true); // fsub ds:flt_858FD8 + injector::WriteMemory(0x554230 + 0x3FA + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fsub ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x192 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x1B8 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x1DB + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x24E + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x258 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x262 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x314 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x31E + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x328 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x382 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x39A + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x554FE0 + 0x3A8 + 0x2, &fMaxDrawDistanceForNormalObjects, true); //fmul ds:flt_858FD8 + injector::WriteMemory(0x5B51E0 + 0x09A + 0x2, &fMaxDrawDistanceForNormalObjects, true); // fcomp ds:flt_858FD8 + injector::WriteMemory(0x554230 + 0x3B6 + 0x2, &fMaxDrawDistanceForNormalObjects, true); // fcomp ds:flt_858FD8 + injector::WriteMemory(0x554230 + 0x3D0 + 0x2, &fMaxDrawDistanceForNormalObjects, true); // fld ds:flt_858FD8 + injector::WriteMemory(0x554230 + 0x3FA + 0x2, &fMaxDrawDistanceForNormalObjects, true); // fsub ds:flt_858FD8 } } if (bLoadAllBinaryIPLs) { - injector::MakeCALL(0x5D19A4, LoadAllBinaryIPLs, true); + struct LoadAllBinaryIPLs + { + void operator()(injector::reg_pack&) + { + static auto CIplStoreLoad = (char *(__cdecl *)()) 0x5D54A0; + CIplStoreLoad(); + + static auto IplFilePoolLocate = (int(__cdecl *)(const char *name)) 0x404AC0; + static auto CIplStoreRequestIplAndIgnore = (char *(__cdecl *)(int a1)) 0x405850; + + injector::address_manager::singleton().IsHoodlum() ? + injector::WriteMemory(0x015651C1 + 3, 0, true) : + injector::WriteMemory(0x405881 + 3, 0, true); + + static std::vector IPLStreamNames = { "LAE_STREAM0", "LAE_STREAM1", "LAE_STREAM2", "LAE_STREAM3", "LAE_STREAM4", "LAE_STREAM5", + "LAE2_STREAM0", "LAE2_STREAM1", "LAE2_STREAM2", "LAE2_STREAM3", "LAE2_STREAM4", "LAE2_STREAM5", "LAE2_STREAM6", "LAHILLS_STREAM0", + "LAHILLS_STREAM1", "LAHILLS_STREAM2", "LAHILLS_STREAM3", "LAHILLS_STREAM4", "LAN_STREAM0", "LAN_STREAM1", "LAN_STREAM2", "LAN2_STREAM0", + "LAN2_STREAM1", "LAN2_STREAM2", "LAN2_STREAM3", "LAS_STREAM0", "LAS_STREAM1", "LAS_STREAM2", "LAS_STREAM3", "LAS_STREAM4", "LAS_STREAM5", + "LAS2_STREAM0", "LAS2_STREAM1", "LAS2_STREAM2", "LAS2_STREAM3", "LAS2_STREAM4", "LAW_STREAM0", "LAW_STREAM1", "LAW_STREAM2", "LAW_STREAM3", "LAW_STREAM4", + "LAW_STREAM5", "LAW2_STREAM0", "LAW2_STREAM1", "LAW2_STREAM2", "LAW2_STREAM3", "LAW2_STREAM4", "LAWN_STREAM0", "LAWN_STREAM1", "LAWN_STREAM2", "LAWN_STREAM3", + "COUNTN2_STREAM0", "COUNTN2_STREAM1", "COUNTN2_STREAM2", "COUNTN2_STREAM3", "COUNTN2_STREAM4", "COUNTN2_STREAM5", "COUNTN2_STREAM6", "COUNTN2_STREAM7", "COUNTN2_STREAM8", + "COUNTRYE_STREAM0", "COUNTRYE_STREAM1", "COUNTRYE_STREAM2", "COUNTRYE_STREAM3", "COUNTRYE_STREAM4", "COUNTRYE_STREAM5", "COUNTRYE_STREAM6", "COUNTRYE_STREAM7", "COUNTRYE_STREAM8", + "COUNTRYE_STREAM9", "COUNTRYN_STREAM0", "COUNTRYN_STREAM1", "COUNTRYN_STREAM2", "COUNTRYN_STREAM3", "COUNTRYS_STREAM0", "COUNTRYS_STREAM1", "COUNTRYS_STREAM2", "COUNTRYS_STREAM3", "COUNTRYS_STREAM4", + "COUNTRYW_STREAM0", "COUNTRYW_STREAM1", "COUNTRYW_STREAM2", "COUNTRYW_STREAM3", "COUNTRYW_STREAM4", "COUNTRYW_STREAM5", "COUNTRYW_STREAM6", "COUNTRYW_STREAM7", "COUNTRYW_STREAM8", "SFE_STREAM0", + "SFE_STREAM1", "SFE_STREAM2", "SFE_STREAM3", "SFN_STREAM0", "SFN_STREAM1", "SFN_STREAM2", "SFS_STREAM0", "SFS_STREAM1", "SFS_STREAM2", "SFS_STREAM3", "SFS_STREAM4", "SFS_STREAM5", "SFS_STREAM6", + "SFS_STREAM7", "SFS_STREAM8", "SFSE_STREAM0", "SFSE_STREAM1", "SFSE_STREAM2", "SFSE_STREAM3", "SFSE_STREAM4", "SFSE_STREAM5", "SFSE_STREAM6", "SFW_STREAM0", "SFW_STREAM1", "SFW_STREAM2", "SFW_STREAM3", + "SFW_STREAM4", "SFW_STREAM5", "VEGASE_STREAM0", "VEGASE_STREAM1", "VEGASE_STREAM2", "VEGASE_STREAM3", "VEGASE_STREAM4", "VEGASE_STREAM5", "VEGASE_STREAM6", "VEGASE_STREAM7", "VEGASE_STREAM8", + "VEGASN_STREAM0", "VEGASN_STREAM1", "VEGASN_STREAM2", "VEGASN_STREAM3", "VEGASN_STREAM4", "VEGASN_STREAM5", "VEGASN_STREAM6", "VEGASN_STREAM7", "VEGASN_STREAM8", "VEGASS_STREAM0", "VEGASS_STREAM1", + "VEGASS_STREAM2", "VEGASS_STREAM3", "VEGASS_STREAM4", "VEGASS_STREAM5", "VEGASW_STREAM0", "VEGASW_STREAM1", "VEGASW_STREAM2", "VEGASW_STREAM3", "VEGASW_STREAM4", "VEGASW_STREAM5", "VEGASW_STREAM6", + "VEGASW_STREAM7", "VEGASW_STREAM8", "VEGASW_STREAM9" }; + + for (auto it = IPLStreamNames.cbegin(); it != IPLStreamNames.cend(); it++) + { + CIplStoreRequestIplAndIgnore(IplFilePoolLocate(it->c_str())); + } + + injector::address_manager::singleton().IsHoodlum() ? + injector::WriteMemory(0x015651C1 + 3, 1, true) : + injector::WriteMemory(0x405881 + 3, 1, true); + } + }; injector::MakeInline(0x5D19A4); } + if (bPreloadLODs) -{ + { + static std::vector lods; // CEntity* + static auto RequestModel = injector::cstd::call<0x4087E0>; + static auto LoadAllRequestedModels = injector::cstd::call<0x40EA10>; + using h53BCAB = injector::function_hooker<0x53BCAB, void()>; - + injector::MakeInline<0x5B5295, 0x5B5295 + 8>([](injector::reg_pack& regs) { regs.ecx = *(uint16_t*)(regs.eax + 0x22); // mah let's make it unsigned regs.edx = *(uint16_t*)(regs.esi + 0x22); - lods.push_back( (void*)regs.eax ); + lods.push_back((void*)regs.eax); }); injector::make_static_hook([](h53BCAB::func_type AfterInit2) @@ -573,73 +435,202 @@ void CLODLightManager::SA::ApplyMemoryPatches() std::vector lods_id(lods.size()); std::transform(lods.begin(), lods.end(), lods_id.begin(), [](void* entity) { - return *(uint16_t*)((uintptr_t)(entity) + 0x22); + return *(uint16_t*)((uintptr_t)(entity)+0x22); }); // Load all lod models - std::for_each(lods_id.begin(), std::unique(lods_id.begin(), lods_id.end()), RequestLod); + std::for_each(lods_id.begin(), std::unique(lods_id.begin(), lods_id.end()), [](uint16_t id) { RequestModel(id, 2); }); // STREAMING_CANNOT_DELETE LoadAllRequestedModels(false); // Instantiate all lod entities RwObject - if(false) + if (false) std::for_each(lods.begin(), lods.end(), [](void* entity) - { - auto rwObject = *(void**)((uintptr_t)(entity) + 0x18); - if(rwObject == nullptr) - injector::thiscall::vtbl<7>(entity); - }); + { + auto rwObject = *(void**)((uintptr_t)(entity)+0x18); + if (rwObject == nullptr) + injector::thiscall::vtbl<7>(entity); + }); return AfterInit2(); }); } } -void CLODLightManager::SA::Init() +void CLODLightManager::SA::RegisterCustomCoronas() { - CIniReader iniReader(""); - bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1); - CoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); - SlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; - if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) - CoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); - else - autoFarClip = true; - szCustomCoronaTexturePath = iniReader.ReadString("LodLights", "CustomCoronaTexturePath", ".\\corona.png"); + unsigned short nModelID = 65534; - RenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0); - IncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreaseCarsShadowsDrawDistance", 0); - StaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); - StaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); - TrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); - TrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); + gpCustomCoronaTexture = CPNGFileReadFromFile(szCustomCoronaTexturePath); + if (gpCustomCoronaTexture) + injector::WriteMemory(0xC3E004, *(unsigned int*)gpCustomCoronaTexture); - RenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1); - fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); - SmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); - - EnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0); - MinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); - Factor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); - Factor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); - StaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); - - AdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0); - MinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); - MaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); - MaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); - - MaxDrawDistanceForNormalObjects = 300.0f; //iniReader.ReadFloat("IDETweaker", "MaxDrawDistanceForNormalObjects", 0.0f); - TimedObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "TimedObjectsDrawDistance", 0.0f); - LODObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "LODObjectsDrawDistance", 0.0f); - GenericObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "GenericObjectsDrawDistance", 0.0f); - AllNormalObjectsDrawDistance = iniReader.ReadFloat("IDETweaker", "AllNormalObjectsDrawDistance", 0.0f); - VegetationDrawDistance = iniReader.ReadFloat("IDETweaker", "VegetationDrawDistance", 0.0f); - bLoadAllBinaryIPLs = iniReader.ReadInteger("IDETweaker", "LoadAllBinaryIPLs", 0) == 1; - bPreloadLODs = iniReader.ReadInteger("IDETweaker", "PreloadLODs", 0) == 1; + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, 0.0f)); +} - ApplyMemoryPatches(); +CEntity * CLODLightManager::SA::PossiblyAddThisEntity(CEntity * pEntity) +{ + if (m_bCatchLamppostsNow && IsModelALamppost(pEntity->GetModelIndex())) + RegisterLamppost(pEntity); + + // Saves some hacking + return pEntity; +} + +void CLODLightManager::SA::RegisterLamppost(CEntity * pObj) +{ + unsigned short nModelID = pObj->GetModelIndex(); + CMatrix dummyMatrix; + CSimpleTransform& objTransform = pObj->GetTransform(); + + if (objTransform.m_translate.x == 0.0f && objTransform.m_translate.y == 0.0f) + return; + + dummyMatrix.SetTranslateOnly(objTransform.m_translate.x, objTransform.m_translate.y, objTransform.m_translate.z); + dummyMatrix.SetRotateZOnly(objTransform.m_heading); + + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(dummyMatrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, pObj->GetTransform().m_heading)); +} + +void CLODLightManager::SA::RegisterLODLights() +{ + if (GetIsTimeInRange(20, 7) && *ActiveInterior == 0) + { + unsigned char bAlpha = 0; + float fRadius = 0.0f; + unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; + unsigned int curMin = *CurrentTimeMinutes; + fCoronaFarClip = autoFarClip ? **fCurrentFarClip : fCoronaFarClip; + + if (nTime >= 20 * 60) + bAlpha = static_cast((15.0f / 16.0f)*nTime - 1095.0f); // http://goo.gl/O03RpE {(20*60)a + y = 30, (24*60)a + y = 255} + else if (nTime < 3 * 60) + bAlpha = 255; + else + bAlpha = static_cast((-15.0f / 16.0f)*nTime + 424.0f); // http://goo.gl/M8Dev9 {(7*60)a + y = 30, (3*60)a + y = 150} + + for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) + { + if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) + { + CVector* pCamPos = &TheCamera.Cams[TheCamera.ActiveCam].Source; + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + + if ((fDistSqr > 250.0f*250.0f && fDistSqr < fCoronaFarClip*fCoronaFarClip) || it->nNoDistance) + { + if (it->nNoDistance) + fRadius = 3.5f; + else + fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx + + if (bSlightlyIncreaseRadiusWithDistance) + fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC + + if (it->fCustomSizeMult != 0.45f) + { + if (!it->nCoronaShowMode) + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + bRenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), SSHADT_INTENSIVE, *(RwTexture **)0xC403F4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, (it->colour.r / 3), (it->colour.g / 3), (it->colour.b / 3), 15.0f, 1.0f, fCoronaFarClip, false, 0.0f) : nullptr; + } + else + { + static float blinking; + if (IsBlinkingNeeded(it->nCoronaShowMode)) + blinking -= CTimer::ms_fTimeStep / 1000.0f; + else + blinking += CTimer::ms_fTimeStep / 1000.0f; + + (blinking > 1.0f) ? blinking = 1.0f : (blinking < 0.0f) ? blinking = 0.0f : 0.0f; + + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, blinking * (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + } + else + { + if ((it->colour.r >= 250 && it->colour.g >= 100 && it->colour.b <= 100) && ((curMin == 9 || curMin == 19 || curMin == 29 || curMin == 39 || curMin == 49 || curMin == 59))) //yellow + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + else + { + if ((abs(it->fHeading) >= (3.1415f / 6.0f) && abs(it->fHeading) <= (5.0f * 3.1415f / 6.0f))) + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + } + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + else + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0, 255.0f, false, false); + } + } + } + } + } + } + } + } + } + CLODLights::Update(); } +void CLODLightManager::SA::DrawDistanceChanger() +{ + static Fps _fps; + fNewFarClip = 500.0f; + static DWORD* pPlayerPed = (DWORD*)0xB6F5F0; + + if (*pPlayerPed) + { + if (*(BYTE*)((*pPlayerPed) + 0x2F) != 8) //[byte] Location status + { + if (*ActiveInterior == 0) + { + if (bAdaptiveDrawDistanceEnabled) + { + _fps.update(); + int FPScount = _fps.get(); + if (FPScount < nMinFPSValue) + { + fMinDrawDistanceOnTheGround -= 2.0f; + } + else if (FPScount >= nMaxFPSValue) + { + fMinDrawDistanceOnTheGround += 2.0f; + } + if (fMinDrawDistanceOnTheGround < 800.0f) + fMinDrawDistanceOnTheGround = 800.0f; + else + if (fMinDrawDistanceOnTheGround > fMaxPossibleDrawDistance) + fMinDrawDistanceOnTheGround = fMaxPossibleDrawDistance; + } + fNewFarClip = (fFactor1 / fFactor2) * (GetCamPos()->z) + fMinDrawDistanceOnTheGround; + } + } + } +} + + BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { if (reason == DLL_PROCESS_ATTACH) diff --git a/SALodLights/stdafx.cpp b/SALodLights/stdafx.cpp deleted file mode 100644 index 8aaa1a9..0000000 --- a/SALodLights/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// SALodLights.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/SALodLights/stdafx.h b/SALodLights/stdafx.h deleted file mode 100644 index f3a0737..0000000 --- a/SALodLights/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/SALodLights/targetver.h b/SALodLights/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/SALodLights/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/VCLodLights/CSearchlights.cpp b/VCLodLights/CSearchlights.cpp new file mode 100644 index 0000000..76f6e4d --- /dev/null +++ b/VCLodLights/CSearchlights.cpp @@ -0,0 +1,429 @@ +#include "CSearchlights.h" + +extern float* CWeatherFoggyness; +extern CVector* GetCamPos(); + +struct CHeliVC +{ + char pad[0x34]; + RwV3D pos; + char pad2[0x284]; + RwV3D shadowPos; + char pad3[0xC]; + float unk; + char pad4[0x7C]; +}; + +void CSearchlights::RenderHeliSearchLightsVC() +{ + static CHeliVC ***pPoliceHelis = (CHeliVC ***)0x5AC506; + CHeliVC* HeliInst = nullptr; + int nOffset = 0; + short NumOfHelisRequired = *(short*)0xA10A6A; + if (NumOfHelisRequired > 0) + { + nOffset = 0; + do + { + HeliInst = *(nOffset + (*pPoliceHelis)); + if (HeliInst) + { + if (HeliInst->unk > 0.0f) + { + RwV3D EndPoint = HeliInst->shadowPos; + + if (EndPoint.x && EndPoint.y) + { + EndPoint.z = CLODLightManager::VC::FindGroundZFor3DCoord(HeliInst->shadowPos.x, HeliInst->shadowPos.y, HeliInst->pos.z, 0, 0); + drawCustomSpotLightVC(HeliInst->pos, EndPoint, 13.0f, 1.0f, 255.0f, 8, 0.8f); //white + } + } + } + nOffset++; + --NumOfHelisRequired; + } while (NumOfHelisRequired > 0); + } +} + +void CSearchlights::RenderSearchLightsVC() +{ + if ((CLODLightManager::VC::bRenderOnlyDuringFoggyWeather && *CWeatherFoggyness) || !CLODLightManager::VC::bRenderOnlyDuringFoggyWeather) + { + if (CLODLightManager::VC::GetIsTimeInRange(19, 7)) + { + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEZWRITEENABLE, (void*)0); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEZTESTENABLE, (void*)1); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATESRCBLEND, (void*)2); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEDESTBLEND, (void*)2); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEVERTEXALPHAENABLE, (void*)1); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATETEXTURERASTER, (void*)0); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEFOGENABLE, (void*)0); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATESHADEMODE, (void*)2); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEALPHATESTFUNCTION, (void*)7); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)0); + + for (auto it = CLODLightManager::VC::m_pLampposts->cbegin(); it != CLODLightManager::VC::m_pLampposts->cend(); ++it) + { + if (it->nDrawSearchlight) + { + CVector* pCamPos = GetCamPos(); + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); + + if ((fDistSqr > 50.0f*50.0f) && (fDistSqr < 300.0f*300.0f)) + { + float fVisibility = CLODLightManager::VC::fSearchlightEffectVisibilityFactor * ((0.0233333f)*sqrt(fDistSqr) - 1.16667f); + //if (*CWeatherFoggyness) + // fVisibility *= 0.5f; + + RwV3D EndPoint = *(RwV3D*)&it->vecPos; + EndPoint.z = CLODLightManager::VC::FindGroundZFor3DCoord(it->vecPos.x, it->vecPos.y, it->vecPos.z, 0, 0); + + if (!(it->colour.r == 255 && it->colour.g == 255 && it->colour.b == 255)) + { + //yellow + drawCustomSpotLightVC(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 5.0f, 8, fVisibility); + } + else //if (!(it->colour.r == 254 && it->colour.g == 117 && it->colour.b == 134)) + { + //white + drawCustomSpotLightVC(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 255.0f, 8, fVisibility); + } + //else + //{ + // //pink + // drawCustomSpotLightVC(*(RwV3D*)&it->vecPos, EndPoint, min((8.0f * (it->vecPos.z - EndPoint.z)), 90.0f), it->fCustomSizeMult / 6.0f, 200.0f, 18, fVisibility); + //} + } + } + } + + CLODLightManager::VC::bRenderHeliSearchlights ? RenderHeliSearchLightsVC() : nullptr; + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEZWRITEENABLE, (void*)1); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEZTESTENABLE, (void*)1); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATESRCBLEND, (void*)5); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEDESTBLEND, (void*)6); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATECULLMODE, (void*)2); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEALPHATESTFUNCTION, (void*)5); + CLODLightManager::VC::RwRenderStateSetVC(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)2); + } + } +} + +void __cdecl CSearchlights::drawCustomSpotLightVC(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) +{ + static short TempBufferRenderIndexList[4096]; + static RxObjSpace3dVertex TempVertexBuffer[500]; + static int TempBufferIndicesStored = 0; + static unsigned int TempBufferVerticesStored = 0; + + RwMatrix *v12; // ebx@1 + RwV3D *v13; // eax@4 + signed int v19; // esi@8 + float v20; // fst7@9 + float v21; // ST7C_4@9 + float v22; // ST60_4@9 + float v23; // fst7@9 + float v24; // fst6@9 + float v25; // fst4@9 + float v26; // ST7C_4@9 + float v27; // ST68_4@9 + float v28; // ST6C_4@9 + float v29; // fst4@9 + float v30; // fst3@9 + float v31; // ST80_4@9 + float v32; // fst2@9 + float v33; // ST60_4@9 + float v34; // ST74_4@9 + float v35; // ST78_4@9 + float v36; // ST78_4@9 + float v37; // ST60_4@9 + float v38; // fst7@15 + float v39; // fst5@15 + float v40; // ST80_4@16 + float v41; // fst4@15 + float v42; // fst7@17 + unsigned int v43; // eax@17 + float v44; // fst7@17 + float v45; // fst7@17 + float v46; // fst7@17 + float v47; // fst7@19 + int v49; // ebp@21 + float v50; // fst7@22 + unsigned int v51; // edi@24 + signed int v52; // esi@25 + float v53; // fst7@26 + unsigned char *v54; // ebp@26 + float v55; // fst6@27 + int v56; // ebx@27 + unsigned __int64 v57; // qax@27 + float v59; // fst6@27 + int v60; // ebx@27 + unsigned __int64 v61; // qax@27 + float v63; // fst6@27 + int v64; // ebx@27 + unsigned __int64 v65; // qax@27 + float v66; // fst6@27 + float v67; // fst7@30 + float v68; // fst6@31 + signed int v88; // [sp+44h] [bp-424h]@8 + signed int v89; // [sp+44h] [bp-424h]@26 + void *v90; // [sp+44h] [bp-424h]@30 + float a4; // [sp+48h] [bp-420h]@9 + float EndPointa; // [sp+4Ch] [bp-41Ch]@9 + float v97; // [sp+50h] [bp-418h]@9 + float a6; // [sp+54h] [bp-414h]@9 + float a7; // [sp+58h] [bp-410h]@9 + float v104; // [sp+5Ch] [bp-40Ch]@9 + float v105; // [sp+64h] [bp-404h]@17 + RwV3D a; // [sp+68h] [bp-400h]@1 + float v107; // [sp+74h] [bp-3F4h]@8 + RwV3D v108; // [sp+78h] [bp-3F0h]@1 + float v109; // [sp+84h] [bp-3E4h]@9 + RwV3D v110; // [sp+88h] [bp-3E0h]@6 + RwV3D v111; // [sp+94h] [bp-3D4h]@9 + float v112; // [sp+A0h] [bp-3C8h]@9 + float v113; // [sp+A4h] [bp-3C4h]@9 + RwV3D v115; // [sp+ACh] [bp-3BCh]@16 + float v116; // [sp+B8h] [bp-3B0h]@9 + float v117; // [sp+BCh] [bp-3ACh]@9 + float v118; // [sp+C0h] [bp-3TargetRadiush]@9 + RwV3D out; // [sp+C4h] [bp-3A4h]@9 + float v120; // [sp+D0h] [bp-398h]@16 + float v121; // [sp+D4h] [bp-394h]@16 + float v122; // [sp+D8h] [bp-390h]@16 + float v123; // [sp+DCh] [bp-38Ch]@3 + float v124; // [sp+E0h] [bp-388h]@3 + float v125; // [sp+E4h] [bp-384h]@3 + float v126; // [sp+E8h] [bp-380h]@9 + float v127; // [sp+ECh] [bp-37Ch]@9 + float v128; // [sp+F0h] [bp-378h]@9 + RwV3D v132; // [sp+100h] [bp-368h]@9 + float v133; // [sp+10Ch] [bp-35Ch]@9 + float v134; // [sp+110h] [bp-358h]@9 + float v135; // [sp+118h] [bp-350h]@9 + float v136; // [sp+11Ch] [bp-34Ch]@9 + RwV3D b; // [sp+124h] [bp-344h]@9 + RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 + RwV3D v140; // [sp+158h] [bp-310h]@14 + float v141; // [sp+164h] [bp-304h]@9 + float v142; // [sp+178h] [bp-2F0h]@16 + float v143; // [sp+17Ch] [bp-2ECh]@9 + float v144; // [sp+188h] [bp-2E0h]@9 + float v145; // [sp+19Ch] [bp-2CCh]@9 + float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 + RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 + RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 + + v108.x = EndPoint.x - StartPoint.x; + a.x = v108.x; + v108.y = EndPoint.y - StartPoint.y; + a.y = v108.y; + v108.z = EndPoint.z - StartPoint.z; + a.z = v108.z; + CLODLightManager::VC::CVectorNormalize(&a); + v12 = 0; + EndPoint.x = a.x * 3.0f + EndPoint.x; + EndPoint.y = a.y * 3.0f + EndPoint.y; + EndPoint.z = a.z * 3.0f + EndPoint.z; + v123 = a.x * 100.0f + StartPoint.x; + v124 = a.y * 100.0f + StartPoint.y; + v125 = a.z * 100.0f + StartPoint.z; + v13 = (RwV3d*)GetCamPos(); + v110.x = v13->x - StartPoint.x; + v110.y = v13->y - StartPoint.y; + v110.z = v13->z - StartPoint.z; + CLODLightManager::VC::CVectorNormalize(&v110); + v19 = 0; + v107 = 0.0f; + TempBufferIndicesStored = 0; + TempBufferVerticesStored = 0; + v88 = 0; + do + { + b.x = 0; + b.y = 0; + b.z = 1.0f; + CLODLightManager::VC::CrossProduct(&out, &a, &b); + CLODLightManager::VC::CVectorNormalize(&out); + CLODLightManager::VC::CrossProduct(&v132, &out, &a); + CLODLightManager::VC::CVectorNormalize(&v132); + v20 = (float)v88 * 0.15707964f; + v21 = sin(v20); + v22 = cos(v20); + v23 = out.x * v21; + v141 = v23; + v24 = out.y * v21; + v25 = out.z * v21; + v26 = v25; + v133 = v141 * baseRadius; + v134 = v24 * baseRadius; + v27 = v134 + StartPoint.y; + v28 = v25 * baseRadius + StartPoint.z; + v29 = v132.x * v22; + v109 = v29; + v30 = v132.y * v22; + v31 = v30; + v32 = v132.z * v22; + v33 = v32; + v145 = v32; + v126 = v29 * baseRadius; + v127 = v30 * baseRadius; + v128 = v145 * baseRadius; + v146 = v33; + a4 = v126 + v133 + StartPoint.x; + EndPointa = v127 + v27; + v97 = v128 + v28; + v144 = v23; + v135 = v144 * TargetRadius; + v136 = v24 * TargetRadius; + v34 = v136 + v124; + v35 = v26 * TargetRadius + v125; + v116 = v109 * TargetRadius; + v117 = v31 * TargetRadius; + v118 = v33 * TargetRadius; + v36 = v118 + v35; + v37 = (v97 - EndPoint.z) / (v97 - v36); + v143 = v135 + v123 + v116 - a4; + v112 = v143 * v37; + v113 = (v117 + v34 - EndPointa) * v37; + v111.x = v112 + a4; + v111.y = v113 + EndPointa; + a6 = v111.x; + a7 = v111.y; + v111.z = (v36 - v97) * v37 + v97; + v104 = v111.z; + if (v19 && v19 != 10) + { + if (v19 == 20) + { + v139.x = v111.x; + v139.y = v111.y; + v139.z = v111.z; + } + else + { + if (v19 == 30) + { + v140.x = v111.x; + v140.y = v111.y; + v140.z = v111.z; + } + } + } + v38 = v111.x - a4; + v39 = v111.y - EndPointa; + v41 = v111.z - v97; + v109 = v41; + if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) + { + v115.x = v38; + v40 = v39; + v115.y = v40; + v115.z = v109; + CLODLightManager::VC::CVectorNormalize(&v115); + v142 = v115.z * 100.0f; + v120 = v115.x * 100.0f + a4; + a6 = v120; + v121 = v115.y * 100.0f + EndPointa; + a7 = v121; + v122 = v142 + v97; + v104 = v122; + } + v42 = slAlpha * 0.15000001f + 0.1f; + v43 = TempBufferVerticesStored; + TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; + v105 = v42; + TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; + v44 = a4 - StartPoint.x; + TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; + v108.x = v44; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; + v45 = EndPointa - StartPoint.y; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; + TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; + v108.y = v45; + v108.z = v97 - StartPoint.z; + CLODLightManager::VC::CVectorNormalize(&v108); + v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; + if (v46 < 0.0f) + v46 = -v46; + v47 = v46 * v46; + if (v47 > v107) + v107 = v47; + v49 = TempBufferIndicesStored; + *(&v149[0].red + TempBufferVerticesStored) = v105; + *(&v149[0].green + TempBufferVerticesStored) = 0; + *(&v148[0].red + TempBufferVerticesStored) = v47; + *(&v148[0].green + TempBufferVerticesStored) = v47; + if (v19 != 40) + { + v50 = baseRadius; + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); + v49 += 3; + TempBufferIndicesStored = v49; + if (v50 > 0.0f) + { + TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; + TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); + TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); + v49 += 3; + TempBufferIndicesStored = v49; + } + } + v51 = TempBufferVerticesStored + 2; + ++v19; + TempBufferVerticesStored = v51; + v88 = v19; + } while (v19 <= 40); + v52 = 0; + if ((signed int)v51 >= 4) + { + v89 = 3; + v53 = CLODLightManager::VC::fSearchlightEffectVisibilityFactor / v107; + v54 = (unsigned char *)&TempVertexBuffer[1 + CLODLightManager::VC::nSmoothEffect].color; + do + { + v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; + v56 = (((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v57 = (unsigned __int64)(v55 * slColorFactor1); + *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); + v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; + v60 = (((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v61 = (unsigned __int64)(v59 * slColorFactor1); + *(DWORD *)v54 = (DWORD)(v61 | v60); + v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; + v64 = (((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v65 = (unsigned __int64)(v63 * slColorFactor1); + *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); + v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); + *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2) + 0x80000000u; + v52 += 4; + v54 = (unsigned char *)v54 + 144; + v89 += 4; + } while (v89 < (signed int)v51); + v49 = TempBufferIndicesStored; + v12 = 0; + } + if (v52 < (signed int)v51) + { + v67 = CLODLightManager::VC::fSearchlightEffectVisibilityFactor / v107; + v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + CLODLightManager::VC::nSmoothEffect].color); + do + { + v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; + *(unsigned __int64 *)v90 = ((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)) + 0x80000000u; + ++v52; + v90 = (char *)v90 + 0x24; + } while (v52 < (signed int)v51); + v12 = 0; + } + + if (v49 >(signed int)v12 && CLODLightManager::VC::RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) + { + CLODLightManager::VC::RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); + CLODLightManager::VC::RwIm3DEnd(); + } +} \ No newline at end of file diff --git a/VCLodLights/CSearchlights.h b/VCLodLights/CSearchlights.h new file mode 100644 index 0000000..97b04ad --- /dev/null +++ b/VCLodLights/CSearchlights.h @@ -0,0 +1,14 @@ +#ifndef __SEARCHLIGHTS +#define __SEARCHLIGHTS +#include "..\includes\stdafx.h" +#include "..\includes\CLODLightManager.h" + +class CSearchlights +{ +public: + static void (__cdecl drawCustomSpotLightVC)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); + static void RenderHeliSearchLightsVC(); + static void RenderSearchLightsVC(); +}; + +#endif \ No newline at end of file diff --git a/VCLodLights/SearchlightsVC.h b/VCLodLights/SearchlightsVC.h deleted file mode 100644 index 4e2ed2d..0000000 --- a/VCLodLights/SearchlightsVC.h +++ /dev/null @@ -1,605 +0,0 @@ -enum RwRenderState -{ - rwRENDERSTATENARENDERSTATE = 0, - - rwRENDERSTATETEXTURERASTER, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: FALSE. - */ - rwRENDERSTATESTENCILFAIL, - /**<\ref RwStencilOperation used when the stencil test passes. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILZFAIL, - /**<\ref RwStencilOperation used when the stencil test passes and - * the depth test (z-test) fails. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILPASS, - /**<\ref RwStencilOperation used when both the stencil and the depth - * (z) tests pass. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILOPERATIONKEEP. - */ - rwRENDERSTATESTENCILFUNCTION, - /**<\ref RwStencilFunction for the stencil test. - * Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: rwSTENCILFUNCTIONALWAYS. - */ - rwRENDERSTATESTENCILFUNCTIONREF, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0. - */ - rwRENDERSTATESTENCILFUNCTIONMASK, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0xffffffff. - */ - rwRENDERSTATESTENCILFUNCTIONWRITEMASK, - /** Supported on Xbox, D3D8, D3D9, and OpenGL only. - * Default: 0xffffffff. - */ - rwRENDERSTATEALPHATESTFUNCTION, - /**<\ref RwAlphaTestFunction for the alpha test. When a pixel fails, - * neither the frame buffer nor the Z-buffer are updated. - * Default: rwALPHATESTFUNCTIONGREATER (GameCube, Xbox, D3D8, D3D9 - * and OpenGL). The default PS2 behaviour is to always update the - * frame buffer and update the Z-buffer only if a greater than or - * equal test passes. - */ - rwRENDERSTATEALPHATESTFUNCTIONREF, - /** Range is 0 to 255, mapped to the platform's actual range - * Default: 128 (PS2) 0 (GameCube, Xbox, D3D8, D3D9 and OpenGL). - */ - - -}; - -struct CHeliVC -{ - char pad[0x34]; - RwV3D pos; - char pad2[0x284]; - RwV3D shadowPos; - char pad3[0xC]; - float unk; - char pad4[0x7C]; -}; - -void CLODLightManager::VC::RenderHeliSearchLights() -{ - static CHeliVC ***pPoliceHelis = (CHeliVC ***)0x5AC506; - CHeliVC* HeliInst; - int nOffset = 0; - short NumOfHelisRequired = *(short*)0xA10A6A; - if (NumOfHelisRequired > 0) - { - nOffset = 0; - do - { - HeliInst = *(nOffset + (*pPoliceHelis)); - if (HeliInst) - { - if (HeliInst->unk > 0.0f) - { - RwV3D StartPoint = { 0.0f,0.0f,0.0f }; - RwV3D EndPoint = { 0.0f,0.0f,0.0f }; - StartPoint.x = HeliInst->pos.x; - EndPoint.x = HeliInst->shadowPos.x; - - if (EndPoint.x && EndPoint.y) - { - StartPoint.y = HeliInst->pos.y; - StartPoint.z = HeliInst->pos.z; - - EndPoint.y = HeliInst->shadowPos.y; - EndPoint.z = FindGroundZFor3DCoord(HeliInst->shadowPos.x, HeliInst->shadowPos.y, HeliInst->pos.z, 0, 0); - - //white - drawCustomSpotLight(StartPoint, EndPoint, 10.0f, 1.0f, 255.0f, 8, 0.8f); - } - } - } - //MessageBox(0, "0", "0", 0); - nOffset++; - --NumOfHelisRequired; - } while (NumOfHelisRequired > 0); - } -} - -void CLODLightManager::VC::RenderSearchLights() -{ - static CPool **pObjectPool = (CPool **)0x94DBE0; - CEntityVC *ObjectInst; - int nObjectPoolSize = (*pObjectPool)->size; - - if (nObjectPoolSize && GetIsTimeInRange(20, 7)) - { - int nOffset = 0x1A0 * nObjectPoolSize; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); - RwRenderStateSet(rwRENDERSTATESRCBLEND, 2); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, 2); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 1); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, 0); - RwRenderStateSet(rwRENDERSTATEFOGENABLE, 0); - RwRenderStateSet(rwRENDERSTATESHADEMODE, 2); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, 7); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, 0); - do - { - --nObjectPoolSize; - nOffset -= 0x1A0; - if (*(BYTE *)(nObjectPoolSize + (*pObjectPool)->flags) >= 0) - { - ObjectInst = (CEntityVC *)(nOffset + (*pObjectPool)->objects); - if (ObjectInst) - { - int IsObjectDamaged = ((ObjectInst->field_53 & 1) == 1 || (ObjectInst->m_bRenderDamaged)); - if (!IsObjectDamaged) - { - auto itEnd = pFileContent->upper_bound(PackKey(ObjectInst->m_nModelIndex, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(ObjectInst->m_nModelIndex, 0)); it != itEnd; it++) - { - if (it->second.nDrawSearchlight) - { - RwV3D StartPoint; - RwV3D EndPoint; - RwV3D zeroCoords; zeroCoords.x = zeroCoords.y = zeroCoords.z = 0.0f; - CVector result = ObjectInst->matrix * it->second.vecPos; - StartPoint.x = result.x; StartPoint.y = result.y; StartPoint.z = result.z; - - if (GetDistance(GetCamPos(), &StartPoint) < 1000.0f && GetDistance(&zeroCoords, &StartPoint) > 100.0f) - { - EndPoint = StartPoint; - float grZ = FindGroundZFor3DCoord(StartPoint.x, StartPoint.y, StartPoint.z, 0, 0); - EndPoint.z = grZ; - - if (!(it->second.colour.r == 255u && it->second.colour.g == 255u && it->second.colour.b == 255u)) - { - //yellow - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ) * 1.8f, it->second.fCustomSizeMult / 6.0f, 5.0f, 8, fSearchlightEffectVisibilityFactor); - - } - else //if (ObjectInst->m_nModelIndex != GetModelInfoUInt16("Gay_lamppost")) - { - //white - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ) * 1.8f, it->second.fCustomSizeMult / 6.0f, 255.0f, 8, fSearchlightEffectVisibilityFactor); - } - /*else - { - //pink - drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), it->second.fCustomSizeMult / 6.0f, 200.0f, 18, fSearchlightEffectVisibilityFactor); - }*/ - } - } - } - } - } - } - } while (nObjectPoolSize); - true ? RenderHeliSearchLights() : nullptr; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 1); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); - RwRenderStateSet(rwRENDERSTATESRCBLEND, 5); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, 6); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 0); - RwRenderStateSet(rwRENDERSTATECULLMODE, 2); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, 5); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, 2); - } -} - - -void __cdecl CLODLightManager::VC::drawCustomSpotLight(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha) -{ - RwMatrix *v12; // ebx@1 - RwV3D *v13; // eax@4 - signed int v19; // esi@8 - float v20; // fst7@9 - float v21; // ST7C_4@9 - float v22; // ST60_4@9 - float v23; // fst7@9 - float v24; // fst6@9 - float v25; // fst4@9 - float v26; // ST7C_4@9 - float v27; // ST68_4@9 - float v28; // ST6C_4@9 - float v29; // fst4@9 - float v30; // fst3@9 - float v31; // ST80_4@9 - float v32; // fst2@9 - float v33; // ST60_4@9 - float v34; // ST74_4@9 - float v35; // ST78_4@9 - float v36; // ST78_4@9 - float v37; // ST60_4@9 - float v38; // fst7@15 - float v39; // fst5@15 - float v40; // ST80_4@16 - float v41; // fst4@15 - float v42; // fst7@17 - unsigned int v43; // eax@17 - float v44; // fst7@17 - float v45; // fst7@17 - float v46; // fst7@17 - float v47; // fst7@19 - int v49; // ebp@21 - float v50; // fst7@22 - unsigned int v51; // edi@24 - signed int v52; // esi@25 - float v53; // fst7@26 - unsigned char *v54; // ebp@26 - float v55; // fst6@27 - int v56; // ebx@27 - unsigned __int64 v57; // qax@27 - float v59; // fst6@27 - int v60; // ebx@27 - unsigned __int64 v61; // qax@27 - float v63; // fst6@27 - int v64; // ebx@27 - unsigned __int64 v65; // qax@27 - float v66; // fst6@27 - float v67; // fst7@30 - float v68; // fst6@31 - signed int v88; // [sp+44h] [bp-424h]@8 - signed int v89; // [sp+44h] [bp-424h]@26 - void *v90; // [sp+44h] [bp-424h]@30 - float a4; // [sp+48h] [bp-420h]@9 - float EndPointa; // [sp+4Ch] [bp-41Ch]@9 - float v97; // [sp+50h] [bp-418h]@9 - float a6; // [sp+54h] [bp-414h]@9 - float a7; // [sp+58h] [bp-410h]@9 - float v104; // [sp+5Ch] [bp-40Ch]@9 - float v105; // [sp+64h] [bp-404h]@17 - RwV3D a; // [sp+68h] [bp-400h]@1 - float v107; // [sp+74h] [bp-3F4h]@8 - RwV3D v108; // [sp+78h] [bp-3F0h]@1 - float v109; // [sp+84h] [bp-3E4h]@9 - RwV3D v110; // [sp+88h] [bp-3E0h]@6 - RwV3D v111; // [sp+94h] [bp-3D4h]@9 - float v112; // [sp+A0h] [bp-3C8h]@9 - float v113; // [sp+A4h] [bp-3C4h]@9 - RwV3D v115; // [sp+ACh] [bp-3BCh]@16 - float v116; // [sp+B8h] [bp-3B0h]@9 - float v117; // [sp+BCh] [bp-3ACh]@9 - float v118; // [sp+C0h] [bp-3TargetRadiush]@9 - RwV3D out; // [sp+C4h] [bp-3A4h]@9 - float v120; // [sp+D0h] [bp-398h]@16 - float v121; // [sp+D4h] [bp-394h]@16 - float v122; // [sp+D8h] [bp-390h]@16 - float v123; // [sp+DCh] [bp-38Ch]@3 - float v124; // [sp+E0h] [bp-388h]@3 - float v125; // [sp+E4h] [bp-384h]@3 - float v126; // [sp+E8h] [bp-380h]@9 - float v127; // [sp+ECh] [bp-37Ch]@9 - float v128; // [sp+F0h] [bp-378h]@9 - RwV3D v132; // [sp+100h] [bp-368h]@9 - float v133; // [sp+10Ch] [bp-35Ch]@9 - float v134; // [sp+110h] [bp-358h]@9 - float v135; // [sp+118h] [bp-350h]@9 - float v136; // [sp+11Ch] [bp-34Ch]@9 - RwV3D b; // [sp+124h] [bp-344h]@9 - RwV3D v139; // [sp+14Ch] [bp-31Ch]@12 - RwV3D v140; // [sp+158h] [bp-310h]@14 - float v141; // [sp+164h] [bp-304h]@9 - float v142; // [sp+178h] [bp-2F0h]@16 - float v143; // [sp+17Ch] [bp-2ECh]@9 - float v144; // [sp+188h] [bp-2E0h]@9 - float v145; // [sp+19Ch] [bp-2CCh]@9 - float v146; // [sp+1TargetRadiush] [bp-2C0h]@9 - RwRGBAReal v148[30]; // [sp+1D8h] [bp-290h]@21 - RwRGBAReal v149[30]; // [sp+320h] [bp-148h]@21 - - v108.x = EndPoint.x - StartPoint.x; - a.x = v108.x; - v108.y = EndPoint.y - StartPoint.y; - a.y = v108.y; - v108.z = EndPoint.z - StartPoint.z; - a.z = v108.z; - CVectorNormalize(&a); - v12 = 0; - EndPoint.x = a.x * 3.0f + EndPoint.x; - EndPoint.y = a.y * 3.0f + EndPoint.y; - EndPoint.z = a.z * 3.0f + EndPoint.z; - v123 = a.x * 100.0f + StartPoint.x; - v124 = a.y * 100.0f + StartPoint.y; - v125 = a.z * 100.0f + StartPoint.z; - v13 = GetCamPos(); - v110.x = v13->x - StartPoint.x; - v110.y = v13->y - StartPoint.y; - v110.z = v13->z - StartPoint.z; - CVectorNormalize(&v110); - v19 = 0; - v107 = 0.0f; - TempBufferIndicesStored = 0; - TempBufferVerticesStored = 0; - v88 = 0; - do - { - b.x = 0; - b.y = 0; - b.z = 1.0f; - CrossProduct(&out, &a, &b); - CVectorNormalize(&out); - CrossProduct(&v132, &out, &a); - CVectorNormalize(&v132); - v20 = (float)v88 * 0.15707964f; - v21 = sin(v20); - v22 = cos(v20); - v23 = out.x * v21; - v141 = v23; - v24 = out.y * v21; - v25 = out.z * v21; - v26 = v25; - v133 = v141 * baseRadius; - v134 = v24 * baseRadius; - v27 = v134 + StartPoint.y; - v28 = v25 * baseRadius + StartPoint.z; - v29 = v132.x * v22; - v109 = v29; - v30 = v132.y * v22; - v31 = v30; - v32 = v132.z * v22; - v33 = v32; - v145 = v32; - v126 = v29 * baseRadius; - v127 = v30 * baseRadius; - v128 = v145 * baseRadius; - v146 = v33; - a4 = v126 + v133 + StartPoint.x; - EndPointa = v127 + v27; - v97 = v128 + v28; - v144 = v23; - v135 = v144 * TargetRadius; - v136 = v24 * TargetRadius; - v34 = v136 + v124; - v35 = v26 * TargetRadius + v125; - v116 = v109 * TargetRadius; - v117 = v31 * TargetRadius; - v118 = v33 * TargetRadius; - v36 = v118 + v35; - v37 = (v97 - EndPoint.z) / (v97 - v36); - v143 = v135 + v123 + v116 - a4; - v112 = v143 * v37; - v113 = (v117 + v34 - EndPointa) * v37; - v111.x = v112 + a4; - v111.y = v113 + EndPointa; - a6 = v111.x; - a7 = v111.y; - v111.z = (v36 - v97) * v37 + v97; - v104 = v111.z; - if (v19 && v19 != 10) - { - if (v19 == 20) - { - v139.x = v111.x; - v139.y = v111.y; - v139.z = v111.z; - } - else - { - if (v19 == 30) - { - v140.x = v111.x; - v140.y = v111.y; - v140.z = v111.z; - } - } - } - v38 = v111.x - a4; - v39 = v111.y - EndPointa; - v41 = v111.z - v97; - v109 = v41; - if (sqrt(v41 * v41 + v39 * v39 + v38 * v38) > 100.0f) - { - v115.x = v38; - v40 = v39; - v115.y = v40; - v115.z = v109; - CVectorNormalize(&v115); - v142 = v115.z * 100.0f; - v120 = v115.x * 100.0f + a4; - a6 = v120; - v121 = v115.y * 100.0f + EndPointa; - a7 = v121; - v122 = v142 + v97; - v104 = v122; - } - v42 = slAlpha * 0.15000001f + 0.1f; - v43 = TempBufferVerticesStored; - TempVertexBuffer[TempBufferVerticesStored].objVertex.x = a4; - v105 = v42; - TempVertexBuffer[TempBufferVerticesStored].objVertex.y = EndPointa; - v44 = a4 - StartPoint.x; - TempVertexBuffer[TempBufferVerticesStored].objVertex.z = v97; - v108.x = v44; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.x = a6; - v45 = EndPointa - StartPoint.y; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.y = a7; - TempVertexBuffer[TempBufferVerticesStored + 1].objVertex.z = v104; - v108.y = v45; - v108.z = v97 - StartPoint.z; - CVectorNormalize(&v108); - v46 = v108.x * v110.x + v108.z * v110.z + v108.y * v110.y; - if (v46 < 0.0f) - v46 = -v46; - v47 = v46 * v46; - if (v47 > v107) - v107 = v47; - v49 = TempBufferIndicesStored; - *(&v149[0].red + TempBufferVerticesStored) = v105; - *(&v149[0].green + TempBufferVerticesStored) = 0; - *(&v148[0].red + TempBufferVerticesStored) = v47; - *(&v148[0].green + TempBufferVerticesStored) = v47; - if (v19 != 40) - { - v50 = baseRadius; - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 3); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 1); - v49 += 3; - TempBufferIndicesStored = v49; - if (v50 > 0.0f) - { - TempBufferRenderIndexList[v49] = (short)TempBufferVerticesStored; - TempBufferRenderIndexList[v49 + 1] = (short)(TempBufferVerticesStored + 2); - TempBufferRenderIndexList[v49 + 2] = (short)(TempBufferVerticesStored + 3); - v49 += 3; - TempBufferIndicesStored = v49; - } - } - v51 = TempBufferVerticesStored + 2; - ++v19; - TempBufferVerticesStored = v51; - v88 = v19; - } while (v19 <= 40); - v52 = 0; - if ((signed int)v51 >= 4) - { - v89 = 3; - v53 = fSearchlightEffectVisibilityFactor / v107; - v54 = (unsigned char *)&TempVertexBuffer[1 + SmoothEffect].color; - do - { - v55 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v53; - v56 = (((unsigned __int64)(200.0f * v55) | ((unsigned __int64)(200.0f * v55) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v57 = (unsigned __int64)(v55 * slColorFactor1); - *((DWORD *)v54 - 9) = (DWORD)(v57 | v56); - v59 = *(&v148[0].green + v52) * *(&v149[0].green + v52) * v53; - v60 = (((unsigned __int64)(200.0f * v59) | ((unsigned __int64)(200.0f * v59) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v61 = (unsigned __int64)(v59 * slColorFactor1); - *(DWORD *)v54 = (DWORD)(v61 | v60); - v63 = *(&v149[0].blue + v52) * *(&v148[0].blue + v52) * v53; - v64 = (((unsigned __int64)(200.0f * v63) | ((unsigned __int64)(200.0f * v63) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v65 = (unsigned __int64)(v63 * slColorFactor1); - *((DWORD *)v54 + 9) = (DWORD)(v65 | v64); - v66 = *(&v149[0].alpha + v52) * *(&v148[0].alpha + v52); - *((DWORD *)v54 + 18) = (unsigned __int64)(v66 * v53 * 255.0f) | (((unsigned __int64)(200.0f * v66 * v53) | ((unsigned __int64)(200.0f * v66 * v53) << slColorFactor2)) << slColorFactor2) + 0x80000000u; - v52 += 4; - v54 = (unsigned char *)v54 + 144; - v89 += 4; - } while (v89 < (signed int)v51); - v49 = TempBufferIndicesStored; - v12 = 0; - } - if (v52 < (signed int)v51) - { - v67 = fSearchlightEffectVisibilityFactor / v107; - v90 = (void *)(36 * v52 + (unsigned char *)&TempVertexBuffer[0 + SmoothEffect].color); - do - { - v68 = *(&v148[0].red + v52) * *(&v149[0].red + v52) * v67; - *(unsigned __int64 *)v90 = ((unsigned __int64)(v68 * slColorFactor1) | (((unsigned __int64)(200.0 * v68) | ((unsigned __int64)(200.0 * v68) << slColorFactor2)) << slColorFactor2)) + 0x80000000u; - ++v52; - v90 = (char *)v90 + 0x24; - } while (v52 < (signed int)v51); - v12 = 0; - } - - if (v49 >(signed int)v12 && RwIm3DTransform(TempVertexBuffer, v51, v12, 0x18u)) - { - RwIm3DRenderIndexedPrimitive(3, TempBufferRenderIndexList, TempBufferIndicesStored); - RwIm3DEnd(); - } -} \ No newline at end of file diff --git a/VCLodLights/VCLodLights.vcxproj b/VCLodLights/VCLodLights.vcxproj index 913be50..4967830 100644 --- a/VCLodLights/VCLodLights.vcxproj +++ b/VCLodLights/VCLodLights.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,17 @@ Release Win32 + + Debug + x64 + + + Release + x64 + - {4304D8B7-2551-42BA-B62F-B898C42EABF2} + {EA7315B9-C110-4B2D-98D2-955D65CC4C20} Win32Proj VCLodLights 8.1 @@ -20,7 +28,7 @@ DynamicLibrary true - v120 + v140 Unicode @@ -30,27 +38,55 @@ true MultiByte + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + true + + true + false .asi $(SolutionDir)$(Configuration)\$(ProjectName)\ + + false + - Use + + Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;VCLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) @@ -60,10 +96,24 @@ true + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;VCLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + - Level4 - Use + Level3 + + MaxSpeed true true @@ -72,34 +122,43 @@ Windows + true + true true + + + copy /y "$(TargetPath)" "Z:\WGTA\Modloader\Grand Theft Auto Vice City\modloader\mods\VC.Project2DFXv4\VCLodLights.asi" + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;VCLODLIGHTS_EXPORTS;%(PreprocessorDefinitions) + + + Windows true true + true - - cd $(TargetDir) -del *.iobj - - - - + + + + + - - - false - - - false - - - - - Create - Create - + + + + diff --git a/VCLodLights/VCLodLights.vcxproj.filters b/VCLodLights/VCLodLights.vcxproj.filters index 336a621..d85964a 100644 --- a/VCLodLights/VCLodLights.vcxproj.filters +++ b/VCLodLights/VCLodLights.vcxproj.filters @@ -15,25 +15,34 @@ - - Header Files - - - Header Files - - - Header Files - - - - + Source Files - + + Source Files + + Source Files - + Source Files + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/VCLodLights/dllmain.cpp b/VCLodLights/dllmain.cpp index 4b2cfb3..92abd42 100644 --- a/VCLodLights/dllmain.cpp +++ b/VCLodLights/dllmain.cpp @@ -1,124 +1,132 @@ -//#include "stdafx.h" -#include +#include "..\includes\stdafx.h" #include "..\includes\CLODLightManager.h" -#include "SearchlightsVC.h" - -void CLODLightManager::VC::RenderLODLights() +#include "..\includes\CLODLights.h" +#include "CSearchlights.h" + +int numCoronas; +std::vector VecEntities; +std::vector ExplosionTypes = { 0,2,6,7,8,9,10,11 }; //1,3,4,5 - barrel crash +RwCamera*& Camera = *(RwCamera**)0x8100BC; +int& CTimer::m_snTimeInMillisecondsPauseMode = *(int*)0x974B2C; +float& CTimer::ms_fTimeStep = *(float*)0x975424; + +char* CLODLightManager::VC::CurrentTimeHours = (char*)0xA10B6B; +char* CLODLightManager::VC::CurrentTimeMinutes = (char*)0xA10B92; +float** CLODLightManager::VC::fCurrentFarClip = (float**)0x4A602D; +char(__cdecl *CLODLightManager::VC::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x4870F0; +bool(__cdecl *const CLODLightManager::VC::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CLODLightManager::VC::CShadowsStoreStaticShadow))0x56E780; +float(__cdecl *CLODLightManager::VC::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x4D53A0; +RwV3D* (__cdecl *CLODLightManager::VC::TransformPoint)(RwV3d *a1, RwV3d *a2, int a3, RwMatrix *a4) = (struct RwV3D *(__cdecl *)(RwV3d *a1, RwV3d *a2, int a3, RwMatrix *a4)) 0x647160; +bool CLODLightManager::VC::CCameraIsSphereVisible(RwV3D *origin, float radius) { - if (GetIsTimeInRange(19, 7)) + RwV3D SpherePos; + SpherePos.x = origin->x; + SpherePos.y = origin->y; + SpherePos.z = origin->z; + if (origin->z <= *(float *)0x688640) + SpherePos.z = FindGroundZFor3DCoord(origin->x, origin->y, origin->z, nullptr, nullptr); + TransformPoint(&SpherePos, &SpherePos, 1, (RwMatrix*)0x7E4EA8); + + if (SpherePos.y + radius >= *(float *)0x978534) { - unsigned char bAlpha; - float fRadius; - unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; - unsigned int curMin = *CurrentTimeMinutes; - CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip; - - if (nTime >= 19 * 60) - bAlpha = static_cast((1.0f / 2.0f)*nTime - 570.0f); // http://goo.gl/3rI2tc - else if (nTime < 3 * 60) - bAlpha = 150; - else - bAlpha = static_cast((-5.0f / 8.0f)*nTime + 262.5f); // http://goo.gl/M8Dev9 - - for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) + if (SpherePos.y - radius <= *(float *)0xA10678) { - if (GetDistance((RwV3d*)&it->vecPos, GetCamPos()) <= CoronaFarClip) + if (SpherePos.y * *(float *)0x7E4F44 + SpherePos.x * *(float *)0x7E4F40 <= radius) { - if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 530.0f)) + if (SpherePos.y * *(float *)0x7E4F50 + SpherePos.x * *(float *)0x7E4F4C <= radius) { - if (CCameraIsSphereVisible((RwV3d*)&it->vecPos, 5.0f)) + if (SpherePos.z * *(float *)0x7E4F60 + SpherePos.y * *(float *)0x7E4F5C <= radius) { - RwV3D* pCamPos = GetCamPos(); - float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); - - if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance) - { - if (!it->nNoDistance) - fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - else - fRadius = 3.5f; - - if (SlightlyIncreaseRadiusWithDistance) - fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC - - if (it->fCustomSizeMult != 0.45f) - { - RegisterCorona(reinterpret_cast(&*it), it->colour.r, it->colour.g, it->colour.b, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f, false, 1.5f); - RenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), 2, *(RwTexture **)0x978DB4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, it->colour.r, it->colour.g, it->colour.b, 15.0f, 1.0f, CoronaFarClip, false, 0.0f) : nullptr; - } - else - { - if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50)) - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f, false, 1.5f); - else - RegisterCorona(reinterpret_cast(&*it), 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f, false, 1.5f); - } - else - { - if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2) - RegisterCorona(reinterpret_cast(&*it), 0u, 255u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f, false, 1.5f); - else - RegisterCorona(reinterpret_cast(&*it), 255u, 0u, 0u, bAlpha, (RwV3d*)&it->vecPos, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier), CoronaFarClip, 1, 0, 4, 0, 0, 0.0f, false, 1.5f); - } - } - } + if (SpherePos.z * *(float *)0x7E4F6C + SpherePos.y * *(float *)0x7E4F68 <= radius) + return true; } } } } } + return false; } - -Fps _fps; -void CLODLightManager::VC::DrawDistanceChanger() +void(__cdecl *CLODLightManager::VC::RegisterCorona)(int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16) = (void(__cdecl *)(int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16)) 0x5427A0; +void(__fastcall *CLODLightManager::VC::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x4DFEA0; +RwV3D *(__cdecl *CLODLightManager::VC::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x4E00B0; +int(__cdecl *CLODLightManager::VC::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x65AE90; +int(__cdecl *CLODLightManager::VC::RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices) = (int(__cdecl *)(int primType, short *indices, int numIndices)) 0x65AF90; +int(__cdecl *CLODLightManager::VC::RwIm3DEnd)() = (int(__cdecl *)()) 0x65AF60; +int(__cdecl *CLODLightManager::VC::RwRenderStateSetVC)(RwRenderState nState, void *pParam) = (int(__cdecl *)(RwRenderState nState, void *pParam)) 0x649BA0; +void RwRenderStateSetVC(RwRenderState nState, void *pParam) { - if (AdaptiveDrawDistanceEnabled) - { - _fps.update(); - int FPScount = _fps.get(); - if (FPScount < MinFPSValue) - { - MinDrawDistanceOnTheGround -= 2.0f; - } - else if (FPScount >= MaxFPSValue) - { - MinDrawDistanceOnTheGround += 2.0f; - } - if (MinDrawDistanceOnTheGround < 800.0f) - MinDrawDistanceOnTheGround = 800.0f; - else - if (MinDrawDistanceOnTheGround > MaxPossibleDrawDistance) - MinDrawDistanceOnTheGround = MaxPossibleDrawDistance; - } - fNewFarClip = (Factor1 / Factor2) * (GetCamPos()->z) + MinDrawDistanceOnTheGround; + CLODLightManager::VC::RwRenderStateSetVC(nState, pParam); } +void(*_RwRenderStateSet)(RwRenderState nState, void *pParam) = &RwRenderStateSetVC; -void CLODLightManager::VC::RegisterLamppost(CEntityVC* entity) +CVector* GetCamPos() { - auto itEnd = pFileContent->upper_bound(PackKey(entity->m_nModelIndex, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(entity->m_nModelIndex, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(entity->matrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); + return (CVector*)(0x7E4688 + 0x7D8); } -void CLODLightManager::VC::RegisterAllLampposts() +void CLODLightManager::VC::Init() { - for (auto i : VecEntities) { - if (IsModelALamppost(i.m_nModelIndex)) - { - RegisterLamppost(&i); - } - } + CIniReader iniReader(""); + bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1) != 0; + numCoronas = iniReader.ReadInteger("LodLights", "MaxNumberOfLodLights", 25000); + fCoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); + bSlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; + if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) + fCoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); + else + autoFarClip = true; + szCustomCoronaTexturePath = iniReader.ReadString("LodLights", "CustomCoronaTexturePath", ".\\corona.png"); + + bRenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0) != 0; + bIncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreaseCarsShadowsDrawDistance", 0) != 0; + fStaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); + fStaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); + fTrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); + fTrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); + + bRenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1) != 0; + bRenderHeliSearchlights = iniReader.ReadInteger("SearchLights", "RenderHeliSearchlights", 1) != 0; + fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); + nSmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); + + bEnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0) != 0; + fMinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); + fFactor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); + fFactor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); + fStaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); + + bAdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0) != 0; + nMinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); + nMaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); + fMaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); + + fMaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0); + fDrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0f); + bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) != 0; + + bRandomExplosionEffects = iniReader.ReadInteger("Misc", "RandomExplosionEffects", 0) != 0; + bReplaceSmokeTrailWithBulletTrail = iniReader.ReadInteger("Misc", "ReplaceSmokeTrailWithBulletTrail", 0) != 0; + + ApplyMemoryPatches(); } -void CLODLightManager::VC::RegisterCustomCoronas() +template +void CWorldAddHook() { - unsigned short nModelID = 65534; + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type CWorldAdd, CEntityVC* EntityVC) + { + if (CLODLightManager::VC::bPreloadLODs) + { + if (EntityVC->m_nModelIndex == 2600 || EntityVC->m_nModelIndex == 2544 || EntityVC->m_nModelIndex == 2634 || EntityVC->m_nModelIndex == 2545) + { + EntityVC->m_bIsVisible = 0; + } + } + VecEntities.push_back(*EntityVC); - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); + CWorldAdd(EntityVC); + }); } template @@ -129,138 +137,186 @@ void RenderSirenParticles() { RegisterCorona(id, r, g, b, alpha, pos, radius, farClp, a9, lensflare, a11, see_through_effect, trace, a14, a15, a16); CLODLightManager::VC::CShadowsStoreStaticShadow(id, 2, *(RwTexture **)0x978DB4, (CVector*)pos, 8.0f, 0.0f, 0.0f, -8.0f, 80, r != 0 ? 25 : 0, g != 0 ? 25 : 0, b != 0 ? 25 : 0, 15.0f, 1.0f, farClp, false, 8.0f); - return; + }); +} + +template +void CBulletTracesAddTrace() +{ + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddTrace, CVector* start, CVector* end, float, unsigned int, unsigned char) + { + CVector endPoint = CVector(); + endPoint.x = (end->x - start->x) * 0.15f; + endPoint.y = (end->y - start->y) * 0.15f; + endPoint.z = (end->z - start->z) * 0.15f; + injector::cstd::call<0x5648F0>(56, *start, endPoint, 0, 0.0f, 0, 0, 0, 0); }); } template void CExplosionAddModifiedExplosion() { - using func_hook = injector::function_hooker; - injector::make_static_hook([](func_hook::func_type AddExplosion, uintptr_t *vehicle, CPed *ped, int type, RwV3d *pos, int delay, char a6) + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddExplosion, CEntity* pTarget, CEntity* pSource, int nType, CVector* pVector, uint32_t uTimer, bool bUnknown) { std::random_shuffle(ExplosionTypes.begin(), ExplosionTypes.end()); injector::MakeNOP(0x5C6661, 5, true); for (auto it = ExplosionTypes.begin(); it != ExplosionTypes.end(); ++it) { - if (*it == type) + if (*it == nType) break; - AddExplosion(vehicle, ped, *it, pos, delay, a6); + AddExplosion(pTarget, pSource, *it, pVector, uTimer, bUnknown); } injector::MakeCALL(0x5C6661, 0x4D82D0, true); - AddExplosion(vehicle, ped, type, pos, delay, a6); - return; - }); -} -template -void CBulletTracesAddTrace() -{ - using func_hook = injector::function_hooker; - injector::make_static_hook([](func_hook::func_type AddTrace, CVector* start, CVector* end, float, unsigned int, unsigned char) - { - injector::MakeNOP(0x5C9C06, 5, true); //CParticle__AddParticle 5648F0 - //injector::MakeNOP(0x5C9CF5, 5, true); //CParticle__AddParticle 5648F0 - injector::MakeNOP(0x5C9E85, 5, true); //CParticle__AddParticle 5648F0 - injector::MakeNOP(0x5C9F6C, 5, true); //CParticle__AddParticle 5648F0 - injector::MakeNOP(0x5CA073, 5, true); //CParticle__AddParticle 5648F0 - injector::MakeNOP(0x5C9C6B, 5, true); //sub_567700 - injector::MakeNOP(0x5C9C8F, 5, true); //sub_4D92D0 - injector::MakeNOP(0x5C9D68, 5, true); //sub_5035F0 - injector::MakeNOP(0x5C9D73, 5, true); //sub_52CF70 - injector::MakeNOP(0x5C9D86, 5, true); //sub_4058B0 - injector::MakeNOP(0x5C9DBE, 5, true); //sub_525B20 - injector::MakeNOP(0x5C9DD5, 5, true); //sub_4885D0 - injector::MakeNOP(0x5C9EFB, 5, true); //sub_5B9020 - injector::MakeNOP(0x5C9F25, 5, true); //sub_5F9210 - injector::MakeNOP(0x5C9F94, 5, true); //CAudio__?PlayAudioEventOnEntity 5F9DA0 - injector::MakeNOP(0x5C9FB9, 5, true); //CAudio__?PlayAudioEventOnEntity 5F9DA0 - injector::MakeNOP(0x5C9FC4, 5, true); //sub_5226B0 - injector::MakeNOP(0x5CA00B, 5, true); //sub_5C2C80 - injector::MakeNOP(0x5CA085, 5, true); //sub_5F9210 - injector::cstd::call<0x5C9BB0>(start, end, 0); - injector::MakeCALL(0x5C9C06, (void*)0x5648F0, true); - injector::MakeCALL(0x5C9E85, (void*)0x5648F0, true); - injector::MakeCALL(0x5C9F6C, (void*)0x5648F0, true); - injector::MakeCALL(0x5CA073, (void*)0x5648F0, true); - injector::MakeCALL(0x5C9C6B, (void*)0x567700, true); - injector::MakeCALL(0x5C9C8F, (void*)0x4D92D0, true); - injector::MakeCALL(0x5C9D68, (void*)0x5035F0, true); - injector::MakeCALL(0x5C9D73, (void*)0x52CF70, true); - injector::MakeCALL(0x5C9D86, (void*)0x4058B0, true); - injector::MakeCALL(0x5C9DBE, (void*)0x525B20, true); - injector::MakeCALL(0x5C9DD5, (void*)0x4885D0, true); - injector::MakeCALL(0x5C9EFB, (void*)0x5B9020, true); - injector::MakeCALL(0x5C9F25, (void*)0x5F9210, true); - injector::MakeCALL(0x5C9F94, (void*)0x5F9DA0, true); - injector::MakeCALL(0x5C9FB9, (void*)0x5F9DA0, true); - injector::MakeCALL(0x5C9FC4, (void*)0x5226B0, true); - injector::MakeCALL(0x5CA00B, (void*)0x5C2C80, true); - injector::MakeCALL(0x5CA085, (void*)0x5F9210, true); - return; + return AddExplosion(pTarget, pSource, nType, pVector, uTimer, bUnknown); }); } void CLODLightManager::VC::ApplyMemoryPatches() { - if (bRenderLodLights) + injector::WriteMemory(0x542E66, 127, true); // sun reflection + injector::WriteMemory(0x68A860, 300.0f, true); // Traffic lights coronas draw distance + + RenderSirenParticles<(0x58C704)>(); + RenderSirenParticles<(0x58C764)>(); + + struct GenericIDEHook { - injector::MakeCALL(0x4A6547, RenderLODLights, true); + void operator()(injector::reg_pack& regs) + { + *(uint8_t*)(regs.ebp + 0x7D7C38) = 32; - injector::MakeNOP(0x544186, 6, true); //disable ambientBrightness change - injector::MakeNOP(0x544533, 6, true); - } + static char* buffer = (char *)0x7D7C38; + unsigned int modelID = 0, IDEDrawDistance = 0; - if (RenderSearchlightEffects) + auto tempptr = strchr(buffer, ','); + auto tempptr2 = strchr(buffer, '.'); + + if (!tempptr && !tempptr2) + { + sscanf(buffer, "%d %*s %*s %*d %d %*s %*s %*s", &modelID, &IDEDrawDistance); + if ((modelID >= 300 && modelID <= 632)) + { + if (IDEDrawDistance >= 10 && IDEDrawDistance < 300) + { + char sIDEDrawDistance[5] = { 0 }, Flags2[20] = { 0 }; + sprintf(sIDEDrawDistance, "%d", IDEDrawDistance); + tempptr = strstr(buffer + 10, sIDEDrawDistance); + + if (IDEDrawDistance >= 100) + strncpy(Flags2, tempptr + 4, 15); + else + strncpy(Flags2, tempptr + 3, 15); + + strncpy(tempptr, "300 ", 5); + strncpy(tempptr + 5, Flags2, 15); + } + } + } + else + { + tempptr2 = strstr(buffer, "shad_exp"); + if (!tempptr && tempptr2) + { + sscanf(tempptr2 + 11, "%d", &IDEDrawDistance); + + if (IDEDrawDistance >= 100 && IDEDrawDistance < 300) + { + strncpy(tempptr2 + 11, "300", 3); + } + } + } + } + }; injector::MakeInline(0x48D4BD, 0x48D4BD + 7); + + struct Render { - injector::MakeJMP(0x4A6560, RenderSearchLights, true); - } + void operator()(injector::reg_pack&) + { + ((void(__cdecl *)())0x543500)(); //CCoronas::Render(); + + if (bRenderLodLights) + CLODLights::RenderBuffered(); + + if (bRenderSearchlightEffects) + CSearchlights::RenderSearchLightsVC(); + } + }; injector::MakeInline(0x4A653D); - if (SmoothEffect) + + if (bRenderLodLights) { - SmoothEffect = 1; - } + CLODLights::Inject(); - injector::WriteMemory(0x542E66, 127, true); // sun reflection + //injector::MakeNOP(0x544186, 6, true); //disable ambientBrightness change + //injector::MakeNOP(0x544533, 6, true); - injector::WriteMemory(0x68A860, 300.0f, true); // Traffic lights coronas draw distance + CWorldAddHook<(0x48AD9C)>(); + CWorldAddHook<(0x48AF52)>(); - RenderSirenParticles<(0x58C704)>(); - RenderSirenParticles<(0x58C764)>(); + struct asmInit + { + void operator()(injector::reg_pack& regs) + { + LoadDatFile(); + + for (auto i : VecEntities) { + if (m_bCatchLamppostsNow && IsModelALamppost(i.m_nModelIndex)) + { + RegisterLamppost(&i); + } + } - if (TrafficLightsShadowsDrawDistance) + RegisterCustomCoronas(); + m_bCatchLamppostsNow = false; + m_pLampposts->shrink_to_fit(); + VecEntities.clear(); + pFileContent->clear(); + + injector::MakeCALL(0x4A6547, RegisterLODLights, true); + } + }; injector::MakeInline(0x4A4D10); + } + + if (nSmoothEffect) + { + nSmoothEffect = 1; + } + + if (fTrafficLightsShadowsDrawDistance) { - injector::WriteMemory(0x68A848, TrafficLightsShadowsDrawDistance, true); + injector::WriteMemory(0x68A848, fTrafficLightsShadowsDrawDistance, true); } - if (StaticShadowsDrawDistance) + if (fStaticShadowsDrawDistance) { - injector::WriteMemory(0x6882A4, StaticShadowsDrawDistance, true); - injector::WriteMemory(0x541590 + 0x7A4 + 2, &StaticShadowsDrawDistance, true); - injector::WriteMemory(0x541590 + 0x8D5 + 2, &StaticShadowsDrawDistance, true); + injector::WriteMemory(0x6882A4, fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x541590 + 0x7A4 + 2, &fStaticShadowsDrawDistance, true); + injector::WriteMemory(0x541590 + 0x8D5 + 2, &fStaticShadowsDrawDistance, true); } - if (StaticShadowsIntensity) + if (fStaticShadowsIntensity) { - injector::WriteMemory(0x69587C, StaticShadowsIntensity, true); + injector::WriteMemory(0x69587C, fStaticShadowsIntensity, true); injector::WriteMemory(0x465914, 255, true); } - if (TrafficLightsShadowsIntensity) + if (fTrafficLightsShadowsIntensity) { - injector::WriteMemory(0x463F90 + 0x7E9 + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0x82E + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0x873 + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0xF4F + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0xF94 + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0xFD7 + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0x18CE + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0x1913 + 2, &TrafficLightsShadowsIntensity, true); - injector::WriteMemory(0x463F90 + 0x1956 + 2, &TrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x7E9 + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x82E + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x873 + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0xF4F + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0xF94 + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0xFD7 + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x18CE + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x1913 + 2, &fTrafficLightsShadowsIntensity, true); + injector::WriteMemory(0x463F90 + 0x1956 + 2, &fTrafficLightsShadowsIntensity, true); } - //Car Shadows - if (IncreasePedsCarsShadowsDrawDistance) + if (bIncreasePedsCarsShadowsDrawDistance) { injector::MakeJMP(0x56DA3F, 0x56DBF3, true); //ped shadows draw distance @@ -272,29 +328,29 @@ void CLODLightManager::VC::ApplyMemoryPatches() injector::WriteMemory(0x0058E2B9, 0x55u, true); injector::WriteMemory(0x0058E2BB, 0x55u, true); } - - if (DrawDistance) + + if (fDrawDistance) { - injector::WriteMemory(0x690220, *(float*)0x690220 * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x690220, *(float*)0x690220 * (fDrawDistance / 1.8f), true); injector::MakeInline<0x498B65>([](injector::reg_pack& regs) { *(uintptr_t*)regs.esp = 0x498CC8; - injector::WriteMemory(0x690220, *(float*)0x690220 * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x690220, *(float*)0x690220 * (fDrawDistance / 1.8f), true); }); - injector::MakeInline<0x490132>([](injector::reg_pack&) + injector::MakeInline<0x490132, 0x490132+6>([](injector::reg_pack&) { - _asm fstp dword ptr ds: [00690220h] - injector::WriteMemory(0x690220, *(float*)0x690220 * (DrawDistance / 1.8f), true); + _asm fstp dword ptr ds : [00690220h] + injector::WriteMemory(0x690220, *(float*)0x690220 * (fDrawDistance / 1.8f), true); }); - injector::WriteMemory(0x499800 + 3, 1.2f * (DrawDistance / 1.8f), true); + injector::WriteMemory(0x499800 + 3, 1.2f * (fDrawDistance / 1.8f), true); } - - if (MaxDrawDistanceForNormalObjects) + + if (fMaxDrawDistanceForNormalObjects) { - injector::WriteMemory(0x69022C, MaxDrawDistanceForNormalObjects, true); + injector::WriteMemory(0x69022C, fMaxDrawDistanceForNormalObjects, true); } - if (EnableDrawDistanceChanger) + if (bEnableDrawDistanceChanger) { injector::MakeJMP(0x4A65CD, DrawDistanceChanger, true); @@ -302,40 +358,50 @@ void CLODLightManager::VC::ApplyMemoryPatches() //injector::WriteMemory(0x4A6037 + 0x2, &fNewFarClip, true); } - if (bRandomExplosionEffects) + if (bPreloadLODs) { - for (int i = 0; i < 12; ++i) + injector::WriteMemory(0x487CD8, 0xEB, true); + + struct SetupBigBuildingVisibilityHook //Lods in the interiors { - if (i != 1) - ExplosionTypes.push_back(i); - } + void operator()(injector::reg_pack& regs) + { + if (*(uint32_t*)0x978810 == 0) //nCurrentInterior + *(uintptr_t*)(regs.esp - 4) = 0x4C799A; + else + *(uintptr_t*)(regs.esp - 4) = 0x4C7961; + } + }; injector::MakeInline(0x4C7957); + } - CExplosionAddModifiedExplosion<(0x44038A)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x4579A7)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5869B5)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x588DC9)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5997C6)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x59F819)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5AD18F)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5AD3F2)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5AFEC2)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5B0320)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5B040F)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5B0867)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C6DB9)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C6DDC)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C6E23)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C6EDE)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - //CExplosionAddModifiedExplosion<(0x5C6EFD)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) molotov expl - CExplosionAddModifiedExplosion<(0x5C6F3D)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C704E)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - //CExplosionAddModifiedExplosion<(0x5C706D)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) molotov expl - CExplosionAddModifiedExplosion<(0x5C70AD)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C71C5)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x5C720F)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - //CExplosionAddModifiedExplosion<(0x5C8B89)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) barrels - CExplosionAddModifiedExplosion<(0x60A51D)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) - CExplosionAddModifiedExplosion<(0x630168)>(); //0x5C5720 + 0x0 -> call CExplosion::AddExplosion(CEntity *,CEntity *,eExplosionType,CVector const&,uint,uchar,float) + if (bRandomExplosionEffects) + { + CExplosionAddModifiedExplosion<(0x44038A)>(); + CExplosionAddModifiedExplosion<(0x4579A7)>(); + CExplosionAddModifiedExplosion<(0x5869B5)>(); + CExplosionAddModifiedExplosion<(0x588DC9)>(); + CExplosionAddModifiedExplosion<(0x5997C6)>(); + CExplosionAddModifiedExplosion<(0x59F819)>(); + CExplosionAddModifiedExplosion<(0x5AD18F)>(); + CExplosionAddModifiedExplosion<(0x5AD3F2)>(); + CExplosionAddModifiedExplosion<(0x5AFEC2)>(); + CExplosionAddModifiedExplosion<(0x5B0320)>(); + CExplosionAddModifiedExplosion<(0x5B040F)>(); + CExplosionAddModifiedExplosion<(0x5B0867)>(); + CExplosionAddModifiedExplosion<(0x5C6DB9)>(); + CExplosionAddModifiedExplosion<(0x5C6DDC)>(); + CExplosionAddModifiedExplosion<(0x5C6E23)>(); + CExplosionAddModifiedExplosion<(0x5C6EDE)>(); + //CExplosionAddModifiedExplosion<(0x5C6EFD)>(); //molotov + CExplosionAddModifiedExplosion<(0x5C6F3D)>(); + CExplosionAddModifiedExplosion<(0x5C704E)>(); + //CExplosionAddModifiedExplosion<(0x5C706D)>(); //molotov + CExplosionAddModifiedExplosion<(0x5C70AD)>(); + CExplosionAddModifiedExplosion<(0x5C71C5)>(); + CExplosionAddModifiedExplosion<(0x5C720F)>(); + CExplosionAddModifiedExplosion<(0x5C8B89)>(); //barrels + CExplosionAddModifiedExplosion<(0x60A51D)>(); + CExplosionAddModifiedExplosion<(0x630168)>(); } if (bReplaceSmokeTrailWithBulletTrail) @@ -344,223 +410,145 @@ void CLODLightManager::VC::ApplyMemoryPatches() } } -void CLODLightManager::VC::LoadDatFile() +void CLODLightManager::VC::RegisterCustomCoronas() { - CIniReader iniReader(""); - DataFilePath = iniReader.GetIniPath(); - char* tempPointer; - tempPointer = strrchr(DataFilePath, '.'); - *tempPointer = '\0'; - strcat(DataFilePath, ".dat"); - - if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) - { - unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; - - while (const char* pLine = CFileMgr::LoadLine(hFile)) - { - if (pLine[0] && pLine[0] != '#') - { - if (pLine[0] == '%') - { - nCurIndexForModel = 0; - if (strcmp(pLine, "%additional_coronas") != 0) - nModel = GetModelInfoUInt16(pLine + 1); - else - nModel = 65534; - } - else - { - float fOffsetX, fOffsetY, fOffsetZ; - unsigned int nRed, nGreen, nBlue; - float fCustomSize = 1.0f; - int nNoDistance = 0; - int nDrawSearchlight = 0; - sscanf(pLine, "%d %d %d %f %f %f %f %d %d", &nRed, &nGreen, &nBlue, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nNoDistance, &nDrawSearchlight); - pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast(nRed), static_cast(nGreen), static_cast(nBlue)), fCustomSize, nNoDistance, nDrawSearchlight))); - } - } - } - - m_pLampposts = new std::vector; + unsigned short nModelID = 65534; - CFileMgr::CloseFile(hFile); - } - else - { - RenderSearchlightEffects = 0; - bRenderLodLights = 0; - } + auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, 0.0f)); } -DWORD jmpAddress = 0x48D4C4; -char* buffer = (char *)0x7D7C38; -char* tempptr; -char* tempptr2; -unsigned int IDEmodelID, IDEDrawDistance; -char sIDEDrawDistance[5], Flags2[20]; -void __declspec(naked) CLODLightManager::VC::GenericIDEHook() +void CLODLightManager::VC::RegisterLamppost(CEntityVC* entity) { - __asm MOV BYTE PTR SS : [EBP + 7D7C38h], 20h + auto itEnd = pFileContent->upper_bound(PackKey(entity->m_nModelIndex, 0xFFFF)); + for (auto it = pFileContent->lower_bound(PackKey(entity->m_nModelIndex, 0)); it != itEnd; it++) + m_pLampposts->push_back(CLamppostInfo(entity->matrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nCoronaShowMode, it->second.nNoDistance, it->second.nDrawSearchlight, atan2(entity->matrix.GetUp()->y, -entity->matrix.GetUp()->x))); +} - tempptr = strchr(buffer, ','); - tempptr2 = strchr(buffer, '.'); - if (!tempptr && !tempptr2) +void CLODLightManager::VC::RegisterLODLights() +{ + if (GetIsTimeInRange(19, 7)) { - sscanf(buffer, "%d %*s %*s %*d %d %*s %*s %*s", &IDEmodelID, &IDEDrawDistance); + unsigned char bAlpha = 0; + float fRadius = 0.0f; + unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes; + unsigned int curMin = *CurrentTimeMinutes; + fCoronaFarClip = autoFarClip ? **fCurrentFarClip : fCoronaFarClip; + + if (nTime >= 19 * 60) + bAlpha = static_cast((3.0f / 4.0f)*nTime - 825.0f); // http://goo.gl/O03RpE {(19*60)a + y = 30, (24*60)a + y = 255} + else if (nTime < 3 * 60) + bAlpha = 255; + else + bAlpha = static_cast((-15.0f / 16.0f)*nTime + 424.0f); // http://goo.gl/M8Dev9 {(7*60)a + y = 30, (3*60)a + y = 255} - if ((IDEmodelID >= 300 && IDEmodelID <= 632)) + for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++) { - if (IDEDrawDistance >= 10 && IDEDrawDistance < 300) + if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f)) { - sprintf(sIDEDrawDistance, "%d", IDEDrawDistance); - tempptr = strstr(buffer + 10, sIDEDrawDistance); - if (IDEDrawDistance >= 100) - strncpy(Flags2, tempptr + 4, 15); - else - strncpy(Flags2, tempptr + 3, 15); + CVector* pCamPos = (CVector*)GetCamPos(); + float fDistSqr = (pCamPos->x - it->vecPos.x)*(pCamPos->x - it->vecPos.x) + (pCamPos->y - it->vecPos.y)*(pCamPos->y - it->vecPos.y) + (pCamPos->z - it->vecPos.z)*(pCamPos->z - it->vecPos.z); - strncpy(tempptr, "300 ", 5); - strncpy(tempptr + 5, Flags2, 15); - } - } - } - else - { - tempptr2 = strstr(buffer, "shad_exp"); - if (!tempptr && tempptr2) - { - sscanf(tempptr2 + 11, "%d", &IDEDrawDistance); + if ((fDistSqr > 250.0f*250.0f && fDistSqr < fCoronaFarClip*fCoronaFarClip) || it->nNoDistance) + { + if (it->nNoDistance) + fRadius = 3.5f; + else + fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx - if (IDEDrawDistance >= 100 && IDEDrawDistance < 300) - { - strncpy(tempptr2 + 11, "3", 1); + if (bSlightlyIncreaseRadiusWithDistance) + fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC + + if (it->fCustomSizeMult != 0.45f) + { + if (!it->nCoronaShowMode) + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + bRenderStaticShadowsForLODs ? CShadowsStoreStaticShadow(reinterpret_cast(&*it), 2, *(RwTexture **)0x978DB4, (CVector*)&it->vecPos, 8.0f, 0.0f, 0.0f, -8.0f, bAlpha, it->colour.r, it->colour.g, it->colour.b, 15.0f, 1.0f, fCoronaFarClip, false, 0.0f) : nullptr; + } + else + { + static float blinking = 1.0f; + if (IsBlinkingNeeded(it->nCoronaShowMode)) + blinking -= CTimer::ms_fTimeStep / 1000.0f; + else + blinking += CTimer::ms_fTimeStep / 1000.0f; + + (blinking > 1.0f) ? blinking = 1.0f : (blinking < 0.0f) ? blinking = 0.0f : 0.0f; + + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, blinking * (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + else + { + if ((it->colour.r >= 250 && it->colour.g >= 100 && it->colour.b <= 100) && ((curMin == 9 || curMin == 19 || curMin == 29 || curMin == 39 || curMin == 49 || curMin == 59))) //yellow + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((abs(it->fHeading) >= (3.1415f / 6.0f) && abs(it->fHeading) <= (5.0f * 3.1415f / 6.0f))) + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + } + else + { + if ((it->colour.r == 0 && it->colour.g >= 250 && it->colour.b == 0) && (((curMin >= 0 && curMin < 9) || (curMin >= 20 && curMin < 29) || (curMin >= 40 && curMin < 49)))) //red + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + else + { + if ((it->colour.r >= 250 && it->colour.g < 100 && it->colour.b == 0) && (((curMin > 9 && curMin < 19) || (curMin > 29 && curMin < 39) || (curMin > 49 && curMin < 59)))) //green + { + CLODLights::RegisterCorona(reinterpret_cast(&*it), nullptr, it->colour.r, it->colour.g, it->colour.b, (bAlpha * (it->colour.a / 255.0f)), it->vecPos, (fRadius * it->fCustomSizeMult * fCoronaRadiusMultiplier), fCoronaFarClip, 1, 0, false, false, 0, 0.0f, false, 0.0f, 0xFF, 255.0f, false, false); + } + } + } + } + } + } } } } - __asm jmp jmpAddress + CLODLights::Update(); } -DWORD ipljmpAddress1 = 0x48AD9C; -DWORD ipljmpAddress2 = 0x48AF57; -DWORD _EAX; -CEntityVC* EntityVC; -void __declspec(naked) CLODLightManager::VC::IPLDataHook1() -{ - _asm - { - mov _EAX, eax - mov eax, 0x4DFAE0 - call eax - mov eax, _EAX - push ebx - mov EntityVC, ebx - } - - VecEntities.push_back(*EntityVC); - __asm jmp ipljmpAddress1 -} -void __declspec(naked) CLODLightManager::VC::IPLDataHook2() +void CLODLightManager::VC::DrawDistanceChanger() { - _asm - { - push esi - mov EntityVC, esi - } - if (bPreloadLODs) + static Fps _fps; + if (bAdaptiveDrawDistanceEnabled) { - if (EntityVC->m_nModelIndex == 2600 || EntityVC->m_nModelIndex == 2544 || EntityVC->m_nModelIndex == 2634 || EntityVC->m_nModelIndex == 2545) + _fps.update(); + int FPScount = _fps.get(); + if (FPScount < nMinFPSValue) { - EntityVC->m_bIsVisible = 0; + fMinDrawDistanceOnTheGround -= 2.0f; } + else if (FPScount >= nMaxFPSValue) + { + fMinDrawDistanceOnTheGround += 2.0f; + } + if (fMinDrawDistanceOnTheGround < 800.0f) + fMinDrawDistanceOnTheGround = 800.0f; + else + if (fMinDrawDistanceOnTheGround > fMaxPossibleDrawDistance) + fMinDrawDistanceOnTheGround = fMaxPossibleDrawDistance; } - VecEntities.push_back(*EntityVC); - _asm - { - mov _EAX, eax - mov eax, 0x4DB3F0 - call eax - mov eax, _EAX - jmp ipljmpAddress2 - } -} - -void __declspec(naked) SetupBigBuildingVisibilityHook() -{ - _asm - { - mov eax, dword ptr ds: [0x978810] - test eax, eax - jz label2 - label1: - mov eax, 0x4C7961 - jmp eax - label2: - xor eax, eax - add esp, 20h - pop ebp - pop edi - pop esi - pop ebx - retn - } -} - - -void CLODLightManager::VC::Init() -{ - CIniReader iniReader(""); - bRenderLodLights = iniReader.ReadInteger("LodLights", "RenderLodLights", 1); - CoronaRadiusMultiplier = iniReader.ReadFloat("LodLights", "CoronaRadiusMultiplier", 1.0f); - SlightlyIncreaseRadiusWithDistance = iniReader.ReadInteger("LodLights", "SlightlyIncreaseRadiusWithDistance", 1) != 0; - if (strncmp(iniReader.ReadString("LodLights", "CoronaFarClip", "auto"), "auto", 4) != 0) - CoronaFarClip = iniReader.ReadFloat("LodLights", "CoronaFarClip", 0.0f); - else - autoFarClip = true; - - RenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0); - IncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreasePedsCarsShadowsDrawDistance", 0); - StaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); - StaticShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "StaticShadowsDrawDistance", 0.0f); - TrafficLightsShadowsIntensity = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsIntensity", 0.0f); - TrafficLightsShadowsDrawDistance = iniReader.ReadFloat("StaticShadows", "TrafficLightsShadowsDrawDistance", 0.0f); - - RenderSearchlightEffects = iniReader.ReadInteger("SearchLights", "RenderSearchlightEffects", 1); - fSearchlightEffectVisibilityFactor = iniReader.ReadFloat("SearchLights", "SearchlightEffectVisibilityFactor", 0.4f); - SmoothEffect = iniReader.ReadInteger("SearchLights", "SmoothEffect", 1); - - EnableDrawDistanceChanger = iniReader.ReadInteger("DrawDistanceChanger", "Enable", 0); - MinDrawDistanceOnTheGround = iniReader.ReadFloat("DrawDistanceChanger", "MinDrawDistanceOnTheGround", 800.0f); - Factor1 = iniReader.ReadFloat("DrawDistanceChanger", "Factor1", 2.0f); - Factor2 = iniReader.ReadFloat("DrawDistanceChanger", "Factor2", 1.0f); - StaticSunSize = iniReader.ReadFloat("DrawDistanceChanger", "StaticSunSize", 20.0f); - - AdaptiveDrawDistanceEnabled = iniReader.ReadInteger("AdaptiveDrawDistance", "Enable", 0); - MinFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MinFPSValue", 0); - MaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); - MaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); - - MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0); - DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0); - bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1; - - bRandomExplosionEffects = iniReader.ReadInteger("Misc", "RandomExplosionEffects", 0) == 1; - bReplaceSmokeTrailWithBulletTrail = iniReader.ReadInteger("Misc", "ReplaceSmokeTrailWithBulletTrail", 0) == 1; - - LoadDatFile(); - if (bRenderLodLights) - { - RegisterAllLampposts(); - RegisterCustomCoronas(); - } - - ApplyMemoryPatches(); - - //delete pFileContent; - //VecEntities.clear(); + fNewFarClip = (fFactor1 / fFactor2) * (GetCamPos()->z) + fMinDrawDistanceOnTheGround; } @@ -572,25 +560,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { if (injector::address_manager::singleton().GetMajorVersion() == 1 && injector::address_manager::singleton().GetMinorVersion() == 0) { - injector::MakeJMP(0x48D4BD, CLODLightManager::VC::GenericIDEHook); - injector::MakeJMP(0x48AD96, CLODLightManager::VC::IPLDataHook1); - injector::MakeJMP(0x48AF51, CLODLightManager::VC::IPLDataHook2); - injector::MakeCALL(0x4A4D10, CLODLightManager::VC::Init); - - CIniReader iniReader(""); - if ((bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0)) == 1) - { - injector::WriteMemory(0x4DE4A7, nLevelPortland, true); - - injector::WriteMemory(0x4C8C31 + 0x1, &nLevelPortland, true); - - injector::MakeInline<0x40EEB8>([](injector::reg_pack&) - { }); - - injector::WriteMemory(0x691538, 0x4DDDDD, true); //CFileLoader::LoadMapZones((char const *)) - - injector::MakeJMP(0x4C7957, SetupBigBuildingVisibilityHook, true); //Lods in the interiors - } + CLODLightManager::VC::Init(); } } } diff --git a/VCLodLights/stdafx.cpp b/VCLodLights/stdafx.cpp deleted file mode 100644 index 925b99d..0000000 --- a/VCLodLights/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// VCLodLights.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/VCLodLights/stdafx.h b/VCLodLights/stdafx.h deleted file mode 100644 index f3a0737..0000000 --- a/VCLodLights/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/VCLodLights/targetver.h b/VCLodLights/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/VCLodLights/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/includes/CLODLightManager.cpp b/includes/CLODLightManager.cpp new file mode 100644 index 0000000..1f09da2 --- /dev/null +++ b/includes/CLODLightManager.cpp @@ -0,0 +1,139 @@ +#include "..\includes\stdafx.h" +#include "CLODLightManager.h" + +std::vector Lampposts; +std::map FileContent; +std::vector* CLODLightManager::m_pLampposts = &Lampposts; +std::map* CLODLightManager::pFileContent = &FileContent; +bool CLODLightManager::m_bCatchLamppostsNow; + +bool CLODLightManager::bRenderLodLights; +float CLODLightManager::fCoronaRadiusMultiplier; +bool CLODLightManager::bSlightlyIncreaseRadiusWithDistance; +float CLODLightManager::fCoronaFarClip; +bool CLODLightManager::autoFarClip; +char* CLODLightManager::szCustomCoronaTexturePath; +bool CLODLightManager::bRenderStaticShadowsForLODs; +bool CLODLightManager::bIncreasePedsCarsShadowsDrawDistance; +float CLODLightManager::fStaticShadowsIntensity, CLODLightManager::fStaticShadowsDrawDistance; +float CLODLightManager::fTrafficLightsShadowsIntensity, CLODLightManager::fTrafficLightsShadowsDrawDistance; +bool CLODLightManager::bRenderSearchlightEffects; +bool CLODLightManager::bRenderOnlyDuringFoggyWeather; +bool CLODLightManager::bRenderHeliSearchlights; +int CLODLightManager::nSmoothEffect; +float CLODLightManager::fSearchlightEffectVisibilityFactor; +bool CLODLightManager::bEnableDrawDistanceChanger; +float CLODLightManager::fMinDrawDistanceOnTheGround, CLODLightManager::fFactor1, CLODLightManager::fFactor2, CLODLightManager::fStaticSunSize; +bool CLODLightManager::bAdaptiveDrawDistanceEnabled; +int CLODLightManager::nMinFPSValue, CLODLightManager::nMaxFPSValue; +float CLODLightManager::fNewFarClip, CLODLightManager::fMaxPossibleDrawDistance; +float CLODLightManager::fMaxDrawDistanceForNormalObjects, CLODLightManager::fTimedObjectsDrawDistance, CLODLightManager::fNeonsDrawDistance, CLODLightManager::fLODObjectsDrawDistance; +float CLODLightManager::fGenericObjectsDrawDistance, CLODLightManager::fAllNormalObjectsDrawDistance, CLODLightManager::fVegetationDrawDistance; +bool CLODLightManager::bLoadAllBinaryIPLs, CLODLightManager::bPreloadLODs; +float CLODLightManager::fDrawDistance; +bool CLODLightManager::bRandomExplosionEffects, CLODLightManager::bReplaceSmokeTrailWithBulletTrail; + +bool CLODLightManager::IsModelALamppost(unsigned short nModel) +{ + auto it = pFileContent->lower_bound(PackKey(nModel, 0)); + return it != pFileContent->end() && it->first >> 16 == nModel; +} + +void CLODLightManager::LoadDatFile() +{ + CIniReader iniReader(""); + char* DataFilePath = iniReader.GetIniPath(); + char* tempPointer; + tempPointer = strrchr(DataFilePath, '.'); + *tempPointer = '\0'; + strcat(DataFilePath, ".dat"); + + if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) + { + unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; + + while (const char* pLine = CFileMgr::LoadLine(hFile)) + { + if (pLine[0] && pLine[0] != '#') + { + if (pLine[0] == '%') + { + nCurIndexForModel = 0; + if (strcmp(pLine, "%additional_coronas") != 0) + { + if (injector::address_manager::singleton().IsIV() || injector::address_manager::singleton().IsEFLC()) + nModel = CLODLightManager::IV::GetHashKey((char *)(pLine + 1), 0); + else + nModel = GetModelInfoUInt16(pLine + 1); + } + else + nModel = 65534; + } + else + { + float fOffsetX, fOffsetY, fOffsetZ; + unsigned int nRed, nGreen, nBlue, nAlpha; + float fCustomSize = 1.0f; + int nNoDistance = 0; + int nDrawSearchlight = 0; + int nCoronaShowMode = 0; + sscanf(pLine, "%d %d %d %d %f %f %f %f %d %d %d", &nRed, &nGreen, &nBlue, &nAlpha, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nCoronaShowMode, &nNoDistance, &nDrawSearchlight); + pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast(nRed), static_cast(nGreen), static_cast(nBlue), static_cast(nAlpha)), fCustomSize, nCoronaShowMode, nNoDistance, nDrawSearchlight, 0.0f))); + } + } + } + + m_bCatchLamppostsNow = true; + CFileMgr::CloseFile(hFile); + } + else + { + bRenderLodLights = 0; + bRenderSearchlightEffects = 0; + } +} + +bool CLODLightManager::IsBlinkingNeeded(int BlinkType) +{ + signed int nOnDuration = 0; + signed int nOffDuration = 0; + + switch (BlinkType) + { + case BlinkTypes::DEFAULT: + return false; + case BlinkTypes::RANDOM_FLASHING: + nOnDuration = 500; + nOffDuration = 500; + break; + case BlinkTypes::T_1S_ON_1S_OFF: + nOnDuration = 1000; + nOffDuration = 1000; + break; + case BlinkTypes::T_2S_ON_2S_OFF: + nOnDuration = 2000; + nOffDuration = 2000; + break; + case BlinkTypes::T_3S_ON_3S_OFF: + nOnDuration = 3000; + nOffDuration = 3000; + break; + case BlinkTypes::T_4S_ON_4S_OFF: + nOnDuration = 4000; + nOffDuration = 4000; + break; + case BlinkTypes::T_5S_ON_5S_OFF: + nOnDuration = 5000; + nOffDuration = 5000; + break; + case BlinkTypes::T_6S_ON_4S_OFF: + nOnDuration = 6000; + nOffDuration = 4000; + break; + default: + return false; + } + + return CTimer::m_snTimeInMillisecondsPauseMode % (nOnDuration + nOffDuration) < nOnDuration; +} + diff --git a/includes/CLODLightManager.h b/includes/CLODLightManager.h index 05531d4..88d589b 100644 --- a/includes/CLODLightManager.h +++ b/includes/CLODLightManager.h @@ -1,58 +1,33 @@ -#pragma once -#include -#include -#include -#include -#include "General.h" -#include "Camera.h" -#include "..\includes\injector\injector.hpp" -#include "..\includes\injector\hooking.hpp" -#include "..\includes\injector\calling.hpp" -#include "..\includes\injector\assembly.hpp" -#include "IniReader.h" +#ifndef __CLODLightManager +#define __CLODLightManager -int bRenderLodLights, AdaptiveDrawDistanceEnabled; -float CoronaRadiusMultiplier; -float CoronaFarClip; -float DrawDistance; -float MaxDrawDistanceForNormalObjects; -float TimedObjectsDrawDistance; -float LODObjectsDrawDistance; -float GenericObjectsDrawDistance; -float AllNormalObjectsDrawDistance; -float VegetationDrawDistance; -bool bLoadAllBinaryIPLs, bPreloadLODs; -int RenderStaticShadowsForLODs, IncreasePedsCarsShadowsDrawDistance; -float TrafficLightsShadowsIntensity, TrafficLightsShadowsDrawDistance; -float StaticShadowsIntensity, StaticShadowsDrawDistance; -char* szCustomCoronaTexturePath; -DWORD nCoronasLimit; -uintptr_t hookJmpAddr, hookJmpAddr2; -int currentCamera; -int RenderSearchlightEffects, SmoothEffect; -float fOne = 1.0f; -float fSearchlightEffectVisibilityFactor; -float fSpotlightColorFactor = 255.0f; -int EnableDrawDistanceChanger; -float MinDrawDistanceOnTheGround, Factor1, Factor2, StaticSunSize; -float fNewFarClip, MaxPossibleDrawDistance; -bool autoFarClip, SlightlyIncreaseRadiusWithDistance; -int MinFPSValue, MaxFPSValue; -bool bRandomExplosionEffects, bReplaceSmokeTrailWithBulletTrail; -std::vector ExplosionTypes; +enum BlinkTypes +{ + DEFAULT, + RANDOM_FLASHING, + T_1S_ON_1S_OFF, + T_2S_ON_2S_OFF, + T_3S_ON_3S_OFF, + T_4S_ON_4S_OFF, + T_5S_ON_5S_OFF, + T_6S_ON_4S_OFF +}; -__int16 TempBufferRenderIndexList[4096]; -RxObjSpace3dVertex TempVertexBuffer[500]; -int TempBufferIndicesStored = 0; -unsigned int TempBufferVerticesStored = 0; -static int nLevelPortland = 1; -static auto CPopulationDealWithZoneChange = injector::cstd::call<0x4F6200>; -static auto LoadCollisionFile1 = injector::cstd::call<0x476520>; -static auto sub_595BD0 = injector::cstd::call<0x595BD0>; +class CLamppostInfo +{ +public: + CVector vecPos; + CRGBA colour; + float fCustomSizeMult; + int nNoDistance; + int nDrawSearchlight; + float fHeading; + int nCoronaShowMode; -typedef struct { float X, Y, Z; } Vector3; -#define RwV3D RwV3d -float GetDistance(RwV3D *v1, RwV3D *v2); + CLamppostInfo(const CVector& pos, const CRGBA& col, float fCustomMult, int CoronaShowMode, int nNoDistance, int nDrawSearchlight, float heading) + : vecPos(pos), colour(col), fCustomSizeMult(fCustomMult), nCoronaShowMode(CoronaShowMode), nNoDistance(nNoDistance), nDrawSearchlight(nDrawSearchlight), fHeading(heading) + {} +}; struct WplInstance { @@ -70,43 +45,82 @@ struct WplInstance float Unknown3; }; -class CLamppostInfo +class CLODLightManager { public: - CVector vecPos; - CRGBA colour; - float fCustomSizeMult; - int nNoDistance; - int nDrawSearchlight; + static std::vector* m_pLampposts; + static std::map* pFileContent; + static bool m_bCatchLamppostsNow; public: - CLamppostInfo(const CVector& pos, const CRGBA& col, float fCustomMult, int nNoDistance, int nDrawSearchlight) - : vecPos(pos), colour(col), fCustomSizeMult(fCustomMult), nNoDistance(nNoDistance), nDrawSearchlight(nDrawSearchlight) - {} -}; + static bool bRenderLodLights; + static float fCoronaRadiusMultiplier; + static bool bSlightlyIncreaseRadiusWithDistance; + static float fCoronaFarClip; + static bool autoFarClip; + static char* szCustomCoronaTexturePath; + static bool bRenderStaticShadowsForLODs; + static bool bIncreasePedsCarsShadowsDrawDistance; + static float fStaticShadowsIntensity, fStaticShadowsDrawDistance; + static float fTrafficLightsShadowsIntensity, fTrafficLightsShadowsDrawDistance; + static bool bRenderSearchlightEffects; + static bool bRenderOnlyDuringFoggyWeather; + static bool bRenderHeliSearchlights; + static int nSmoothEffect; + static float fSearchlightEffectVisibilityFactor; + static bool bEnableDrawDistanceChanger; + static float fMinDrawDistanceOnTheGround, fFactor1, fFactor2, fStaticSunSize; + static bool bAdaptiveDrawDistanceEnabled; + static int nMinFPSValue, nMaxFPSValue; + static float fNewFarClip, fMaxPossibleDrawDistance; + static float fMaxDrawDistanceForNormalObjects, fTimedObjectsDrawDistance, fNeonsDrawDistance, fLODObjectsDrawDistance; + static float fGenericObjectsDrawDistance, fAllNormalObjectsDrawDistance, fVegetationDrawDistance; + static bool bLoadAllBinaryIPLs, bPreloadLODs; + static float fDrawDistance; + static bool bRandomExplosionEffects, bReplaceSmokeTrailWithBulletTrail; + + static int* ActiveInterior; + static char* CurrentTimeHours; + static char* CurrentTimeMinutes; + static float** fCurrentFarClip; + static RwTexture* gpCustomCoronaTexture; -class CLODLightManager -{ -private: - static std::vector* m_pLampposts; - static std::map* pFileContent; - static bool m_bCatchLamppostsNow; - - static bool IsModelALamppost(unsigned short nModel); - - static inline bool LampsRegisteringOn() - { - return m_bCatchLamppostsNow; - } - static inline void EndRegistering() + static inline unsigned short GetModelInfoUInt16(const char* pName) { - m_bCatchLamppostsNow = false; m_pLampposts->shrink_to_fit(); + static int* (__cdecl *GetModelInfoSA)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x4C5940; + static int* (__cdecl *GetModelInfoVC)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x55F7D0; + static int* (__cdecl *GetModelInfoIII)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x50B860; + int nID = 0; + auto gvm = injector::address_manager::singleton(); + if (gvm.IsSA()) + GetModelInfoSA(pName, &nID); + else + if (gvm.IsVC()) + GetModelInfoVC(pName, &nID); + else + GetModelInfoIII(pName, &nID); + + return static_cast(nID); } + static inline unsigned int PackKey(unsigned short nModel, unsigned short nIndex) { return nModel << 16 | nIndex; } + static inline float GetDistance(RwV3D *v1, RwV3D *v2) + { + RwV3D v3; + v3.x = v2->x - v1->x; + v3.y = v2->y - v1->y; + v3.z = v2->z - v1->z; + return sqrt(v3.x * v3.x + v3.y * v3.y + v3.z * v3.z); + } + + static bool IsModelALamppost(unsigned short nModel); + static void LoadDatFile(); + static bool IsBlinkingNeeded(int BlinkType); + public: class III; class VC; @@ -115,199 +129,106 @@ class CLODLightManager class EFLC; }; -class CLODLightManager::III : public CLODLightManager +class CLODLightManager::SA : public CLODLightManager { -private: - static char* CurrentTimeHours; - static char* CurrentTimeMinutes; - static float** fCurrentFarClip; - static char* DataFilePath; - static std::vector VecEntities; - public: static void Init(); - static void GenericIDEHook(); - static void IPLDataHook1(); - static void IPLDataHook2(); - static void LoadDatFile(); - -private: static void ApplyMemoryPatches(); static void RegisterCustomCoronas(); - static void RegisterAllLampposts(); - static void RenderSearchLights(); - static void RenderHeliSearchLights(); - static void RegisterLamppost(CEntityIII* entity); + static CEntity* PossiblyAddThisEntity(CEntity* pEntity); + static void RegisterLamppost(CEntity* pObj); + static void RegisterLODLights(); static void DrawDistanceChanger(); - static void RenderLODLights(); - static int* (__cdecl *GetModelInfo)(const char*, int*); static char (__cdecl *GetIsTimeInRange)(char hourA, char hourB); + static int* (__cdecl *GetModelInfo)(const char*, int*); + static void (__cdecl *const CShadowsUpdateStaticShadows)(); static bool (__cdecl *const CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist); static float (__cdecl *FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject); - static RwV3D* (__cdecl *TransformPoint)(struct RwV3D *, struct RwMatrix *, struct RwV3D *); - static bool (__thiscall *CCameraIsSphereVisible)(int *camera, RwV3D *origin, float radius); - static void (__cdecl *RegisterCorona)(int coronaID, char r, char g, char b, char a, RwV3D *pos, float size, float farClip, char type, char flare, char reflection, char obstacles, char notUsed, float normalAngle); - static void (__cdecl drawCustomSpotLight)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); + static RwV3D* (__cdecl *TransformPoint)(RwV3D *outPoint, CMatrix *m, RwV3D *point); + static bool (__thiscall *CCameraIsSphereVisible)(int *camera, RwV3d *origin, float radius); + static void (__cdecl *RegisterCorona)(int id, int *vehicle, char r, char g, char b, char alpha, RwV3d *pos, float radius, float farClip, char type, char flareType, char enableReflection, char checkObstacles, int notUsed, float normalAngle, char longDistance, float nearClip, char someFadeFlag, float flashInertia, char onlyFromBelow, char flag); + + static C2dfx* (__fastcall *Get2dfx)(CBaseModelInfo *model, int edx0, int number); + static void (__cdecl *drawSpotLight)(int coronaIndex, float StartX, float StartY, float StartZ, float EndX, float EndY, float EndZ, float TargetRadius, float intensity, char flag1, char drawShadow, RwV3D *pVec1, RwV3D *pVec2, RwV3D *pVec3, char unkTrue, float BaseRadius); + static bool (__thiscall *CObjectIsDamaged)(CObject *pclObject); static void (__fastcall *CVectorNormalize)(RwV3D *in); static RwV3D* (__cdecl *CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b); static int (__cdecl *RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags); - static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices); + static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices); static int (__cdecl *RwIm3DEnd)(); - static int (__cdecl *RwRenderStateSet)(int a1, int a2); - - static inline RwV3D * GetCamPos() - { - return (RwV3D *)(0x006FACF8 + 0x770); - } - static inline unsigned short GetModelInfoUInt16(const char* pName) - { - int nID; GetModelInfo(pName, &nID); return static_cast(nID); - } }; class CLODLightManager::VC : public CLODLightManager { -private: - static char* CurrentTimeHours; - static char* CurrentTimeMinutes; - static float** fCurrentFarClip; - static char* DataFilePath; - static std::vector VecEntities; - public: static void Init(); - static void GenericIDEHook(); - static void IPLDataHook1(); - static void IPLDataHook2(); - static void LoadDatFile(); - -private: static void ApplyMemoryPatches(); - static void FillIplStringsArray(); static void RegisterCustomCoronas(); - static void RegisterAllLampposts(); - static void RenderSearchLights(); - static void RenderHeliSearchLights(); - static void RegisterLamppost(CEntityVC* entity); + static void RegisterLamppost(CEntityVC* entity); + static void RegisterLODLights(); static void DrawDistanceChanger(); - static void RenderLODLights(); static int* (__cdecl *GetModelInfo)(const char*, int*); static char (__cdecl *GetIsTimeInRange)(char hourA, char hourB); -public: static bool (__cdecl *const CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist); -private: static float (__cdecl *FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject); static RwV3D* (__cdecl *TransformPoint)(RwV3d *a1, RwV3d *a2, int a3, RwMatrix *a4); static bool CCameraIsSphereVisible(RwV3D *origin, float radius); static void (__cdecl *RegisterCorona)(int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16); - static void (__cdecl drawCustomSpotLight)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); static void (__fastcall *CVectorNormalize)(RwV3D *in); static RwV3D* (__cdecl *CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b); static int (__cdecl *RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags); - static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices); + static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices); static int (__cdecl *RwIm3DEnd)(); - static int (__cdecl *RwRenderStateSet)(int a1, int a2); - - static inline RwV3D * GetCamPos() - { - return (RwV3D *)(0x7E4688 + 0x7D8); - } - static inline unsigned short GetModelInfoUInt16(const char* pName) - { - int nID; GetModelInfo(pName, &nID); return static_cast(nID); - } + static int (__cdecl *RwRenderStateSetVC)(RwRenderState nState, void *pParam); }; -class CLODLightManager::SA : public CLODLightManager +class CLODLightManager::III : public CLODLightManager { -private: - static char* CurrentTimeHours; - static char* CurrentTimeMinutes; - static float** fCurrentFarClip; - static char* DataFilePath; - static CCamera& TheCamera; - static int* ActiveInterior; - public: static void Init(); - static void LoadDatFile(); - -private: - static void RegisterLamppost(CEntity* pObj); - static void RegisterCustomCoronas(); - static CEntity* PossiblyAddThisEntity(CEntity* pEntity); - static void RenderShadows(); - static void StoreCustomStaticShadows(); - static void RenderSearchLights(); - static bool IsModelALamppostNotTrafficLight(unsigned short nModelIndex); - static void DrawDistanceChanger(); static void ApplyMemoryPatches(); - static void RenderLODLights(); + static void RegisterCustomCoronas(); + static void RegisterLamppost(CEntityIII* entity); + static void RegisterLODLights(); + static void DrawDistanceChanger(); - static char (__cdecl *GetIsTimeInRange)(char hourA, char hourB); static int* (__cdecl *GetModelInfo)(const char*, int*); - static void (__cdecl *const CShadowsUpdateStaticShadows)(); + static char (__cdecl *GetIsTimeInRange)(char hourA, char hourB); static bool (__cdecl *const CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist); static float (__cdecl *FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject); - static RwV3D* (__cdecl *TransformPoint)(RwV3D *outPoint, CMatrix *m, RwV3D *point); - static bool (__thiscall *CCameraIsSphereVisible)(int *camera, RwV3d *origin, float radius); - static void (__cdecl *RegisterCorona)(int id, int *vehicle, char r, char g, char b, char alpha, RwV3d *pos, float radius, float farClip, char type, char flareType, char enableReflection, char checkObstacles, int notUsed, float normalAngle, char longDistance, float nearClip, char someFadeFlag, float flashInertia, char onlyFromBelow, char flag); - - static C2dfx* (__fastcall *CLODLightManager::SA::Get2dfx)(CBaseModelInfo *model, int edx0, int number); - static void (__cdecl *CLODLightManager::SA::drawSpotLight)(int coronaIndex, float StartX, float StartY, float StartZ, float EndX, float EndY, float EndZ, float TargetRadius, float intensity, char flag1, char drawShadow, RwV3D *pVec1, RwV3D *pVec2, RwV3D *pVec3, char unkTrue, float BaseRadius); - static bool (__thiscall *CLODLightManager::SA::CObjectIsDamaged)(CObject *pclObject); - static void (__cdecl drawCustomSpotLight)(RwV3D StartPoint, RwV3D EndPoint, float TargetRadius, float baseRadius, float slColorFactor1, char slColorFactor2, float slAlpha = 1.0f); + static RwV3D* (__cdecl *TransformPoint)(RwV3D *, RwMatrix *, RwV3D *); + static bool (__thiscall *CCameraIsSphereVisible)(int *camera, RwV3D *origin, float radius); + static void (__cdecl *RegisterCorona)(int coronaID, char r, char g, char b, char a, RwV3D *pos, float size, float farClip, char type, char flare, char reflection, char obstacles, char notUsed, float normalAngle); static void (__fastcall *CVectorNormalize)(RwV3D *in); static RwV3D* (__cdecl *CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b); static int (__cdecl *RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags); - static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices); + static int (__cdecl *RwIm3DRenderIndexedPrimitive)(int primType, short *indices, int numIndices); static int (__cdecl *RwIm3DEnd)(); -public: - static inline void Shutdown() - { - delete m_pLampposts; - } - static inline unsigned short GetModelInfoUInt16(const char* pName) - { - int nID; GetModelInfo(pName, &nID); return static_cast(nID); - } + static int (__cdecl *RwRenderStateSetIII)(RwRenderState nState, void *pParam); }; class CLODLightManager::IV : public CLODLightManager { -private: - static char* CurrentTimeHours; - static char* CurrentTimeMinutes; - static char* DataFilePath; - - public: - static bool IsModelALamppost(unsigned int nModel); - - static int (__cdecl *DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); - static void (__stdcall *GetRootCam)(int *camera); - static void (__stdcall *GetGameCam)(int *camera); - static bool (__cdecl *CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); - static void (__cdecl *GetCamPos)(int camera, float *pX, float *pY, float *pZ); - public: - static void Init(); + static void Init(); + static void GetMemoryAddresses(); + static void IncreaseCoronaLimit(); + static void RegisterCustomCoronas(); + static WplInstance* PossiblyAddThisEntity(WplInstance * pInstance); + static void RegisterLamppost(WplInstance * pObj); + static void RegisterLODLights(); -private: - static void GetMemoryAddresses(); - static void IncreaseCoronaLimit(); - static void LoadDatFile(); - static void RenderLODLights(); - static void LoadObjectInstanceHook(); -public: - static inline unsigned int PackKey(unsigned int nModel, unsigned short nIndex) - { - return nModel | nIndex; - } + static int (__cdecl *DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); + static int (__cdecl *DrawCorona2)(int id, char r, char g, char b, float a5, CVector* pos, float radius, float a8, float a9, int a10, float a11, char a12, char a13, int a14); + static void (__stdcall *GetRootCam)(int *camera); + static void (__stdcall *GetGameCam)(int *camera); + static bool (__cdecl *CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); + static void (__cdecl *GetCamPos)(int camera, float *pX, float *pY, float *pZ); - static inline unsigned int GetHashKey(char *str, unsigned int a2) + static unsigned int GetHashKey(char *str, unsigned int a2) { unsigned int v2; char *temp; @@ -333,344 +254,11 @@ class CLODLightManager::IV : public CLODLightManager } return 32769 * (9 * v2 ^ (9 * v2 >> 11)); } - - static inline void RegisterLamppost(WplInstance* pObj) - { - DWORD nModelID = pObj->ModelNameHash; - CMatrix dummyMatrix; - CSimpleTransform objTransform; - - objTransform.m_translate.x = pObj->PositionX; - objTransform.m_translate.y = pObj->PositionY; - objTransform.m_translate.z = pObj->PositionZ; - - if (objTransform.m_translate.x == 0.0f && objTransform.m_translate.y == 0.0f) - return; - - if (GetDistance((RwV3d*)&objTransform.m_translate, (RwV3d*)&CVector(-278.37f, -1377.48f, 90.98f)) <= 300.0f) - return; - - dummyMatrix.SetTranslateOnly(objTransform.m_translate.x, objTransform.m_translate.y, objTransform.m_translate.z); - dummyMatrix.SetRotateZOnly(objTransform.m_heading); - - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(dummyMatrix * it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); - } - - static inline void RegisterCustomCoronas() - { - DWORD nModelID = 4294967294; - - auto itEnd = pFileContent->upper_bound(PackKey(nModelID, 0xFFFF)); - for (auto it = pFileContent->lower_bound(PackKey(nModelID, 0)); it != itEnd; it++) - m_pLampposts->push_back(CLamppostInfo(it->second.vecPos, it->second.colour, it->second.fCustomSizeMult, it->second.nNoDistance, it->second.nDrawSearchlight)); - } - - static inline WplInstance* PossiblyAddThisEntity(WplInstance* pInstance) - { - if (m_bCatchLamppostsNow && IsModelALamppost(pInstance->ModelNameHash)) - RegisterLamppost(pInstance); - - return pInstance; - } }; class CLODLightManager::EFLC : public CLODLightManager::IV { -public: - static char* CurrentTimeHours; - static char* CurrentTimeMinutes; - static char* DataFilePath; - static int (__cdecl *DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); - static void (__stdcall *GetRootCam)(int *camera); - static void (__stdcall *GetGameCam)(int *camera); - static bool (__cdecl *CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); - static void (__cdecl *GetCamPos)(int camera, float *pX, float *pY, float *pZ); - - static void RenderLODLights(); }; -std::map* CLODLightManager::pFileContent; -std::vector* CLODLightManager::m_pLampposts = nullptr; -std::vector CLODLightManager::VC::VecEntities; -std::vector CLODLightManager::III::VecEntities; -bool CLODLightManager::m_bCatchLamppostsNow = false; - -bool CLODLightManager::IsModelALamppost(unsigned short nModel) -{ - auto it = pFileContent->lower_bound(PackKey(nModel, 0)); - return it != pFileContent->end() && it->first >> 16 == nModel; -} - -bool CLODLightManager::IV::IsModelALamppost(unsigned int nModel) -{ - auto it = pFileContent->lower_bound(PackKey(nModel, 0)); - return it != pFileContent->end() && it->first == nModel; -} - -char* CLODLightManager::III::CurrentTimeHours = (char*)0x95CDA6; -char* CLODLightManager::III::CurrentTimeMinutes = (char*)0x95CDC8; -float** CLODLightManager::III::fCurrentFarClip = (float**)0x48E5DC; -char* CLODLightManager::III::DataFilePath; -char(__cdecl *CLODLightManager::III::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x473420; -int* (__cdecl *CLODLightManager::III::GetModelInfo)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x50B860; -bool(__cdecl *const CLODLightManager::III::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CLODLightManager::III::CShadowsStoreStaticShadow))0x5130A0; -float(__cdecl *CLODLightManager::III::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x4B3AE0; -RwV3D* (__cdecl *CLODLightManager::III::TransformPoint)(struct RwV3D *, struct RwMatrix *, struct RwV3D *) = (struct RwV3D *(__cdecl *)(struct RwV3D *, struct RwMatrix *, struct RwV3D *)) 0x4BA4D0; -bool(__thiscall *CLODLightManager::III::CCameraIsSphereVisible)(int *camera, RwV3D *origin, float radius) = (bool(__thiscall *)(int *, RwV3D *, float)) 0x0043D3B0; -void(__cdecl *CLODLightManager::III::RegisterCorona)(int coronaID, char r, char g, char b, char a, RwV3D *pos, float size, float farClip, char type, char flare, char reflection, char obstacles, char notUsed, float normalAngle) = (void(__cdecl *)(int, char, char, char, char, RwV3D *, float, float, char, char, char, char, char, float)) 0x4FA080; -void(__fastcall *CLODLightManager::III::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x4BA560; -RwV3D *(__cdecl *CLODLightManager::III::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x4BA350; -int(__cdecl *CLODLightManager::III::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x5B6720; -int(__cdecl *CLODLightManager::III::RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices) = (int(__cdecl *)(int primType, __int16 *indices, int numIndices)) 0x5B6820; -int(__cdecl *CLODLightManager::III::RwIm3DEnd)() = (int(__cdecl *)()) 0x5B67F0; -int(__cdecl *CLODLightManager::III::RwRenderStateSet)(int a1, int a2) = (int(__cdecl *)(int a1, int a2)) 0x5A43C0; - - -char* CLODLightManager::VC::CurrentTimeHours = (char*)0xA10B6B; -char* CLODLightManager::VC::CurrentTimeMinutes = (char*)0xA10B92; -float** CLODLightManager::VC::fCurrentFarClip = (float**)0x4A602D; -char* CLODLightManager::VC::DataFilePath; -char (__cdecl *CLODLightManager::VC::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x4870F0; -int* (__cdecl *CLODLightManager::VC::GetModelInfo)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x55F7D0; -bool(__cdecl *const CLODLightManager::VC::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CLODLightManager::VC::CShadowsStoreStaticShadow))0x56E780; -float(__cdecl *CLODLightManager::VC::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x4D53A0; -RwV3D* (__cdecl *CLODLightManager::VC::TransformPoint)(RwV3d *a1, RwV3d *a2, int a3, RwMatrix *a4) = (struct RwV3D *(__cdecl *)(RwV3d *a1, RwV3d *a2, int a3, RwMatrix *a4)) 0x647160; -bool CLODLightManager::VC::CCameraIsSphereVisible(RwV3D *origin, float radius) -{ - RwV3D SpherePos; - SpherePos.x = origin->x; - SpherePos.y = origin->y; - SpherePos.z = origin->z; - if (origin->z <= *(float *)0x688640) - SpherePos.z = FindGroundZFor3DCoord(origin->x, origin->y, origin->z, false, false); - TransformPoint(&SpherePos, &SpherePos, 1, (RwMatrix*)0x7E4EA8); - - if (SpherePos.y + radius >= *(float *)0x978534) - { - if (SpherePos.y - radius <= *(float *)0xA10678) - { - if (SpherePos.y * *(float *)0x7E4F44 + SpherePos.x * *(float *)0x7E4F40 <= radius) - { - if (SpherePos.y * *(float *)0x7E4F50 + SpherePos.x * *(float *)0x7E4F4C <= radius) - { - if (SpherePos.z * *(float *)0x7E4F60 + SpherePos.y * *(float *)0x7E4F5C <= radius) - { - if (SpherePos.z * *(float *)0x7E4F6C + SpherePos.y * *(float *)0x7E4F68 <= radius) - return true; - } - } - } - } - } - return false; -} -void(__cdecl *CLODLightManager::VC::RegisterCorona)(int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16) = (void(__cdecl *)(int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16)) 0x5427A0; -void(__fastcall *CLODLightManager::VC::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x4DFEA0; -RwV3D *(__cdecl *CLODLightManager::VC::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x4E00B0; -int(__cdecl *CLODLightManager::VC::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x65AE90; -int(__cdecl *CLODLightManager::VC::RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices) = (int(__cdecl *)(int primType, __int16 *indices, int numIndices)) 0x65AF90; -int(__cdecl *CLODLightManager::VC::RwIm3DEnd)() = (int(__cdecl *)()) 0x65AF60; -int(__cdecl *CLODLightManager::VC::RwRenderStateSet)(int a1, int a2) = (int(__cdecl *)(int a1, int a2)) 0x649BA0; - - - -char* CLODLightManager::SA::CurrentTimeHours = (char*)0xB70153; -char* CLODLightManager::SA::CurrentTimeMinutes = (char*)0xB70152; -float** CLODLightManager::SA::fCurrentFarClip = (float**)0x53EA95; -char* CLODLightManager::SA::DataFilePath; -CCamera& CLODLightManager::SA::TheCamera = *(CCamera*)0xB6F028; -int* CLODLightManager::SA::ActiveInterior = (int*)0xB72914; -char(__cdecl *CLODLightManager::SA::GetIsTimeInRange)(char hourA, char hourB) = (char(__cdecl *)(char, char)) 0x52CEE0; -int* (__cdecl *CLODLightManager::SA::GetModelInfo)(const char*, int*) = (int*(__cdecl *)(const char*, int*)) 0x4C5940; -void(__cdecl *const CLODLightManager::SA::CShadowsUpdateStaticShadows)() = (decltype(CShadowsUpdateStaticShadows))0x707F40; -bool(__cdecl *const CLODLightManager::SA::CShadowsStoreStaticShadow)(unsigned int id, unsigned char type, RwTexture *particle, CVector *pos, float x1, float y1, float x2, float y2, short alpha, unsigned char red, unsigned char green, unsigned char blue, float, float, float drawdist, bool lifetime, float updist) = (decltype(CShadowsStoreStaticShadow))0x70BA00; -float(__cdecl *CLODLightManager::SA::FindGroundZFor3DCoord)(float x, float y, float z, BOOL *pCollisionResult, CEntity **pGroundObject) = (float(__cdecl *)(float, float, float, BOOL *, CEntity **)) 0x5696C0; -RwV3D *(__cdecl *CLODLightManager::SA::TransformPoint)(RwV3D *outPoint, CMatrix *m, RwV3D *point) = (RwV3D *(__cdecl *)(RwV3D *, CMatrix *, RwV3D *)) 0x59C890; -bool(__thiscall *CLODLightManager::SA::CCameraIsSphereVisible)(int *camera, RwV3d *origin, float radius) = (bool(__thiscall *)(int *, RwV3d *, float)) 0x00420D40; -void(__cdecl *CLODLightManager::SA::RegisterCorona)(int id, int *vehicle, char r, char g, char b, char alpha, RwV3d *pos, float radius, float farClip, char type, char flareType, char enableReflection, char checkObstacles, int notUsed, float normalAngle, char longDistance, float nearClip, char someFadeFlag, float flashInertia, char onlyFromBelow, char flag) = (void(__cdecl *)(int, int *, char, char, char, char, RwV3d *, float, float, char, char, char, char, int, float, char, float, char, float, char, char)) 0x6FC580; -void(__fastcall *CLODLightManager::SA::CVectorNormalize)(RwV3D *in) = (void(__fastcall *)(RwV3D *in)) 0x59C910; -RwV3D *(__cdecl *CLODLightManager::SA::CrossProduct)(RwV3D *out, RwV3D *a, RwV3D *b) = (RwV3D *(__cdecl *)(RwV3D *out, RwV3D *a, RwV3D *b)) 0x59C730; -int(__cdecl *CLODLightManager::SA::RwIm3DTransform)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags) = (int(__cdecl *)(RxObjSpace3dVertex *pVerts, unsigned int numVerts, RwMatrix *ltm, unsigned int flags)) 0x7EF450; -int(__cdecl *CLODLightManager::SA::RwIm3DRenderIndexedPrimitive)(int primType, __int16 *indices, int numIndices) = (int(__cdecl *)(int primType, __int16 *indices, int numIndices)) 0x7EF550; -int(__cdecl *CLODLightManager::SA::RwIm3DEnd)() = (int(__cdecl *)()) 0x7EF520; -C2dfx *(__fastcall *CLODLightManager::SA::Get2dfx)(CBaseModelInfo *model, int edx0, int number) = (C2dfx *(__fastcall *)(CBaseModelInfo *, int, int)) 0x4C4C70; -void(__cdecl *CLODLightManager::SA::drawSpotLight)(int coronaIndex, float StartX, float StartY, float StartZ, float EndX, float EndY, float EndZ, float TargetRadius, float intensity, char flag1, char drawShadow, RwV3D *pVec1, RwV3D *pVec2, RwV3D *pVec3, char unkTrue, float BaseRadius) = (void(cdecl *)(int, float, float, float, float, float, float, float, float, char, char, RwV3D *, RwV3D *, RwV3D *, char, float)) 0x6C58E0; -bool(__thiscall *CLODLightManager::SA::CObjectIsDamaged)(CObject *pclObject) = (bool(__thiscall *)(CObject *))0x0046A2F0; -float GetDistance(RwV3D *v1, RwV3D *v2) -{ - RwV3D v3; - v3.x = v2->x - v1->x; - v3.y = v2->y - v1->y; - v3.z = v2->z - v1->z; - return sqrt(v3.x * v3.x + v3.y * v3.y + v3.z * v3.z); -} - -RwV3D * GetCamPos() -{ - return (RwV3D *)(0xB6F338 + (*(BYTE *)0xB6F081 * 0x238)); -} -short MTraffic1, MTraffic2, MTraffic3, MTraffic4, trafficlight1, VGSSTRIPTLIGHTS1, CJ_TRAFFIC_LIGHT3; -short CJ_TRAFFIC_LIGHT4, GAY_TRAFFIC_LIGHT, Streetlamp1, Streetlamp2, Gay_lamppost, bollardlight; -bool CLODLightManager::SA::IsModelALamppostNotTrafficLight(unsigned short nModelIndex) -{ - if (!MTraffic1) - { - MTraffic1 = GetModelInfoUInt16("MTraffic1"); - MTraffic2 = GetModelInfoUInt16("MTraffic2"); - MTraffic3 = GetModelInfoUInt16("MTraffic3"); - MTraffic4 = GetModelInfoUInt16("MTraffic4"); - trafficlight1 = GetModelInfoUInt16("trafficlight1"); - VGSSTRIPTLIGHTS1 = GetModelInfoUInt16("VGSSTRIPTLIGHTS1"); - CJ_TRAFFIC_LIGHT3 = GetModelInfoUInt16("CJ_TRAFFIC_LIGHT3"); - CJ_TRAFFIC_LIGHT4 = GetModelInfoUInt16("CJ_TRAFFIC_LIGHT4"); - GAY_TRAFFIC_LIGHT = GetModelInfoUInt16("GAY_TRAFFIC_LIGHT"); - Streetlamp1 = GetModelInfoUInt16("Streetlamp1"); - Streetlamp2 = GetModelInfoUInt16("Streetlamp2"); - Gay_lamppost = GetModelInfoUInt16("Gay_lamppost"); - bollardlight = GetModelInfoUInt16("bollardlight"); - } - - if (nModelIndex != MTraffic1 - && nModelIndex != MTraffic2 - && nModelIndex != MTraffic3 - && nModelIndex != MTraffic4 - && nModelIndex != trafficlight1 - && nModelIndex != VGSSTRIPTLIGHTS1 - && nModelIndex != CJ_TRAFFIC_LIGHT3) - { - return true; - } - return false; -} - -enum SShadType -{ - SSHADT_NONE, - SSHADT_DEFAULT, // SSHAD_RM_COLORONLY (shad_car, shad_ped, shad_heli, shad_bike, shad_rcbaron, bloodpool_64, wincrack_32, lamp_shad_64) - SSHADT_INTENSIVE, // SSHAD_RM_OVERLAP (shad_exp, headlight, headlight1, handman) - SSHADT_NEGATIVE, // SSHAD_RM_INVCOLOR - SSHADT4, // SSHAD_RM_COLORONLY - SSHADT5, // SSHAD_RM_COLORONLY - SSHADT6, // SSHAD_RM_COLORONLY - SSHADT8 = 8 // SSHAD_RM_COLORONLY -}; - -enum SShadRenderMode -{ - SSHAD_RM_NONE, // Shadow type: <0, 0, >8. - SSHAD_RM_COLORONLY, // Shadow type: 1, 4, 5, 6, 8. The texture alpha is present if the alpha channel is set. - SSHAD_RM_OVERLAP, // Shadow type: 2. Any shadow alpha greater than 0 does not make any difference. - SSHAD_RM_INVCOLOR // Shadow type: 3. Same tip above goes here. -}; - -static RwTexture* gpCustomCoronaTexture = nullptr; -RwImage*(__cdecl *const RtPNGImageRead)(const char* imageName) = (decltype(RtPNGImageRead))0x7CF9B0; -RwImage*(__cdecl *const RwImageFindRasterFormat)(RwImage* ipImage, int nRasterType, int* npWidth, int* npHeight, int* npDepth, int* npFormat) = (decltype(RwImageFindRasterFormat))0x8042C0; -RwRaster*(__cdecl *const RwRasterCreate)(int width, int height, int depth, int flags) = (decltype(RwRasterCreate))0x7FB230; -RwRaster*(__cdecl *const RwRasterSetFromImage)(RwRaster* raster, RwImage* image) = (decltype(RwRasterSetFromImage))0x804290; -RwTexture*(__cdecl *const RwTextureCreate)(RwRaster* raster) = (decltype(RwTextureCreate))0x7F37C0; -bool*(__cdecl *const RwImageDestroy)(RwImage* image) = (decltype(RwImageDestroy))0x802740; -RwTexture* CPNGFileReadFromFile(const char* pFileName) -{ - RwTexture* pTexture = nullptr; - - if (RwImage* pImage = RtPNGImageRead(pFileName)) - { - int dwWidth, dwHeight, dwDepth, dwFlags; - RwImageFindRasterFormat(pImage, 4/*rwRASTERTYPETEXTURE*/, &dwWidth, &dwHeight, &dwDepth, &dwFlags); - if (RwRaster* pRaster = RwRasterCreate(dwWidth, dwHeight, dwDepth, dwFlags)) - { - RwRasterSetFromImage(pRaster, pImage); - - pTexture = RwTextureCreate(pRaster); - } - RwImageDestroy(pImage); - } - return pTexture; -} - -std::vector IPLStreamNames = { "LAE_STREAM0", "LAE_STREAM1", "LAE_STREAM2", "LAE_STREAM3", "LAE_STREAM4", "LAE_STREAM5", -"LAE2_STREAM0", "LAE2_STREAM1", "LAE2_STREAM2", "LAE2_STREAM3", "LAE2_STREAM4", "LAE2_STREAM5", "LAE2_STREAM6", "LAHILLS_STREAM0", -"LAHILLS_STREAM1", "LAHILLS_STREAM2", "LAHILLS_STREAM3", "LAHILLS_STREAM4", "LAN_STREAM0", "LAN_STREAM1", "LAN_STREAM2", "LAN2_STREAM0", -"LAN2_STREAM1", "LAN2_STREAM2", "LAN2_STREAM3", "LAS_STREAM0", "LAS_STREAM1", "LAS_STREAM2", "LAS_STREAM3", "LAS_STREAM4", "LAS_STREAM5", -"LAS2_STREAM0", "LAS2_STREAM1", "LAS2_STREAM2", "LAS2_STREAM3", "LAS2_STREAM4", "LAW_STREAM0", "LAW_STREAM1", "LAW_STREAM2", "LAW_STREAM3", "LAW_STREAM4", -"LAW_STREAM5", "LAW2_STREAM0", "LAW2_STREAM1", "LAW2_STREAM2", "LAW2_STREAM3", "LAW2_STREAM4", "LAWN_STREAM0", "LAWN_STREAM1", "LAWN_STREAM2", "LAWN_STREAM3", -"COUNTN2_STREAM0", "COUNTN2_STREAM1", "COUNTN2_STREAM2", "COUNTN2_STREAM3", "COUNTN2_STREAM4", "COUNTN2_STREAM5", "COUNTN2_STREAM6", "COUNTN2_STREAM7", "COUNTN2_STREAM8", -"COUNTRYE_STREAM0", "COUNTRYE_STREAM1", "COUNTRYE_STREAM2", "COUNTRYE_STREAM3", "COUNTRYE_STREAM4", "COUNTRYE_STREAM5", "COUNTRYE_STREAM6", "COUNTRYE_STREAM7", "COUNTRYE_STREAM8", -"COUNTRYE_STREAM9", "COUNTRYN_STREAM0", "COUNTRYN_STREAM1", "COUNTRYN_STREAM2", "COUNTRYN_STREAM3", "COUNTRYS_STREAM0", "COUNTRYS_STREAM1", "COUNTRYS_STREAM2", "COUNTRYS_STREAM3", "COUNTRYS_STREAM4", -"COUNTRYW_STREAM0", "COUNTRYW_STREAM1", "COUNTRYW_STREAM2", "COUNTRYW_STREAM3", "COUNTRYW_STREAM4", "COUNTRYW_STREAM5", "COUNTRYW_STREAM6", "COUNTRYW_STREAM7", "COUNTRYW_STREAM8", "SFE_STREAM0", -"SFE_STREAM1", "SFE_STREAM2", "SFE_STREAM3", "SFN_STREAM0", "SFN_STREAM1", "SFN_STREAM2", "SFS_STREAM0", "SFS_STREAM1", "SFS_STREAM2", "SFS_STREAM3", "SFS_STREAM4", "SFS_STREAM5", "SFS_STREAM6", -"SFS_STREAM7", "SFS_STREAM8", "SFSE_STREAM0", "SFSE_STREAM1", "SFSE_STREAM2", "SFSE_STREAM3", "SFSE_STREAM4", "SFSE_STREAM5", "SFSE_STREAM6", "SFW_STREAM0", "SFW_STREAM1", "SFW_STREAM2", "SFW_STREAM3", -"SFW_STREAM4", "SFW_STREAM5", "VEGASE_STREAM0", "VEGASE_STREAM1", "VEGASE_STREAM2", "VEGASE_STREAM3", "VEGASE_STREAM4", "VEGASE_STREAM5", "VEGASE_STREAM6", "VEGASE_STREAM7", "VEGASE_STREAM8", -"VEGASN_STREAM0", "VEGASN_STREAM1", "VEGASN_STREAM2", "VEGASN_STREAM3", "VEGASN_STREAM4", "VEGASN_STREAM5", "VEGASN_STREAM6", "VEGASN_STREAM7", "VEGASN_STREAM8", "VEGASS_STREAM0", "VEGASS_STREAM1", -"VEGASS_STREAM2", "VEGASS_STREAM3", "VEGASS_STREAM4", "VEGASS_STREAM5", "VEGASW_STREAM0", "VEGASW_STREAM1", "VEGASW_STREAM2", "VEGASW_STREAM3", "VEGASW_STREAM4", "VEGASW_STREAM5", "VEGASW_STREAM6", -"VEGASW_STREAM7", "VEGASW_STREAM8", "VEGASW_STREAM9" }; - -char* CLODLightManager::IV::CurrentTimeHours; -char* CLODLightManager::IV::CurrentTimeMinutes; -char* CLODLightManager::EFLC::CurrentTimeHours; -char* CLODLightManager::EFLC::CurrentTimeMinutes; -char* CLODLightManager::IV::DataFilePath; -WplInstance* pInstance; - -int(__cdecl *CLODLightManager::IV::DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); -void(__stdcall *CLODLightManager::IV::GetRootCam)(int *camera); -void(__stdcall *CLODLightManager::IV::GetGameCam)(int *camera); -bool(__cdecl *CLODLightManager::IV::CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); -void(__cdecl *CLODLightManager::IV::GetCamPos)(int camera, float *pX, float *pY, float *pZ); - -int(__cdecl *CLODLightManager::EFLC::DrawCorona)(float x, float y, float z, float radius, unsigned int unk, float unk2, unsigned char r, unsigned char g, unsigned char b); -void(__stdcall *CLODLightManager::EFLC::GetRootCam)(int *camera); -void(__stdcall *CLODLightManager::EFLC::GetGameCam)(int *camera); -bool(__cdecl *CLODLightManager::EFLC::CamIsSphereVisible)(int camera, float pX, float pY, float pZ, float radius); -void(__cdecl *CLODLightManager::EFLC::GetCamPos)(int camera, float *pX, float *pY, float *pZ); - -void CLODLightManager::IV::LoadDatFile() -{ - CIniReader iniReader(""); - DataFilePath = iniReader.GetIniPath(); - char* tempPointer; - tempPointer = strrchr(DataFilePath, '.'); - *tempPointer = '\0'; - strcat(DataFilePath, ".dat"); - - if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) - { - DWORD nModel = 0xFFFFFFFF; unsigned short nCurIndexForModel = 0; - pFileContent = new std::map; - - while (const char* pLine = CFileMgr::LoadLine(hFile)) - { - if (pLine[0] && pLine[0] != '#') - { - if (pLine[0] == '%') - { - nCurIndexForModel = 0; - if (strcmp(pLine, "%additional_coronas") != 0) - nModel = GetHashKey((char *)(pLine + 1), 0); - else - nModel = 4294967294; - } - else - { - float fOffsetX, fOffsetY, fOffsetZ; - unsigned int nRed, nGreen, nBlue; - float fCustomSize = 1.0f; - int nNoDistance = 0; - int nDrawSearchlight = 0; - - sscanf(pLine, "%f %f %f %d %d %d %f %d %d", &fOffsetX, &fOffsetY, &fOffsetZ, &nRed, &nGreen, &nBlue, &fCustomSize, &nNoDistance, &nDrawSearchlight); - pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast(nRed), static_cast(nGreen), static_cast(nBlue)), fCustomSize, nNoDistance, nDrawSearchlight))); - } - } - } - - m_pLampposts = new std::vector; - m_bCatchLamppostsNow = true; - - CFileMgr::CloseFile(hFile); - } -} \ No newline at end of file +#endif \ No newline at end of file diff --git a/includes/CLODLights.cpp b/includes/CLODLights.cpp new file mode 100644 index 0000000..948cf26 --- /dev/null +++ b/includes/CLODLights.cpp @@ -0,0 +1,315 @@ +#include "CLODLights.h" +#include "Sprite.h" + +std::map CLODLights::UsedMap; +CLODLightsLinkedListNode CLODLights::FreeList, CLODLights::UsedList; +std::vector CLODLights::aLinkedList; +std::vector CLODLights::aCoronas; + +float* CWeatherFoggyness; +RwTexture** g_TexCoronastar; +void* RwEngineInstance; +extern int numCoronas; +extern void(*_RwRenderStateSet)(RwRenderState nState, void *pParam); +extern CVector* GetCamPos(); + +void CRegisteredCorona::Update() +{ + if (!RegisteredThisFrame) + { + Intensity = 0; + } + if (!Intensity && !JustCreated) + { + Identifier = 0; + } + JustCreated = 0; + RegisteredThisFrame = 0; +} + +void CLODLights::RegisterCorona(unsigned int nID, CEntity* pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, RwTexture* pTex, unsigned char flareType, unsigned char reflectionType, unsigned char LOSCheck, unsigned char unused, float normalAngle, bool bNeonFade, float PullTowardsCam, bool bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool bWhiteCore) +{ + UNREFERENCED_PARAMETER(unused); + + CVector vecPosToCheck = Position; + CVector* pCamPos = GetCamPos(); + if (Range * Range >= (pCamPos->x - vecPosToCheck.x)*(pCamPos->x - vecPosToCheck.x) + (pCamPos->y - vecPosToCheck.y)*(pCamPos->y - vecPosToCheck.y)) + { + if (bNeonFade) + { + float fDistFromCam = CVector(*pCamPos - vecPosToCheck).Magnitude(); + + if (fDistFromCam < 35.0f) + return; + if (fDistFromCam < 50.0f) + A *= static_cast((fDistFromCam - 35.0f) * (2.0f / 3.0f)); + } + + // Is corona already present? + CRegisteredCorona* pSuitableSlot; + auto it = UsedMap.find(nID); + + if (it != UsedMap.end()) + { + pSuitableSlot = it->second->GetFrom(); + + if (pSuitableSlot->Intensity == 0 && A == 0) + { + // Mark as free + it->second->GetFrom()->Identifier = 0; + it->second->Add(&FreeList); + UsedMap.erase(nID); + return; + } + } + else + { + if (!A) + return; + + // Adding a new element + auto pNewEntry = FreeList.First(); + if (!pNewEntry) + { + //LogToFile("ERROR: Not enough space for coronas!"); + return; + } + + pSuitableSlot = pNewEntry->GetFrom(); + + // Add to used list and push this index to the map + pNewEntry->Add(&UsedList); + UsedMap[nID] = pNewEntry; + + pSuitableSlot->FadedIntensity = A; + pSuitableSlot->OffScreen = true; + pSuitableSlot->JustCreated = true; + pSuitableSlot->Identifier = nID; + } + + pSuitableSlot->Red = R; + pSuitableSlot->Green = G; + pSuitableSlot->Blue = B; + pSuitableSlot->Intensity = A; + pSuitableSlot->Coordinates = Position; + pSuitableSlot->Size = Size; + pSuitableSlot->NormalAngle = normalAngle; + pSuitableSlot->Range = Range; + pSuitableSlot->pTex = pTex; + pSuitableSlot->FlareType = flareType; + pSuitableSlot->ReflectionType = reflectionType; + pSuitableSlot->LOSCheck = LOSCheck; + pSuitableSlot->RegisteredThisFrame = true; + pSuitableSlot->PullTowardsCam = PullTowardsCam; + pSuitableSlot->FadeSpeed = FadeSpeed; + + pSuitableSlot->NeonFade = bNeonFade; + pSuitableSlot->OnlyFromBelow = bOnlyFromBelow; + pSuitableSlot->WhiteCore = bWhiteCore; + + pSuitableSlot->bIsAttachedToEntity = false; + pSuitableSlot->pEntityAttachedTo = nullptr; + } +} + +void CLODLights::RegisterCorona(unsigned int nID, CEntity *pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, unsigned char coronaType, unsigned char flareType, bool enableReflection, bool checkObstacles, int unused, float normalAngle, bool longDistance, float nearClip, unsigned char bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool reflectionDelay) +{ + CLODLights::RegisterCorona(nID, pAttachTo, R, G, B, A, Position, Size, Range, *(g_TexCoronastar + coronaType), flareType, enableReflection, checkObstacles, unused, normalAngle, longDistance, nearClip, bFadeIntensity, FadeSpeed, bOnlyFromBelow, reflectionDelay); +} + +void CLODLights::Update() +{ + auto pNode = UsedList.First(); + if (pNode) + { + while (pNode != &UsedList) + { + unsigned int nIndex = pNode->GetFrom()->Identifier; + auto pNext = pNode->GetNextNode(); + + pNode->GetFrom()->Update(); + + // Did it become invalid? + if (!pNode->GetFrom()->Identifier) + { + // Remove from used list + pNode->Add(&FreeList); + UsedMap.erase(nIndex); + } + + pNode = pNext; + } + } +} + +void CLODLights::Init() +{ + if (aCoronas.size() != numCoronas) + { + aLinkedList.resize(numCoronas); + aCoronas.resize(numCoronas); + + // Initialise the lists + FreeList.Init(); + UsedList.Init(); + + for (size_t i = 0; i < aLinkedList.size(); i++) + { + aLinkedList[i].Add(&FreeList); + aLinkedList[i].SetEntry(&aCoronas[i]); + } + } +} + +void CLODLights::RenderBuffered() +{ + int nWidth = RwRasterGetWidth(RwCameraGetRaster(Camera)); + int nHeight = RwRasterGetHeight(RwCameraGetRaster(Camera)); + + RwRaster* pLastRaster = nullptr; + bool bLastZWriteRenderState = true; + + _RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); + _RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + _RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); + _RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + _RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + + for (size_t i = 0; i < aCoronas.size(); i++) + { + if (aCoronas[i].Identifier) + { + if (aCoronas[i].Intensity > 0) + { + RwV3d vecCoronaCoords, vecTransformedCoords; + float fComputedWidth, fComputedHeight; + + vecCoronaCoords.x = aCoronas[i].Coordinates.x; + vecCoronaCoords.y = aCoronas[i].Coordinates.y; + vecCoronaCoords.z = aCoronas[i].Coordinates.z; + + if (CSprite::CalcScreenCoors(vecCoronaCoords, &vecTransformedCoords, &fComputedWidth, &fComputedHeight, true, true)) + { + aCoronas[i].OffScreen = !(vecTransformedCoords.x >= 0.0 && vecTransformedCoords.x <= nWidth && + vecTransformedCoords.y >= 0.0 && vecTransformedCoords.y <= nHeight); + + if (aCoronas[i].Intensity > 0 && vecTransformedCoords.z <= aCoronas[i].Range) + { + float fInvFarClip = 1.0f / vecTransformedCoords.z; + float fHalfRange = aCoronas[i].Range * 0.5f; + + short nFadeIntensity = (short)(aCoronas[i].Intensity * (vecTransformedCoords.z > fHalfRange ? 1.0f - (vecTransformedCoords.z - fHalfRange) / fHalfRange : 1.0f)); + + if (bLastZWriteRenderState != aCoronas[i].LOSCheck == false) + { + bLastZWriteRenderState = aCoronas[i].LOSCheck == false; + CSprite::FlushSpriteBuffer(); + + _RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)bLastZWriteRenderState); + } + + if (aCoronas[i].pTex) + { + float fColourFogMult = Min(40.0f, vecTransformedCoords.z) * *CWeatherFoggyness * 0.025f + 1.0f; + + if (aCoronas[i].Identifier == 1) // Sun core + vecTransformedCoords.z = RwCameraGetFarClipPlane(Camera) * 0.95f; + + // This R* tweak broke the sun + //_RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + if (pLastRaster != RwTextureGetRaster(aCoronas[i].pTex)) + { + pLastRaster = RwTextureGetRaster(aCoronas[i].pTex); + CSprite::FlushSpriteBuffer(); + + _RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pLastRaster); + } + + RwV3d vecCoronaCoordsAfterPull = vecCoronaCoords; + CVector vecTempVector(vecCoronaCoordsAfterPull); + vecTempVector -= *GetCamPos(); + vecTempVector.Normalise(); + + vecCoronaCoordsAfterPull.x -= (vecTempVector.x * aCoronas[i].PullTowardsCam); + vecCoronaCoordsAfterPull.y -= (vecTempVector.y * aCoronas[i].PullTowardsCam); + vecCoronaCoordsAfterPull.z -= (vecTempVector.z * aCoronas[i].PullTowardsCam); + + if (CSprite::CalcScreenCoors(vecCoronaCoordsAfterPull, &vecTransformedCoords, &fComputedWidth, &fComputedHeight, true, true)) + { + CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(vecTransformedCoords.x, vecTransformedCoords.y, vecTransformedCoords.z, aCoronas[i].Size * fComputedWidth, aCoronas[i].Size * fComputedHeight * fColourFogMult, aCoronas[i].Red / fColourFogMult, aCoronas[i].Green / fColourFogMult, aCoronas[i].Blue / fColourFogMult, nFadeIntensity, fInvFarClip * 20.0f, 0.0, 0xFF); + } + } + } + } + else + aCoronas[i].OffScreen = true; + } + } + } + + CSprite::FlushSpriteBuffer(); +} + +void CLODLights::Inject() +{ + auto& gvm = injector::address_manager::singleton(); + if (gvm.IsSA()) + { + CWeatherFoggyness = (float*)0xC81300; + g_TexCoronastar = (RwTexture**)0xC3E000; + + CSprite::CalcScreenCoors = &CSprite::CalcScreenCoorsSA; + CSprite::CalcAddr = 0x70CE30; + CSprite::FlushAddr = 0x70CF20; + CSprite::RenderOneAddr = 0x70D490; + CSprite::RenderBufferedAddr = 0x70E780; + + injector::MakeCALL(0x5BA36D, CLODLights::Init, true); + } + else + { + if (gvm.IsVC()) + { + CWeatherFoggyness = (float*)0x94DDC0; + g_TexCoronastar = (RwTexture**)0x695538; + + CSprite::CalcScreenCoors = &CSprite::CalcScreenCoorsIIIVC; + CSprite::CalcAddr = 0x5778B0; + CSprite::FlushAddr = 0x577790; + CSprite::RenderOneAddr = 0x576690; + CSprite::RenderBufferedAddr = 0x576B30; + + struct Init + { + void operator()(injector::reg_pack&) + { + ((void(__cdecl *)())0x542830)(); //CCoronas::Init(); + CLODLights::Init(); + } + }; injector::MakeInline(0x4A4E55); + } + else + { + if (gvm.IsIII()) + { + CWeatherFoggyness = (float*)0x885AF4; + g_TexCoronastar = (RwTexture**)0x5FAF44; + + CSprite::CalcScreenCoors = &CSprite::CalcScreenCoorsIIIVC; + CSprite::CalcAddr = 0x51C3A0; + CSprite::FlushAddr = 0x51C520; + CSprite::RenderOneAddr = 0x51D110; + CSprite::RenderBufferedAddr = 0x51CCD0; + + struct Init + { + void operator()(injector::reg_pack&) + { + ((void(__cdecl *)())0x4F9F90)(); //CCoronas::Init(); + CLODLights::Init(); + } + }; injector::MakeInline(0x48C22A); + } + } + } +} \ No newline at end of file diff --git a/includes/CLODLights.h b/includes/CLODLights.h new file mode 100644 index 0000000..02a9d5e --- /dev/null +++ b/includes/CLODLights.h @@ -0,0 +1,101 @@ +#ifndef __CORONAS +#define __CORONAS +#include "..\includes\stdafx.h" + +class CRegisteredCorona +{ +public: + CVector Coordinates; // Where is it exactly. + DWORD Identifier; // Should be unique for each corona. Address or something (0 = empty) + RwTexture* pTex; // Pointer to the actual texture to be rendered + float Size; // How big is this fellow + float NormalAngle; // Is corona normal (if relevant) facing the camera? + float Range; // How far away is this guy still visible + float PullTowardsCam; // How far away is the z value pulled towards camera. + float HeightAboveGround; // Stired so that we don't have to do a ProcessVerticalLine every frame + // The following fields are used for trails behind coronas (glowy lights) + float FadeSpeed; // The speed the corona fades in and out ##SA## + BYTE Red, Green, Blue; // Rendering colour. + BYTE Intensity; // 255 = full + BYTE FadedIntensity; // Intensity that lags behind the given intenisty and fades out if the LOS is blocked + BYTE RegisteredThisFrame; // Has this guy been registered by game code this frame + BYTE FlareType; // What type of flare to render + BYTE ReflectionType; // What type of reflection during wet weather + BYTE LOSCheck : 1; // Do we check the LOS or do we render at the right Z value + BYTE OffScreen : 1; // Set by the rendering code to be used by the update code + BYTE JustCreated; // If this guy has been created this frame we won't delete it (It hasn't had the time to get its OffScreen cleared) ##SA removed from packed byte ## + BYTE NeonFade : 1; // Does the guy fade out when closer to cam + BYTE OnlyFromBelow : 1; // This corona is only visible if the camera is below it. ##SA## + BYTE bHasValidHeightAboveGround : 1; + BYTE WhiteCore : 1; // This corona rendered with a small white core. + BYTE bIsAttachedToEntity : 1; + + CEntity* pEntityAttachedTo; + +public: + CRegisteredCorona() + : Identifier(0), pEntityAttachedTo(nullptr) + {} + + void Update(); +}; + +class CLODLightsLinkedListNode +{ +private: + CLODLightsLinkedListNode* pNext; + CLODLightsLinkedListNode* pPrev; + CRegisteredCorona* pEntry; + +private: + inline void Remove() + { pNext->pPrev = pPrev; pPrev->pNext = pNext; pNext = nullptr; } + +public: + inline void Init() + { pNext = pPrev = this; } + inline void Add(CLODLightsLinkedListNode* pHead) + { if ( pNext ) Remove(); + pNext = pHead->pNext; pPrev = pHead; pHead->pNext->pPrev = this; pHead->pNext = this; } + inline void SetEntry(CRegisteredCorona* pEnt) + { pEntry = pEnt; } + inline CRegisteredCorona* GetFrom() + { return pEntry; } + inline CLODLightsLinkedListNode* GetNextNode() + { return pNext; } + inline CLODLightsLinkedListNode* GetPrevNode() + { return pPrev; } + + inline CLODLightsLinkedListNode* First() + { return pNext == this ? nullptr : pNext; } +}; + +class CLODLights +{ +private: + static std::map UsedMap; + static CLODLightsLinkedListNode FreeList, UsedList; + static std::vector aLinkedList; + static std::vector aCoronas; +public: + static int& bChangeBrightnessImmediately; + static float& ScreenMult; + +public: + static void RegisterCorona(unsigned int nID, CEntity* pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, RwTexture* pTex, unsigned char flareType, unsigned char reflectionType, unsigned char LOSCheck, unsigned char unused, float normalAngle, bool bNeonFade, float PullTowardsCam, bool bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool bWhiteCore); + static void RegisterCorona(unsigned int nID, CEntity *pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, unsigned char coronaType, unsigned char flareType, bool enableReflection, bool checkObstacles, int unused, float normalAngle, bool longDistance, float nearClip, unsigned char bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool reflectionDelay); + + static void Update(); + static void UpdateCoronaCoors(unsigned int nID, const CVector& vecPosition, float fMaxDist, float fNormalAngle); + static void Init(); + + static void RegisterLODLights(); + static void RenderBuffered(); + static void Inject(); +}; + +extern RwTexture** const gpCoronaTexture; + +static_assert(sizeof(CRegisteredCorona) == 0x3C, "Wrong size: CRegisteredCorona"); + +#endif \ No newline at end of file diff --git a/includes/CPatch.h b/includes/CPatch.h deleted file mode 100644 index 05f4ee2..0000000 --- a/includes/CPatch.h +++ /dev/null @@ -1,145 +0,0 @@ -#pragma once -#include - -class CPatch -{ -public: - inline static void Patch(void* address, void* data, int size) - { - unsigned long protect[2]; - VirtualProtect(address, size, PAGE_EXECUTE_READWRITE, &protect[0]); - memcpy(address, data, size); - VirtualProtect(address, size, protect[0], &protect[1]); - } - - inline static void Patch2(int address, void* data, int size) - { - unsigned long protect[2]; - VirtualProtect((void *)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); - memcpy((void *)address, data, size); - VirtualProtect((void *)address, size, protect[0], &protect[1]); - } - - inline static void Unprotect(int address, int size) - { - unsigned long protect[2]; - VirtualProtect((void *)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); - } - inline static void Nop(int address, int size) - { - unsigned long protect[2]; - VirtualProtect((void *)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); - memset((void *)address, 0x90, size); - VirtualProtect((void *)address, size, protect[0], &protect[1]); - } - inline static void FillWithZeroes(int address, int size) - { - unsigned long protect[2]; - VirtualProtect((void *)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); - memset((void *)address, 0x00, size); - VirtualProtect((void *)address, size, protect[0], &protect[1]); - } - inline static void RedirectCall(int address, void *func) - { - int temp = 0xE8; - Patch((void *)address, &temp, 1); - temp = (int)func - ((int)address + 5); - Patch((void *)((int)address + 1), &temp, 4); - } - inline static void RedirectJump(int address, void *func) - { - int temp = 0xE9; - Patch((void *)address, &temp, 1); - temp = (int)func - ((int)address + 5); - Patch((void *)((int)address + 1), &temp, 4); - } - inline static void SetChar(int address, char value) - { - Patch((void *)address, &value, 1); - } - inline static void SetUChar(int address, unsigned char value) - { - Patch((void *)address, &value, 1); - } - inline static void SetShort(int address, short value) - { - Patch((void *)address, &value, 2); - } - inline static void SetUShort(int address, unsigned short value) - { - Patch((void *)address, &value, 2); - } - inline static void SetInt(int address, int value) - { - Patch((void *)address, &value, 4); - } - inline static void SetUInt(int address, unsigned int value) - { - Patch((void *)address, &value, 4); - } - inline static void SetUIntWithCheck(int address, unsigned int value, unsigned int expectedValue) - { - if (*(unsigned int *)address == expectedValue) - Patch((void *)address, &value, 4); - } - inline static void SetFloat(int address, float value) - { - Patch((void *)address, &value, 4); - } - inline static void SetDouble(int address, double value) - { - Patch((void *)address, &value, 8); - } - inline static void SetPointer(int address, void *value) - { - Patch((void *)address, &value, 4); - } - - inline static void AdjustPointer(int address, void *value, DWORD offset, DWORD end) - { - int result; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } else { - address = address + 1; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } else { - address = address + 1; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } else { - address = address + 1; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } else { - address = address + 1; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } else { - address = address + 1; - if((DWORD)*(DWORD*)address >= offset && (DWORD)*(DWORD*)address <= end) { - result = (DWORD)value + (DWORD)*(DWORD*)address - (DWORD)offset; - Patch((void *)address, &result, 4); - } - } - } - } - } - } - } - - inline static bool FileExists(const TCHAR *fileName) - { - DWORD fileAttr; - fileAttr = GetFileAttributes(fileName); - if (0xFFFFFFFF == fileAttr && GetLastError()==ERROR_FILE_NOT_FOUND) - return false; - return true; - } -}; \ No newline at end of file diff --git a/includes/General.cpp b/includes/General.cpp deleted file mode 100644 index 3065f5e..0000000 --- a/includes/General.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "stdafx.h" -#include "General.h" -#include - - -void CMatrix::SetRotateXOnly(float fAngle) -{ - matrix.right.x = 1.0f; - matrix.right.y = 0.0f; - matrix.right.z = 0.0f; - - matrix.up.x = 0.0f; - matrix.up.y = cos(fAngle); - matrix.up.z = sin(fAngle); - - matrix.at.x = 0.0f; - matrix.at.y = -sin(fAngle); - matrix.at.z = cos(fAngle); -} - -void CMatrix::SetRotateYOnly(float fAngle) -{ - matrix.right.x = cos(fAngle); - matrix.right.y = 0.0f; - matrix.right.z = sin(fAngle); - - matrix.up.x = 0.0f; - matrix.up.y = 1.0f; - matrix.up.z = 0.0f; - - matrix.at.x = -sin(fAngle); - matrix.at.y = 0.0f; - matrix.at.z = cos(fAngle); -} - -void CMatrix::SetRotateZOnly(float fAngle) -{ - matrix.at.x = 0.0f; - matrix.at.y = 0.0f; - matrix.at.z = 1.0f; - - matrix.up.x = -sin(fAngle); - matrix.up.y = cos(fAngle); - matrix.up.z = 0.0f; - - matrix.right.x = cos(fAngle); - matrix.right.y = sin(fAngle); - matrix.right.z = 0.0f; -} - -void CMatrix::SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ) -{ - matrix.right.x = cos(fAngleZ) * cos(fAngleY) - sin(fAngleZ) * sin(fAngleX) * sin(fAngleY); - matrix.right.y = cos(fAngleZ) * sin(fAngleX) * sin(fAngleY) + sin(fAngleZ) * cos(fAngleY); - matrix.right.z = -cos(fAngleX) * sin(fAngleY); - - matrix.up.x = -sin(fAngleZ) * cos(fAngleX); - matrix.up.y = cos(fAngleZ) * cos(fAngleX); - matrix.up.z = sin(fAngleX); - - matrix.at.x = sin(fAngleZ) * sin(fAngleX) * cos(fAngleY) + cos(fAngleZ) * sin(fAngleY); - matrix.at.y = sin(fAngleZ) * sin(fAngleY) - cos(fAngleZ) * sin(fAngleX) * cos(fAngleY); - matrix.at.z = cos(fAngleX) * cos(fAngleY); -} \ No newline at end of file diff --git a/includes/General.h b/includes/General.h index c5967e3..881e473 100644 --- a/includes/General.h +++ b/includes/General.h @@ -1,421 +1,137 @@ -#include -#include #ifndef __GENERAL #define __GENERAL -#pragma warning(disable:4996) - -#define RAD_TO_DEG (180.0/M_PI) -#define DEG_TO_RAD (M_PI/180.0) -#define RwV3D RwV3d - -// TODO: Reverse it -#define FUNC_CPlaceable__GetRotation 0x441DB0 #define FUNC_CEntity__GetBoundCentre 0x534250 +#define NOVMT __declspec(novtable) +#define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a -struct CBaseModelInfo -{ - int _vmt, m_dwKey; - short usageCount, m_wTxdIndex; - char _fC, m_nbCount2dfx; - short m_w2dfxIndex, m_wObjectInfoIndex, m_wFlags; - int m_pColModel; - float m_fDrawDistance; - int m_pRwObject; -}; - -struct RwV2D -{ - float x, y; -}; - -struct RwV3d -{ - float x, y, z; -}; - -struct RwMatrix -{ - RwV3d right; - DWORD flags; - RwV3d up; - DWORD _pad1; - RwV3d at; - DWORD _pad2; - RwV3d pos; - DWORD _pad3; -}; -struct RwRGBA -{ - unsigned char r, g, b, a; -}; -struct RwRGBAReal -{ - float red, green, blue, alpha; -}; -struct RwObject -{ - char type, subType, flags, privateFlags; - struct RwFrame *parent; -}; -struct RwLLLink -{ - void *next; - void *prev; -}; -struct RwLinkList -{ - RwLLLink link; -}; -struct RpClump -{ - RwObject object; - RwLinkList atomicList, lightList, cameraList; - RwLLLink inWorldList; - DWORD callback; -}; - -struct RwRaster -{ - void *parent; - char *cpPixels; - char *palette; - int width, height, depth, stride; - short u, v; - char cType, cFlags, privateFlags, cFormat; - char *originalPixels; - int originalWidth, originalHeight, originalStride; -}; - +#include "rwsdk\rwcore.h" +#include "rwsdk\rpworld.h" -struct RwTexDictionary +enum SShadType { - RwObject object; - RwLinkList texturesInDict; - RwLLLink lInInstance; + SSHADT_NONE, + SSHADT_DEFAULT, // SSHAD_RM_COLORONLY (shad_car, shad_ped, shad_heli, shad_bike, shad_rcbaron, bloodpool_64, wincrack_32, lamp_shad_64) + SSHADT_INTENSIVE, // SSHAD_RM_OVERLAP (shad_exp, headlight, headlight1, handman) + SSHADT_NEGATIVE, // SSHAD_RM_INVCOLOR + SSHADT4, // SSHAD_RM_COLORONLY + SSHADT5, // SSHAD_RM_COLORONLY + SSHADT6, // SSHAD_RM_COLORONLY + SSHADT8 = 8 // SSHAD_RM_COLORONLY }; -struct RwTexture +enum SShadRenderMode { - RwRaster *raster; - RwTexDictionary *dict; - RwLLLink lInDictionary; - char name[32]; - char mask[32]; - char filterAddressing; - char _pad[3]; - int refCount; + SSHAD_RM_NONE, // Shadow type: <0, 0, >8. + SSHAD_RM_COLORONLY, // Shadow type: 1, 4, 5, 6, 8. The texture alpha is present if the alpha channel is set. + SSHAD_RM_OVERLAP, // Shadow type: 2. Any shadow alpha greater than 0 does not make any difference. + SSHAD_RM_INVCOLOR // Shadow type: 3. Same tip above goes here. }; -struct RwImage -{ - int flags; - - int width; /* Device may have different ideas */ - int height; /* internally !! */ - - int depth; /* Of referenced image */ - int stride; - - unsigned int *cpPixels; - RwRGBA *palette; -}; - -struct RwObjectHasFrame -{ - RwObject object; - RwLLLink lFrame; - DWORD sync; -}; - -struct RwPlane -{ - RwV3d normal; - float distance; -}; - -struct RwFrustumPlane -{ - RwPlane plane; - char closestX, closestY, closestZ, _pad; -}; - -struct RwBBox -{ - RwV3d sup, inf; -}; - -struct RwCamera -{ - RwObjectHasFrame object; - DWORD projectionType, beginUpdate, endUpdate; - RwMatrix viewMatrix; - RwRaster *frameBuffer; - RwRaster *zBuffer; - RwV2D viewWindow, recipViewWindow, viewOffset; - float nearPlane, farPlane, fogPlane, zScale, zShift; - RwFrustumPlane frustrumPlanes[6]; - RwBBox frustrumBoundBox; - RwV3d frustrumCorners[8]; -}; - -struct CShadowImage -{ - RwCamera *camera; - RwTexture *texture; -}; - -struct RpLight -{ - RwObjectHasFrame object; - float radius; - RwRGBAReal color; - float minusCosAngle; - RwLinkList WorldSectorsInLight; - RwLLLink InWorld; - WORD lightFrame, _pad; -}; - -struct RwSphere -{ - RwV3d center; - float radius; -}; - -struct CShadowData -{ - int *owner; - char isExist, intensity, _pad1[2]; - CShadowImage image; - char isBlurred, _pad2[3]; - CShadowImage blurredImage; - int blurLevel; - char createBlurTypeB, _pad3[3]; - int objectType; - RpLight *light; - RwSphere boundingSphere, baseSphere; -}; - -struct CRegisteredShadow -{ - RwV3d position; - float x1, y1, x2, y2, zDistance, scale; - RwTexture *texture; - CShadowData *shadowData; - short intensity; - char type, red, green, blue; - short flags; /* - 0001 DRAW_ON_WATER - 0010 IGNORE_MAP_OBJECTS - 0100 DRAW_ON_BUILDINGS - */ -}; - -struct CPool -{ - int objects; - int flags, size, top; - char initialized, _f11; - short _pad; -}; - -struct CObjectInfo -{ - float m_fMass; - float m_fTurnMass; - float m_fAirResistance; - float m_fElasticity; - float m_fBuoyancyConstant; - float m_fUprootLimit; - float m_fColDamageMultiplier; - BYTE m_bColDamageEffect; - BYTE m_bSpecialColResponseCase; - BYTE m_bCameraAvoidObject; - BYTE m_bCausesExplosion; - BYTE m_bFxType; - BYTE field_21; - BYTE field_22; - BYTE field_23; - RwV3D m_vFxOffset; - void *m_pFxSystem; // CFxSystem - int field_34; - RwV3D m_vBreakVelocity; - float m_fBreakVelocityRand; - float m_fSmashMultiplier; - DWORD m_dwSparksOnImpact; -}; - -struct C2dfx -{ - RwV3D offset; - int type; - RwRGBA color; - float coronaFarClip; - float pointlightRange; - float coronaSize; - float shadowSize; - union flagsInfo; - char coronaFlashType; - char coronaEnableReflection; - char coronaFlareType; - char shadowColorMultiplier; - char shadowZDistance; - char offsetX; - char offsetY; - char offsetZ; - char __pad[2]; - RwTexture *coronaTex; - RwTexture *shadowTex; - int field_38; - int field_3C; -}; - -struct VehAddonCtrl -{ - struct VehicleAdditional *additional; - DWORD _pad[2]; -}; - -struct Placement -{ - union - { - RwV3D pos; - VehAddonCtrl ctrl; - } base; - float angle; -}; +#define RwV3D RwV3d -class CVector +class CFileMgr { public: - float x, y, z; - - CVector() - {} - - CVector(float fX, float fY, float fZ=0.0f) - : x(fX), y(fY), z(fZ) - {} - - CVector(const RwV3d& rwVec) - : x(rwVec.x), y(rwVec.y), z(rwVec.z) - {} - - CVector& operator+=(const CVector& vec) - { x += vec.x; y += vec.y; z += vec.z; - return *this; } - - inline float Magnitude() - { return sqrt(x * x + y * y + z * z); } + static inline FILE* OpenFile(const char* path, const char* mode) + { + return fopen(path, mode); + }; + static inline int CloseFile(FILE* stream) + { + return fclose(stream); + }; + static inline bool ReadLine(FILE* stream, char* str, int num) + { + return fgets(str, num, stream) != nullptr; + }; + static inline size_t Read(FILE* stream, void* buf, size_t len) + { + return fread(buf, 1, len, stream); + }; + static inline size_t Write(FILE* stream, const char* ptr, size_t len) + { + return fwrite(ptr, 1, len, stream); + }; + static inline bool Seek(FILE* stream, long pos, int from) + { + return fseek(stream, pos, from) != 0; + }; + static inline const char* LoadLine(FILE* hFile) + { + static char cLineBuffer[512]; - friend inline float DotProduct(const CVector& vec1, const CVector& vec2) - { return vec1.x * vec2.x + vec1.x * vec2.y + vec1.z * vec2.z; } + if (!CFileMgr::ReadLine(hFile, cLineBuffer, sizeof(cLineBuffer))) + return nullptr; - friend inline CVector CrossProduct(const CVector& vec1, const CVector& vec2) - { - return CVector(vec1.y * vec2.z - vec1.z * vec2.y, vec1.z * vec2.x - vec1.x * vec2.z, vec1.x * vec2.y - vec1.y * vec2.x); - } + for (int i = 0; cLineBuffer[i]; ++i) + { + if (cLineBuffer[i] == '\n') + cLineBuffer[i] = '\0'; + else if (cLineBuffer[i] < ' ' || cLineBuffer[i] == ',') + cLineBuffer[i] = ' '; + } - friend inline CVector operator*(const CVector& in, float fMul) - { return CVector(in.x * fMul, in.y * fMul, in.z * fMul); } - friend inline CVector operator+(const CVector& vec1, const CVector& vec2) - { return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); } - friend inline CVector operator-(const CVector& vec1, const CVector& vec2) - { return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); } + const char* p = cLineBuffer; + while (*p <= ' ') + { + if (!*p++) + break; + } + return p; + }; }; -class CVector2D +class CTimer { public: - float x, y; - - CVector2D() - {} - - CVector2D(float fX, float fY) - : x(fX), y(fY) - {} + static int& m_snTimeInMilliseconds; + static int& m_snTimeInMillisecondsPauseMode; + static float& ms_fTimeStep; + //static unsigned int& m_FrameCounter; }; -class CMatrix +class CSimpleTransform { public: - RwMatrix matrix; - RwMatrix* pMatrix; - BOOL haveRwMatrix; + CVector m_translate; + float m_heading; public: - CMatrix() - : pMatrix(nullptr), haveRwMatrix(FALSE) - {} - - CMatrix(RwMatrix* rwMatrix, bool bAttach=false) - : matrix(*rwMatrix), haveRwMatrix(bAttach), pMatrix(bAttach ? rwMatrix : nullptr) - {} + void UpdateMatrix(CMatrix* pMatrix) const + { + pMatrix->SetTranslate(m_translate.x, m_translate.y, m_translate.z); + pMatrix->SetRotateZOnly(m_heading); + } - CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos) + void UpdateRwMatrix(RwMatrix* pMatrix) const { - matrix.right.x = vecRight.x; - matrix.right.y = vecRight.y; - matrix.right.z = vecRight.z; + pMatrix->right.x = cos(m_heading); + pMatrix->right.y = sin(m_heading); + pMatrix->right.z = 0.0f; - matrix.up.x = vecUp.x; - matrix.up.y = vecUp.y; - matrix.up.z = vecUp.z; + pMatrix->at.x = 0.0f; + pMatrix->at.y = 0.0f; + pMatrix->at.z = 1.0f; - matrix.at.x = vecAt.x; - matrix.at.y = vecAt.y; - matrix.at.z = vecAt.z; + pMatrix->up.x = -sin(m_heading); + pMatrix->up.y = cos(m_heading); + pMatrix->up.z = 0.0f; - matrix.pos.x = vecPos.x; - matrix.pos.y = vecPos.y; - matrix.pos.z = vecPos.z; - } + pMatrix->pos.x = m_translate.x; + pMatrix->pos.y = m_translate.y; + pMatrix->pos.z = m_translate.z; - friend inline CMatrix operator*(const CMatrix& Rot1, const CMatrix& Rot2) - { return CMatrix( CVector(Rot1.matrix.right.x * Rot2.matrix.right.x + Rot1.matrix.right.y * Rot2.matrix.up.x + Rot1.matrix.right.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, - Rot1.matrix.right.x * Rot2.matrix.right.y + Rot1.matrix.right.y * Rot2.matrix.up.y + Rot1.matrix.right.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, - Rot1.matrix.right.x * Rot2.matrix.right.z + Rot1.matrix.right.y * Rot2.matrix.up.z + Rot1.matrix.right.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), - CVector(Rot1.matrix.up.x * Rot2.matrix.right.x + Rot1.matrix.up.y * Rot2.matrix.up.x + Rot1.matrix.up.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, - Rot1.matrix.up.x * Rot2.matrix.right.y + Rot1.matrix.up.y * Rot2.matrix.up.y + Rot1.matrix.up.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, - Rot1.matrix.up.x * Rot2.matrix.right.z + Rot1.matrix.up.y * Rot2.matrix.up.z + Rot1.matrix.up.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), - CVector(Rot1.matrix.at.x * Rot2.matrix.right.x + Rot1.matrix.at.y * Rot2.matrix.up.x + Rot1.matrix.at.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, - Rot1.matrix.at.x * Rot2.matrix.right.y + Rot1.matrix.at.y * Rot2.matrix.up.y + Rot1.matrix.at.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, - Rot1.matrix.at.x * Rot2.matrix.right.z + Rot1.matrix.at.y * Rot2.matrix.up.z + Rot1.matrix.at.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), - CVector(Rot1.matrix.pos.x * Rot2.matrix.right.x + Rot1.matrix.pos.y * Rot2.matrix.up.x + Rot1.matrix.pos.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, - Rot1.matrix.pos.x * Rot2.matrix.right.y + Rot1.matrix.pos.y * Rot2.matrix.up.y + Rot1.matrix.pos.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, - Rot1.matrix.pos.x * Rot2.matrix.right.z + Rot1.matrix.pos.y * Rot2.matrix.up.z + Rot1.matrix.pos.z * Rot2.matrix.at.z + Rot2.matrix.pos.z)); }; - - friend inline CVector operator*(const CMatrix& matrix, const CVector& vec) - { return CVector(matrix.matrix.up.x * vec.y + matrix.matrix.right.x * vec.x + matrix.matrix.at.x * vec.z + matrix.matrix.pos.x, - matrix.matrix.up.y * vec.y + matrix.matrix.right.y * vec.x + matrix.matrix.at.y * vec.z + matrix.matrix.pos.y, - matrix.matrix.up.z * vec.y + matrix.matrix.right.z * vec.x + matrix.matrix.at.z * vec.z + matrix.matrix.pos.z); }; - - inline CVector* GetUp() - { return reinterpret_cast(&matrix.up); } - - inline CVector* GetAt() - { return reinterpret_cast(&matrix.at); } - - inline CVector* GetPos() - { return reinterpret_cast(&matrix.pos); } - - inline void SetTranslateOnly(float fX, float fY, float fZ) - { matrix.pos.x = fX; matrix.pos.y = fY; matrix.pos.z = fZ; } - - void SetRotateXOnly(float fAngle); - void SetRotateYOnly(float fAngle); - void SetRotateZOnly(float fAngle); - - void SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ); -}; + pMatrix->flags &= ~(0x00000003 | 0x00020000); + } -class CSimpleTransform -{ -public: - CVector m_translate; - float m_heading; + void Invert(const CSimpleTransform& src) + { + m_translate.x = -(cos(src.m_heading) * src.m_translate.x - sin(src.m_heading) * src.m_translate.y);; + m_translate.y = sin(src.m_heading) * src.m_translate.x - cos(m_heading) * src.m_translate.y; + m_translate.z = -src.m_translate.z; + m_heading = -src.m_heading; + } }; class CRGBA @@ -433,11 +149,26 @@ class CRGBA : r(in.r), g(in.g), b(in.b), a(alpha) {} - inline CRGBA(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255) : r(red), g(green), b(blue), a(alpha) {} + template + friend CRGBA Blend(const CRGBA& One, T OneStrength, const CRGBA& Two, T TwoStrength) + { T TotalStrength = OneStrength + TwoStrength; + return CRGBA( ((One.r * OneStrength) + (Two.r * TwoStrength))/TotalStrength, + ((One.g * OneStrength) + (Two.g * TwoStrength))/TotalStrength, + ((One.b * OneStrength) + (Two.b * TwoStrength))/TotalStrength, + ((One.a * OneStrength) + (Two.a * TwoStrength))/TotalStrength); } + + template + friend CRGBA Blend(const CRGBA& One, T OneStrength, const CRGBA& Two, T TwoStrength, const CRGBA& Three, T ThreeStrength) + { T TotalStrength = OneStrength + TwoStrength + ThreeStrength; + return CRGBA( ((One.r * OneStrength) + (Two.r * TwoStrength) + (Three.r * ThreeStrength))/TotalStrength, + ((One.g * OneStrength) + (Two.g * TwoStrength) + (Three.g * ThreeStrength))/TotalStrength, + ((One.b * OneStrength) + (Two.b * TwoStrength) + (Three.b * ThreeStrength))/TotalStrength, + ((One.a * OneStrength) + (Two.a * TwoStrength) + (Three.a * ThreeStrength))/TotalStrength); } + void BaseColors__Constructor(); }; @@ -458,7 +189,6 @@ class CPlaceable { private: CSimpleTransform m_transform; -public: CMatrix* m_pCoords; public: @@ -473,25 +203,28 @@ class CPlaceable UNREFERENCED_PARAMETER(dummy); } - inline CVector* GetCoords() - { return m_pCoords ? reinterpret_cast(&m_pCoords->matrix.pos) : &m_transform.m_translate; } + inline CVector& GetCoords() + { return m_pCoords ? reinterpret_cast(m_pCoords->matrix.pos) : m_transform.m_translate; } inline CMatrix* GetMatrix() { return m_pCoords; } inline CSimpleTransform& GetTransform() { return m_transform; } + inline float GetHeading() + { return m_pCoords ? atan2(-m_pCoords->GetUp()->x, m_pCoords->GetUp()->y) : m_transform.m_heading; } inline void SetCoords(const CVector& pos) { if ( m_pCoords ) { m_pCoords->matrix.pos.x = pos.x; m_pCoords->matrix.pos.y = pos.y; m_pCoords->matrix.pos.z = pos.z; } else m_transform.m_translate = pos; } inline void SetHeading(float fHeading) { if ( m_pCoords ) m_pCoords->SetRotateZOnly(fHeading); else m_transform.m_heading = fHeading; } + + void AllocateMatrix(); }; // TODO: May not be the best place to put it? -class __declspec(novtable) CEntity : public CPlaceable +class NOVMT CEntity : public CPlaceable { public: - /********** BEGIN VTBL **************/ virtual void Add_CRect(); virtual void Add(); virtual void Remove(); @@ -515,7 +248,7 @@ class __declspec(novtable) CEntity : public CPlaceable virtual void FlagToDestroyWhenNextProcessed(); //private: - RpClump* m_pRwObject; // 0x18 + RwObject* m_pRwObject; // 0x18 /********** BEGIN CFLAGS (0x1C) **************/ unsigned long bUsesCollision : 1; // does entity use collision @@ -571,6 +304,9 @@ class __declspec(novtable) CEntity : public CPlaceable BYTE nStatus : 5; // control status // 0x36 //********* END CEntityInfo ************// + // VCS PC class extension + bool bIveBeenRenderedOnce : 1; // for realtime shadows + public: explicit inline CEntity(int dummy) : CPlaceable(dummy) @@ -583,166 +319,174 @@ class __declspec(novtable) CEntity : public CPlaceable inline short GetModelIndex() { return m_nModelIndex; } + class CRealTimeShadow* GetRealTimeShadow(); + void SetRealTimeShadow(class CRealTimeShadow* pShadow); + void UpdateRW(); void RegisterReference(CEntity** pAddress); void CleanUpOldReference(CEntity** pAddress); }; -class __declspec(novtable) CPhysical : public CEntity +class NOVMT CPhysical : public CEntity { private: - float pad1; // 56 - int __pad2; // 60 - - unsigned int b0x01 : 1; // 64 - unsigned int bApplyGravity : 1; - unsigned int bDisableFriction : 1; - unsigned int bCollidable : 1; - unsigned int b0x10 : 1; - unsigned int bDisableMovement : 1; - unsigned int b0x40 : 1; - unsigned int b0x80 : 1; - - unsigned int bSubmergedInWater : 1; // 65 - unsigned int bOnSolidSurface : 1; - unsigned int bBroken : 1; - unsigned int b0x800 : 1; // ref @ 0x6F5CF0 - unsigned int b0x1000 : 1;// - unsigned int b0x2000 : 1;// - unsigned int b0x4000 : 1;// - unsigned int b0x8000 : 1;// - - unsigned int b0x10000 : 1; // 66 - unsigned int b0x20000 : 1; // ref @ CPhysical__processCollision - unsigned int bBulletProof : 1; - unsigned int bFireProof : 1; - unsigned int bCollisionProof : 1; - unsigned int bMeeleProof : 1; - unsigned int bInvulnerable : 1; - unsigned int bExplosionProof : 1; - - unsigned int b0x1000000 : 1; // 67 - unsigned int bAttachedToEntity : 1; - unsigned int b0x4000000 : 1; - unsigned int bTouchingWater : 1; - unsigned int bEnableCollision : 1; - unsigned int bDestroyed : 1; - unsigned int b0x40000000 : 1; - unsigned int b0x80000000 : 1; - - CVector m_vecLinearVelocity; // 68 - CVector m_vecAngularVelocity; // 80 - CVector m_vecCollisionLinearVelocity; // 92 - CVector m_vecCollisionAngularVelocity; // 104 - CVector m_vForce; // 0x74 - CVector m_vTorque; // 0x80 - float fMass; // 0x8C - float fTurnMass; // 0x90 - float m_fVelocityFrequency; // 0x94 - float m_fAirResistance; // 0x98 - float m_fElasticity; // 0x9C - float m_fBuoyancyConstant; // 0xA0 - - CVector vecCenterOfMass; // 0xA4 - DWORD dwUnk1; // 0xB0 - void* unkCPtrNodeDoubleLink; // 0xB4 - BYTE byUnk: 8; // 0xB8 - BYTE byCollisionRecords: 8; // 0xB9 - BYTE byUnk2: 8; // 0xBA (Baracus) - BYTE byUnk3: 8; // 0xBB - - float pad4[6]; // 0xBC - - float fDistanceTravelled; // 0xD4 - float fDamageImpulseMagnitude; // 0xD8 - CEntity* damageEntity; // 0xDC - BYTE pad2[28]; // 0xE0 - CEntity* pAttachedEntity; // 0xFC - CVector m_vAttachedPosition; // 0x100 - CVector m_vAttachedRotation; // 0x10C - BYTE pad3[20]; // 0x118 - float fLighting; // 0x12C col lighting? CPhysical::GetLightingFromCol - float fLighting_2; // 0x130 added to col lighting in CPhysical::GetTotalLighting - BYTE pad3a[4]; // 0x134 + float pad1; // 56 + int __pad2; // 60 + + unsigned int b0x01 : 1; // 64 + unsigned int bApplyGravity : 1; + unsigned int bDisableFriction : 1; + unsigned int bCollidable : 1; + unsigned int b0x10 : 1; + unsigned int bDisableMovement : 1; + unsigned int b0x40 : 1; + unsigned int b0x80 : 1; + + unsigned int bSubmergedInWater : 1; // 65 + unsigned int bOnSolidSurface : 1; + unsigned int bBroken : 1; + unsigned int b0x800 : 1; // ref @ 0x6F5CF0 + unsigned int b0x1000 : 1;// + unsigned int b0x2000 : 1;// + unsigned int b0x4000 : 1;// + unsigned int b0x8000 : 1;// + + unsigned int b0x10000 : 1; // 66 + unsigned int b0x20000 : 1; // ref @ CPhysical__processCollision + unsigned int bBulletProof : 1; + unsigned int bFireProof : 1; + unsigned int bCollisionProof : 1; + unsigned int bMeeleProof : 1; + unsigned int bInvulnerable : 1; + unsigned int bExplosionProof : 1; + + unsigned int b0x1000000 : 1; // 67 + unsigned int bAttachedToEntity : 1; + unsigned int b0x4000000 : 1; + unsigned int bTouchingWater : 1; + unsigned int bEnableCollision : 1; + unsigned int bDestroyed : 1; + unsigned int b0x40000000 : 1; + unsigned int b0x80000000 : 1; + + CVector m_vecLinearVelocity; // 68 + CVector m_vecAngularVelocity; // 80 + CVector m_vecCollisionLinearVelocity; // 92 + CVector m_vecCollisionAngularVelocity; // 104 + CVector m_vForce; // 0x74 + CVector m_vTorque; // 0x80 + float fMass; // 0x8C + float fTurnMass; // 0x90 + float m_fVelocityFrequency; // 0x94 + float m_fAirResistance; // 0x98 + float m_fElasticity; // 0x9C + float m_fBuoyancyConstant; // 0xA0 + + CVector vecCenterOfMass; // 0xA4 + DWORD dwUnk1; // 0xB0 + void* unkCPtrNodeDoubleLink; // 0xB4 + BYTE byUnk: 8; // 0xB8 + BYTE byCollisionRecords: 8; // 0xB9 + BYTE byUnk2: 8; // 0xBA (Baracus) + BYTE byUnk3: 8; // 0xBB + + float pad4[6]; // 0xBC + + float fDistanceTravelled; // 0xD4 + float fDamageImpulseMagnitude; // 0xD8 + CEntity* damageEntity; // 0xDC + BYTE pad2[28]; // 0xE0 + CEntity* pAttachedEntity; // 0xFC + CVector m_vAttachedPosition; // 0x100 + CVector m_vAttachedRotation; // 0x10C + BYTE pad3[20]; // 0x118 + float fLighting; // 0x12C col lighting? CPhysical::GetLightingFromCol + float fLighting_2; // 0x130 added to col lighting in CPhysical::GetTotalLighting + class CRealTimeShadow* m_pShadow; // 0x134 public: + inline class CRealTimeShadow* GetRealTimeShadow() + { return m_pShadow; } + inline CVector& GetLinearVelocity() + { return m_vecLinearVelocity; } + + inline void SetRealTimeShadow(class CRealTimeShadow* pShadow) + { m_pShadow = pShadow; } + // Temp CPhysical() : CEntity(0) {} }; -// TODO: Move it away -class CKeyGen +struct C2dfx { -public: - static unsigned int GetUppercaseKey(const char* pEntry); + RwV3D offset; + int type; + RwRGBA color; + float coronaFarClip; + float pointlightRange; + float coronaSize; + float shadowSize; + union flagsInfo; + char coronaFlashType; + char coronaEnableReflection; + char coronaFlareType; + char shadowColorMultiplier; + char shadowZDistance; + char offsetX; + char offsetY; + char offsetZ; + char __pad[2]; + RwTexture *coronaTex; + RwTexture *shadowTex; + int field_38; + int field_3C; }; -// TODO: Move away? -class CGame +struct CBaseModelInfo { -private: - static bool& bMissionPackGame; - -public: - static inline bool IsMissionPackGame() - { return bMissionPackGame; } + int _vmt, m_dwKey; + short usageCount, m_wTxdIndex; + char _fC, m_nbCount2dfx; + short m_w2dfxIndex, m_wObjectInfoIndex, m_wFlags; + int m_pColModel; + float m_fDrawDistance; + int m_pRwObject; }; - -bool CalcScreenCoors(const CVector& vecIn, CVector* vecOut); -void LoadingScreenLoadingFile(const char* pText); - -class CFileMgr +struct RxObjSpace3dVertex // sizeof = 0x24 { -public: - static inline FILE* OpenFile(const char* path, const char* mode) - { - return fopen(path, mode); - }; - static inline int CloseFile(FILE* stream) - { - return fclose(stream); - }; - static inline bool ReadLine(FILE* stream, char* str, int num) - { - return fgets(str, num, stream) != nullptr; - }; - static inline size_t Read(FILE* stream, void* buf, size_t len) - { - return fread(buf, 1, len, stream); - }; - static inline size_t Write(FILE* stream, const char* ptr, size_t len) - { - return fwrite(ptr, 1, len, stream); - }; - static inline bool Seek(FILE* stream, long pos, int from) - { - return fseek(stream, pos, from) != 0; - }; - static inline const char* LoadLine(FILE* hFile) - { - static char cLineBuffer[512]; - - if (!CFileMgr::ReadLine(hFile, cLineBuffer, sizeof(cLineBuffer))) - return nullptr; - - for (int i = 0; cLineBuffer[i]; ++i) - { - if (cLineBuffer[i] == '\n') - cLineBuffer[i] = '\0'; - else if (cLineBuffer[i] < ' ' || cLineBuffer[i] == ',') - cLineBuffer[i] = ' '; - } + RwV3D objVertex; + RwV3D objNormal; + DWORD color; + float u; + float v; +}; - const char* p = cLineBuffer; - while (*p <= ' ') - { - if (!*p++) - break; - } - return p; - }; +struct CObjectInfo +{ + float m_fMass; + float m_fTurnMass; + float m_fAirResistance; + float m_fElasticity; + float m_fBuoyancyConstant; + float m_fUprootLimit; + float m_fColDamageMultiplier; + BYTE m_bColDamageEffect; + BYTE m_bSpecialColResponseCase; + BYTE m_bCameraAvoidObject; + BYTE m_bCausesExplosion; + BYTE m_bFxType; + BYTE field_21; + BYTE field_22; + BYTE field_23; + RwV3D m_vFxOffset; + void *m_pFxSystem; // CFxSystem + int field_34; + RwV3D m_vBreakVelocity; + float m_fBreakVelocityRand; + float m_fSmashMultiplier; + DWORD m_dwSparksOnImpact; }; struct CObject : public CPhysical @@ -775,36 +519,29 @@ struct CObject : public CPhysical float field_178; }; -struct CColPoint // sizeof = 0x2C -{ - RwV3D point; - DWORD field_C; - RwV3D normal; - DWORD field_1C; - BYTE surfaceTypeA; - BYTE pieceTypeA; - BYTE lightingA; - BYTE surfaceTypeB; - BYTE pieceTypeB; - BYTE lightingB; - BYTE field_26[2]; - DWORD depth; -}; -struct RxObjSpace3dVertex // sizeof = 0x24 +bool CalcScreenCoors(const CVector& vecIn, CVector* vecOut); +void LoadingScreenLoadingFile(const char* pText); + +extern CRGBA* BaseColors; +extern RwCamera*& Camera; + +static_assert(sizeof(CEntity) == 0x38, "Wrong size: CEntity"); +static_assert(sizeof(CPhysical) == 0x138, "Wrong size: CPhysical"); + +struct CPool { - RwV3D objVertex; - RwV3D objNormal; - DWORD color; - float u; - float v; + int objects; + int flags, size, top; + char initialized, _f11; + short _pad; }; struct CEntityVC // sizeof = 0x64 { DWORD __vmt; CMatrix matrix; - DWORD rwObject; + //DWORD rwObject; CMatrix sizeof is +4 for some reason BYTE flags; BYTE type; @@ -836,7 +573,7 @@ class CEntityIII public: DWORD __vmt; CMatrix matrix; - RwObject *m_pRwObject; + //RwObject *m_pRwObject; CMatrix sizeof is +4 for some reason unsigned char m_nType : 3; unsigned char m_nState : 5; @@ -898,7 +635,7 @@ class Interval unsigned int initial_; public: - inline Interval() : initial_(GetTickCount()) { } + inline Interval() : initial_(GetTickCount()) { } virtual ~Interval() { } @@ -943,4 +680,5 @@ class Fps return m_fps; } }; + #endif \ No newline at end of file diff --git a/includes/Maths.h b/includes/Maths.h new file mode 100644 index 0000000..ce513cb --- /dev/null +++ b/includes/Maths.h @@ -0,0 +1,505 @@ +#ifndef __MATHS__H +#define __MATHS__H + +#include +#include "rwsdk\rwcore.h" + +#define RAD_TO_DEG (180.0/M_PI) +#define DEG_TO_RAD (M_PI/180.0) + +class CVector +{ +public: + float x, y, z; + + CVector() + {} + + CVector(float fX, float fY, float fZ=0.0f) + : x(fX), y(fY), z(fZ) + {} + + CVector(const RwV3d& rwVec) + : x(rwVec.x), y(rwVec.y), z(rwVec.z) + {} + + CVector& operator+=(const CVector& vec) + { x += vec.x; y += vec.y; z += vec.z; + return *this; } + CVector& operator+=(const RwV3d& vec) + { x += vec.x; y += vec.y; z += vec.z; + return *this; } + CVector& operator-=(const CVector& vec) + { x -= vec.x; y -= vec.y; z -= vec.z; + return *this; } + CVector& operator-=(const RwV3d& vec) + { x -= vec.x; y -= vec.y; z -= vec.z; + return *this; } + + inline float Magnitude() + { return sqrt(x * x + y * y + z * z); } + inline float MagnitudeSqr() + { return x * x + y * y + z * z; } + inline CVector& Normalise() + { float fInvLen = 1.0f / Magnitude(); x *= fInvLen; y *= fInvLen; z *= fInvLen; return *this; } + inline float NormaliseAndMag() + { float fLen = Magnitude(); float fInvLen = 1.0f / fLen; x *= fInvLen; y *= fInvLen; z *= fInvLen; return fLen; } + + friend inline float DotProduct(const CVector& vec1, const CVector& vec2) + { return vec1.x * vec2.x + vec1.x * vec2.y + vec1.z * vec2.z; } + friend inline CVector CrossProduct(const CVector& vec1, const CVector& vec2) + { return CVector( vec1.y * vec2.z - vec1.z * vec2.y, + vec1.z * vec2.x - vec1.x * vec2.z, + vec1.x * vec2.y - vec1.y * vec2.x); } + + friend inline CVector operator*(const CVector& in, float fMul) + { return CVector(in.x * fMul, in.y * fMul, in.z * fMul); } + friend inline CVector operator+(const CVector& vec1, const CVector& vec2) + { return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); } + friend inline CVector operator+(const CVector& vec1, const RwV3d& vec2) + { return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); } + friend inline CVector operator-(const CVector& vec1, const CVector& vec2) + { return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); } + friend inline CVector operator-(const CVector& vec1, const RwV3d& vec2) + { return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); } + friend inline CVector operator-(const CVector& vec) + { return CVector(-vec.x, -vec.y, -vec.z); } + + inline CVector& FromMultiply(const class CMatrix& mat, const CVector& vec); + inline CVector& FromMultiply3X3(const class CMatrix& mat, const CVector& vec); +}; + +class CVector2D +{ +public: + float x, y; + + CVector2D() + {} + + CVector2D(float fX, float fY) + : x(fX), y(fY) + {} + + CVector2D(const RwV2d& rwVec) + : x(rwVec.x), y(rwVec.y) + {} + + CVector2D& operator+=(const CVector2D& vec) + { x += vec.x; y += vec.y; + return *this; } + CVector2D& operator-=(const CVector2D& vec) + { x -= vec.x; y -= vec.y; + return *this; } + + inline float Magnitude() + { return sqrt(x * x + y * y); } + inline float MagnitudeSqr() + { return x * x + y * y; } + inline CVector2D& Normalise() + { float fInvLen = 1.0f / Magnitude(); x *= fInvLen; y *= fInvLen; return *this; } + inline float NormaliseAndMag() + { float fLen = Magnitude(); float fInvLen = 1.0f / fLen; x *= fInvLen; y *= fInvLen; return fLen; } + + friend inline float DotProduct(const CVector2D& vec1, const CVector2D& vec2) + { return vec1.x * vec2.x + vec1.x * vec2.y; } + friend inline float CrossProduct(const CVector2D& vec1, const CVector2D& vec2) + { return vec1.x * vec2.y - vec1.y * vec2.x; } + + friend inline CVector2D operator*(const CVector2D& in, float fMul) + { return CVector2D(in.x * fMul, in.y * fMul); } + friend inline CVector2D operator+(const CVector2D& vec1, const CVector2D& vec2) + { return CVector2D(vec1.x + vec2.x, vec1.y + vec2.y); } + friend inline CVector2D operator-(const CVector2D& vec1, const CVector2D& vec2) + { return CVector2D(vec1.x - vec2.x, vec1.y - vec2.y); } + friend inline CVector2D operator-(const CVector2D& vec) + { return CVector2D(-vec.x, -vec.y); } +}; + +class CSphere +{ +public: + RwSphere sphere; + +public: + void Set(float fRadius, const CVector& vecCenter) + { + sphere.center.x = vecCenter.x; + sphere.center.y = vecCenter.y; + sphere.center.z = vecCenter.z; + sphere.radius = fRadius; + } +}; + +class CMatrix +{ +public: + RwMatrix matrix; + RwMatrix* pMatrix; + int haveRwMatrix; + +public: + inline CMatrix() + : pMatrix(nullptr), haveRwMatrix(FALSE) + {} + + inline CMatrix(RwMatrix* pMatrix, bool bHasMatrix=false) + : pMatrix(nullptr) + { Attach(pMatrix, bHasMatrix); } + + inline CMatrix(const CMatrix& theMatrix) + : pMatrix(nullptr), haveRwMatrix(FALSE), matrix(theMatrix.matrix) + {} + + inline CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos) + { + matrix.right.x = vecRight.x; + matrix.right.y = vecRight.y; + matrix.right.z = vecRight.z; + + matrix.up.x = vecUp.x; + matrix.up.y = vecUp.y; + matrix.up.z = vecUp.z; + + matrix.at.x = vecAt.x; + matrix.at.y = vecAt.y; + matrix.at.z = vecAt.z; + + matrix.pos.x = vecPos.x; + matrix.pos.y = vecPos.y; + matrix.pos.z = vecPos.z; + } + + int(__cdecl *RwMatrixDestroy)(RwMatrix* mpMat) = (int(__cdecl *)(RwMatrix* mpMat))0x7F2A20; + + inline ~CMatrix() + { if ( haveRwMatrix && pMatrix ) + RwMatrixDestroy(pMatrix); } + + friend inline CMatrix operator*(const CMatrix& Rot1, const CMatrix& Rot2) + { return CMatrix( CVector(Rot1.matrix.right.x * Rot2.matrix.right.x + Rot1.matrix.right.y * Rot2.matrix.up.x + Rot1.matrix.right.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, + Rot1.matrix.right.x * Rot2.matrix.right.y + Rot1.matrix.right.y * Rot2.matrix.up.y + Rot1.matrix.right.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, + Rot1.matrix.right.x * Rot2.matrix.right.z + Rot1.matrix.right.y * Rot2.matrix.up.z + Rot1.matrix.right.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), + CVector(Rot1.matrix.up.x * Rot2.matrix.right.x + Rot1.matrix.up.y * Rot2.matrix.up.x + Rot1.matrix.up.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, + Rot1.matrix.up.x * Rot2.matrix.right.y + Rot1.matrix.up.y * Rot2.matrix.up.y + Rot1.matrix.up.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, + Rot1.matrix.up.x * Rot2.matrix.right.z + Rot1.matrix.up.y * Rot2.matrix.up.z + Rot1.matrix.up.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), + CVector(Rot1.matrix.at.x * Rot2.matrix.right.x + Rot1.matrix.at.y * Rot2.matrix.up.x + Rot1.matrix.at.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, + Rot1.matrix.at.x * Rot2.matrix.right.y + Rot1.matrix.at.y * Rot2.matrix.up.y + Rot1.matrix.at.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, + Rot1.matrix.at.x * Rot2.matrix.right.z + Rot1.matrix.at.y * Rot2.matrix.up.z + Rot1.matrix.at.z * Rot2.matrix.at.z + Rot2.matrix.pos.z), + CVector(Rot1.matrix.pos.x * Rot2.matrix.right.x + Rot1.matrix.pos.y * Rot2.matrix.up.x + Rot1.matrix.pos.z * Rot2.matrix.at.x + Rot2.matrix.pos.x, + Rot1.matrix.pos.x * Rot2.matrix.right.y + Rot1.matrix.pos.y * Rot2.matrix.up.y + Rot1.matrix.pos.z * Rot2.matrix.at.y + Rot2.matrix.pos.y, + Rot1.matrix.pos.x * Rot2.matrix.right.z + Rot1.matrix.pos.y * Rot2.matrix.up.z + Rot1.matrix.pos.z * Rot2.matrix.at.z + Rot2.matrix.pos.z)); }; + + friend inline CVector operator*(const CMatrix& matrix, const CVector& vec) + { return CVector(matrix.matrix.up.x * vec.y + matrix.matrix.right.x * vec.x + matrix.matrix.at.x * vec.z + matrix.matrix.pos.x, + matrix.matrix.up.y * vec.y + matrix.matrix.right.y * vec.x + matrix.matrix.at.y * vec.z + matrix.matrix.pos.y, + matrix.matrix.up.z * vec.y + matrix.matrix.right.z * vec.x + matrix.matrix.at.z * vec.z + matrix.matrix.pos.z); }; + + friend inline CMatrix operator+(const CMatrix& Rot1, const CMatrix& Rot2) + { return CMatrix( CVector(Rot1.matrix.right.x + Rot2.matrix.right.x, Rot1.matrix.right.y + Rot2.matrix.right.y, Rot1.matrix.right.z + Rot2.matrix.right.z), + CVector(Rot1.matrix.up.x + Rot2.matrix.up.x, Rot1.matrix.up.y + Rot2.matrix.up.y, Rot1.matrix.up.z + Rot2.matrix.up.z), + CVector(Rot1.matrix.at.x + Rot2.matrix.at.x, Rot1.matrix.at.y + Rot2.matrix.at.y, Rot1.matrix.at.z + Rot2.matrix.at.z), + CVector(Rot1.matrix.pos.x + Rot2.matrix.pos.x, Rot1.matrix.pos.y + Rot2.matrix.pos.y, Rot1.matrix.pos.z + Rot2.matrix.pos.z)); } + + inline CMatrix& operator=(const CMatrix& mat) + { + matrix = mat.matrix; + if ( this->pMatrix ) + UpdateRwMatrix(pMatrix); + return *this; + } + + inline CMatrix& operator+=(const CMatrix& mat) + { + matrix.right.x += mat.matrix.right.x; + matrix.right.y += mat.matrix.right.y; + matrix.right.z += mat.matrix.right.z; + + matrix.up.x += mat.matrix.up.x; + matrix.up.y += mat.matrix.up.y; + matrix.up.z += mat.matrix.up.z; + + matrix.at.x += mat.matrix.at.x; + matrix.at.y += mat.matrix.at.y; + matrix.at.z += mat.matrix.at.z; + + matrix.pos.x += mat.matrix.pos.x; + matrix.pos.y += mat.matrix.pos.y; + matrix.pos.z += mat.matrix.pos.z; + + return *this; + } + + friend inline CMatrix& Invert(const CMatrix& src, CMatrix& dst) + { + dst.matrix.right.x = src.matrix.right.x; + dst.matrix.right.y = src.matrix.up.x; + dst.matrix.right.z = src.matrix.at.x; + + dst.matrix.up.x = src.matrix.right.y; + dst.matrix.up.y = src.matrix.up.y; + dst.matrix.up.z = src.matrix.at.y; + + dst.matrix.at.x = src.matrix.right.z; + dst.matrix.at.y = src.matrix.up.z; + dst.matrix.at.z = src.matrix.at.z; + + dst.matrix.pos.x = dst.matrix.right.x * src.matrix.pos.x; + dst.matrix.pos.y = dst.matrix.right.y * src.matrix.pos.x; + dst.matrix.pos.z = dst.matrix.right.z * src.matrix.pos.x; + + dst.matrix.pos.x += dst.matrix.up.x * src.matrix.pos.y; + dst.matrix.pos.y += dst.matrix.up.y * src.matrix.pos.y; + dst.matrix.pos.z += dst.matrix.up.z * src.matrix.pos.y; + + dst.matrix.pos.x += dst.matrix.at.x * src.matrix.pos.z; + dst.matrix.pos.y += dst.matrix.at.y * src.matrix.pos.z; + dst.matrix.pos.z += dst.matrix.at.z * src.matrix.pos.z; + + dst.matrix.pos.x = -dst.matrix.pos.x; + dst.matrix.pos.y = -dst.matrix.pos.y; + dst.matrix.pos.z = -dst.matrix.pos.z; + + return dst; + } + + friend inline CMatrix Invert(const CMatrix& src) + { + CMatrix NewMatrix; + return CMatrix(Invert(src, NewMatrix)); + } + + friend inline CVector Multiply3x3(const CMatrix& matrix, const CVector& vec) + { return CVector(matrix.matrix.up.x * vec.y + matrix.matrix.right.x * vec.x + matrix.matrix.at.x * vec.z, + matrix.matrix.up.y * vec.y + matrix.matrix.right.y * vec.x + matrix.matrix.at.y * vec.z, + matrix.matrix.up.z * vec.y + matrix.matrix.right.z * vec.x + matrix.matrix.at.z * vec.z); }; + + friend inline CVector Multiply3x3(const CVector& vec, const CMatrix& matrix) + { return CVector(matrix.matrix.right.x * vec.x + matrix.matrix.right.y * vec.y + matrix.matrix.right.z * vec.z, + matrix.matrix.up.x * vec.x + matrix.matrix.up.y * vec.y + matrix.matrix.up.z * vec.z, + matrix.matrix.at.x * vec.x + matrix.matrix.at.y * vec.y + matrix.matrix.at.z * vec.z); }; + + inline CVector* GetRight() + { return reinterpret_cast(&matrix.right); } + inline CVector* GetUp() + { return reinterpret_cast(&matrix.up); } + inline CVector* GetAt() + { return reinterpret_cast(&matrix.at); } + inline CVector* GetPos() + { return reinterpret_cast(&matrix.pos); } + + inline void SetTranslateOnly(float fX, float fY, float fZ) + { matrix.pos.x = fX; matrix.pos.y = fY; matrix.pos.z = fZ; } + + inline void SetRotateX(float fAngle) + { SetRotateXOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; } + inline void SetRotateY(float fAngle) + { SetRotateYOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; } + inline void SetRotateZ(float fAngle) + { SetRotateZOnly(fAngle); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; } + inline void SetRotate(float fAngleX, float fAngleY, float fAngleZ) + { SetRotateOnly(fAngleX, fAngleY, fAngleZ); matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; } + inline void SetTranslate(float fX, float fY, float fZ) + { matrix.right.x = 1.0f; matrix.right.y = 0.0f; matrix.right.z = 0.0f; + matrix.up.x = 0.0f; matrix.up.y = 1.0f; matrix.up.z = 0.0f; + matrix.at.x = 0.0f; matrix.at.y = 0.0f; matrix.at.z = 1.0f; + SetTranslateOnly(fX, fY, fZ); } + + inline void ResetOrientation() + { + matrix.right.x = 1.0f; matrix.right.y = 0.0f; matrix.right.z = 0.0f; + matrix.up.x = 0.0f; matrix.up.y = 1.0f; matrix.up.z = 0.0f; + matrix.at.x = 0.0f; matrix.at.y = 0.0f; matrix.at.z = 1.0f; + } + + inline void SetUnity() + { + matrix.right.x = 1.0f; matrix.right.y = 0.0f; matrix.right.z = 0.0f; + matrix.up.x = 0.0f; matrix.up.y = 1.0f; matrix.up.z = 0.0f; + matrix.at.x = 0.0f; matrix.at.y = 0.0f; matrix.at.z = 1.0f; + matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; + } + + inline void SetScale(float fScale) + { + matrix.right.x = fScale; matrix.right.y = 0.0f; matrix.right.z = 0.0f; + matrix.up.x = 0.0f; matrix.up.y = fScale; matrix.up.z = 0.0f; + matrix.at.x = 0.0f; matrix.at.y = 0.0f; matrix.at.z = fScale; + matrix.pos.x = 0.0f; matrix.pos.y = 0.0f; matrix.pos.z = 0.0f; + } + + inline void RotateX(float fAngle) + { + CMatrix RotationMatrix; + RotationMatrix.SetRotateX(fAngle); + *this = *this * RotationMatrix; + } + + inline void RotateY(float fAngle) + { + CMatrix RotationMatrix; + RotationMatrix.SetRotateY(fAngle); + *this = *this * RotationMatrix; + } + + inline void RotateZ(float fAngle) + { + CMatrix RotationMatrix; + RotationMatrix.SetRotateZ(fAngle); + *this = *this * RotationMatrix; + } + + inline void Rotate(float fAngleX, float fAngleY, float fAngleZ) + { + CMatrix RotationMatrix; + RotationMatrix.SetRotate(fAngleX, fAngleY, fAngleZ); + *this = *this * RotationMatrix; + } + + inline void SetRotateXOnly(float fAngle) + { + matrix.right.x = 1.0f; + matrix.right.y = 0.0f; + matrix.right.z = 0.0f; + + matrix.up.x = 0.0f; + matrix.up.y = cos(fAngle); + matrix.up.z = sin(fAngle); + + matrix.at.x = 0.0f; + matrix.at.y = -sin(fAngle); + matrix.at.z = cos(fAngle); + } + + inline void SetRotateYOnly(float fAngle) + { + matrix.right.x = cos(fAngle); + matrix.right.y = 0.0f; + matrix.right.z = sin(fAngle); + + matrix.up.x = 0.0f; + matrix.up.y = 1.0f; + matrix.up.z = 0.0f; + + matrix.at.x = -sin(fAngle); + matrix.at.y = 0.0f; + matrix.at.z = cos(fAngle); + } + + inline void SetRotateZOnly(float fAngle) + { + matrix.at.x = 0.0f; + matrix.at.y = 0.0f; + matrix.at.z = 1.0f; + + matrix.up.x = -sin(fAngle); + matrix.up.y = cos(fAngle); + matrix.up.z = 0.0f; + + matrix.right.x = cos(fAngle); + matrix.right.y = sin(fAngle); + matrix.right.z = 0.0f; + } + + inline void SetRotateOnly(float fAngleX, float fAngleY, float fAngleZ) + { + matrix.right.x = cos(fAngleZ) * cos(fAngleY) - sin(fAngleZ) * sin(fAngleX) * sin(fAngleY); + matrix.right.y = cos(fAngleZ) * sin(fAngleX) * sin(fAngleY) + sin(fAngleZ) * cos(fAngleY); + matrix.right.z = -cos(fAngleX) * sin(fAngleY); + + matrix.up.x = -sin(fAngleZ) * cos(fAngleX); + matrix.up.y = cos(fAngleZ) * cos(fAngleX); + matrix.up.z = sin(fAngleX); + + matrix.at.x = sin(fAngleZ) * sin(fAngleX) * cos(fAngleY) + cos(fAngleZ) * sin(fAngleY); + matrix.at.y = sin(fAngleZ) * sin(fAngleY) - cos(fAngleZ) * sin(fAngleX) * cos(fAngleY); + matrix.at.z = cos(fAngleX) * cos(fAngleY); + } + + inline void Attach(RwMatrix* pMatrix, bool bHasMatrix) + { + if ( this->pMatrix && haveRwMatrix ) + RwMatrixDestroy(this->pMatrix); + + this->pMatrix = pMatrix; + haveRwMatrix = bHasMatrix; + + Update(); + } + + inline void AttachRw(RwMatrix* pMatrix, bool bHasMatrix) + { + if ( this->pMatrix && haveRwMatrix ) + RwMatrixDestroy(this->pMatrix); + + this->pMatrix = pMatrix; + haveRwMatrix = bHasMatrix; + + UpdateRW(); + } + + inline void Detach() + { + if ( pMatrix ) + { + if ( haveRwMatrix ) + RwMatrixDestroy(pMatrix); + pMatrix = nullptr; + } + } + + inline void UpdateRW() const + { + if ( pMatrix ) + UpdateRwMatrix(pMatrix); + } + + inline void Update() + { + UpdateMatrix(pMatrix); + } + + inline void UpdateMatrix(RwMatrix* pMatrix) + { + matrix.right = pMatrix->right; + matrix.up = pMatrix->up; + matrix.at = pMatrix->at; + matrix.pos = pMatrix->pos; + } + + inline void UpdateRwMatrix(RwMatrix* pMatrix) const + { + pMatrix->right = matrix.right; + pMatrix->up = matrix.up; + pMatrix->at = matrix.at; + pMatrix->pos = matrix.pos; + pMatrix->flags &= ~(rwMATRIXTYPEMASK | rwMATRIXINTERNALIDENTITY); + } + + inline void CopyToRwMatrix(RwMatrix* pMatrix) const + { + pMatrix->right = this->pMatrix->right; + pMatrix->up = this->pMatrix->up; + pMatrix->at = this->pMatrix->at; + pMatrix->pos = this->pMatrix->pos; + pMatrix->flags &= ~(rwMATRIXTYPEMASK | rwMATRIXINTERNALIDENTITY); + } + + inline void CopyOnlyMatrix(const CMatrix& from) + { + matrix = from.matrix; + } +}; + +// These need to land here +inline CVector& CVector::FromMultiply(const CMatrix& mat, const CVector& vec) +{ + return *this = mat * vec; +} + +inline CVector& CVector::FromMultiply3X3(const CMatrix& mat, const CVector& vec) +{ + return *this = Multiply3x3(mat, vec); +} + +#endif \ No newline at end of file diff --git a/includes/Sprite.cpp b/includes/Sprite.cpp new file mode 100644 index 0000000..d34f3b8 --- /dev/null +++ b/includes/Sprite.cpp @@ -0,0 +1,37 @@ +#include "Sprite.h" + + +uint32_t CSprite::CalcAddr; +uint32_t CSprite::FlushAddr; +uint32_t CSprite::RenderOneAddr; +uint32_t CSprite::RenderBufferedAddr; +bool (*CSprite::CalcScreenCoors)(const RwV3d& vecIn, RwV3d* vecOut, float* fWidth, float* fHeight, bool bCheckFarClip, bool bCheckNearClip); + +bool CSprite::CalcScreenCoorsSA(RwV3d const &vecIn, RwV3d *vecOut, float *fWidth, float *fHeight, bool bCheckFarClip, bool bCheckNearClip) +{ + return ((bool(__cdecl *)(RwV3d const &, RwV3d *, float *, float *, bool, bool))CalcAddr) + (vecIn, vecOut, fWidth, fHeight, bCheckFarClip, bCheckNearClip); +} + +bool CSprite::CalcScreenCoorsIIIVC(RwV3d const &vecIn, RwV3d *vecOut, float *fWidth, float *fHeight, bool bCheckFarClip, bool bCheckNearClip) +{ + return ((bool(__cdecl *)(RwV3d const &, RwV3d *, float *, float *, bool))CalcAddr) + (vecIn, vecOut, fWidth, fHeight, bCheckFarClip); +} + +void CSprite::FlushSpriteBuffer() +{ + return ((void(__cdecl *)())FlushAddr)(); +} + +void CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float halfWidth, float halfHeight, unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, float rotate, unsigned char aspect) +{ + return ((void(__cdecl *)(float x, float y, float z, float halfWidth, float halfHeight, unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, float rotate, unsigned char aspect))RenderOneAddr) + (x, y, z, halfWidth, halfHeight, red, green, blue, alpha, rhw, rotate, aspect); +} + +void CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float halfWidth, float halfHeight, unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, float rotate, unsigned char aspect) +{ + return ((void(__cdecl *)(float x, float y, float z, float halfWidth, float halfHeight, unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, float rotate, unsigned char aspect))RenderBufferedAddr) + (x, y, z, halfWidth, halfHeight, red, green, blue, alpha, rhw, rotate, aspect); +} \ No newline at end of file diff --git a/includes/Sprite.h b/includes/Sprite.h new file mode 100644 index 0000000..6faa923 --- /dev/null +++ b/includes/Sprite.h @@ -0,0 +1,26 @@ +#ifndef __SPRITE +#define __SPRITE +#include "..\includes\stdafx.h" + +class CSprite +{ +public: + static uint32_t CalcAddr; + static uint32_t FlushAddr; + static uint32_t RenderOneAddr; + static uint32_t RenderBufferedAddr; + + static bool (*CalcScreenCoors)(const RwV3d& vecIn, RwV3d* vecOut, float* fWidth, float* fHeight, bool bCheckFarClip, bool bCheckNearClip); + static bool CalcScreenCoorsSA(const RwV3d& vecIn, RwV3d* vecOut, float* fWidth, float* fHeight, bool bCheckFarClip, bool bCheckNearClip); + static bool CalcScreenCoorsIIIVC(const RwV3d& vecIn, RwV3d* vecOut, float* fWidth, float* fHeight, bool bCheckFarClip, bool bCheckNearClip); + static void FlushSpriteBuffer(); + + static void RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float halfWidth, float halfHeight, + unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, + float rotate, unsigned char aspect); + + static void RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float halfWidth, float halfHeight, + unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, + float rotate, unsigned char aspect); +}; +#endif \ No newline at end of file diff --git a/includes/rwsdk/errcom.def b/includes/rwsdk/errcom.def new file mode 100644 index 0000000..25f44e1 --- /dev/null +++ b/includes/rwsdk/errcom.def @@ -0,0 +1,60 @@ +RWECODE(E_RW_BADENGINESTATE, + "Engine in incorrect state for this operation") +RWECODE(E_RW_BADOPEN, + "Error opening the file %s") +RWECODE(E_RW_BADPARAM, + "Invalid Parameter passed. %s") +RWECODE(E_RW_BADVERSION, + "The binary file format version is incompatible with this library") +RWECODE(E_RW_DEBUGSTACK, + "Debug Library has Stack Depth mismatch") +RWECODE(E_RW_DEFAULTPIPELINECREATION, + "Creation of a default pipeline (%s) failed") +RWECODE(E_RW_FRAMENOMATRIX, + "The frame does not have an associated matrix") +RWECODE(E_RW_INVIMAGEDEPTH, + "Invalid Image Depth") +RWECODE(E_RW_INVIMAGEFORMAT, + "Image has no pixel memory allocated") +RWECODE(E_RW_INVIMAGEMASK, + "The mask and image are not the same size") +RWECODE(E_RW_INVIMAGESIZE, + "Destination and source images are of differing sizes") +RWECODE(E_RW_INVRASTERDEPTH, + "Invalid Raster depth") +RWECODE(E_RW_INVRASTERFORMAT, + "Unrecognized raster format") +RWECODE(E_RW_INVRASTERLOCKREQ, + "Invalid Raster lock request") +RWECODE(E_RW_INVRASTERMIPLEVEL, + "Invalid Raster mipmap level") +RWECODE(E_RW_INVRASTERSIZE, + "Invalid Raster size") +RWECODE(E_RW_INVRASTERUNLOCKREQ, + "Invalid Raster unlock request") +RWECODE(E_RW_NOFRAME, + "Unable to find Frame") +RWECODE(E_RW_NOMEM, + "Unable to allocate %d bytes of memory") +RWECODE(E_RW_NOMIPMAPGENERATIONCALLBACK, + "No Mipmap generation callback set - use RtMipmapUseDefaultMipmapGenerationCallback") +RWECODE(E_RW_NOTSSEENABLEDCPU, + "Not SSE enabled CPU") +RWECODE(E_RW_NULLP, + "NULL pointer passed to library routine") +RWECODE(E_RW_PLUGININIT, + "Plugin has already been initialized") +RWECODE(E_RW_PLUGINNOTINIT, + "Plugin not initialized") +RWECODE(E_RW_RANGE, + "A supplied parameter was outside the expected range") +RWECODE(E_RW_READ, + "Read error on stream") +RWECODE(E_RW_REDUNDANT_FUNCTION, + "Call to redundant function - scheduled to be dropped from future releases") +RWECODE(E_RW_WRITE, + "Write error on stream") +RWECODE(E_RX_MESHES_RANGES_OVERLAP, + "\n Geometry is in an invalid format for RxPipeline rendering.\n There may be visible artifacts and/or decreased performance.\n Use RpGeometrySortByMaterial.\n [stream %p type %s]") +RWECODE(E_RW_STRING_TRUNCATION, + "strlen(%s) >= %d; truncating at character #%d == %c") diff --git a/includes/rwsdk/errcore.def b/includes/rwsdk/errcore.def new file mode 100644 index 0000000..c71eed5 --- /dev/null +++ b/includes/rwsdk/errcore.def @@ -0,0 +1,117 @@ +RWECODE(E_RW_BADWINDOW, + "Invalid view window dimensions supplied") +RWECODE(E_RW_CHUNKTYPEGET, + "Unable to get a chunk of the given type") +RWECODE(E_RW_DEVICEERROR, + "Device specific error: %s") +RWECODE(E_RW_DEVICEOPEN, + "Request to open device system refused") +RWECODE(E_RW_DEVICESTART, + "Attempt to start Device failed") +RWECODE(E_RW_ENDOFSTREAM, + "At the end of the stream.") +RWECODE(E_RW_FRAMEDESTROYSTATIC, + "RwFrameDestroy called on static frame.") +RWECODE(E_RW_FRAMEBUFFERMISMATCH, + "Resolutions of parent rasters of frame buffer and Z buffer are different") +RWECODE(E_RW_FREELISTFREED, + "Free List value already on the free list") +RWECODE(E_RW_FREELISTINVADDRESS, + "Invalid Free List memory address") +RWECODE(E_RW_FREELISTINVMEMBOUND, + "Invalid Free List memory boundary") +RWECODE(E_RW_FREELISTTRASH, + "An unused Free List entry has been overwritten") +RWECODE(E_RW_INSUFFICIENTRESOURCES, + "Insufficient resources to satisfy the allocation of %d bytes.") +RWECODE(E_RW_INVSTREAMACCESSTYPE, + "Invalid stream access type.") +RWECODE(E_RW_INVSTREAMTYPE, + "Invalid stream type.") +RWECODE(E_RW_NEGCLIPPLANE, + "Negative positioned clip planes are invalid") +RWECODE(E_RW_NOCAMERA, + "Cannot render until a Camera has been created") +RWECODE(E_RW_NOFRAMEBUFFER, + "Camera has no frame buffer raster") +RWECODE(E_RW_NOPARENT, + "The given object has no parent") +RWECODE(E_RW_RASTERRECT, + "Rectangle is not totally within Raster") +RWECODE(E_RW_RASTERSTACK, + "Insufficient Raster stack space available") +RWECODE(E_RW_RASTERSTACKEMPTY, + "No Raster Currently on Stack") +RWECODE(E_RW_READTEXMASK, + "Unable to read Texture %s / Mask %s") +RWECODE(E_RW_STREAMOPEN, + "Unable to open stream : %s") +RWECODE(E_RW_SYSTEMREQUEST, + "A system request call has failed, request code : 0x%x") +RWECODE(E_RW_ZEROLENGTH, + "A Vector of Zero Length was passed for normalizing") +RWECODE(E_RX_CANNOT_TRANSFER_BETWEEN_NODES, + "Node %s cannot output to node %s") +RWECODE(E_RX_CANNOT_TRANSFER_FROM_NODE_TO_PIPELINE, + "Node %s cannot output to specified pipeline") +RWECODE(E_RX_CYCLICPIPELINE, + "Pipeline contains cycles; illegal") +RWECODE(E_RX_DEP_DEPENDENCIESMISMATCH, + "\n" + "*** dependencies cannot be satisfied.\n" + "*** rxCLREQ_REQUIRED on cluster %s, originating\n" + "*** with node %s, not serviced by a rxCLVALID_VALID -\n" + "*** blocked at node %s, output #%ld (\"%s\").") +RWECODE(E_RX_DEP_DUPLICATECLUSTERDEFS, + "\n" + "*** Node %s specifies RxClusterDefinition for cluster %s more than once in\n" + "*** clusters of interest array. Distinct clusters within a pipeline must reference\n" + "*** distinct RxClusterDefinitions, even if the clusters contain the same data type\n") +RWECODE(E_RX_DEP_NULLCLUSTERDEF, + "Node %s specified with RxClusterDefinition pointer NULL for cluster of interest %d\n") +RWECODE(E_RX_DEP_OUTOFMEMORY, + "Dependency chasing; memory alloc failed") +RWECODE(E_RX_EMPTYPIPELINE, + "RwPipeline2Execute cannot execute a pipeline with no nodes :)") +RWECODE(E_RX_FRAGMENTEDPIPELINE, + "Pipeline forms two or more unconnected graphs; illegal") +RWECODE(E_RX_IM3DNOTACTIVE, + "Cannot render Im3D primitives outside of a RwIm3dTransform()/RwIm3dEnd() pair") +RWECODE(E_RX_INVALIDENTRYPOINT, + "Pipeline has an invalid entry point") +RWECODE(E_RX_INVALIDPRIMTYPE, + "Unknown primitive type %d") +RWECODE(E_RX_INVALIDRESUMEPIPELINE, + "RwPipeline2Execute cannot resume a different pipeline to the one previously interrupted") +RWECODE(E_RX_LOCKEDPIPE, + "Illegal operation on a locked pipeline") +RWECODE(E_RX_NODETOOMANYCLUSTERSOFINTEREST, + "Node contains more than RXNODEMAXCLUSTERSOFINTEREST clusters of interest; illegal") +RWECODE(E_RX_NODETOOMANYOUTPUTS, + "Node contains more than RXNODEMAXOUTPUTS outputs; illegal") +RWECODE(E_RX_PIPELINETOOMANYNODES, + "Maximum nodes per pipeline exceeded! You may increase the limit by changing the value of _rxPipelineMaxNodes BEFORE starting RenderWare") +RWECODE(E_RX_NODE_EXECUTION_FAILED, + "Node execution failed - %s") +RWECODE(E_RX_NOVERTS, + "Cannot render Im3D primitive - not enough vertices transformed") +RWECODE(E_RX_PACKETPTRINVALID, + "Value of input/output interruption packets pointer not as expected") +RWECODE(E_RX_PACKETSCOPYFAILED, + "Failed to make copies of packets input to RxPipelineExecute()") +RWECODE(E_RX_RUNFROMNOTVALID, + "RunFrom node not a member of the specified pipeline") +RWECODE(E_RX_RUNTOANDRUNFROM, + "RwPipeline2Execute cannot accept both RunTo *and* RunFrom") +RWECODE(E_RX_RUNTONOTVALID, + "RunTo node not a member of the specified pipeline") +RWECODE(E_RX_TOOMANYVERTS, + "More than 65536 vertices passed to RwIm3DTransform; illegal") +RWECODE(E_RX_UNFINISHEDPIPELINE, + "RwPipeline2Execute must resume and finish an interrupted pipeline") +RWECODE(E_RX_UNLOCKEDPIPE, + "Illegal operation on an unlocked pipeline") +RWECODE(E_RX_UNPROCESSED_PACKETS, + "Unprocessed packets found in finished execution context") +RWECODE(E_RX_UNSATISFIED_REQUIREMENTS, + "Cannot send packet between pipelines, requirements not satisfied. Cluster '%s' is missing") diff --git a/includes/rwsdk/rpadc.h b/includes/rwsdk/rpadc.h new file mode 100644 index 0000000..a66d841 --- /dev/null +++ b/includes/rwsdk/rpadc.h @@ -0,0 +1,116 @@ + +/* *INDENT-OFF* */ + +/* RWPUBLIC */ + +/**************************************************************************** + * + * File: rwg/rwsdk/plugin/adc/rpadc.h + * + * Copyright (C) 2002 Criterion Technologies. + * + * Purpose: RenderWare ADC flag generation plugin + * + ****************************************************************************/ + +#if (!defined(_RP_ADC_H)) +#define _RP_ADC_H + +/** + * \defgroup rpadc RpADC + * \ingroup basicgeometry + * + * Address Control flag generation plugin for RenderWare Graphics. + */ + + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ +#include + +/*===========================================================================* + *--- Private Types ---------------------------------------------------------* + *===========================================================================*/ + +/** + * \ingroup rpadc + * \struct RpADCDataTag + * A structure that handles an object ADC support information. + */ +typedef struct RpADCDataTag +{ + RwBool adcFormatted; /**< ADC support flag */ + RwInt8 *adcBits; /**< Pointer to the object ADC flag array */ + RwInt32 numBits; /**< Number of Bits used for streaming */ +} RpADCData; + +/** + * \ingroup rpadc + * \ref RpADCMeshCallback + * Optional per-mesh callback, allowing the application to opt out of + * conversion of specific meshes by returning FALSE. + * + * \param mesh Pointer to the mesh. + * + * \return TRUE to generate ADC flags. + */ +typedef RwBool (* RpADCMeshCallback)(RpMesh *mesh); + +/* RWPUBLICEND */ + +/*===========================================================================* + *--- Private Variables -----------------------------------------------------* + *===========================================================================*/ + +/*===========================================================================* + *--- Private Defines -------------------------------------------------------* + *===========================================================================*/ + +/*===========================================================================* + *--- Private Functions -----------------------------------------------------* + *===========================================================================*/ + +/* RWPUBLIC */ + +#if (defined(__cplusplus)) +extern "C" +{ +#endif /* (defined(__cplusplus)) */ + +extern RwBool +RpADCPluginAttach(void); + +extern RwBool +RpADCGeometryConvertIgnoreWinding(RpGeometry *geometry); + +extern RwBool +RpADCWorldSectorConvertIgnoreWinding(RpWorldSector *sector); + +extern RwBool +RpADCGeometryConvertPreserveWinding(RpGeometry *geometry); + +extern RwBool +RpADCWorldSectorConvertPreserveWinding(RpWorldSector *sector); + +extern RwInt8 * +RpADCGeometryGetADCSupport(RpGeometry *geometry); + +extern RwInt8 * +RpADCWorldSectorGetADCSupport(RpWorldSector *sector); + +extern RpADCMeshCallback +RpADCGetMeshCallback(void); + +extern void +RpADCSetMeshCallback(RpADCMeshCallback callback); + +#if (defined(__cplusplus)) +} +#endif /* (defined(__cplusplus)) */ + +#endif /* (!defined(_RP_ADC_H)) */ + +/* RWPUBLICEND */ + +/* *INDENT-ON* */ diff --git a/includes/rwsdk/rpadc.rpe b/includes/rwsdk/rpadc.rpe new file mode 100644 index 0000000..82cada7 --- /dev/null +++ b/includes/rwsdk/rpadc.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionADC +{ + + + + e_rwdb_CriterionADCLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionADC e_rwdb_CriterionADC; + + diff --git a/includes/rwsdk/rpanisot.h b/includes/rwsdk/rpanisot.h new file mode 100644 index 0000000..323786f --- /dev/null +++ b/includes/rwsdk/rpanisot.h @@ -0,0 +1,54 @@ +/** + * Anisotropic Texture Sampling Plugin for RenderWare. + */ + +#ifndef RPANISOTPLUGIN_H +#define RPANISOTPLUGIN_H + +/** + * \defgroup rpanisot RpAnisot + * \ingroup mipmapping + * + * Anisotropic Texture Sampling Plugin for RenderWare Graphics. + */ + +/** + * \ingroup rpanisot + * \page rpanisotoverview RpAnisot Plugin Overview + * + * \par Requirements + * \li \b Headers: rwcore.h, rpworld.h, rpanisot.h + * \li \b Libraries: rwcore, rpworld, rpanisot + * \li \b Plugin \b attachments: \ref RpWorldPluginAttach, \ref RpAnisotPluginAttach + * + * \subsection anisotoverview Overview + * The RpAnisot plugin is used to extend an \ref RwTexture with a maximum + * anisotropy value that will be used when a particular texture is drawn. + * When textured polygons are viewed nearly edge on, for example when looking + * dowm a road or a football pitch, distant pixels are not sampled very well + * by trilinear mipmapping and the texture looks smeary. + * Anisotropic sampling takes additional samples, resulting in sharper looking + * textures. Higher numbers of samples will produce better quality results but + * run slower, so should be used in moderation. + * + */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy(void); + +extern RwTexture *RpAnisotTextureSetMaxAnisotropy(RwTexture *tex, RwInt8 val); +extern RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture *tex); + +extern RwBool RpAnisotPluginAttach(void); + +#ifdef __cplusplus +} +#endif + +#endif /* RPANISOTPLUGIN_H */ diff --git a/includes/rwsdk/rpanisot.rpe b/includes/rwsdk/rpanisot.rpe new file mode 100644 index 0000000..bff3120 --- /dev/null +++ b/includes/rwsdk/rpanisot.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLabel +{ + + + + e_rwdb_CriterionLabelLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLabel e_rwdb_CriterionLabel; + + diff --git a/includes/rwsdk/rpcollis.h b/includes/rwsdk/rpcollis.h new file mode 100644 index 0000000..588b627 --- /dev/null +++ b/includes/rwsdk/rpcollis.h @@ -0,0 +1,980 @@ + +/***************************************************************************** + * + * File : rpcollis.h + * + * Abstract : Renderware Graphics Collision Plugin. + * + ***************************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2003 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + *****************************************************************************/ + +#ifndef RPCOLLIS_H +#define RPCOLLIS_H + +/****************************************************************************** + * Include files + */ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpcollis.rpe" /* automatically generated header file */ + +/*---- start: ./ctdata.h----*/ + +/****************************************************************************** + * Defines + */ + +#define rpCOLLTREE_MAXDEPTH 32 + +#define rpCOLLSPLIT_ALIGNMENT 16 + +/* Allow 16 special contents values */ +#define rpCOLLSECTOR_CONTENTS_MAXCOUNT 0xef +#define rpCOLLSECTOR_CONTENTS_SPLIT 0xff + +#define rpCOLLSECTOR_TYPE_NEG 0x01 +#define rpCOLLSECTOR_TYPE_AXISMASK (0x08 | 0x04) +#define rpCOLLSECTOR_TYPE_X 0x00 +#define rpCOLLSECTOR_TYPE_Y 0x04 +#define rpCOLLSECTOR_TYPE_Z 0x08 + +/****************************************************************************** + * Types + */ + +/** + * \ingroup rpcollis + * \struct RpCollSector + * This opaque type represents a node of an \ref RpCollTree, and corresponds + * to a region of space within an axis aligned bounding box. A branch sector + * references a pair of overlapping sub-sectors, and a leaf sector references + * any entries that are contained within the region. + */ +typedef struct RpCollSector RpCollSector; + + +/** + * \ingroup rpcollis + * \struct RpCollTree + * This opaque type represents a collision tree, which uses overlapping + * sectors to recursively divide a set of 'entries' into smaller groups. + * The entries would normally be the triangles of a world + * sector or geometry, but in principle could be anything contained by a + * bounding box (hence the name 'entries' rather than 'triangles'). + * + * The external entries may be sorted according to their location in the + * collision tree, such that any node of the tree corresponds to a contiguous + * block of the ordered set. Alternatively, a remapping array is stored with + * the tree (see \ref RpCollTreeGetEntryMap). The leaf nodes of the tree + * reference the external entries that they contain by specifying a slice of + * the ordered array. + * + * Functions are available for iterating over a collision tree to find all + * leaf sectors that intersect a given line or bounding box. + * + * \see RpCollisionWorldSectorBuildData + * \see RpCollisionGeometryBuildData + * \see RpCollisionWorldSectorGetCollTree + * \see RpCollisionGeometryGetCollTree + * \see RpCollSectorLineItInit + * \see RpCollSectorBBoxItInit + * \see \ref rpcollisoverview + */ +typedef struct RpCollTree RpCollTree; + + +#if !defined(DOXYGEN) + +enum RpCollTreeFlags +{ + rpCOLLTREE_USEMAP = 0x01, + + rpCOLLTREEFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpCollTreeFlags RpCollTreeFlags; + +struct RpCollSector +{ + RwUInt8 type; + RwUInt8 contents; + RwUInt16 index; + RwReal value; +}; + +typedef struct RpCollSplit RpCollSplit; +struct RpCollSplit +{ + RpCollSector leftSector; + RpCollSector rightSector; +}; + +struct RpCollTree +{ + RwUInt32 flags; + RwBBox bbox; + RwUInt16 numEntries; + RwUInt16 numSplits; + RpCollSplit *splits; + RwUInt16 *map; +}; + +#endif /* !defined(DOXYGEN) */ + + +/****************************************************************************** + * Macros + */ + +#define RpCollTreeGetEntryMapMacro(_tree) ((_tree)->map) + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +#define RpCollTreeGetEntryMap(_tree) RpCollTreeGetEntryMapMacro(_tree) +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/****************************************************************************** + * Functions + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpCollTree * +_rpCollTreeCreate(RwUInt16 numEntries, + RwUInt16 numSplits, + RwBBox *bbox, + RwUInt32 flags); + +extern void +_rpCollTreeDestroy(RpCollTree *tree); + +/* + * Streaming + */ +extern RwUInt32 +_rpCollTreeStreamGetSize(const RpCollTree *tree); + +extern const RpCollTree * +_rpCollTreeStreamWrite(const RpCollTree *tree, RwStream *stream); + +extern RpCollTree * +_rpCollTreeStreamRead(RwStream *stream); + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RwUInt16 * +RpCollTreeGetEntryMap(RpCollTree *tree); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./ctdata.h----*/ +/*---- start: ./ctbuild.h----*/ +/*---- end: ./ctbuild.h----*/ +/*---- start: ./ctquery.h----*/ + +#if !defined(DOXYGEN) + +/* RpSector - BBox iterator */ + +typedef struct RpSectorBBoxItNodeInfo RpSectorBBoxItNodeInfo; +struct RpSectorBBoxItNodeInfo +{ + RpSector *sector; +}; + +struct RpSectorBBoxIt +{ + RwBBox bbox; + RpSectorBBoxItNodeInfo stack[rpWORLDMAXBSPDEPTH+1]; + RpSectorBBoxItNodeInfo *curr; +}; + +/* RpCollSector - BBox iterator */ + +typedef struct RpCollSectorBBoxItNodeInfo RpCollSectorBBoxItNodeInfo; +struct RpCollSectorBBoxItNodeInfo +{ + RpCollSector *sector; + RwUInt32 clipFlags; /* RpCollBBoxClipFlags */ +}; + +struct RpCollSectorBBoxIt +{ + RpCollTree *tree; + RwBBox bbox; /* Used for rejection tests. Should be + completely outside object. */ + RwBBox clipBBox; /* Used for setting clip flags. Should + be completely inside object. */ + RpCollSector dummy; + RpCollSectorBBoxItNodeInfo stack[rpCOLLTREE_MAXDEPTH+1]; + RpCollSectorBBoxItNodeInfo *curr; +}; + +/* RpSector - Line iterator */ + +typedef struct RpSectorLineItNodeInfo RpSectorLineItNodeInfo; +struct RpSectorLineItNodeInfo +{ + RpSector *sector; + RwReal pa; /* Start parameter for segment of line in sector */ + RwReal pb; /* End parameter for segment of line in sector */ +}; + +struct RpSectorLineIt +{ + RwV3d start; + RwV3d delta; + RwV3d recip; + RwV3d padding; + RpSectorLineItNodeInfo stack[rpWORLDMAXBSPDEPTH+1]; + RpSectorLineItNodeInfo *curr; +}; + +/* RpCollSector - Line iterator */ + +typedef struct RpCollSectorLineItNodeInfo RpCollSectorLineItNodeInfo; +struct RpCollSectorLineItNodeInfo +{ + RpCollSector *sector; + RwReal pa; /* Start parameter for segment of line in sector */ + RwReal pb; /* End parameter for segment of line in sector */ +}; + +struct RpCollSectorLineIt +{ + RpCollTree *tree; + RwV3d start; + RwV3d delta; + RwV3d recip; + RwV3d padding; + RpCollSector dummy; + RpCollSectorLineItNodeInfo stack[rpCOLLTREE_MAXDEPTH+1]; + RpCollSectorLineItNodeInfo *curr; +}; + +#endif /* !defined(DOXYGEN) */ + + +/** + * \ingroup rpcollis + * RpCollBBoxClipFlags are used to indicate the faces of an \ref RwBBox + * that clip a leaf sector of a collision tree (\ref RpCollTree). The shape + * of the leaf sector is also an axis aligned bounding box. If the flags are + * zero, then the sector is entirely inside the clip box. + * + * \see RpCollSectorBBoxIt + */ +enum RpCollBBoxClipFlags +{ + rpCOLLBBOXCLIP_INFX = 0x01, /**< Clipped by infimum on x-axis */ + rpCOLLBBOXCLIP_SUPX = 0x02, /**< Clipped by supremum on x-axis */ + rpCOLLBBOXCLIP_INFY = 0x04, /**< Clipped by infimum on y-axis */ + rpCOLLBBOXCLIP_SUPY = 0x08, /**< Clipped by supremum on y-axis */ + rpCOLLBBOXCLIP_INFZ = 0x10, /**< Clipped by infimum on z-axis */ + rpCOLLBBOXCLIP_SUPZ = 0x20, /**< Clipped by supremum on z-axis */ + + rpCOLLBBOXCLIP_MASK = 0x3f, + + rpCOLLBBOXCLIPFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum RpCollBBoxClipFlags RpCollBBoxClipFlags; + + +/** + * \ingroup rpcollis + * \struct RpSectorBBoxIt + * This opaque type is an iterator object used for traversing the RpSector + * tree of an \ref RpWorld to find each \ref RpWorldSector (a leaf + * node of the tree) that intersects a given \ref RwBBox. + * + * \see RpSectorBBoxItInit + * \see RpSectorBBoxItFinished + * \see RpSectorBBoxItFindNextWorldSector + */ +typedef struct RpSectorBBoxIt RpSectorBBoxIt; + + +/** + * \ingroup rpcollis + * \struct RpCollSectorBBoxIt + * This opaque type is an iterator object used for traversing the + * \ref RpCollSector nodes of an \ref RpCollTree to find the leaf nodes that + * intersect a given \ref RwBBox. + * + * \see RpCollSectorBBoxItInit + * \see RpCollSectorBBoxItFinished + * \see RpCollSectorBBoxItFindNextEntries + */ +typedef struct RpCollSectorBBoxIt RpCollSectorBBoxIt; + + +/** + * \ingroup rpcollis + * \struct RpSectorLineIt + * This opaque type is an iterator object used for traversing the + * RpSector tree of an \ref RpWorld to find each \ref RpWorldSector + * (a leaf node of the tree) that intersects a given line. + * + * \see RpSectorLineItInit + * \see RpSectorLineItFinished + * \see RpSectorLineItFindNextWorldSector + * \see RpSectorLineItSetFarClip + */ +typedef struct RpSectorLineIt RpSectorLineIt; + + +/** + * \ingroup rpcollis + * \struct RpCollSectorLineIt + * This opaque type is an iterator object used for traversing the + * \ref RpCollSector nodes of an \ref RpCollTree to find the leaf nodes + * that intersect a given line. + * + * \see RpCollSectorLineItInit + * \see RpCollSectorLineItInitFromSectorIt + * \see RpCollSectorLineItFinished + * \see RpCollSectorLineItFindNextEntries + * \see RpCollSectorLineItSetFarClip + */ +typedef struct RpCollSectorLineIt RpCollSectorLineIt; + + +/****************************************************************************** + * Macros + */ + +/* + * Line and BBox Iterators - test for completion + */ + +#define _rpSectorLineItFinishedMacro(_it) ((_it)->curr <= (_it)->stack) +#define _rpSectorBBoxItFinishedMacro(_it) ((_it)->curr <= (_it)->stack) +#define _rpCollSectorLineItFinishedMacro(_it) ((_it)->curr <= (_it)->stack) +#define _rpCollSectorBBoxItFinishedMacro(_it) ((_it)->curr <= (_it)->stack) + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpSectorLineItFinished(_it) _rpSectorLineItFinishedMacro(_it) +#define RpSectorBBoxItFinished(_it) _rpSectorBBoxItFinishedMacro(_it) +#define RpCollSectorLineItFinished(_it) _rpCollSectorLineItFinishedMacro(_it) +#define RpCollSectorBBoxItFinished(_it) _rpCollSectorBBoxItFinishedMacro(_it) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RwBool +RpSectorBBoxItFinished(RpSectorBBoxIt *it); + +extern RwBool +RpSectorLineItFinished(RpSectorLineIt *it); + +extern RwBool +RpCollSectorBBoxItFinished(RpCollSectorBBoxIt *it); + +extern RwBool +RpCollSectorLineItFinished(RpCollSectorLineIt *it); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* + * RpSector iterators + */ + +extern void +RpSectorBBoxItInit(RpSectorBBoxIt *it, + RpWorld *world, + RwBBox *bbox); + +extern RpWorldSector * +RpSectorBBoxItFindNextWorldSector(RpSectorBBoxIt *it); + +extern void +RpSectorLineItInit(RpSectorLineIt *it, + RpWorld *world, + RwLine *line, + RwV3d *padding); + +extern RpWorldSector * +RpSectorLineItFindNextWorldSector(RpSectorLineIt *it); + +extern void +RpSectorLineItSetFarClip(RpSectorLineIt *it, + RwReal value); + +/* + * RpCollSector iterators + */ + +extern void +RpCollSectorBBoxItInit(RpCollSectorBBoxIt *it, + RpCollTree *tree, + RwBBox *outerBBox, + RwBBox *innerBBox); + +extern void +RpCollSectorBBoxItFindNextEntries(RpCollSectorBBoxIt *it, + RwUInt16 *start, + RwUInt16 *count, + RwUInt32 *clipFlags); + +extern void +RpCollSectorLineItInit(RpCollSectorLineIt *it, + RpCollTree *tree, + RwLine *line, + RwV3d *padding); + +extern void +RpCollSectorLineItInitFromSectorIt(RpCollSectorLineIt *it, + RpCollTree *tree, + RpSectorLineIt *sectIt); + +extern void +RpCollSectorLineItFindNextEntries(RpCollSectorLineIt *it, + RwUInt16 *start, + RwUInt16 *count); + +extern void +RpCollSectorLineItSetFarClip(RpCollSectorLineIt *it, + RwReal value); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./ctquery.h----*/ + +/*---- start: ./colldata.h----*/ + +/****************************************************************************** + * API types/globals/macros + */ + +#if !defined(DOXYGEN) +typedef struct RpCollisionData RpCollisionData; +struct RpCollisionData +{ + RpCollTree *tree; +}; +#endif /* !defined(DOXYGEN) */ + +#define _rpCollisionGeometryGetDataMacro(_geometry) \ + RWPLUGINOFFSET(RpCollisionData, _geometry, _rpCollisionGeometryDataOffset) + +#define _rpCollisionWorldSectorGetDataMacro(_sector) \ + RWPLUGINOFFSET(RpCollisionData, _sector, _rpCollisionWorldSectorDataOffset) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpCollisionGeometryGetCollTree(_geometry) \ + (_rpCollisionGeometryGetDataMacro(_geometry)->tree) + +#define RpCollisionWorldSectorGetCollTree(_sector) \ + (_rpCollisionWorldSectorGetDataMacro(_sector)->tree) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/****************************************************************************** + * Functions + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwInt32 _rpCollisionGeometryDataOffset; +extern RwInt32 _rpCollisionWorldSectorDataOffset; + +/* + * Collision data + */ + +extern RwBool +RpCollisionPluginAttach(void); + +/* + * Worlds + */ +extern RwBool +RpCollisionWorldQueryData(RpWorld *world); + +extern RpWorld * +RpCollisionWorldDestroyData(RpWorld *world); + +/* + * World Sectors + */ + +extern RpWorldSector * +RpCollisionWorldSectorDestroyData(RpWorldSector *worldSector); + +extern RwBool +RpCollisionWorldSectorQueryData(RpWorldSector *worldSector); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RpCollTree * +RpCollisionWorldSectorGetCollTree(RpWorldSector *worldSector); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RpWorldSector * +_rpCollisionWorldSectorSetCollTree(RpWorldSector *worldSector, + RpCollTree *collTree); +/* + * Geometries + */ + +extern RpGeometry * +RpCollisionGeometryDestroyData(RpGeometry *geometry); + +extern RwBool +RpCollisionGeometryQueryData(RpGeometry *geometry); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RpCollTree * +RpCollisionGeometryGetCollTree(RpGeometry *geometry); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RpGeometry * +_rpCollisionGeometrySetCollTree(RpGeometry *geometry, + RpCollTree *collTree); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./colldata.h----*/ +/*---- start: ./collbuild.h----*/ + +/****************************************************************************** + * Types + */ + +/** + * \ingroup rpcollis + * These flags are used in an \ref RpCollisionBuildParam structure to + * control the generation of collision data for an \ref RpGeometry or + * \ref RpWorldSector. + * + * \see RpCollisionGeometryBuildData + * \see RpCollisionWorldSectorBuildData + * \see RpCollisionWorldBuildData + */ +enum RpCollisionBuildFlags +{ + rpCOLLISIONBUILD_SORTTRIANGLES = 0x01, + /**< + * Use with caution. This specifies that the triangles of an + * \ref RpWorldSector or \ref RpGeometry should be sorted according to + * their location in the collision tree, thus eliminating the need + * for a remapping array in the datastructure (see + * \ref RpCollTreeGetEntryMap). + * + * If this option is used, it is the responsibility of the application to + * update any additional data in the world sector or geometry that is + * dependent on the triangle order. + * + * If the sort order is required by the application, an + * \ref RpCollisionBuildSortCallBack should be specified in the + * \ref RpCollisionBuildParam. + */ + + rpCOLLISIONBUILDFLAGS_FORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpCollisionBuildFlags RpCollisionBuildFlags; + + +/** + * \ingroup rpcollis + * RpCollisionBuildSortCallBack represents a function that may be called + * during the generation of collision data for an \ref RpWorldSector or + * \ref RpGeometry when the \ref rpCOLLISIONBUILD_SORTTRIANGLES option is + * used. This option means that the triangles of the world sector + * or geometry are automatically sorted, and this call back is only + * required in cases where additional triangle data must be processed + * such as an \ref RpUserDataArray. + * + * The call back may be setup in the \ref RpCollisionBuildParam. + * + * \param object \ref RpWorldSector or \ref RpGeometry. Use + * \ref RwObjectGetType to distinguish between the two. + * \param tree The \ref RpCollTree for the sector or geometry. + * \param table An array holding the sort table. This represents the + * new triangle array and each entry contains the + * original index of the triangle. + * \param data Application specific data. + * + * \return Pointer to the world sector or geometry. + * + * \see RpCollisionGeometryBuildData + * \see RpCollisionWorldSectorBuildData + * \see RpCollisionWorldBuildData + */ +typedef void * (*RpCollisionBuildSortCallBack)(void *object, + RpCollTree *tree, + RwUInt16 *sortTable, + void *data); + +/** + * \ingroup rpcollis + * \struct RpCollisionBuildParam + * This parameter block may be passed to the functions + * \ref RpCollisionWorldSectorBuildData, \ref RpCollisionWorldBuildData + * and \ref RpCollisionGeometryBuildData to control the generation of + * collision data (otherwise a NULL argument indicates that default + * settings should be used). The function + * \ref RpCollisionBuildParamInitDefaults can be used to initialize the + * parameters to their default settings. + */ +typedef struct RpCollisionBuildParam RpCollisionBuildParam; +struct RpCollisionBuildParam +{ + RwUInt32 flags; + /**< \ref RpCollisionBuildFlags */ + + RpCollisionBuildSortCallBack sortCallBack; + /**< Function to recieve information about sorting order when the + \ref rpCOLLISIONBUILD_SORTTRIANGLES option is set. */ + + void *sortCallBackData; + /**< Data to be passed to the sort call back */ +}; + + +/****************************************************************************** + * Functions + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* General collision data */ +extern RpCollisionBuildParam * +RpCollisionBuildParamInitDefaults(RpCollisionBuildParam *param); + +/* WorldSector collision data */ +extern RpWorldSector * +RpCollisionWorldSectorBuildData( + RpWorldSector *worldSector, + RpCollisionBuildParam *param); + +/* World collision data (convenience functions which call WorldSector functions) */ +extern RpWorld * +RpCollisionWorldBuildData( + RpWorld *world, + RpCollisionBuildParam *param); + +/* Geometry collision data */ +extern RpGeometry * +RpCollisionGeometryBuildData( + RpGeometry *geometry, + RpCollisionBuildParam *param); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./collbuild.h----*/ +/*---- start: ./collquery.h----*/ + +/****************************************************************************** + * Types + */ + +/** + * \ingroup rpcollis + * RpIntersectType, this type represents the different types of + * primitives that can be used to intersect with an object (for example, see + * \ref RpCollisionWorldForAllIntersections): + */ +enum RpIntersectType +{ + rpINTERSECTNONE = 0, + rpINTERSECTLINE, /** +#include + +#include +#include + +#ifdef RWDEBUG + +/**************************************************************************** + Defines + */ + + /**************************************************************************** + Local (static) Globals + */ + +/* The strings used in the debug error reporting are derived from the + * .def files + */ + +#define RWECODE(a,b) RWSTRING(b), + +static const RwChar *rw_err_str[] = +{ +#include "rperror.def" + RWSTRING("Last Error") +}; + +#undef RWECODE +#define RWECODE(a,b) RWSTRING(#a), + +static const RwChar *rw_err_cstr[] = +{ +#include "rperror.def" + RWSTRING("E_RW_LAST") +}; + +#undef RWECODE + +static RwChar dberr[512]; + +RwChar * +rwPLUGIN_ERRFUNC(RwInt32 code,...) +{ + va_list ap; + +#if (0) + RWFUNCTION(RWSTRING("rwPLUGIN_ERRFUNC")); +#endif /* (0) */ + + va_start(ap, code); + + rwstrcpy(dberr, rw_err_cstr[code]); + rwstrcat(dberr, RWSTRING(" : ")); + rwvsprintf(&dberr[rwstrlen(dberr)], rw_err_str[code], ap); + va_end(ap); + return dberr; +} + +#endif /* RWDEBUG */ + diff --git a/includes/rwsdk/rpdbgerr.h b/includes/rwsdk/rpdbgerr.h new file mode 100644 index 0000000..a3284a9 --- /dev/null +++ b/includes/rwsdk/rpdbgerr.h @@ -0,0 +1,311 @@ +/*************************************************************************** + * * + * Module : badebug.h * + * * + * Purpose : Debug handling * + * * + **************************************************************************/ + +#ifndef RWDEBUG_H +#define RWDEBUG_H + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) +#if (defined(_MSC_VER)) +#if (_MSC_VER>=1000) + +/* Pick up _ASSERTE macro */ +#ifdef _XBOX +#include +#endif /* _XBOX */ +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#undef RWASSERTE +#define RWASSERTE(_condition) _ASSERTE(_condition) +#endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#if (!defined(RWASSERTE)) +#define RWASSERTE(_condition) /* No-Op */ +#endif /* (!defined(RWASSERTE)) */ + +#if (!defined(RWPENTER)) +#define RWPENTER(_func) /* No-Op */ +#endif /* (!defined(RWPENTER)) */ + +#if (!defined(RWPEXIT)) +#define RWPEXIT(_func) /* No-Op */ +#endif /* (!defined(RWPEXIT)) */ + +/**************************************************************************** + Includes + */ + +#include + +#include "rpplugin.h" + +/**************************************************************************** + Defines + */ + +#ifdef RWDEBUG + +#if (!(defined(RWDEBUGSTACKDEPTH))) +#define RWDEBUGSTACKDEPTH (RWSRCGLOBAL(debugStackDepth)) +#endif /* (!(defined(RWDEBUGSTACKDEPTH))) */ + +/* Message macros */ + +#ifdef RWTRACE + +/* Note RWTRACE should only be defined for internal builds. It should + * also only be used rarely. It will cause the generation of Trace + * messages for all functions. Not just those directly called from + * the application + */ + +#define RWAPIFUNCTION(function) \ +static const RwChar __dbFunctionName[] = function; \ +const RwInt32 startstackdepth = RWDEBUGSTACKDEPTH++; \ +RWPENTER(__dbFunctionName); \ +if (RWSRCGLOBAL(debugTrace)) \ +{ \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, \ + _rwdbsprintf("Enter %s [Depth %d]", \ + (startstackdepth)?"SPI":"API", \ + (int)startstackdepth)); \ +} + +#define RWFUNCTION(function) RWAPIFUNCTION(function) + +#define RWRETURN(result) \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon(E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return (result); \ +} \ +while (0) + +#define RWRETURNVOID() \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon (E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return; \ +} \ +while(0) + +#else /* RWTRACE */ + +/* Defining RWSTACKDEPTHCHECKING in a non-RWTRACE build will enable stack + depth checking on entry and exit of API and non API functions. It also + allows a trace of the entry and exit from the RenderWare Graphics + library. + This functionality is disabled by default because it is not thread-safe + */ +#ifdef RWSTACKDEPTHCHECKING + +#define RWSTACKDEPTHCHECKONENTRY() \ + const RwInt32 startstackdepth = RWDEBUGSTACKDEPTH++; \ + if (RWSRCGLOBAL(debugTrace) && !startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Enter")); \ + } + +#define RWSTACKDEPTHCHECKONRETURN() \ +MACRO_START \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon(E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace) && (!startstackdepth)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ +} \ +MACRO_STOP + +#else /* RWSTACKDEPTHCHECKING */ + +#define RWSTACKDEPTHCHECKONENTRY() +#define RWSTACKDEPTHCHECKONRETURN() + +#endif /* RWSTACKDEPTHCHECKING */ + + +#define RWAPIFUNCTION(function) \ +static const RwChar __dbFunctionName[] = function; \ +do { } while (__dbFunctionName != __dbFunctionName); \ +RWSTACKDEPTHCHECKONENTRY(); \ +RWPENTER(__dbFunctionName); + +#define RWFUNCTION(function) RWAPIFUNCTION(function) + +#define RWRETURN(result) \ +MACRO_START \ +{ \ + RWSTACKDEPTHCHECKONRETURN(); \ + RWPEXIT(__dbFunctionName); \ + return (result); \ +} \ +MACRO_STOP + +#define RWRETURNVOID() \ +MACRO_START \ +{ \ + RWSTACKDEPTHCHECKONRETURN(); \ + RWPEXIT(__dbFunctionName); \ + return; \ +} \ +MACRO_STOP + +#endif /* RWTRACE */ + +#define RWERROR(ecode) \ +do \ +{ \ + RwError _rwErrorCode; \ + \ + _rwErrorCode.pluginID = rwPLUGIN_ID; \ + _rwErrorCode.errorCode = _rwerror ecode; \ + \ + RwErrorSet(&_rwErrorCode); \ + \ + if (_rwErrorCode.errorCode & 0x80000000) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon ecode); \ + } \ + else \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + rwPLUGIN_ERRFUNC ecode); \ + } \ +} \ +while(0); + +#define RWMESSAGE(args) \ +do \ +{ \ + RwDebugSendMessage(rwDEBUGMESSAGE, \ + __dbFunctionName, \ + _rwdbsprintf args); \ +} \ +while (0) + +#define RWASSERT(condition) \ +do \ +{ \ + if (!(condition)) \ + { \ + RwDebugSendMessage(rwDEBUGASSERT, \ + __dbFunctionName, \ + RWSTRING(#condition)); \ + } \ + RWASSERTE(condition); \ +} \ +while (0) + +#define RWASSERTM(condition, messageArgs) \ +do \ +{ \ + if (!(condition)) \ + { \ + RwDebugSendMessage(rwDEBUGASSERT, \ + __dbFunctionName, \ + RWSTRING(#condition)); \ + RwDebugSendMessage(rwDEBUGMESSAGE, \ + __dbFunctionName, \ + _rwdbsprintf messageArgs); \ + } \ + RWASSERTE(condition); \ +} \ +while (0) + +#else /* RWDEBUG */ + +#define RWRETURN(value) return(value) +#define RWRETURNVOID() return +#define RWERROR(errorcode) \ +do \ +{ \ + RwError _rwErrorCode; \ + \ + _rwErrorCode.pluginID = rwPLUGIN_ID; \ + _rwErrorCode.errorCode = _rwerror errorcode; \ + \ + RwErrorSet(&_rwErrorCode); \ +} \ +while (0) +#define RWFUNCTION(name) +#define RWAPIFUNCTION(name) +#define RWASSERT(condition) +#define RWASSERTM(condition, messageArgs) +#define RWMESSAGE(args) + +#endif + +#ifdef RWSTACKDEPTHCHECKING +#define RWVALIDATEDEBUGSTACKDEPTH() \ + RWASSERT(1 == (RWDEBUGSTACKDEPTH - startstackdepth)) +#else /* RWSTACKDEPTHCHECKING */ +#define RWVALIDATEDEBUGSTACKDEPTH() +#endif /* RWSTACKDEPTHCHECKING */ + +/**************************************************************************** + Functions + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +RwChar *rwPLUGIN_ERRFUNC(RwInt32 code, ...); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWDEBUG_H */ diff --git a/includes/rwsdk/rpdmorph.h b/includes/rwsdk/rpdmorph.h new file mode 100644 index 0000000..7dc47dd --- /dev/null +++ b/includes/rwsdk/rpdmorph.h @@ -0,0 +1,502 @@ +#ifndef RPDMORPH_H +#define RPDMORPH_H + +#include +#include + +#if ((defined(GCN_DRVMODEL_H) || \ + defined(XBOX_DRVMODEL_H))) +#include "dmorphplatformapi.h" +#endif + +/*---- start: ./dmorph.h----*/ +/** + * \defgroup rpdmorph RpDMorph + * \ingroup deltamorphing + * + * Delta Morphing Plugin for RenderWare Graphics. + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +extern RwBool RpDMorphPluginAttach( void ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/*---- end: ./dmorph.h----*/ +/*---- start: ./dmphanim.h----*/ +#define rpDMORPHNULLFRAME ((RwUInt32)~0) +/*--- rpDMorphFrame --------------------------------------------------------- + * + * Animation frame. + */ +typedef struct rpDMorphFrame rpDMorphFrame; + +#if (!defined(DOXYGEN)) +struct rpDMorphFrame +{ + /* Ordering must be maintained here for stream compatibility */ + + /*--- Interpolation data ---*/ + RwReal startValue; + RwReal endValue; + RwReal duration; + /*--- Utility data ---*/ + RwReal recipDuration; + /*--- Linking ---*/ + RwUInt32 nextFrame; +}; +#endif /* (!defined(DOXYGEN)) */ + +/*--- rpDMorphFrameSequence ------------------------------------------------- + * + * A linked sequence of animation frames. + */ +typedef struct rpDMorphFrameSequence rpDMorphFrameSequence; + +#if (!defined(DOXYGEN)) +struct rpDMorphFrameSequence +{ + RwUInt32 numFrames; + rpDMorphFrame *frames; + +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpdmorph + * \struct RpDMorphAnimation + * Contains frame sequences for animating delta + * morph target objects. + * This should be considered an opaque type. + * Use the RpDMorphAnimation API + * functions to access. + */ +typedef struct RpDMorphAnimation RpDMorphAnimation; + +/*--- RpDMorphAnimation ----------------------------------------------------- + * + * An array of animation sequences, one for each morph target. + */ +#if (!defined(DOXYGEN)) +struct RpDMorphAnimation +{ + RwUInt32 numDMorphTargets; + rpDMorphFrameSequence *frameSequences; +}; +#endif /* (!defined(DOXYGEN)) */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/*===========================================================================* + *--- Plugin API Functions --------------------------------------------------* + *===========================================================================*/ + +/*--- Animation Functions -------------------------------------------------- + */ +extern RpDMorphAnimation * +RpDMorphAnimationCreate(RwUInt32 numDMorphTargets); + +extern RpDMorphAnimation * +RpDMorphAnimationDestroy(RpDMorphAnimation *anim); + +extern RwUInt32 +RpDMorphAnimationGetNumDMorphTargets(RpDMorphAnimation *animation); + +/* Animation Frames */ +extern RpDMorphAnimation * +RpDMorphAnimationCreateFrames(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 numFrames); + +extern RpDMorphAnimation * +RpDMorphAnimationDestroyFrames(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex); + +extern RwUInt32 +RpDMorphAnimationGetNumFrames(RpDMorphAnimation *animation, + RwUInt32 dMorphTargetIndex); + +/* Stream I/O */ +extern RpDMorphAnimation * +RpDMorphAnimationStreamRead(RwStream *stream); + +extern RpDMorphAnimation * +RpDMorphAnimationStreamWrite(RpDMorphAnimation *animation, + RwStream *stream); + +extern RwUInt32 +RpDMorphAnimationStreamGetSize(RpDMorphAnimation *animation); + +extern RpDMorphAnimation * +RpDMorphAnimationRead(const RwChar *filename); + +extern RpDMorphAnimation * +RpDMorphAnimationWrite(RpDMorphAnimation *animation, const RwChar *filename); + +/*--- Animation Frame Functions -------------------------------------------- + * + * These functions work on the DMorphAnimationFrame level. + * Each Frame can have a reference to the next Frame for the + * DMorphTarget. + */ +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetNext(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwUInt32 nextFrame ); + +extern RwUInt32 +RpDMorphAnimationFrameGetNext(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSet(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal startValue, + RwReal endValue, + RwReal duration, + RwUInt32 nextFrame ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetStartValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal startValue ); + +extern RwReal +RpDMorphAnimationFrameGetStartValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetEndValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal endValue ); + +extern RwReal +RpDMorphAnimationFrameGetEndValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetDuration(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal duration ); + +extern RwReal +RpDMorphAnimationFrameGetDuration(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/*---- end: ./dmphanim.h----*/ +/*---- start: ./dmphintp.h----*/ +/*--- RpDMorphInterpolator -------------------------------------------------- + * + * Data holding current position in an animation. + */ +typedef struct rpDMorphInterpolator rpDMorphInterpolator; + +#if (!defined(DOXYGEN)) +struct rpDMorphInterpolator +{ + RpDMorphAnimation *animation; + RwReal animTime; + rpDMorphFrame **currFrames; + RwReal *currTimes; + RpAtomicCallBack loopCallBack; + void *loopCallBackData; +}; +#endif /* (!defined(DOXYGEN)) */ + +/*--- rpDMorphAtomicData --------------------------------------------------- + * + * This is an extension to RpAtomic. + */ +typedef struct rpDMorphAtomicData rpDMorphAtomicData; + +#if (!defined(DOXYGEN)) +struct rpDMorphAtomicData +{ + /*--- Morph state data ---*/ + RwReal *values; + + /*--- Animation interpolator ---*/ + rpDMorphInterpolator *interpolator; + + /*--- Render callback chaining ---*/ + RpAtomicCallBackRender defRenderCallBack; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpdmorph + * \ref RpDMorphType defines the different ways a dmorph atomic can + * be rendered. Once a dmorph \ref RpGeometry has been attached to + * an \ref RpAtomic the atomic must be setup with the correct dmorph + * rendering pipeline with \ref RpDMorphAtomicSetType. + */ +enum RpDMorphType +{ + rpNADMORPHTYPE = 0, /** +#include +#include + +#include +#include + +#include /* Note: each vendor can choose their own method for + * allocation of unique ID's. This file defines + * the ID's used by Criterion. + */ +#include /* automatically generated header file */ +#include +#include + +#define rpHANIMSTREAMCURRENTVERSION 0x100 + +#if (!defined(DOXYGEN)) + +typedef struct RpHAnimAtomicGlobalVars RpHAnimAtomicGlobalVars; + +struct RpHAnimAtomicGlobalVars +{ + RwInt32 engineOffset; + RwFreeList *HAnimFreeList; +}; + +#endif /* (!defined(DOXYGEN)) */ + +#define rpHANIMSTDKEYFRAMESIZE sizeof(RpHAnimKeyFrame) +#define rpHANIMSTDKEYFRAMETYPEID 0x1 + +#define RpV3dInterpolate(o,a,s,b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ((s)) * (((b)->x) - ((a)->x))); \ + (o)->y = (((a)->y) + ((s)) * (((b)->y) - ((a)->y))); \ + (o)->z = (((a)->z) + ((s)) * (((b)->z) - ((a)->z))); \ +} \ +MACRO_STOP + + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrame + * typedef for struct RpHAnimKeyFrame. Based on \ref RtAnimKeyFrameHeader. + */ +typedef struct RpHAnimKeyFrame RpHAnimKeyFrame; + +/** + * \ingroup rphanim + * \struct RpHAnimKeyFrame + * A structure representing the standard keyframe data. Sequences of + * such keyframes in an \ref RtAnimAnimation defines the animation of each + * node in a hierarchy. + */ +struct RpHAnimKeyFrame +{ + RpHAnimKeyFrame *prevFrame; /**< Pointer to the previous keyframe */ + RwReal time; /**< Time at keyframe */ + RtQuat q; /**< Quaternion rotation at keyframe */ + RwV3d t; /**< Translation at keyframe */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimInterpFrame + * typedef for struct RpHAnimInterpFrame. Based on \ref RtAnimInterpFrameHeader. + */ +typedef struct RpHAnimInterpFrame RpHAnimInterpFrame; + +/** + * \ingroup rphanim + * \struct RpHAnimInterpFrame + * A structure representing an interpolated keyframe. The initial part of the + * structure matches \ref RtAnimInterpFrameHeader. + */ +struct RpHAnimInterpFrame +{ + RpHAnimKeyFrame *keyFrame1; + /**< Pointer to 1st keyframe of current interpolation pair */ + RpHAnimKeyFrame *keyFrame2; + /**< Pointer to 2nd keyframe of current interpolation pair */ + RtQuat q; /**< Quaternion rotation */ + RwV3d t; /**< Translation */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimHierarchy typedef for struct RpHAnimHierarchy + */ +typedef struct RpHAnimHierarchy RpHAnimHierarchy; + +/* Flags for FrameInfos */ + +#define rpHANIMPOPPARENTMATRIX 0x01 +#define rpHANIMPUSHPARENTMATRIX 0x02 + +/** + * \ingroup rphanim + * \ref RpHAnimNodeInfo + * typedef for struct RpHAnimNodeInfo + */ +typedef struct RpHAnimNodeInfo RpHAnimNodeInfo; + +/** + * \ingroup rphanim + * \struct RpHAnimNodeInfo + * + * Used to describe a hierarchy toplogy. + * It holds flags representing its position in the + * hierarchy as well as a pointer to the matching \ref RwFrame if the + * hierarchy has been attached to a \ref RwFrame hierarchy. + * + */ +struct RpHAnimNodeInfo +{ + RwInt32 nodeID; /**< User defined ID for this node */ + RwInt32 nodeIndex; /**< Array index of node */ + RwInt32 flags; /**< Matrix push/pop flags */ + RwFrame * pFrame; /**< Pointer to an attached RwFrame (see \ref RpHAnimHierarchyAttach) */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimHierarchyFlag defines type and update modes in HAnimHierarchies + */ +enum RpHAnimHierarchyFlag +{ + /* creation flags */ + rpHANIMHIERARCHYSUBHIERARCHY = 0x01, /**< This hierarchy is a sub-hierarchy */ + rpHANIMHIERARCHYNOMATRICES = 0x02, /**< This hierarchy has no local matrices */ + + /* update flags */ + rpHANIMHIERARCHYUPDATEMODELLINGMATRICES = 0x1000, /**< This hierarchy updates modeling matrices */ + rpHANIMHIERARCHYUPDATELTMS = 0x2000, /**< This hierarchy updates LTMs */ + rpHANIMHIERARCHYLOCALSPACEMATRICES = 0x4000, /**< This hierarchy calculates matrices in a space + relative to its root */ + + rpHANIMHIERARCHYFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/* + * These flags are used to control the creation and + * update status of the hierarchy + */ +typedef enum RpHAnimHierarchyFlag RpHAnimHierarchyFlag; + +/** + * \ingroup rphanim + * \struct RpHAnimHierarchy + * An RpHAnimHierarchy is used to "play back" an animation. + * + * The structure of a hierarchy is defined by an array + * of \ref RpHAnimNodeInfo structures. + * + * The hierarchy is defined by running through the node array in order, + * pushing the parent-node's matrix whenever a child is reached that has + * more than one sibling, and popping the parent matrix when a "leaf" + * node is encountered. + * + */ +struct RpHAnimHierarchy +{ + RwInt32 flags; /**< Flags for the hierarchy */ + RwInt32 numNodes; /**< Number of nodes in the hierarchy */ + + RwMatrix *pMatrixArray; /**< Pointer to node matrices*/ + void *pMatrixArrayUnaligned; /**< Pointer to memory used for node matrices + * from which the aligned pMatrixArray is allocated */ + RpHAnimNodeInfo *pNodeInfo; /**< Array of node information (push/pop flags etc) */ + RwFrame *parentFrame; /**< Pointer to the Root RwFrame of the hierarchy this + * RpHAnimHierarchy represents */ + RpHAnimHierarchy *parentHierarchy; /**< Internal use */ + RwInt32 rootParentOffset; /**< Internal use */ + + RtAnimInterpolator *currentAnim; /**< Internal use */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimFrameExtension typedef for struct RpHAnimFrameExtension + */ + +typedef struct RpHAnimFrameExtension RpHAnimFrameExtension; + +/** + * \ingroup rphanim + * \struct RpHAnimFrameExtension + * + * Used to extend \ref RwFrame objects, and thus + * allow the mapping between animation hierarchy node ID and \ref RwFrame. + * + */ +struct RpHAnimFrameExtension +{ + RwInt32 id; /**< ID given to this RwFrame (default of -1) */ + RpHAnimHierarchy *hierarchy; /**< Pointer to Animation hierarchy attached to this RwFrame */ +}; + +/*--- Plugin API Functions ---*/ + +#define RpHAnimHierarchySetFlagsMacro(hierarchy,_flags) \ + (((hierarchy)->flags = _flags), (hierarchy)) + +#define RpHAnimHierarchyGetFlagsMacro(hierarchy) \ + ((hierarchy)->flags) + +#define RpHAnimKeyFrameToMatrixMacro(_matrix,_voidIFrame) \ +MACRO_START \ +{ \ + RpHAnimInterpFrame * iFrame = (RpHAnimInterpFrame *)(_voidIFrame); \ + \ + /* \ + * RpHAnim uses the same types of quaternion as RtQuat \ + * hence no conjugate call as in RpSkin \ + */ \ + \ + RtQuatUnitConvertToMatrix(&iFrame->q,(_matrix)); \ + \ + (_matrix)->pos.x = iFrame->t.x; \ + (_matrix)->pos.y = iFrame->t.y; \ + (_matrix)->pos.z = iFrame->t.z; \ +} \ +MACRO_STOP + + + +#if (! defined(RWDEBUG)) + +#define RpHAnimHierarchySetFlags(hierarchy,_flags) \ + RpHAnimHierarchySetFlagsMacro(hierarchy,_flags) + +#define RpHAnimHierarchyGetFlags(hierarchy) \ + (RpHAnimHierarchyFlag)RpHAnimHierarchyGetFlagsMacro(hierarchy) +#endif /* (! defined(RWDEBUG)) */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpHAnimAtomicGlobalVars RpHAnimAtomicGlobals; + +#if (defined(RWDEBUG)) + +extern RpHAnimHierarchy * +RpHAnimHierarchySetFlags(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyFlag flags); + +extern RpHAnimHierarchyFlag +RpHAnimHierarchyGetFlags(RpHAnimHierarchy *hierarchy); + +#endif /* (defined(RWDEBUG)) */ + +/* Animation hierarchy creation */ +extern void +RpHAnimHierarchySetFreeListCreateParams(RwInt32 blockSize,RwInt32 numBlocksToPrealloc); + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreate(RwInt32 numNodes, + RwUInt32 *nodeFlags, + RwInt32 *nodeIDs, + RpHAnimHierarchyFlag flags, + RwInt32 maxInterpKeyFrameSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreateFromHierarchy(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyFlag flags, + RwInt32 maxInterpKeyFrameSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDestroy(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreateSubHierarchy(RpHAnimHierarchy *parentHierarchy, + RwInt32 startNode, + RpHAnimHierarchyFlag flags, + RwInt32 maxInterpKeyFrameSize); + +extern RtAnimAnimation * +RpHAnimRemoveDuplicates( RtAnimAnimation *animsrc, + RwInt32 numBones, + RwReal tolerance, + RwReal averageNodeSize); + +extern RtAnimAnimation * +RpHAnimRemoveInterpolate( RtAnimAnimation *animsrc, + RwInt32 numBones, + RwReal tolerance, + RwReal averageNodeSize); + +extern RtAnimAnimation * +RpHAnimRemoveInterpolateLoop( RtAnimAnimation *animsrc, + RwInt32 numBones, + RwReal tolerance, + RwReal averageNodeSize); + +extern RtAnimAnimation * +RpHAnimRemoveInterpolatesLoopLength( RtAnimAnimation *animsrc, + RwUInt32 *pushpops, + RwInt32 numBones, + RwReal tolerance, + RwReal averageNodeSize); + +extern RtAnimAnimation * +RpHAnimRemoveNoLeafChange( RtAnimAnimation *animsrc, + RwUInt32 *pushpops, + RwInt32 numBones, + RwReal tolerance, + RwReal averageNodeSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyAttach(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDetach(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyAttachFrameIndex(RpHAnimHierarchy *hierarchy, + RwInt32 nodeIndex); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDetachFrameIndex(RpHAnimHierarchy *hierarchy, + RwInt32 nodeIndex); + +extern RwBool +RpHAnimFrameSetHierarchy(RwFrame *frame, + RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimFrameGetHierarchy(RwFrame *frame); + +/* Macros for legacy support of old function names */ +#define RpHAnimSetHierarchy(frame,hierarchy) \ + RpHAnimFrameSetHierarchy(frame,hierarchy) +#define RpHAnimGetHierarchy(frame) RpHAnimFrameGetHierarchy(frame) + +extern RwMatrix * +RpHAnimHierarchyGetMatrixArray(RpHAnimHierarchy *hierarchy); + +extern RwBool +RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy *hierarchy); + +/* Macro for legacy support of old function name */ +#define RpHAnimUpdateHierarchyMatrices RpHAnimHierarchyUpdateMatrices + +extern RwInt32 +RpHAnimIDGetIndex(RpHAnimHierarchy *hierarchy, + RwInt32 ID); + +/* Plugin support */ + +extern RwBool +RpHAnimPluginAttach(void); + +/* Hanim keyframe functions */ + +extern void +RpHAnimKeyFrameApply(void *matrix, + void *voidIFrame); + +extern void +RpHAnimKeyFrameBlend(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal alpha); + +extern void +RpHAnimKeyFrameInterpolate(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal time, + void *customData); + +extern void +RpHAnimKeyFrameAdd(void *voidOut, + void *voidIn1, + void *voidIn2); + +extern void +RpHAnimKeyFrameMulRecip(void *voidFrame, + void *voidStart); + +extern RtAnimAnimation * +RpHAnimKeyFrameStreamRead(RwStream *stream, + RtAnimAnimation *animation); + +extern RwBool +RpHAnimKeyFrameStreamWrite(const RtAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RpHAnimKeyFrameStreamGetSize(const RtAnimAnimation *animation); + +/* Access to RwFrame ID's */ + +extern RwBool +RpHAnimFrameSetID(RwFrame *frame, + RwInt32 id); + +extern RwInt32 +RpHAnimFrameGetID(RwFrame *frame); + +/* + * Utility Functions + */ +#define RpHAnimHierarchySetCurrentAnimMacro(hierarchy,anim)\ + RtAnimInterpolatorSetCurrentAnim((hierarchy)->currentAnim,anim) + +#define RpHAnimHierarchyGetCurrentAnimMacro(hierarchy)\ + RtAnimInterpolatorGetCurrentAnim((hierarchy)->currentAnim) + +#define RpHAnimHierarchySetCurrentAnimTimeMacro(hierarchy,time)\ + RtAnimInterpolatorSetCurrentTime((hierarchy)->currentAnim,time) + +#define RpHAnimHierarchyAddAnimTimeMacro(hierarchy,time)\ + RtAnimInterpolatorAddAnimTime((hierarchy)->currentAnim,time) + +#define RpHAnimHierarchySubAnimTimeMacro(hierarchy,time)\ + RtAnimInterpolatorSubAnimTime((hierarchy)->currentAnim,time) + +#define RpHAnimHierarchySetKeyFrameCallBacksMacro(hierarchy,keyFrameTypeID) \ + RtAnimInterpolatorSetKeyFrameCallBacks((hierarchy)->currentAnim,\ + keyFrameTypeID) + +#define RpHAnimHierarchyBlendMacro(outHierarchy,inHierarchy1,inHierarchy2,alpha)\ + RtAnimInterpolatorBlend((outHierarchy)->currentAnim,\ + (inHierarchy1)->currentAnim,\ + (inHierarchy2)->currentAnim,\ + alpha) + +#define RpHAnimHierarchyAddTogetherMacro(outHierarchy,inHierarchy1,inHierarchy2)\ + RtAnimInterpolatorAddTogether((outHierarchy)->currentAnim,\ + (inHierarchy1)->currentAnim,\ + (inHierarchy2)->currentAnim) + + +#define RpHAnimHierarchySetAnimCallBackMacro(hierarchy,callBack,time,data)\ + RtAnimInterpolatorSetAnimCallBack((hierarchy)->currentAnim,callBack,time,data) + +#define RpHAnimHierarchySetAnimLoopCallBackMacro(hierarchy,callBack,data)\ + RtAnimInterpolatorSetAnimLoopCallBack((hierarchy)->currentAnim,callBack,data) + +#define RpHAnimHierarchyBlendSubHierarchyMacro(outHierarchy,inHierarchy1,inHierarchy2,alpha)\ + RtAnimInterpolatorBlendSubInterpolator((outHierarchy)->currentAnim,(inHierarchy1)->currentAnim,(inHierarchy2)->currentAnim,alpha) + +#define RpHAnimHierarchyAddSubHierarchyMacro(outHierarchy,mainHierarchy,subHierarchy)\ + RtAnimInterpolatorAddSubInterpolator((outHierarchy)->currentAnim,(mainHierarchy)->currentAnim,(subHierarchy)->currentAnim) + +#define RpHAnimHierarchyCopyMacro(outHierarchy,inHierarchy)\ + RtAnimInterpolatorCopy((outHierarchy)->currentAnim,(inHierarchy)->currentAnim) + + + +#ifdef RWDEBUG +extern RwBool +RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy *hierarchy, + RtAnimAnimation *anim); + +extern RtAnimAnimation * +RpHAnimHierarchyGetCurrentAnim(RpHAnimHierarchy *hierarchy); + +extern RwBool +RpHAnimHierarchySetCurrentAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchySubAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchySetKeyFrameCallBacks(RpHAnimHierarchy *hierarchy, + RwInt32 keyFrameTypeID); + +extern void +RpHAnimHierarchySetAnimCallBack(RpHAnimHierarchy *hierarchy, + RtAnimCallBack callBack, + RwReal time, + void *data); + +extern RwBool +RpHAnimHierarchyBlend(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2, + RwReal alpha); + +extern RwBool +RpHAnimHierarchyAddTogether(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2); + +extern void +RpHAnimHierarchySetAnimLoopCallBack(RpHAnimHierarchy *hierarchy, + RtAnimCallBack callBack, + void *data); +extern RwBool +RpHAnimHierarchyBlendSubHierarchy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2, + RwReal alpha); +extern RwBool +RpHAnimHierarchyAddSubHierarchy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *mainHierarchy1, + RpHAnimHierarchy *subHierarchy2); +extern RwBool +RpHAnimHierarchyCopy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy); + +#else + +#define RpHAnimHierarchySetCurrentAnim(hierarchy,anim) \ + RpHAnimHierarchySetCurrentAnimMacro((hierarchy),(anim)) + +#define RpHAnimHierarchyGetCurrentAnim(hierarchy) \ + RpHAnimHierarchyGetCurrentAnimMacro((hierarchy)) + +#define RpHAnimHierarchySetCurrentAnimTime(hierarchy,time) \ + RpHAnimHierarchySetCurrentAnimTimeMacro((hierarchy),(time)) + +#define RpHAnimHierarchyAddAnimTime(hierarchy,time) \ + RpHAnimHierarchyAddAnimTimeMacro((hierarchy),(time)) + +#define RpHAnimHierarchySubAnimTime(hierarchy,time) \ + RpHAnimHierarchySubAnimTimeMacro((hierarchy),(time)) + +#define RpHAnimHierarchySetKeyFrameCallBacks(hierarchy,keyFrameTypeID) \ + RpHAnimHierarchySetKeyFrameCallBacksMacro((hierarchy),(keyFrameTypeID)) + +#define RpHAnimHierarchyBlend(outHierarchy,inHierarchy1,inHierarchy2,alpha) \ + RpHAnimHierarchyBlendMacro((outHierarchy),(inHierarchy1),(inHierarchy2),(alpha)) + +#define RpHAnimHierarchyAddTogether(outHierarchy,inHierarchy1,inHierarchy2) \ + RpHAnimHierarchyAddTogetherMacro((outHierarchy),(inHierarchy1),(inHierarchy2)) + +#define RpHAnimHierarchySetAnimCallBack(hierarchy,callBack,time,data)\ + RpHAnimHierarchySetAnimCallBackMacro((hierarchy),(callBack),(time),(data)) + +#define RpHAnimHierarchySetAnimLoopCallBack(hierarchy,callBack,data)\ + RpHAnimHierarchySetAnimLoopCallBackMacro((hierarchy),(callBack),(data)) + +#define RpHAnimHierarchyBlendSubHierarchy(outHierarchy,inHierarchy1,inHierarchy2,alpha)\ + RpHAnimHierarchyBlendSubHierarchyMacro((outHierarchy),(inHierarchy1),(inHierarchy2),(alpha)) + +#define RpHAnimHierarchyAddSubHierarchy(outHierarchy,mainHierarchy,subHierarchy)\ + RpHAnimHierarchyAddSubHierarchyMacro((outHierarchy),(mainHierarchy),(subHierarchy)) + +#define RpHAnimHierarchyCopy(outHierarchy,inHierarchy)\ + RpHAnimHierarchyCopyMacro((outHierarchy),(inHierarchy)) + +#endif /* RWDEBUG */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Legacy TypeDef */ + + +typedef RtAnimAnimation RpHAnimAnimation; +typedef RpHAnimKeyFrame RpHAnimStdKeyFrame; + +/* Legacy Macros */ + + +/* Animations */ + + +#define RpHAnimAnimationCreate(typeID,numFrames,flags,duration)\ + RtAnimAnimationCreate((typeID),(numFrames),(flags),(duration)) + + +#define RpHAnimAnimationDestroy(animation)\ + RtAnimAnimationDestroy((animation)) + +#define RpHAnimAnimationGetTypeID(animation)\ + RtAnimAnimationGetTypeID((animation)) + + +#define RpHAnimAnimationRead(filename)\ + RtAnimAnimationRead((filename)) + + +#define RpHAnimAnimationWrite(animation,filename)\ + RtAnimAnimationWrite((animation),(filename)) + + +#define RpHAnimAnimationStreamRead(stream)\ + RtAnimAnimationStreamRead((stream)) + + +#define RpHAnimAnimationStreamWrite(animation,stream)\ + RtAnimAnimationStreamWrite((animation),(stream)) + + +#define RpHAnimAnimationStreamGetSize(animation)\ + RtAnimAnimationStreamGetSize((animation)) + + +#define RpHAnimAnimationMakeDelta(animation,numNodes,time)\ + RtAnimAnimationMakeDelta((animation),(numNodes),(time)) + + +/* Animation Interpolator */ + +#define RpHAnimHierarchyStdKeyFrameAddAnimTime(hierarchy,time)\ + RpHAnimHierarchyHAnimKeyFrameAddAnimTime((hierarchy),(time)) + +#define RpHAnimHierarchyHAnimKeyFrameAddAnimTime(hierarchy,time)\ + RpHAnimHierarchyAddAnimTime((hierarchy),(time)) + +#endif /* RPHANIM_H */ diff --git a/includes/rwsdk/rphanim.rpe b/includes/rwsdk/rphanim.rpe new file mode 100644 index 0000000..be0c059 --- /dev/null +++ b/includes/rwsdk/rphanim.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionHANIM +{ + + + + e_rwdb_CriterionHANIMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionHANIM e_rwdb_CriterionHANIM; + + diff --git a/includes/rwsdk/rplodatm.h b/includes/rwsdk/rplodatm.h new file mode 100644 index 0000000..4e9c864 --- /dev/null +++ b/includes/rwsdk/rplodatm.h @@ -0,0 +1,134 @@ + +/****************************************** + * * + * RenderWare(TM) Graphics Library * + * * + ******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + +/*************************************************************************** + * * + * Module : rplodatm.h * + * * + * Purpose : LODATM Geometry * + * * + **************************************************************************/ + +#ifndef RPLODATM_H +#define RPLODATM_H + + +/** + * \defgroup rplodatm RpLODAtomic + * \ingroup scenemanagement + * + * Level of Detail Management Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpcriter.h" /* Note: each vendor can choose their own method for + * allocation of unique ID's. This file defines + * the ID's used by Criterion. + */ +#include "rplodatm.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ +#define RPLODATOMICMAXLOD 10 + + +/**************************************************************************** + Type defs + */ +typedef RwInt32 (*RpLODAtomicLODCallBack)( RpAtomic *atomic ); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + extern void + RpLODAtomicCacheSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + + extern RwBool + RpLODAtomicPluginAttach( void ); + + extern RpAtomic * + RpLODAtomicSetGeometry( + RpAtomic *atomic, RwInt32 lodIdx, RpGeometry *geometry ); + + extern RpGeometry * + RpLODAtomicGetGeometry( + RpAtomic *atomic, RwInt32 lodIdx ); + + extern RpAtomic * + RpLODAtomicSetCurrentLOD( + RpAtomic *atomic, RwInt32 lodIdx ); + + extern RwInt32 + RpLODAtomicGetCurrentLOD( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicSetRange( + RpAtomic *atomic, RwReal farRange ); + + extern RwReal + RpLODAtomicGetRange( + RpAtomic *atomic ); + + extern void + RpLODAtomicSetCamera( + RwCamera *camera ); + + extern RpAtomic * + RpLODAtomicSetLODCallBack( + RpAtomic *atomic, RpLODAtomicLODCallBack callback ); + + extern RpAtomic * + RpLODAtomicSelectLOD( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicForAllLODGeometries( + RpAtomic *atomic, RpGeometryCallBack callback, void *pData ); + + extern RpAtomic * + RpLODAtomicHookRender( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicUnHookRender( + RpAtomic *atomic ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLODATM_H */ + diff --git a/includes/rwsdk/rplodatm.rpe b/includes/rwsdk/rplodatm.rpe new file mode 100644 index 0000000..b34c461 --- /dev/null +++ b/includes/rwsdk/rplodatm.rpe @@ -0,0 +1,522 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLODATM +{ + + + + e_rwdb_CriterionLODATMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLODATM e_rwdb_CriterionLODATM; + + diff --git a/includes/rwsdk/rplogo.h b/includes/rwsdk/rplogo.h new file mode 100644 index 0000000..a46823a --- /dev/null +++ b/includes/rwsdk/rplogo.h @@ -0,0 +1,83 @@ +/** + * Logo plugin + */ + + +/********************************************************************** + * + * File : rplogo.h + * + * Abstract : Add CSL Logo + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 1998 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef RPLOGO_H +#define RPLOGO_H + +/** + * \defgroup rplogo RpLogo + * \ingroup 2dtools + * + * Logo Plugin for RenderWare Graphics. + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rplogo.rpe" /* automatically generated header file */ + +/*--- Global Structures ---*/ + +enum RpLogoPosition +{ + rpNALOGOPOSITION = 0, + rpLOGOTOP, + rpLOGOCENTER, + rpLOGOBOTTOM, + rpLOGOLEFT, + rpLOGORIGHT, + rpLOGOTOPLEFT, + rpLOGOTOPRIGHT, + rpLOGOBOTTOMLEFT, + rpLOGOBOTTOMRIGHT, + rpLOGOPOSITIONFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpLogoPosition RpLogoPosition; + +/*--- Plugin API Functions ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + RwBool RpLogoPluginAttach(void); + RwBool RpLogoSetPosition(RpLogoPosition pos); + RpLogoPosition RpLogoGetPosition(void); + RwBool RpLogoSetState(RwCamera * cam, RwBool state); + RwBool RpLogoGetState(RwCamera * cam); + RwRect *RpLogoGetRenderingRect(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLOGO_H */ + diff --git a/includes/rwsdk/rplogo.rpe b/includes/rwsdk/rplogo.rpe new file mode 100644 index 0000000..d012cfe --- /dev/null +++ b/includes/rwsdk/rplogo.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLogo +{ + + + + e_rwdb_CriterionLogoLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLogo e_rwdb_CriterionLogo; + + diff --git a/includes/rwsdk/rpltmap.h b/includes/rwsdk/rpltmap.h new file mode 100644 index 0000000..6d9d4da --- /dev/null +++ b/includes/rwsdk/rpltmap.h @@ -0,0 +1,116 @@ + +/** + * \defgroup rpltmap RpLtMap + * \ingroup lighting + * + * Lightmap Plugin for RenderWare Graphics. + */ + +#ifndef RPLTMAP_H +#define RPLTMAP_H + +/*===========================================================================* + *--- Includes --------------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + + +/* Used during lightmap illumination (sliver triangles are skipped + * (their texels should be filled by dilate()), because their normals + * can't be accurately calculated) */ +#define rpLTMAPDEFAULTSLIVERAREATHRESHOLD (0.001f) + +/* Used during lightmap UV calculation (polySets may be + * joined on the basis of vertices with equal positions) */ +#define rpLTMAPDEFAULTVERTEXWELDTHRESHOLD (0.1f) + +#define rpLTMAPDEFAULTLIGHTMAPSIZE 128 +#define rpLTMAPMINLIGHTMAPSIZE 16 +#define rpLTMAPMAXLIGHTMAPSIZE 512/*?? any better way of determining this ??*/ + +#define rpLTMAPMAXPREFIXSTRINGLENGTH 4 + +#define rpLTMAPDEFAULTMAXAREALIGHTSAMPLESPERMESH 256 +/* The default tolerance for errors induced by area light ROIs is 1 + * (being the smallest difference in lightmap colour values) */ +#define rpLTMAPDEFAULTAREALIGHTROICUTOFF (1.0f) + + +/* Misc flags for used in the world plugin data. */ +#define rpLTMAPWORLDFLAGLIGHTMAP 0x01 + + + +/** + * \ingroup rpltmap + * \ref RpLtMapStyle + * Flags specifying the rendering style of the lightmap plugin. + * + * \see RpLtMapGetRenderStyle + * \see RpLtMapSetRenderStyle + */ +enum RpLtMapStyle +{ + rpLTMAPSTYLENASTYLE = 0x0, + + rpLTMAPSTYLERENDERBASE = 0x1, /**< The base texture should be rendered */ + rpLTMAPSTYLERENDERLIGHTMAP = 0x2, /**< The lightmap should be rendered */ + rpLTMAPSTYLEPOINTSAMPLE = 0x4, /**< The lightmap should be point-sampled */ + + rpLTMAPSTYLEFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RpLtMapStyle RpLtMapStyle; + +#if (!defined(DOXYGEN)) +typedef struct rpLtMapSampleMap rpLtMapSampleMap; +struct rpLtMapSampleMap +{ + RwUInt32 refCount; + RwUInt8 *samplePixels; +}; +#endif /* (!defined(DOXYGEN)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern RwBool +RpLtMapPluginAttach(void); + +extern RxPipeline * +RpLtMapGetPlatformAtomicPipeline(void); +extern RxPipeline * +RpLtMapGetPlatformWorldSectorPipeline(void); + +extern RwBool +RpLtMapSetRenderStyle(RpLtMapStyle style, RpWorld *world); +extern RpLtMapStyle +RpLtMapGetRenderStyle(void); + +extern RwUInt32 +RpLtMapWorldLightMapsQuery(RpWorld *world); + +extern RwTexture * +RpLtMapWorldSectorGetLightMap(RpWorldSector *sector); +extern RpWorldSector * +RpLtMapWorldSectorSetLightMap(RpWorldSector *sector, RwTexture *lightMap); +extern RwTexture * +RpLtMapAtomicGetLightMap(RpAtomic *atomic); +extern RpAtomic * +RpLtMapAtomicSetLightMap(RpAtomic *atomic, RwTexture *lightMap); + +extern RwUInt32 RpLtMapGetRasterFormat(void); +extern RwBool RpLtMapSetRasterFormat(RwUInt32 format); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLTMAP_H */ + + diff --git a/includes/rwsdk/rpltmap.rpe b/includes/rwsdk/rpltmap.rpe new file mode 100644 index 0000000..0977199 --- /dev/null +++ b/includes/rwsdk/rpltmap.rpe @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLTMAP +{ + + + + e_rwdb_CriterionLTMAPLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLTMAP e_rwdb_CriterionLTMAP; + + diff --git a/includes/rwsdk/rpmatfx.h b/includes/rwsdk/rpmatfx.h new file mode 100644 index 0000000..53d75ef --- /dev/null +++ b/includes/rwsdk/rpmatfx.h @@ -0,0 +1,257 @@ + +#ifndef RPMATFX_H +#define RPMATFX_H + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + +/*---- start: ./matfx.h----*/ + +#ifndef RPMATFX_MATFX_H +#define RPMATFX_MATFX_H + + +/** + * \defgroup rpmatfx RpMatFX + * \ingroup materials + * + * Material Effects Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ + +/** + * \ingroup rpmatfx + * RpMatFXMaterialFlags, this type represents the different types of + * material effects that can be used on a material. The effects are + * initialized with \ref RpMatFXMaterialSetEffects: + */ +enum RpMatFXMaterialFlags +{ + rpMATFXEFFECTNULL = 0, /** + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if (defined(SKY2_DRVMODEL_H)) || (defined(NULLSKY_DRVMODEL_H)) + +#define RpMipmapKLTextureSetDefaultK RpSkyTextureSetDefaultMipmapK + +#define RpMipmapKLTextureSetDefaultL RpSkyTextureSetDefaultMipmapL + +#define RpMipmapKLTextureGetDefaultK RpSkyTextureGetDefaultMipmapK + +#define RpMipmapKLTextureGetDefaultL RpSkyTextureGetDefaultMipmapL + +#define RpMipmapKLTextureSetK RpSkyTextureSetMipmapK + +#define RpMipmapKLTextureSetL RpSkyTextureSetMipmapL + +#define RpMipmapKLTextureGetK RpSkyTextureGetMipmapK + +#define RpMipmapKLTextureGetL RpSkyTextureGetMipmapL + +#define RpMipmapKLPluginAttach() (TRUE) + +#else /* (defined(SKY2_DRVMODEL_H)) || (defined(NULLSKY_DRVMODEL_H)) */ + +extern RwReal RpMipmapKLTextureSetDefaultK(RwReal val); +extern RwUInt32 RpMipmapKLTextureSetDefaultL(RwUInt32 val); +extern RwReal RpMipmapKLTextureGetDefaultK(void); +extern RwUInt32 RpMipmapKLTextureGetDefaultL(void); + +extern RwTexture *RpMipmapKLTextureSetK(RwTexture *tex, RwReal val); +extern RwTexture *RpMipmapKLTextureSetL(RwTexture *tex, RwUInt32 val); +extern RwReal RpMipmapKLTextureGetK(RwTexture *tex); +extern RwUInt32 RpMipmapKLTextureGetL(RwTexture *tex); + +extern RwBool RpMipmapKLPluginAttach(void); + +#endif /* (defined(SKY2_DRVMODEL_H)) || (defined(NULLSKY_DRVMODEL_H)) */ + +#ifdef __cplusplus +} +#endif + +#endif /* RPMIPMAPKLPLUGIN_H */ diff --git a/includes/rwsdk/rpmipkl.rpe b/includes/rwsdk/rpmipkl.rpe new file mode 100644 index 0000000..bff3120 --- /dev/null +++ b/includes/rwsdk/rpmipkl.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLabel +{ + + + + e_rwdb_CriterionLabelLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLabel e_rwdb_CriterionLabel; + + diff --git a/includes/rwsdk/rpmorph.h b/includes/rwsdk/rpmorph.h new file mode 100644 index 0000000..8fe9860 --- /dev/null +++ b/includes/rwsdk/rpmorph.h @@ -0,0 +1,137 @@ + +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + + +/**************************************************************************** + * + * Morph animation controller + * Copyright (C) 1998 Criterion Technologies + * + * Module : rpmorph.h + * + * Purpose : Functions for controlling morph target animation + * + ****************************************************************************/ + +#ifndef RPMORPH_H +#define RPMORPH_H + + +/** + * \defgroup rpmorph RpMorph + * \ingroup morphing + * + * Morphing Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpmorph.rpe" /* automatically generated header file */ + +/**************************************************************************** + Global Types + */ +typedef struct RpMorphInterpolator RpMorphInterpolator; + +/** + * \ingroup rpmorph + * \struct RpMorphInterpolator + * structure describing morph interpolator + */ +struct RpMorphInterpolator +{ + RwInt32 flags; /**< flags */ + RwInt16 startMorphTarget; /**< startMorphTarget */ + RwInt16 endMorphTarget; /**< endMorphTarget */ + RwReal time; /**< time */ + RwReal recipTime; /**< recipTime */ + RpMorphInterpolator *next; /**< next */ +}; + +/* Morph Animation */ + +/** + * \ingroup rpmorph + * This is the callback function supplied to \ref RpMorphGeometrySetCallBack + * and returned from \ref RpMorphGeometryGetCallBack. + * The supplied function will be passed a pointer to the geometry's parent atomic, + * and the position of the current interpolator. + * The function will only be called when the position of the geometry's current + * interpolator moves out of the current range. + * + * \param atomic Pointer to the geometry's parent atomic. + * \param position Value of the current interpolator. + * + * \return The current interpolator position + * + * \see RpMorphGeometrySetCallBack + * \see RpMorphGeometryGetCallBack + */ +typedef RwReal (*RpMorphGeometryCallBack)(RpAtomic *atomic, RwReal position); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool RpMorphPluginAttach(void); + +/* Morph Animation */ +extern RpGeometry *RpMorphGeometryCreateInterpolators(RpGeometry *geometry, RwInt32 numInterps); +extern RpGeometry *RpMorphGeometrySetInterpolator(RpGeometry *geometry, + RwInt32 interpNum, + RwInt32 startKey, RwInt32 endKey, RwReal time); +extern RpGeometry *RpMorphGeometrySetNextInterpolator(RpGeometry *geometry, + RwInt32 interpNum, RwInt32 interpNumNext); +extern RpGeometry *RpMorphGeometrySetCallBack(RpGeometry *geometry, RpMorphGeometryCallBack animCB); +extern RpMorphGeometryCallBack RpMorphGeometryGetCallBack(const RpGeometry *geometry); + +extern RpAtomic *RpMorphAtomicSetCurrentInterpolator(RpAtomic *atomic, RwInt32 interpNum); +extern RwInt32 RpMorphAtomicGetCurrentInterpolator(RpAtomic *atomic); + +extern RpMorphInterpolator *RpMorphGeometryGetInterpolator(RpGeometry *geometry, RwInt32 interpNum); + +extern RpAtomic *RpMorphAtomicSetTime(RpAtomic *atomic, RwReal time); +extern RpAtomic *RpMorphAtomicAddTime(RpAtomic *atomic, RwReal time); + + +/* LEGACY-SUPPORT version: */ +extern RpMorphInterpolator *_rpMorphAtomicGetInterpolator(RpAtomic *atomic, RwInt32 interpNum); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpMorphAtomicGetInterpolator(_atomic, _interpNum) \ + _rpMorphAtomicGetInterpolator(_atomic, _interpNum) + +#endif /* RPMORPH_H */ + diff --git a/includes/rwsdk/rpmorph.rpe b/includes/rwsdk/rpmorph.rpe new file mode 100644 index 0000000..755d30d --- /dev/null +++ b/includes/rwsdk/rpmorph.rpe @@ -0,0 +1,521 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionMorph +{ + + +E_RP_MORPH_INVALIDINTERP, + +E_RP_MORPH_NOGEOMETRY, + + e_rwdb_CriterionMorphLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionMorph e_rwdb_CriterionMorph; + + diff --git a/includes/rwsdk/rpnormmap.h b/includes/rwsdk/rpnormmap.h new file mode 100644 index 0000000..49eaa60 --- /dev/null +++ b/includes/rwsdk/rpnormmap.h @@ -0,0 +1,169 @@ +/*===========================================================================* + *- -* + *- Module : rpnormmap.h -* + *- -* + *- Purpose : Normal Maps plugin public/internal API -* + *- -* + *===========================================================================*/ + +#ifndef RPNORMMAP_H +#define RPNORMMAP_H + +#include "rwcore.h" +#include "rpworld.h" + +/* RWPUBLIC */ + +/** + * \defgroup rpnormmap RpNormMap + * \ingroup lighting + * + * Normal Maps Plugin for RenderWare Graphics. + */ + +/** + * \ingroup rpnormmap + * \ref RpNormMapAtomicPipeline rendering pipelines available within the + * \ref rpnormmap plugin. Use \ref RpNormMapGetAtomicPipeline to retrieve + * the required \ref RxPipeline. + */ +enum RpNormMapAtomicPipeline +{ + rpNANORMMAPATOMICPIPELINE = 0, + rpNORMMAPATOMICSTATICPIPELINE = 1, /**definition.flag) + +#define RpPatchMeshSetFlagsMacro(patchMesh, flags) \ + (patchMesh->definition.flag = flags) + +#define RpPatchMeshGetNumControlPointsMacro(patchMesh) \ + (patchMesh->definition.numControlPoints) + +#define RpPatchMeshGetNumTriPatchesMacro(patchMesh) \ + (patchMesh->definition.numTriPatches) + +#define RpPatchMeshGetNumQuadPatchesMacro(patchMesh) \ + (patchMesh->definition.numQuadPatches) + +#define RpPatchMeshGetNumTexCoordSetsMacro(patchMesh) \ + (patchMesh->definition.numTexCoordSets) + +#define RpPatchMeshGetPositionsMacro(patchMesh) \ + (patchMesh->positions) + +#define RpPatchMeshGetNormalsMacro(patchMesh) \ + (patchMesh->normals) + +#define RpPatchMeshGetPreLightColorsMacro(patchMesh) \ + (patchMesh->preLightColors) + +#define RpPatchMeshGetTexCoordsMacro(patchMesh, index) \ + (patchMesh->texCoords[index - 1]) +/*---------------------------------------------------------------------------*/ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +/*---------------------------------------------------------------------------*/ +extern RwUInt32 +RpPatchMeshGetFlags( const RpPatchMesh *patchMesh ); + +extern RpPatchMesh * +RpPatchMeshSetFlags( RpPatchMesh *patchMesh, + RwUInt32 flags ); + +extern RwUInt32 +RpPatchMeshGetNumControlPoints( const RpPatchMesh *patchMesh ); + +extern RwUInt32 +RpPatchMeshGetNumTriPatches( const RpPatchMesh *patchMesh ); + +extern RwUInt32 +RpPatchMeshGetNumQuadPatches( const RpPatchMesh *patchMesh ); + +extern RwUInt32 +RpPatchMeshGetNumTexCoordSets( const RpPatchMesh *patchMesh ); + +extern RwV3d * +RpPatchMeshGetPositions( const RpPatchMesh *patchMesh ); + +extern RwV3d * +RpPatchMeshGetNormals( const RpPatchMesh *patchMesh ); + +extern RwRGBA * +RpPatchMeshGetPreLightColors( const RpPatchMesh *patchMesh ); + +extern RwTexCoords * +RpPatchMeshGetTexCoords( const RpPatchMesh *patchMesh, + RwTextureCoordinateIndex index ); +/*---------------------------------------------------------------------------*/ + +#else /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/*---------------------------------------------------------------------------*/ +#define RpPatchMeshGetFlags(patchMesh) \ + RpPatchMeshGetFlagsMacro(patchMesh) + +#define RpPatchMeshSetFlags(patchMesh, flags) \ + RpPatchMeshSetFlagsMacro(patchMesh, flags) + +#define RpPatchMeshGetNumControlPoints(patchMesh) \ + RpPatchMeshGetNumControlPointsMacro(patchMesh) + +#define RpPatchMeshGetNumTriPatches(patchMesh) \ + RpPatchMeshGetNumTriPatchesMacro(patchMesh) + +#define RpPatchMeshGetNumQuadPatches(patchMesh) \ + RpPatchMeshGetNumQuadPatchesMacro(patchMesh) + +#define RpPatchMeshGetNumTexCoordSets(patchMesh) \ + RpPatchMeshGetNumTexCoordSetsMacro(patchMesh) + +#define RpPatchMeshGetPositions(patchMesh) \ + RpPatchMeshGetPositionsMacro(patchMesh) + +#define RpPatchMeshGetNormals(patchMesh) \ + RpPatchMeshGetNormalsMacro(patchMesh) + +#define RpPatchMeshGetPreLightColors(patchMesh) \ + RpPatchMeshGetPreLightColorsMacro(patchMesh) + +#define RpPatchMeshGetTexCoords(patchMesh, index) \ + RpPatchMeshGetTexCoordsMacro(patchMesh, index) +/*---------------------------------------------------------------------------*/ + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/*---------------------------------------------------------------------------* + *- Patch streaming functions -* + *---------------------------------------------------------------------------*/ +extern RwUInt32 +RpPatchMeshStreamGetSize( const RpPatchMesh *patchMesh ); + +extern RpPatchMesh * +RpPatchMeshStreamRead( RwStream *stream ); + +extern RpPatchMesh * +_rpPatchMeshStreamReadNoChunk( RwStream *stream ); + +extern const RpPatchMesh * +RpPatchMeshStreamWrite( const RpPatchMesh *patchMesh, + RwStream *stream ); + +/*---------------------------------------------------------------------------* + *- Patch Mesh patch functions -* + *---------------------------------------------------------------------------*/ +extern RpPatchMesh * +RpPatchMeshSetQuadPatch( RpPatchMesh *patchMesh, + RwUInt32 quadIndex, + RpQuadPatch *quadPatch ); + +extern RpPatchMesh * +RpPatchMeshSetTriPatch( RpPatchMesh *patchMesh, + RwUInt32 triIndex, + RpTriPatch *triPatch ); + +extern const RpQuadPatch * +RpPatchMeshGetQuadPatch( const RpPatchMesh *patchMesh, + RwUInt32 quadIndex ); + +extern const RpTriPatch * +RpPatchMeshGetTriPatch( const RpPatchMesh *patchMesh, + RwUInt32 triIndex ); + +/*---------------------------------------------------------------------------* + *- Patch Mesh material functions -* + *---------------------------------------------------------------------------*/ +extern RpPatchMesh * +RpPatchMeshSetQuadPatchMaterial( RpPatchMesh *patchMesh, + RwUInt32 quadIndex, + RpMaterial *material ); + +extern RpPatchMesh * +RpPatchMeshSetTriPatchMaterial( RpPatchMesh *patchMesh, + RwUInt32 triIndex, + RpMaterial *material ); + +extern RpMaterial * +RpPatchMeshGetQuadPatchMaterial( const RpPatchMesh *patchMesh, + RwUInt32 quadIndex ); + +extern RpMaterial * +RpPatchMeshGetTriPatchMaterial( const RpPatchMesh *patchMesh, + RwUInt32 triIndex ); + +extern const RpPatchMesh * +RpPatchMeshForAllMaterials( const RpPatchMesh *patchMesh, + RpMaterialCallBack callBack, + void *userData ); + +extern RwUInt32 +RpPatchMeshGetNumMaterials( const RpPatchMesh *patchMesh ); + +extern RpMaterial * +RpPatchMeshGetMaterial( const RpPatchMesh *patchMesh, + RwUInt32 materialIndex ); + +/*---------------------------------------------------------------------------* + *- Patch Skin functions -* + *---------------------------------------------------------------------------*/ +#if (defined(RPSKIN_H)) + +extern RpSkin * +RpPatchMeshGetSkin( RpPatchMesh *patchMesh ); + +extern RpPatchMesh * +RpPatchMeshSetSkin( RpPatchMesh *patchMesh, + RpSkin *skin ); + +#endif /* (defined(RPSKIN_H)) */ + +/*---------------------------------------------------------------------------* + *- Patch Atomic functions -* + *---------------------------------------------------------------------------*/ +extern RpAtomic * +RpPatchAtomicSetPatchMesh( RpAtomic *atomic, + RpPatchMesh *patchMesh ); + +extern RpPatchMesh * +RpPatchAtomicGetPatchMesh( const RpAtomic *atomic ); + +/*---------------------------------------------------------------------------* + *- Patch Atomic LOD functions -* + *---------------------------------------------------------------------------*/ +extern RwBool +RpPatchAtomicSetPatchLODCallBack( RpAtomic *atomic, + RpPatchLODCallBack callback, + RpPatchLODUserData userData ); + +extern RwBool +RpPatchAtomicGetPatchLODCallBack( const RpAtomic *atomic, + RpPatchLODCallBack *callback, + RpPatchLODUserData *userData ); + +/*---------------------------------------------------------------------------* + *- Patch default LOD range -* + *---------------------------------------------------------------------------*/ +extern RwBool +RpPatchSetDefaultLODCallBackRange( RpPatchLODRange *lodRange ); + +extern RwBool +RpPatchGetDefaultLODCallBackRange( RpPatchLODRange *lodRange ); + +/*---------------------------------------------------------------------------* + *- Patch pipeline -* + *---------------------------------------------------------------------------*/ + +/** + * \ingroup rppatch + * \ref RpPatchType defines the different ways a patch atomic can be rendered. + * Once a \ref RpPatchMesh has been attached to an \ref RpAtomic with + * \ref RpPatchAtomicSetPatchMesh the atomic must be setup with the correct + * rendering pipeline with \ref RpPatchAtomicSetType . + * + * The patch plugin makes no assumptions about how to render the + * patch atomics. Once an \ref RpPatchMesh has been attached to an + * \ref RpAtomic it is necessary to attach a suitable patch + * rendering pipeline. The patch plugin supports four different + * rendering types, these are defined in the \ref RpPatchType + * enumeration: + * \li \ref rpPATCHTYPEGENERIC + * The patch \ref RpAtomic will be rendered with the + * default generic patch rendering pipeline. + * \li \ref rpPATCHTYPESKIN + * The patch \ref RpAtomic will be rendered with a + * custom pipeline for rendering skinning patches. Make sure + * an \ref RpSkin has been attached to the \ref RpPatchMesh + * and an \ref RpHAnimHierarchy has been attached to the + * \ref RpAtomic. + * \li \ref rpPATCHTYPEMATFX + * The patch \ref RpAtomic will be rendered with a + * custom pipeline for rendering the material effects + * of patches. The + * patch matfx pipeline supports all the material effects + * defined in the \ref rpmatfx plugin. The patches + * materials should be setup as usual. + * \li \ref rpPATCHTYPESKINMATFX + * The patch \ref RpAtomic will be rendered with a + * custom skinned material effects patch rendering pipeline. + * The \ref RpPatchMesh, \ref RpAtomic and the patches' + * \ref RpMaterial's must be setup correctly. + */ +enum RpPatchType +{ + rpNAPATCHTYPE = 0, /** the start rotation + 2 PI. + * + * The particle's life is used to interpolate the size. + * + * If this structure is not present, then the particles will either have a global rotation or no rotation. + */ +struct RpPrtStdEmitterPrt2DRotate +{ + RwReal prtStart2DRotate, /**< Particle start 2D rotate */ + prtStart2DRotateBias; /**< Particle start 2D rotate bias */ + RwReal prtEnd2DRotate, /**< Particle end 2D rotate */ + prtEnd2DRotateBias; /**< Particle end 2D rotate bias */ +}; + +/************************************************************************ + * + * + * + ************************************************************************/ + + + +enum RpPrtStdPTankPropertyCode +{ + rpPRTSTDPTANKPROPPARTICLESMAX = 0, + rpPRTSTDPTANKPROPDATAFLAGS, + rpPRTSTDPTANKPROPPLATFORMFLAGS, + rpPRTSTDPTANKPROPPTANK, + rpPRTSTDPTANKPROPFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum RpPrtStdPTankPropertyCode RpPrtStdPTankPropertyCode; + +typedef struct RpPrtStdEmitterPTank RpPrtStdEmitterPTank; + +/** + * \ingroup rpprtstd + * \struct RpPrtStdEmitterPTank + * + * A structure for storing the data required to create a RpPTank for use + * with the emitter. The structure allows the user to create a RpPTank + * manually. + */ +struct RpPrtStdEmitterPTank +{ + RwUInt32 dataFlags, /**< Data flag used in RpPTank creation. See + * \ref RpPTankAtomicCreate */ + platFlags, /**< Platform flag used in RpPTank creation. See + * \ref RpPTankAtomicCreate */ + numPrt, /**< An integer representing the current number of active + * particles */ + maxPrt, /**< An integer representing the maxiumum number of particles + * stored in the RpPTank */ + updateFlags, /**< A flag representing the properties to be updated by + * the particle emiiter during update. A user may select to + * update some properties manually by unsetting the relevant + * bits in the flag. + * The flag settings are the same as \ref RpPTankDataFlags */ + emitFlags; /**< A flag representing the properties to be initialized + * by the particle emitter during particles emission. A user + * may select to initialize some properties manually by + * unsetting the relevant bits in the flag. + * The flag settings are the same as \ref RpPTankDataFlags */ + RpAtomic *pTank; /**< Pointer to the RpPTank \ref RpAtomic. */ + RwChar **dataInPtrs, /**< An array of pointers pointing to the particle's property + * buffers in RpPTank. This array points to the input values to + * be updated. The pointers must be incremented after each + * particle is processed. + * The size of the array is dependant on the number of particle + * properties. The order of the properties is constant. + * \see RpPTankDataLockFlags. */ + **dataOutPtrs; /**< An array of pointers pointing to the particle's property + * buffers in RpPTank. This array points to where updated values + * are to be written. This can be in the input buffer or a + * seperate output buffer. Dead particles are removed by being + * overwritten by live particles. So the pointers should only + * be incremented for each live particle updated. + * The size of the array is dependant on the number of particle + * properties. The order of the properties is constant. + * \see RpPTankDataLockFlags. */ + RwInt32 *dataStride; /**< An array of \ref RwInt32 to store the stride of the + * particle properties in the RpPTank. This is the value the + * data pointers need to be incremented to the next particle. + * The size of the array is dependant on the number of particle + * properties. The order of the stride is constant. + * \see RpPTankDataLockFlags. */ + RwUInt32 strSrcBlend; /**< This is used to set the source blend mode for the RpPTank + * \ref RpAtomic when it is created for the first time. + * \see RpPTankAtomicSetBlendModes. */ + RwUInt32 strDstBlend; /**< This is used to set the destination blend mode for the RpPTank + * \ref RpAtomic when it is created for the first time. + * \see RpPTankAtomicSetBlendModes. */ + RwBool strVtxABlend; /**< This is used to enable vertex alpha blending for the + * RpTank \ref RpAtomic when it is created for the first time. + * \see RpPTankAtomicSetVertexAlpha. */ +}; + +/************************************************************************ + * + * + * + ************************************************************************/ + +#define rpPRTSTDPROPERTYCODEPARTICLESTANDARD 0 +#define rpPRTSTDPROPERTYCODEPARTICLEPOSITION 1 +#define rpPRTSTDPROPERTYCODEPARTICLECOLOR 2 +#define rpPRTSTDPROPERTYCODEPARTICLETEXCOORDS 3 +#define rpPRTSTDPROPERTYCODEPARTICLE2DROTATE 4 +#define rpPRTSTDPROPERTYCODEPARTICLESIZE 5 +#define rpPRTSTDPROPERTYCODEPARTICLEVELOCITY 6 +#define rpPRTSTDPROPERTYCODEPARTICLEMATRIX 7 + +#define rpPRTSTDPARTICLEPROPERTYCOUNT 8 + +#define rpPRTSTDPARTICLEDATAFLAGSTANDARD 0x00000001 +#define rpPRTSTDPARTICLEDATAFLAGPOSITION 0x00000002 +#define rpPRTSTDPARTICLEDATAFLAGCOLOR 0x00000004 +#define rpPRTSTDPARTICLEDATAFLAGTEXCOORDS 0x00000008 +#define rpPRTSTDPARTICLEDATAFLAG2DROTATE 0x00000010 +#define rpPRTSTDPARTICLEDATAFLAGSIZE 0x00000020 +#define rpPRTSTDPARTICLEDATAFLAGVELOCITY 0x00000040 +#define rpPRTSTDPARTICLEDATAFLAGMATRIX 0x00000080 + + +/** + * \ingroup rpprtstd + * \struct RpPrtStdParticleStandard + * A structure represent the set of properties for a basic particle. This structure is mandatory + * for all particles. + * The structure contain the life duration of the particle. The particle will be removed when the current + * time is greater than the end time. The particle timer always starts at zero. + * + * The inverted end time is for interpolating optional particle properties. + */ +typedef struct RpPrtStdParticleStandard RpPrtStdParticleStandard; +struct RpPrtStdParticleStandard +{ + RwInt32 flag; /**< Particle's property flag */ + RwReal currTime, /**< Particle's curr time */ + endTime, /**< Particle's end time */ + invEndTime; /**< Particle's inv end for interpolation */ +}; + + +typedef struct RpPrtStdParticleColor RpPrtStdParticleColor; + +/** + * \ingroup rpprtstd + * \struct RpPrtStdParticleColor + * A structure representing the change in a particle's color during its life time. The structure is optional + * and should not be used if particles have a constant color. + */ +struct RpPrtStdParticleColor +{ + RwRGBAReal startCol, /**< Particle's end size bias */ + deltaCol; /**< Particle's color rate of change */ +}; + +typedef struct RpPrtStdParticleTexCoords RpPrtStdParticleTexCoords; + +/** + * \ingroup rpprtstd + * \struct RpPrtStdParticleTexCoords + * A structure representing the change in a particle's texcoords during its life time. The structure is optional + * and should not be used if particles have a constant texcoords. + */ +struct RpPrtStdParticleTexCoords +{ + RwTexCoords startUV0, /**< Particle's starting top left texcoords */ + startUV1; /**< Particle's starting bottom right texcoords */ + RwTexCoords deltaUV0, /**< Particle's top left texcoords rate of change */ + deltaUV1; /**< Particle's bottom right texcoords rate of change */ +}; + +typedef struct RpPrtStdParticleSize RpPrtStdParticleSize; + +/** + * \ingroup rpprtstd + * \struct RpPrtStdParticleSize + * A structure representing the change in a particle's size during its life time. The structure is optional + * and should not be used if particles have a constant size. + */ +struct RpPrtStdParticleSize +{ + RwV2d startSize, /**< Particle's starting size */ + deltaSize; /**< Particle's size rate of change */ + RwV2d currSize, /**< Particle's current size. Internal use only */ + invCurrSize; /**< Particle's inverse current size. Internal use only */ +}; + +typedef struct RpPrtStdParticle2DRotate RpPrtStdParticle2DRotate; + +/** + * \ingroup rpprtstd + * \struct RpPrtStdParticle2DRotate + * A structure representing the changed in the 2D rotation of a particle during its life time. The structure is optional + * and should not be used if particles does not rotate or uses a matrix. + */ +struct RpPrtStdParticle2DRotate +{ + RwReal start2DRotate, /**< Particle's starting 2D rotation */ + delta2DRotate; /**< Particle's 2D rotation rate of change */ +}; + + +/************************************************************************ + * + * + * + ************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/************************************************************************/ + +extern RwInt32 +_rpPrtStdStreamGetVersion( void ); + +extern RwBool +_rpPrtStdSetPropTabPostReadCBack(_rpPrtStdPropTabCallBack pTabCB); + +extern RwBool +_rpPrtStdGetPropTabPostReadCBack(_rpPrtStdPropTabCallBack *pTabCB); + +extern RwBool +_rpPrtStdSetPropTabDtorCBack(_rpPrtStdPropTabCallBack pTabCB); + +extern RwBool +_rpPrtStdGetPropTabDtorCBack(_rpPrtStdPropTabCallBack *pTabCB); + +extern RpPrtStdEmitter * +_rpPrtStdEmitterCopy(RpPrtStdEmitter *dstEmt, RpPrtStdEmitter *emt); + +/************************************************************************/ + +extern RwBool +RpPrtStdPluginAttach( void ); + +/************************************************************************/ + +extern RwBool +RpAtomicIsParticleEmitter(RpAtomic *atomic); + +extern RpAtomic * +RpPrtStdAtomicCreate(RpPrtStdEmitterClass *eClass, void *data); + +extern RpAtomic * +RpPrtStdAtomicUpdate(RpAtomic *atomic, void *data); + +extern RpAtomic * +RpPrtStdAtomicSetEmitter(RpAtomic *atomic, RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdAtomicGetEmitter(RpAtomic *atomic); + +extern RpAtomic * +RpPrtStdAtomicForAllEmitter(RpAtomic *atomic, + RpPrtStdEmitterCallBack callback, + void *data); + +extern RpAtomic * +RpPrtStdAtomicAddEmitter(RpAtomic *, + RpPrtStdEmitter *emt); + + +/************************************************************************/ + + +extern RpPrtStdEmitter * +RpPrtStdEmitterCreate(RpPrtStdEmitterClass *eClass, void * data); + +extern RwBool +RpPrtStdEmitterDestroy(RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterClone(RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterForAllParticleBatch(RpPrtStdEmitter *emt, + RpPrtStdParticleCallBack callback, + void * data); + + +extern RpPrtStdEmitter * +RpPrtStdEmitterAddEmitter(RpPrtStdEmitter *emtHead, + RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterLinkPTank(RpPrtStdEmitter *emt,RpAtomic *ptank); + +extern RpPrtStdEmitter * +RpPrtStdEmitterCreatePTank(RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterDestroyParticleBatch(RpPrtStdEmitter *emt); + +extern RpPrtStdParticleBatch * +RpPrtStdEmitterNewParticleBatch(RpPrtStdEmitter *emt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterAddParticleBatch(RpPrtStdEmitter *emt, + RpPrtStdParticleBatch *prtBatch); + + +extern RpPrtStdEmitter * +RpPrtStdEmitterSetPClass(RpPrtStdEmitter *emt, + RpPrtStdParticleClass *pClass, + RwInt32 maxPrt); + +extern RpPrtStdEmitter * +RpPrtStdEmitterGetPClass(RpPrtStdEmitter *emt, + RpPrtStdParticleClass **pClass, + RwInt32 *maxPrt); + + +/************************************************************************/ + +extern RpPrtStdParticleBatch * +RpPrtStdParticleBatchCreate(RpPrtStdParticleClass *pClass, RwInt32 maxPrt); + +extern RwBool +RpPrtStdParticleBatchDestroy(RpPrtStdParticleBatch *prtBatch); + +extern RpPrtStdParticleBatch * +RpPrtStdParticleBatchAddBatch(RpPrtStdParticleBatch *prtBatchHead, + RpPrtStdParticleBatch *prtBatch); + +/************************************************************************/ + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabCreate(RwInt32 numProp, + RwInt32 *propID, RwInt32 *propStride); + +extern RwBool +RpPrtStdPropTabDestroy(RpPrtStdPropertyTable *propTab); + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabAppend(RpPrtStdPropertyTable *propTab, + RwInt32 numProp, RwInt32 *propID, RwInt32 *propStride); + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabGetProperties(RpPrtStdPropertyTable *propTab, + RwInt32 *numProp, + RwInt32 **propID, + RwInt32 **propOffset, + RwInt32 **propSize); + +extern RwInt32 +RpPrtStdPropTabGetPropOffset(RpPrtStdPropertyTable *propTab, + RwInt32 propID); + +extern RwInt32 +RpPrtStdPropTabGetPropIndex(RpPrtStdPropertyTable *propTab, + RwInt32 propID); + + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabGet(RwInt32 id); + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabGetByProperties(RwInt32 numProp, RwInt32 *propID, RwInt32 *propStride); + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabStreamRead(RwStream *stream); + +extern RpPrtStdPropertyTable * +RpPrtStdPropTabStreamWrite(RpPrtStdPropertyTable *eClass, + RwStream *stream); + +extern RwInt32 +RpPrtStdPropTabStreamGetSize(RpPrtStdPropertyTable *eClass); +/************************************************************************/ + +extern RwBool +RpPrtStdEClassDestroy(RpPrtStdEmitterClass *eClass); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassCreate( void ); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassSetCallBack(RpPrtStdEmitterClass *eClass, + RwInt32 numCallback, + RpPrtStdEmitterCallBackArray *emtCB); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassGetCallBack(RpPrtStdEmitterClass *eClass, + RwInt32 *numCallback, + RpPrtStdEmitterCallBackArray **emtCB); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassSetPropTab(RpPrtStdEmitterClass *eClass, + RpPrtStdPropertyTable *propTab); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassGetPropTab(RpPrtStdEmitterClass *eClass, + RpPrtStdPropertyTable **propTab); + + +extern RpPrtStdEmitterClass * +RpPrtStdEClassGet(RwInt32 id); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassGetByPropTab(RpPrtStdPropertyTable *propTab); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassStreamRead(RwStream *stream); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassStreamWrite(RpPrtStdEmitterClass *eClass, + RwStream *stream); + +extern RwInt32 +RpPrtStdEClassStreamGetSize(RpPrtStdEmitterClass *eClass); + +/************************************************************************/ + +extern RpPrtStdParticleClass * +RpPrtStdPClassCreate( void ); + +extern RwBool +RpPrtStdPClassDestroy(RpPrtStdParticleClass *pClass); + +extern RpPrtStdParticleClass * +RpPrtStdPClassSetCallBack(RpPrtStdParticleClass *pClass, + RwInt32 numCallback, + RpPrtStdParticleCallBackArray *prtCB); + +extern RpPrtStdParticleClass * +RpPrtStdPClassGetCallBack(RpPrtStdParticleClass *pClass, + RwInt32 *numCallback, + RpPrtStdParticleCallBackArray **prtCB); + +extern RpPrtStdParticleClass * +RpPrtStdPClassSetPropTab(RpPrtStdParticleClass *pClass, + RpPrtStdPropertyTable *propTab); + +extern RpPrtStdParticleClass * +RpPrtStdPClassGetPropTab(RpPrtStdParticleClass *pClass, + RpPrtStdPropertyTable **propTab); + +extern RpPrtStdParticleClass * +RpPrtStdPClassGet(RwInt32 id); + +extern RpPrtStdParticleClass * +RpPrtStdPClassGetByPropTab(RpPrtStdPropertyTable *propTab); + +extern RpPrtStdParticleClass * +RpPrtStdPClassStreamRead(RwStream *stream); + +extern RpPrtStdParticleClass * +RpPrtStdPClassStreamWrite(RpPrtStdParticleClass *pClass, + RwStream *stream); + +extern RwInt32 +RpPrtStdPClassStreamGetSize(RpPrtStdParticleClass *pClass); + +/************************************************************************/ + +extern RwBool +RpPrtStdSetEClassSetupCallBack(RpPrtStdEClassSetupCallBack emtCB); + +extern RwBool +RpPrtStdGetEClassSetupCallBack(RpPrtStdEClassSetupCallBack *emtCB); + +extern RwBool +RpPrtStdSetPClassSetupCallBack(RpPrtStdPClassSetupCallBack prtCB); + +extern RwBool +RpPrtStdGetPClassSetupCallBack(RpPrtStdPClassSetupCallBack *prtCB); + +/************************************************************************/ + + +extern RwStream * +RpPrtStdGlobalDataStreamRead(RwStream *stream); + +extern RwStream * +RpPrtStdGlobalDataStreamWrite(RwStream *stream); + +extern RwInt32 +RpPrtStdGlobalDataStreamGetSize( void ); + +extern void +RpPrtStdGlobalDataSetStreamEmbedded( RwBool embedded ); + +extern RwBool +RpPrtStdGlobalDataGetStreamEmbedded( void ); + +/************************************************************************/ + +extern RpPrtStdEmitter * +RpPrtStdEmitterDefaultCB(RpAtomic * atomic, + RpPrtStdEmitter *prtEmt, void * data); + + +extern RpPrtStdParticleBatch * +RpPrtStdParticleDefaultCB(RpPrtStdEmitter * prtEmt, + RpPrtStdParticleBatch *prtBatch, void * data); + +/************************************************************************/ + +extern RpPrtStdParticleBatch * +RpPrtStdParticleStdUpdateCB(RpPrtStdEmitter *emt, + RpPrtStdParticleBatch *prtBatch, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdEmitCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdCloneCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdCreateCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdDestroyCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdBeginUpdateCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdEndUpdateCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdRenderCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdStreamReadCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdStreamWriteCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + +extern RpPrtStdEmitter * +RpPrtStdEmitterStdStreamGetSizeCB(RpAtomic *atomic, + RpPrtStdEmitter *emt, void *data); + + + +extern RpPrtStdEmitterClass * +RpPrtStdEClassStdCreate( RwInt32 dataFlag ); + +extern RwInt32 +RpPrtStdEClassStdCreateID( RwInt32 dataFlag ); + +extern RpPrtStdParticleClass * +RpPrtStdPClassStdCreate( RwInt32 dataFlag ); + +extern RwInt32 +RpPrtStdPClassStdCreateID( RwInt32 dataFlag ); + +extern RpPrtStdEmitterClass * +RpPrtStdEClassStdSetupCB(RpPrtStdEmitterClass *eClass); + +extern RpPrtStdParticleClass * +RpPrtStdPClassStdSetupCB(RpPrtStdParticleClass *pClass); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./prtstd.h----*/ + +/*---- start: c:/daily/rwsdk/plugin/prtstd/d3d9/prtstdplatform.h----*/ +/*---- end: c:/daily/rwsdk/plugin/prtstd/d3d9/prtstdplatform.h----*/ + +#endif /* RPPRTSTD_H */ + + diff --git a/includes/rwsdk/rpprtstd.rpe b/includes/rwsdk/rpprtstd.rpe new file mode 100644 index 0000000..b75f83d --- /dev/null +++ b/includes/rwsdk/rpprtstd.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPrtStandard +{ + + + + e_rwdb_CriterionPrtStandardLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPrtStandard e_rwdb_CriterionPrtStandard; + + diff --git a/includes/rwsdk/rpptank.h b/includes/rwsdk/rpptank.h new file mode 100644 index 0000000..b83a608 --- /dev/null +++ b/includes/rwsdk/rpptank.h @@ -0,0 +1,832 @@ + +#ifndef RPPTANK_H +#define RPPTANK_H + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + +/*---- start: ./ptank.h----*/ + +/** + * \defgroup rpptank RpPTank + * \ingroup particles + * + * PTank Plugin for RenderWare. + */ + +/*--- Include files ---*/ + +#include + +#include "rwcore.h" + +#include "rpptank.rpe" /* automatically generated header file */ + +/****************************************************************************** + * Global Types + */ + +/** + * \ingroup rpptank + * Passed to \ref RpPTankAtomicCreate, these flags specify + * the type and properties held by the particles. + * Some flags are mutually exclusive and should not be mixed. + * The debug version of the library will assert and signal these problems. + */ +enum RpPTankDataFlags +{ + rpPTANKDFLAGNONE = ((int)0x00000000), + rpPTANKDFLAGPOSITION = ((int)0x00000001), /**actPCount) + +#define RpPTankAtomicGetMaximumParticlesCountMacro(_atm)\ + (RPATOMICPTANKPLUGINDATA(_atm)->maxPCount) + +#define RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGACTNUMCHG;\ + RPATOMICPTANKPLUGINDATA(atm_)->actPCount = cnt_;\ +}\ +MACRO_STOP + +#define RpPTankAtomicSetTextureMacro(atm_, tex_)\ +MACRO_START\ +{\ +RpMaterialSetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0), tex_);\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetTextureMacro(atm_)\ + (RpMaterialGetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0))) + +#define RpPTankAtomicGetMaterialMacro(atm_)\ + (RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0)) + +#define RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend = src_;\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend = dst_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGALPHABLENDING;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_)\ +MACRO_START\ +{\ + *src_ =\ + (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend);\ + *dst_ =\ + (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend);\ +}\ +MACRO_STOP + +#define RpPTankAtomicSetVertexAlphaMacro(atm_, vas_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend = vas_;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetVertexAlphaMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend) + +#define RpPTankAtomicSetConstantCenterMacro(atm_, ctr_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter = *ctr_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCENTER;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantCenterMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter)) + + +#define RpPTankAtomicSetConstantSizeMacro(atm_, size_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize = *size_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSSIZE;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantSizeMacro(atm_)\ + (&RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize) + +#define RpPTankAtomicSetConstantRotateMacro(atm_, rot_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate = rot_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNS2DROTATE;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantRotateMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate) + +#define RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_)\ +MACRO_START\ +{\ + RwMatrixCopy(&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix),mtx_);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSMATRIX;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantMatrixMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix)) + +#define RpPTankAtomicSetConstantColorMacro(atm_, col_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor = *col_;\ + if( RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0) )\ + {\ + (void)RpMaterialSetColor(\ + RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0),\ + &RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor);\ + }\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSCOLOR;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantColorMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor)) + +#define RpPTankAtomicSetConstantVtxColorMacro(atm_, col_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor,\ + col_,\ + sizeof(RwRGBA)*4);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTXCOLOR;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtxColorMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor) + +#define RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\ + uv_,\ + sizeof(RwTexCoords)*2);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX2TEXCOORDS;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV) + +#define RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\ + uv_,\ + sizeof(RwTexCoords)*4);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX4TEXCOORDS;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV) + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpPTankAtomicGetActiveParticlesCount(RpAtomic *atomic); + +extern RwInt32 +RpPTankAtomicGetMaximumParticlesCount(RpAtomic *atomic); + +extern void +RpPTankAtomicSetActiveParticlesCount(RpAtomic *atomic, RwInt32 count); + +extern void +RpPTankAtomicSetTexture(RpAtomic *atomic, RwTexture *texture); + +extern RwTexture * +RpPTankAtomicGetTexture(RpAtomic *atomic); + +extern RpAtomic * +RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material); + +extern RpMaterial * +RpPTankAtomicGetMaterial(RpAtomic *atomic); + +extern void +RpPTankAtomicSetBlendModes(RpAtomic *atomic, + RwBlendFunction srcBlendMode, + RwBlendFunction dstBlendMode ); + +extern void +RpPTankAtomicGetBlendModes(RpAtomic *atomic, + RwBlendFunction *srcBlendMode, + RwBlendFunction *dstBlendMode ); + +extern void +RpPTankAtomicSetVertexAlpha(RpAtomic *atomic, RwBool vtxAlphaState); + +extern RwBool +RpPTankAtomicGetVertexAlpha(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantCenter(RpAtomic *atomic, RwV2d *center); + +const RwV2d * +RpPTankAtomicGetConstantCenter(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantSize(RpAtomic *atomic, RwV2d *size); + +extern const RwV2d * +RpPTankAtomicGetConstantSize(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantRotate(RpAtomic *atomic, RwReal rotate); + +extern RwReal +RpPTankAtomicGetConstantRotate(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantMatrix(RpAtomic *atomic, RwMatrix *matrix); + +extern const RwMatrix * +RpPTankAtomicGetConstantMatrix(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantColor(RpAtomic *atomic, RwRGBA *color); + +extern const RwRGBA * +RpPTankAtomicGetConstantColor(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtxColor(RpAtomic *atomic, RwRGBA *color); + +extern const RwRGBA * +RpPTankAtomicGetConstantVtxColor(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtx2TexCoords(RpAtomic *atomic, RwTexCoords *UVs); + +extern const RwTexCoords * +RpPTankAtomicGetConstantVtx2TexCoords(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtx4TexCoords(RpAtomic *atomic, RwTexCoords *UVs); + +extern const RwTexCoords * +RpPTankAtomicGetConstantVtx4TexCoords(RpAtomic *atomic); +#else + +#define RpPTankAtomicGetActiveParticlesCount(atm_)\ + RpPTankAtomicGetActiveParticlesCountMacro(atm_) + +#define RpPTankAtomicGetMaximumParticlesCount(atm_)\ + RpPTankAtomicGetMaximumParticlesCountMacro(atm_) + +#define RpPTankAtomicSetActiveParticlesCount(atm_,cnt_)\ + RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_) + + +#define RpPTankAtomicSetTexture(atm_,tex_)\ + RpPTankAtomicSetTextureMacro(atm_,tex_) + +#define RpPTankAtomicGetTexture(atm_)\ + RpPTankAtomicGetTextureMacro(atm_) + +extern RpAtomic * +RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material); + +#define RpPTankAtomicGetMaterial(atm_)\ + RpPTankAtomicGetMaterialMacro(atm_) + +#define RpPTankAtomicSetBlendModes(atm_,src_,dst_)\ + RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_) + +#define RpPTankAtomicGetBlendModes(atm_,src_,dst_)\ + RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_) + +#define RpPTankAtomicSetVertexAlpha(atm_, vas_)\ + RpPTankAtomicSetVertexAlphaMacro(atm_, vas_) + +#define RpPTankAtomicGetVertexAlpha(atm_)\ + RpPTankAtomicGetVertexAlphaMacro(atm_) + +#define RpPTankAtomicSetConstantCenter(atm_, ctr_)\ + RpPTankAtomicSetConstantCenterMacro(atm_, ctr_) + +#define RpPTankAtomicGetConstantCenter(atm_)\ + RpPTankAtomicGetConstantCenterMacro(atm_) + +#define RpPTankAtomicSetConstantSize(atm_, size_)\ + RpPTankAtomicSetConstantSizeMacro(atm_, size_) + +#define RpPTankAtomicGetConstantSize(atm_)\ + RpPTankAtomicGetConstantSizeMacro(atm_) + +#define RpPTankAtomicSetConstantRotate(atm_, rot_)\ + RpPTankAtomicSetConstantRotateMacro(atm_, rot_) + +#define RpPTankAtomicGetConstantRotate(atm_)\ + RpPTankAtomicGetConstantRotateMacro(atm_) + +#define RpPTankAtomicSetConstantMatrix(atm_, mtx_)\ + RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_) + +#define RpPTankAtomicGetConstantMatrix(atm_)\ + RpPTankAtomicGetConstantMatrixMacro(atm_) + +#define RpPTankAtomicSetConstantColor(atm_, col_)\ + RpPTankAtomicSetConstantColorMacro(atm_, col_) + +#define RpPTankAtomicGetConstantColor(atm_)\ + RpPTankAtomicGetConstantColorMacro(atm_) + +#define RpPTankAtomicSetConstantVtxColor(atm_, _col)\ + RpPTankAtomicSetConstantVtxColorMacro(atm_, _col) + +#define RpPTankAtomicGetConstantVtxColor(atm_)\ + RpPTankAtomicGetConstantVtxColorMacro(atm_) + +#define RpPTankAtomicSetConstantVtx2TexCoords(atm_, uv_)\ + RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_) + +#define RpPTankAtomicGetConstantVtx2TexCoords(atm_)\ + RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\ + +#define RpPTankAtomicSetConstantVtx4TexCoords(atm_, uv_)\ + RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_) + +#define RpPTankAtomicGetConstantVtx4TexCoords(atm_)\ + RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_) + +#endif + +/* + * Data access API *********************************************************** + */ + +extern RwBool +RpPTankAtomicLock(RpAtomic *atomic, RpPTankLockStruct *dst, + RwUInt32 dataFlags, RpPTankLockFlags lockFlag); + +extern void * +RpPTankAtomicLockByIndex(RpAtomic *atomic, RwInt32 idx, RwUInt32 dataFlags, RpPTankLockFlags lockFlag); + +extern RpAtomic * +RpPTankAtomicUnlock(RpAtomic *atomic); + + +/* + * Stealth functions ********************************************************* + */ +RpAtomic* +_rpPTankAtomicCreateCustom(RwInt32 maxParticleNum, + RwUInt32 dataFlags, RwUInt32 platFlags, + RpPTankCallBacks *callbacks); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./ptank.h----*/ + +/*---- start: c:/daily/rwsdk/plugin/ptank/d3d9/ptankplatform.h----*/ + +/** + * \defgroup rpptankd3d9 D3D9 + * \ingroup rpptank + * + * D3D9 specific documentation. + */ + +/** + * \ingroup rpptankd3d9 + * \par D3D9 specific data flags + * + *
    + *
  • rpPTANKD3D9FLAGSUSEPOINTSPRITES selects the D3D9 optimized pipeline. At the + * moment, this pipeline use point sprites when the hardware supports them, + * which don't allow use of all the PTank flags. Only the following flags are + * supported when using the D3D9 optimized pipes: + * + *
      + *
    • rpPTANKDFLAGPOSITION + *
    • rpPTANKDFLAGNORMAL + *
    • rpPTANKDFLAGSIZE (if the hardware supports the D3DFVF_PSIZE vertex format flag) + *
    • rpPTANKDFLAGCOLOR + *
    • rpPTANKDFLAGUSECENTER + *
    • rpPTANKDFLAGCNSVTX2TEXCOORDS + *
    • rpPTANKDFLAGARRAY + *
    • rpPTANKDFLAGSTRUCTURE + *
    + * + * The texture coordinates are generated by the hardware and can't be specified, + * but rpPTANKDFLAGCNSVTX2TEXCOORDS need to be used tp specify that the point sprites + * are textured. + *
+ * + * If the hardware does not support point sprites, the default pipeline is used + * instead. + * + */ + +enum RpPTankD3D9Flags +{ + rpPTANKD3D9FLAGSUSEPOINTSPRITES = 0x00000001, + + rpPTANKD3D9FLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum RpPTankD3D9Flags RpPTankD3D9Flags; + +/*---- end: c:/daily/rwsdk/plugin/ptank/d3d9/ptankplatform.h----*/ + +#endif /* RPPTANK_H */ + + diff --git a/includes/rwsdk/rpptank.rpe b/includes/rwsdk/rpptank.rpe new file mode 100644 index 0000000..73a85fd --- /dev/null +++ b/includes/rwsdk/rpptank.rpe @@ -0,0 +1,523 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPTank +{ + + + + e_rwdb_CriterionPTankLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPTank e_rwdb_CriterionPTank; + + diff --git a/includes/rwsdk/rppvs.h b/includes/rwsdk/rppvs.h new file mode 100644 index 0000000..7af1eab --- /dev/null +++ b/includes/rwsdk/rppvs.h @@ -0,0 +1,399 @@ +/* + * Potentially Visible Set plug-in + */ + +/********************************************************************** + * + * file : rppvs.h + * + * abstract : handle culling of worldsectors in RenderWare + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2001 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef _RPPVS_H +#define _RPPVS_H + +/** + * \defgroup rppvs RpPVS + * \ingroup pvs + * + * Geometric Potentially Visible Set Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Defines + */ + +typedef RwUInt8 RpPVSVisMap; + +#define PVSFROMWORLDSECTOR(sector) \ + ((RpPVS *)(((char *)(sector))+rpPVSGlobals.sectorOffset)) + +#define WORLDSECTORFROMPVS(pvs) \ + ((RpWorldSector *)(((char *)(pvs))-rpPVSGlobals.sectorOffset)) + +#define PVSFROMCONSTWORLDSECTOR(sector) \ + ((const RpPVS *)(((const char *)(sector))+rpPVSGlobals.sectorOffset)) + + +#define PVSCACHEFROMWORLD(world) \ + ((RpPVSCache *)(((char *)(world))+rpPVSGlobals.worldOffset)) +#define PVSCACHEFROMCONSTWORLD(world) \ + ((const RpPVSCache *)(((const char *)(world))+rpPVSGlobals.worldOffset)) + +#define PVSVISMAPSETSECTOR(_vismap, _id) \ + (_vismap)[(_id) >> 3] |= (1 << ((_id) & 7)) + +#define PVSVISMAPUNSETSECTOR(_vismap, _id) \ + (_vismap)[(_id) >> 3] ^= (1 << ((_id) & 7)) + +#define PVSVISMAPGETSECTOR(_vismap, _id) \ + ((_vismap)[(_id) >> 3] & (1 << ((_id) & 7))) + +#define PVSVISMAPLENGTH(_vismaplength, _nosectors) \ + (_vismaplength) = ((_nosectors + 7) >> 3) + + +/* Progress callback message types */ +#define rpPVSPROGRESSSTART 20 +#define rpPVSPROGRESSUPDATE 12 +#define rpPVSPROGRESSEND 22 + +/** + * \ingroup rppvs + * \ref RpPVSProgressCallBack + * This typedef sets the callback function for sampling within a world sector. + * + * \param value A value between 0.0 and 100.0 to represent the percentage + * completion. + * \param msg The message may take one of the following: + * \li rpPVSPROGRESSSTART + * The PVS creation process is about to start. The argument + * value is equal to 0.0. + * \li rpPVSPROGRESSUPDATE + * The PVS creation process has finished processing a + * subsection of the world. The argument value is equal to + * the percentage of the world processed up to this point. + * \li rpPVSPROGRESSEND + * The PVS creation process has ended. All world sectors + * have been processed. The argument value is equal to 100.0. + * + * \return The progress callback may return FALSE to indicate that the + * generation of PVS data should terminate. Otherwise, return + * TRUE to continue. + * + */ +typedef RwBool(*RpPVSProgressCallBack) (RwInt32 msg, + RwReal value); + + +/** + * \ingroup rppvs + * \ref RpPVSCallBack + * This typedef sets the callback function for sampling within a world sector. + * + * \param worldSector A pointer to the \ref RpWorldSector being sampled. + * \param box The bounding box of the region being sampled. + * \param pData A pointer to private data for the sampling function. + * + * \return Pointer to the current world sector or NULL to terminate the + * iteration and exit early. + */ +typedef RpWorldSector *(*RpPVSCallBack) (RpWorldSector * worldSector, + const RwBBox * box, + void *pData); + +#define RpPVSCallback RpPVSCallBack + +typedef struct _RpPVSCallBack _RpPVSCallBack; + +#if (!defined(DOXYGEN)) +struct _RpPVSCallBack +{ + RpPVSCallBack callback; + void *data; +}; +#endif /* (!defined(DOXYGEN)) */ + +enum _rpPVSPartitionId +{ + rpNAPVSPARTITIONID = 0, + rpPVSFRONT, + rpPVSBACK, + rpPVSSPLIT, + rpPVSCOPLANAR, + rpPVSPARTITIONIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum _rpPVSPartitionId _rpPVSPartitionId; + +typedef struct _rpPVSPolyList _rpPVSPolyList; +typedef struct _rpPVSPolyList *_rpPVSPolyListPtr; + +typedef struct _rpPVSPoly _rpPVSPoly; +typedef struct _rpPVSPoly *_rpPVSPolyPtr; + +#if (!defined(DOXYGEN)) +typedef struct _rpPVSPlaneEq _rpPVSPlaneEq; +struct _rpPVSPlaneEq +{ + RwReal x; + RwReal y; + RwReal z; + RwReal w; + + RwReal l; /* recip of length of the normal */ + + _rpPVSPartitionId lastresult; /* temp: stores result of last polygon wrt this plane */ +}; + +typedef struct RwV3i RwV3i; +struct RwV3i +{ + RwInt32 x; + RwInt32 y; + RwInt32 z; +}; + +typedef struct _rpPVSPolyRecord _rpPVSPolyRecord; +struct _rpPVSPolyRecord +{ + RwBool original; /* True if not a fragment */ + RwReal priority; /* Used for sorting, lower values higher priority */ + _rpPVSPolyListPtr parent; /* Unique pointer to original parent */ + _rpPVSPolyPtr geom; /* corners of the poly */ + _rpPVSPlaneEq plane; /* plane equation of the poly */ + RwInt32 home; /* world sector id in range 0..numsectors */ + RpWorldSector *homeaddr; /* world sector pointer */ + RwBool translucent; + + RwBool hasbeenclipper; /* Used during WA creation */ + + /* used by proximity culling, calculated once */ + RwV3d centroid; + RwReal radius; + RwV3d extreme; /* the vertex furthest away from the centroid */ + + RwReal coneRadius; /* Used during clipping only */ + +}; + +struct _rpPVSPoly +{ + RwV3d v; + _rpPVSPoly *next; + + RwInt32 pscalar; /* Used during clipping only */ + RwReal scalar; /* Used during clipping only */ + _rpPVSPlaneEq shadowPlane; /* Used during clipping only */ +}; + +struct _rpPVSPolyList +{ + _rpPVSPolyRecord data; + _rpPVSPolyList *next; +}; + +typedef struct RpPVS RpPVS; + +struct RpPVS +{ + RwInt32 sectorID; + RwInt32 vismaplength; + RwInt32 sampleKey; + + RpPVSVisMap *vismap; + + _rpPVSPolyListPtr sectailpoly; + _rpPVSPartitionId potential; + + RwUInt32 numpols; + RwBBox sbox; + RwBBox gbox; + RwReal diagonal; + RwV3d centre; + RwInt32 axessig[3]; +}; + +typedef struct RpPVSCache RpPVSCache; +struct RpPVSCache +{ + RwBool processed; + RwBool formatted; + RwInt32 NumWorldSectors; + + RwInt32 ptotal; + RwInt32 paccept; + + RwBool hooked; + + RwUInt32 nextID; + + RwInt32 viscount; + + RpPVSProgressCallBack progressCallBack; + + _rpPVSPolyListPtr polygons; + + RpWorldSectorCallBackRender renderCallBack; +}; + +typedef struct RpPVSGlobalVars RpPVSGlobalVars; +struct RpPVSGlobalVars +{ + RpWorld *World; + + RwInt32 worldOffset; + RwInt32 sectorOffset; + + RwBool collis; + RwBool bfc; + + + RwInt32 progress_count; + RwReal diagonal; + + RwReal gran; + + RwInt32 InSector; + RwV3d ViewPos; + RpPVS *CurrPVS; +}; +#endif /* (!defined(DOXYGEN)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpPVSGlobalVars rpPVSGlobals; + +extern RpWorld * +RpPVSSetProgressCallBack(RpWorld * wpWorld, + RpPVSProgressCallBack + callback); + +extern RpWorldSector * +RpPVSSetViewPosition(RpWorld * wpWorld, + RwV3d * pos); + +extern RpWorldSector * +RpPVSSetViewSector(RpWorld * wpWorld, RpWorldSector * spSect); + +extern RpWorldSector * +RpPVSSetWorldSectorPairedVisibility(RpWorldSector * spSectA, + RpWorldSector * spSectB, + RwBool visible, + RwBool mutual); + +extern RpWorld * +RpPVSDestroy(RpWorld * wpWorld); + +extern RwBool +RpPVSWorldSectorVisible(RpWorldSector * spSect); + +extern RwBool +RpPVSPluginAttach(void); + +extern RwBool +RpPVSQuery(RpWorld * wpWorld); + +extern RwBool +RpPVSAtomicVisible(RpAtomic * atom); + +extern RpWorld * +RpPVSStatisticsGet(RpWorld * wpWorld, + RwInt32 * ptotal, + RwInt32 * paccept); + +extern RpPVSProgressCallBack +RpPVSGetProgressCallBack(RpWorld * + wpWorld); + +extern RpWorld * +RpPVSConstruct(RpWorld * wpWorld, + RpPVSCallBack callback, + void *pData); + +extern RpWorld* +RpPVSConstructSector(RpWorld * wpWorld, + RpWorldSector * spSector, + RpPVSCallBack callback, + void *pData); + + +extern RpWorldSector * +RpPVSGeneric(RpWorldSector * spSect, + const RwBBox __RWUNUSED__ * box, + void *data); + +extern RwBool +RpPVSSetCollisionDetection(RwBool collis); + +extern RwBool +RpPVSSetBackFaceCulling(RwBool bfc); + +extern RpWorld * +RpPVSUnhook(RpWorld * wpWorld); + +extern RpWorld * +RpPVSHook(RpWorld * wpWorld); + +extern RpWorldSector * +RpPVSSetWorldSectorVisibility(RpWorldSector * spSect, + RwBool visible); + +extern RwBool +RpPVSSamplePOV(RwV3d * pos, + RwBool colltest); + +extern RxNodeDefinition * +RxNodeDefinitionGetPVSWorldSectorCSL(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* These functions are added for backwards compatibility... */ +#define RpPVSCreate(_wpWorld, \ + _raster, _zraster, _mindist, \ + _maxdist, _maxdepth, _callback, _pData) \ + RpPVSConstruct(_wpWorld, _callback, _pData) + +#define RpPVSAddPOV(_pos) \ + RpPVSSamplePOV(_pos, FALSE) + +#define RpPVSAddWorldSector(_sector) \ + RpPVSSetWorldSectorVisibility(_sector, TRUE) + +#define RpPVSAddExtraPOV(_world, _raster, _zraster, _mindist, _mazdist, _matrix) \ +MACRO_START \ +{ \ + rpPVSGlobals.World = (_world); \ + RpPVSSamplePOV(&((_matrix)->pos), TRUE); \ +} \ +MACRO_STOP + + +#endif /* _RPPVS_H */ diff --git a/includes/rwsdk/rppvs.rpe b/includes/rwsdk/rppvs.rpe new file mode 100644 index 0000000..b194968 --- /dev/null +++ b/includes/rwsdk/rppvs.rpe @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionGPVS +{ + + + + e_rwdb_CriterionGPVSLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionGPVS e_rwdb_CriterionGPVS; + + diff --git a/includes/rwsdk/rprandom.h b/includes/rwsdk/rprandom.h new file mode 100644 index 0000000..aebbfed --- /dev/null +++ b/includes/rwsdk/rprandom.h @@ -0,0 +1,65 @@ +/********************************************************************** + * + * File : rprandom.h + * + * Abstract : Random Number Generator + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 1998 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef RPRANDOM_H +#define RPRANDOM_H + +/** + * \defgroup rprandom RpRandom + * \ingroup mathtools + * + * Random Number Generation Plugin for RenderWare Graphics. + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rprandom.rpe" /* automatically generated header file */ + +/*--- Plugin API Functions ---*/ + +#define RPRANDMAX (~((~0)<<31)) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +RwBool RpRandomPluginAttach(void); + +/* Getting values */ + +extern RwUInt32 RpRandom(void); +extern void RpRandomSeed(RwUInt32 seed); + +extern RwUInt32 RpRandomMT(void); +extern void RpRandomSeedMT(RwUInt32 seed); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPRANDOM_H */ + diff --git a/includes/rwsdk/rprandom.rpe b/includes/rwsdk/rprandom.rpe new file mode 100644 index 0000000..6bdac88 --- /dev/null +++ b/includes/rwsdk/rprandom.rpe @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRandom +{ + + + + e_rwdb_CriterionRandomLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRandom e_rwdb_CriterionRandom; + + diff --git a/includes/rwsdk/rpskin.h b/includes/rwsdk/rpskin.h new file mode 100644 index 0000000..3e32307 --- /dev/null +++ b/includes/rwsdk/rpskin.h @@ -0,0 +1,291 @@ + +#ifndef RPSKIN_H +#define RPSKIN_H + +/** + * \defgroup rpskin RpSkin + * \ingroup skinning + * + * Skin Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ +#include "rwcore.h" +#include "rpworld.h" + +#include "rpcriter.h" +#include "rpskin.rpe" + +#include "rphanim.h" + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ +typedef struct RwMatrixWeights RwMatrixWeights; + +/** + * \ingroup rpskin + * \struct RwMatrixWeights + * A structure for defining up to four matrix weights per vertex. + * Not all entries need to be used. + * + * \note + * Values should be sorted, such that any zero 0.0f entries appear + * after the valid weights. Any weights that appear after a zero + * entry will be ignored. + * + * \see RpSkinCreate + */ +struct RwMatrixWeights +{ + RwReal w0; /**< The first matrix weight. */ + RwReal w1; /**< The second matrix weight. */ + RwReal w2; /**< The third matrix weight. */ + RwReal w3; /**< The fourth matrix weight. */ +}; + +/** + * \ingroup rpskin + * \struct RpSkin + * + * Skin object. This should be considered an opaque type. + * Use the RpSkin API functions to access. + * + * \see RpSkinCreate + * \see RpSkinDestroy + */ +typedef struct RpSkin RpSkin; + +/*===========================================================================* + *--- Plugin API Functions --------------------------------------------------* + *===========================================================================*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/*---------------------------------------------------------------------------* + *- Plugin functions -* + *---------------------------------------------------------------------------*/ +extern void RpSkinSetFreeListCreateParams( + RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwBool +RpSkinPluginAttach(void); + +/*---------------------------------------------------------------------------* + *- Skin Atomic functions -* + *---------------------------------------------------------------------------*/ +extern RpAtomic * +RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, + RpHAnimHierarchy *hierarchy ); + +extern RpHAnimHierarchy * +RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ); + +/*---------------------------------------------------------------------------* + *- Skin Geometry functions -* + *---------------------------------------------------------------------------*/ +extern RpGeometry * +RpSkinGeometrySetSkin( RpGeometry *geometry, + RpSkin *skin ); + +extern RpSkin * +RpSkinGeometryGetSkin( RpGeometry *geometry ); + +extern RpSkin * +RpSkinCreate( RwUInt32 numVertices, + RwUInt32 numBones, + RwMatrixWeights *vertexWeights, + RwUInt32 *vertexIndices, + RwMatrix *inverseMatrices ); + +extern RpSkin * +RpSkinDestroy( RpSkin *skin ); + +extern RwUInt32 +RpSkinGetNumBones( RpSkin *skin ); + +extern const RwMatrixWeights * +RpSkinGetVertexBoneWeights( RpSkin *skin ); + +extern const RwUInt32 * +RpSkinGetVertexBoneIndices( RpSkin *skin ); + +extern const RwMatrix * +RpSkinGetSkinToBoneMatrices( RpSkin *skin ); + +extern RwBool +RpSkinIsSplit( RpSkin *skin ); + +/*---------------------------------------------------------------------------* + *- Skin pipeline -* + *---------------------------------------------------------------------------*/ + +/** + * \ingroup rpskin + * \ref RpSkinType defines the different ways a skinned atomic can + * be rendered. Once a skinned \ref RpGeometry has been attached to + * an \ref RpAtomic the atomic must be setup with the correct skin + * rendering pipeline with \ref RpSkinAtomicSetType. + */ +enum RpSkinType +{ + rpNASKINTYPE = 0, /** +#include + +/** + * \ingroup rpuserdata + * User data formats + */ +enum RpUserDataFormat +{ + rpNAUSERDATAFORMAT = 0, + rpINTUSERDATA, /**< 32 bit int data */ + rpREALUSERDATA, /**< 32 bit float data */ + rpSTRINGUSERDATA, /**< unsigned byte pointer data */ + rpUSERDATAFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpUserDataFormat RpUserDataFormat; + +typedef struct RpUserDataArray RpUserDataArray; + +/** + * \ingroup rpuserdata + * \struct RpUserDataArray + * A structure representing an array of user data values + */ + +struct RpUserDataArray +{ + RwChar *name; /**< Identifier for this data array */ + RpUserDataFormat format; /**< Data format of this array */ + RwInt32 numElements; /**< Number of elements in this array */ + void *data; /**< Pointer to the array data */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Plugin API */ +extern RwBool RpUserDataPluginAttach(void); + +/* Geometry API */ +extern RwInt32 RpGeometryAddUserDataArray(RpGeometry *geometry, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpGeometry *RpGeometryRemoveUserDataArray(RpGeometry *geometry, RwInt32 index); +extern RpUserDataArray *RpGeometryGetUserDataArray(const RpGeometry *geometry, RwInt32 data); +extern RwInt32 RpGeometryGetUserDataArrayCount(const RpGeometry *geometry); + +/* World Sector API */ +extern RwInt32 RpWorldSectorAddUserDataArray(RpWorldSector *sector, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpWorldSector *RpWorldSectorRemoveUserDataArray(RpWorldSector *sector, RwInt32 index); +extern RpUserDataArray *RpWorldSectorGetUserDataArray(const RpWorldSector *sector, RwInt32 data); +extern RwInt32 RpWorldSectorGetUserDataArrayCount(const RpWorldSector *sector); + +/* RwFrame API */ +extern RwInt32 RwFrameAddUserDataArray(RwFrame *frame, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwFrame *RwFrameRemoveUserDataArray(RwFrame *frame, RwInt32 index); +extern RpUserDataArray *RwFrameGetUserDataArray(const RwFrame *frame, RwInt32 data); +extern RwInt32 RwFrameGetUserDataArrayCount(const RwFrame *frame); + +/* RwCamera API */ +extern RwInt32 RwCameraAddUserDataArray(RwCamera *camera, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwCamera *RwCameraRemoveUserDataArray(RwCamera *camera, RwInt32 index); +extern RpUserDataArray *RwCameraGetUserDataArray(const RwCamera *camera, RwInt32 data); +extern RwInt32 RwCameraGetUserDataArrayCount(const RwCamera *camera); + +/* RpLight API */ +extern RwInt32 RpLightAddUserDataArray(RpLight *light, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpLight *RpLightRemoveUserDataArray(RpLight *light, RwInt32 index); +extern RpUserDataArray *RpLightGetUserDataArray(const RpLight *light, RwInt32 data); +extern RwInt32 RpLightGetUserDataArrayCount(const RpLight *light); + +/* RpMaterial API */ +extern RwInt32 RpMaterialAddUserDataArray(RpMaterial *material, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpMaterial *RpMaterialRemoveUserDataArray(RpMaterial *material, RwInt32 index); +extern RpUserDataArray *RpMaterialGetUserDataArray(const RpMaterial *material, RwInt32 data); +extern RwInt32 RpMaterialGetUserDataArrayCount(const RpMaterial *material); + +/* RwTexture API */ +extern RwInt32 RwTextureAddUserDataArray(RwTexture *texture, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwTexture *RwTextureRemoveUserDataArray(RwTexture *texture, RwInt32 index); +extern RpUserDataArray *RwTextureGetUserDataArray(const RwTexture *texture, RwInt32 data); +extern RwInt32 RwTextureGetUserDataArrayCount(const RwTexture *texture); + +/* User Data Array API */ +extern RwChar *RpUserDataArrayGetName(RpUserDataArray *userData); +extern RpUserDataFormat RpUserDataArrayGetFormat(RpUserDataArray *userData); +extern RwInt32 RpUserDataArrayGetNumElements(RpUserDataArray *userData); + +extern RwInt32 RpUserDataArrayGetInt(RpUserDataArray *userData, RwInt32 index); +extern RwReal RpUserDataArrayGetReal(RpUserDataArray *userData, RwInt32 index); +extern RwChar *RpUserDataArrayGetString(RpUserDataArray *userData, RwInt32 index); + +extern void RpUserDataArraySetInt(RpUserDataArray *userData, RwInt32 index, RwInt32 value); +extern void RpUserDataArraySetReal(RpUserDataArray *userData, RwInt32 index, RwReal value); +extern void RpUserDataArraySetString(RpUserDataArray *userData, RwInt32 index, RwChar *value); + +extern RwInt32 RpUserDataGetFormatSize(RpUserDataFormat format); + +#ifdef __cplusplus +} +#endif + +#endif /* RPUSERDATAPLUGIN_H */ diff --git a/includes/rwsdk/rpusrdat.rpe b/includes/rwsdk/rpusrdat.rpe new file mode 100644 index 0000000..e25e7f2 --- /dev/null +++ b/includes/rwsdk/rpusrdat.rpe @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionUserData +{ + + + + e_rwdb_CriterionUserDataLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionUserData e_rwdb_CriterionUserData; + + diff --git a/includes/rwsdk/rpuvanim.h b/includes/rwsdk/rpuvanim.h new file mode 100644 index 0000000..c58f1e6 --- /dev/null +++ b/includes/rwsdk/rpuvanim.h @@ -0,0 +1,527 @@ +/***************************************************************************** + * + * File : rpuvanim.h + * + * Abstract : UV animation + * + ***************************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2000 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + *****************************************************************************/ + +#ifndef RPUVANIM_H +#define RPUVANIM_H + +/** + * \defgroup rpuvanim RpUVAnim + * \ingroup animtools + * + * UV Animation Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ +#include +#include +#include +#include + +#include +#include "rpuvanim.rpe" /* automatically generated header file */ + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ + +/** + * \ingroup rpuvanim + * \def RP_UVANIM_MAXSLOTS is the maximum number of separate UV animations + * that can be applied to a single material + */ +#define RP_UVANIM_MAXSLOTS (8) +/** + * \ingroup rpuvanim + * \def RP_UVANIM_APPLIEDCHANNELS is the number of UV channels that will be + * updated via the default implementation of \ref RpMaterialUVAnimApplyUpdate + */ +#define RP_UVANIM_APPLIEDCHANNELS (2) + +#define RP_UVANIM_FIRST_PASS_CHANNEL (0) +#define RP_UVANIM_DUAL_PASS_CHANNEL (1) +/** + * \ingroup rpuvanim + * \def RP_UVANIM_MAXNAME is the maximum number of chars stored in a UV + * animation name, including the terminating NULL + */ +#define RP_UVANIM_MAXNAME (32) + +/*===========================================================================* + *--- Global variables ------------------------------------------------------* + *===========================================================================*/ + +/*===========================================================================* + *--- Plugin API Functions --------------------------------------------------* + *===========================================================================*/ + + +/*--- UVAnimPlugin functions ------------------------------------------------*/ + +/**************************************************************************** + Includes + */ + +#if (!defined(DOXYGEN)) +typedef struct RpUVAnimMaterialGlobalVars RpUVAnimMaterialGlobalVars; + +struct RpUVAnimMaterialGlobalVars +{ + RwInt32 engineOffset; +}; + +typedef struct _rpUVAnimCustomData _rpUVAnimCustomData; + +struct _rpUVAnimCustomData /* Warning - streaming depends on layout */ +{ + RwChar name[RP_UVANIM_MAXNAME]; + RwUInt32 nodeToUVChannelMap[RP_UVANIM_MAXSLOTS]; + RwUInt32 refCount; +}; + +extern _rpUVAnimCustomData * +_rpUVAnimCustomDataStreamRead(RwStream *stream); + +extern const _rpUVAnimCustomData * +_rpUVAnimCustomDataStreamWrite(const _rpUVAnimCustomData *customData, + RwStream *stream); + +extern RwUInt32 +_rpUVAnimCustomDataStreamGetSize(const _rpUVAnimCustomData *customData); +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpuvanim + * \ref RpUVAnim + * typedef for struct RpUVAnim + */ +typedef RtAnimAnimation RpUVAnim; + +/** + * \ingroup rpuvanim + * \ref RpUVAnimInterpolator + * typedef for struct RpUVAnimInterpolator + */ +typedef RtAnimInterpolator RpUVAnimInterpolator; + +/** + * \ingroup rpuvanim + * \ref RpUVAnimKeyFrameType + * enum delineating the keyframe schemes that may be used + */ +enum RpUVAnimKeyFrameType +{ + rpUVANIMLINEARKEYFRAMES = 0, /**data.linear; \ + \ + (_matrix)->right.x = lkf->uv[0]; \ + (_matrix)->right.y = lkf->uv[1]; \ + (_matrix)->right.z = 0.0f; \ + (_matrix)->up.x = lkf->uv[2]; \ + (_matrix)->up.y = lkf->uv[3]; \ + (_matrix)->up.z = 0.0f; \ + (_matrix)->at.x = 0.0f; \ + (_matrix)->at.y = 0.0f; \ + (_matrix)->at.z = 0.0f; \ + (_matrix)->pos.x = lkf->uv[4]; \ + (_matrix)->pos.y = lkf->uv[5]; \ + (_matrix)->pos.z = 0.0f; \ + RwMatrixUpdate(_matrix); \ +} \ +MACRO_STOP + +#define RpUVAnimParamKeyFrameToMatrixMacro(_matrix,_voidIFrame, _Pivot, _InvPivot) \ +MACRO_START \ +{ \ + /* RwV3d _InvPivot; */ \ + RpUVAnimParamKeyFrameData *param \ + = &((RpUVAnimKeyFrame *)(_voidIFrame))->data.param; \ + \ + RwV3d zAxis = {0.0f, 0.0f, 1.0f}; \ + \ + (_matrix)->right.x = param->s0; \ + (_matrix)->right.y = param->skew; \ + (_matrix)->right.z = 0.0f; \ + (_matrix)->up.x = 0.0f; \ + (_matrix)->up.y = param->s1; \ + (_matrix)->up.z = 0.0f; \ + (_matrix)->at.x = 0.0f; \ + (_matrix)->at.y = 0.0f; \ + (_matrix)->at.z = 0.0f; \ + (_matrix)->pos.x = param->x; \ + (_matrix)->pos.y = param->y; \ + (_matrix)->pos.z = 0.0f; \ + RwMatrixUpdate((_matrix)); \ + RwMatrixTranslate((_matrix), _Pivot, rwCOMBINEPOSTCONCAT); \ + RwMatrixRotate((_matrix), &zAxis, param->theta/rwPI*180.0f, rwCOMBINEPOSTCONCAT); \ + RwMatrixTranslate((_matrix), _InvPivot, rwCOMBINEPOSTCONCAT); \ +} \ +MACRO_STOP + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpUVAnimMaterialGlobalVars RpUVAnimMaterialGlobals; + +/* Module management */ +void +RpUVAnimSetFreeListCreateParams(RwInt32 blockSize, + RwInt32 numBlocksToPrealloc); + +/* Plugin support */ + +extern RwBool +RpUVAnimPluginAttach(void); + +/* uvanim interpolator info */ +extern RtAnimInterpolatorInfo _rpUVAnimLinearInterpolatorInfo; +extern RtAnimInterpolatorInfo _rpUVAnimParamInterpolatorInfo; + +/* uvanim keyframe functions */ + +extern void +RpUVAnimLinearKeyFrameApply(void *matrix, + void *voidIFrame); + +extern void +RpUVAnimLinearKeyFrameBlend(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal alpha); + +extern void +RpUVAnimLinearKeyFrameInterpolate(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal time, + void *customData); + +extern void +RpUVAnimLinearKeyFrameAdd(void *voidOut, + void *voidIn1, + void *voidIn2); + +extern void +RpUVAnimLinearKeyFrameMulRecip(void *voidFrame, + void *voidStart); + + +extern void +RpUVAnimParamKeyFrameApply(void *matrix, + void *voidIFrame); + +extern void +RpUVAnimParamKeyFrameBlend(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal alpha); + +extern void +RpUVAnimParamKeyFrameInterpolate(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal time, + void *customData); + +extern void +RpUVAnimParamKeyFrameAdd(void *voidOut, + void *voidIn1, + void *voidIn2); + +extern void +RpUVAnimParamKeyFrameMulRecip(void *voidFrame, + void *voidStart); + +extern RtAnimAnimation * +RpUVAnimKeyFrameStreamRead(RwStream *stream, + RtAnimAnimation *animation); + +extern RwBool +RpUVAnimKeyFrameStreamWrite(const RtAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RpUVAnimKeyFrameStreamGetSize(const RtAnimAnimation *animation); + +extern RpUVAnimLinearKeyFrameData * +RpUVAnimLinearKeyFrameDataInitFromMatrix( + RpUVAnimLinearKeyFrameData *data, + const RwMatrix *matrix); + +extern RpUVAnimParamKeyFrameData * +RpUVAnimParamKeyFrameDataInitFromMatrix( + RpUVAnimParamKeyFrameData *data, + const RwMatrix *matrix); + +extern RpUVAnimKeyFrame * +RpUVAnimKeyFrameInit(const RtAnimAnimation *animation, + RpUVAnimKeyFrame *keyFrame, + RpUVAnimKeyFrame *prevFrame, + RwReal time, + const RwMatrix *matrix); + +/* + * Schema Declaration + */ +RTDICTSCHEMADECLARE(_rpUVAnimDictSchema) + +#if defined(DOXYGEN) +/** + * \ingroup rpuvanim + * \ref RpUVAnimGetDictSchema + * returns the dictionary schema used for dictionaries of UV animations + * + * \return The UV animation dictionary schema + * \see RtDictSchemaCreateDict + */ +extern RtDictSchema * +RpUVAnimGetDictSchema(); +#else +#define RpUVAnimGetDictSchema()\ + (&_rpUVAnimDictSchema) +#endif + +/* General API */ +extern RpUVAnim * +RpUVAnimCreate(const RwChar *name, RwUInt32 numNodes, RwUInt32 numFrames, + RwReal duration, RwUInt32 *nodeIndexToUVChannelMap, + RpUVAnimKeyFrameType keyframeType); + +extern RwBool +RpUVAnimDestroy(RpUVAnim *anim); + +extern RpUVAnim * +RpUVAnimAddRef(RpUVAnim *anim); + +extern const RwChar * +RpUVAnimGetName(const RpUVAnim *anim); + +#ifdef RWDEBUG +extern const RpUVAnim * +_rpUVAnimDump(const RpUVAnim *anim); +#endif + +#define RpUVAnimStreamGetSize(anim)\ + RtAnimAnimationStreamGetSize((anim)) + +#define RpUVAnimStreamRead(stream)\ + RtAnimAnimationStreamRead((stream)) + +#define RpUVAnimStreamWrite(anim, stream)\ + RtAnimAnimationStreamWrite((anim), (stream)) + +#define RpUVAnimGetUVNodeToChannelMap(anim)\ + (((_rpUVAnimCustomData *)(anim)->customData)->nodeToUVChannelMap) + +extern RpMaterial * +RpMaterialSetUVAnim(RpMaterial *material, RpUVAnim *anim, RwUInt32 slot); + +extern RpUVAnimInterpolator * +RpMaterialUVAnimGetInterpolator(RpMaterial *material, RwUInt32 slot); + +extern RpMaterial * +RpMaterialUVAnimSetInterpolator(RpMaterial *material, RpUVAnimInterpolator *interp, RwUInt32 slot); + +extern RpMaterial * +RpMaterialUVAnimSetCurrentTime(RpMaterial *material, RwReal time); + +extern RpMaterial * +RpMaterialUVAnimAddAnimTime(RpMaterial *material, RwReal deltaTime); + +extern RpMaterial * +RpMaterialUVAnimSubAnimTime(RpMaterial *material, RwReal deltaTime); + +extern RwBool +RpMaterialUVAnimExists(const RpMaterial *material); + +RpMaterial * +RpMaterialUVAnimApplyUpdate(RpMaterial *material); + +extern const RwV3d rpUVAnimPivot; +extern const RwV3d rpUVAnimInvPivot; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPUVANIM_H */ + diff --git a/includes/rwsdk/rpuvanim.rpe b/includes/rwsdk/rpuvanim.rpe new file mode 100644 index 0000000..993f55c --- /dev/null +++ b/includes/rwsdk/rpuvanim.rpe @@ -0,0 +1,514 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionUVAnim +{ + + + + e_rwdb_CriterionUVAnimLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionUVAnim e_rwdb_CriterionUVAnim; + + diff --git a/includes/rwsdk/rpworld.h b/includes/rwsdk/rpworld.h new file mode 100644 index 0000000..646d206 --- /dev/null +++ b/includes/rwsdk/rpworld.h @@ -0,0 +1,4354 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Thu Feb 12 13:01:34 2004 + * + ************************************************************************/ + +#ifndef RPWORLD_H +#define RPWORLD_H + +/*--- Check For Previous Required Includes ---*/ +#ifndef RWCORE_H +#error "Include RWCORE.H before including this file" +#endif /* RWCORE_H */ + +/*--- System Header Files ---*/ +#include +#include + +/*--- Error enumerations ---*/ +#include "rpworld.rpe" + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/native.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/wrldpipe.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/d3d9vertexshaderutils.h ---*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Call this function before calling to any of the following ones */ +extern void +_rwD3D9VSSetActiveWorldMatrix(const RwMatrix *worldMatrix); + +/* + * Copy the transposed combined world-view-projection matrix to the + * requested destination. + */ +extern void +_rwD3D9VSGetComposedTransformMatrix(void *transformMatrix); + +/* + * Copy the transposed combined world-view matrix to the + * requested destination. + */ +extern void +_rwD3D9VSGetWorldViewTransposedMatrix(void *worldViewMatrix); + +extern void +_rwD3D9VSGetWorldViewMatrix(void *worldViewMatrix); + +extern void +_rwD3D9VSGetInverseWorldMatrix(void *inverseWorldMatrix); + +extern void +_rwD3D9VSGetWorldMultiplyMatrix(RwMatrix *worldMultiplyMatrix, + const RwMatrix *matrix); + +extern void +_rwD3D9VSGetWorldMultiplyTransposeMatrix(void *worldMultiplyMatrix, + const RwMatrix *matrix); + +extern void +_rwD3D9VSGetWorldViewMultiplyTransposeMatrix(void *worldViewMultiplyMatrix, + const RwMatrix *matrix); + +extern void +_rwD3D9VSGetWorldNormalizedMultiplyTransposeMatrix(void *worldMultiplyMatrix, + const RwMatrix *matrix); + +extern void +_rwD3D9VSGetWorldNormalizedViewMultiplyTransposeMatrix(void *worldViewMultiplyMatrix, + const RwMatrix *matrix); + +extern void +_rwD3D9VSGetWorldNormalizedTransposeMatrix(void *worldMatrix); + +extern void +_rwD3D9VSGetProjectionTransposedMatrix(void *projectionMatrix); + +/* Converting light parameters to local space */ +extern void +_rwD3D9VSGetNormalInLocalSpace(const RwV3d *normalWorldSpace, + RwV3d *normalLocalSpace); + +extern void +_rwD3D9VSGetPointInLocalSpace(const RwV3d *pointWorldSpace, + RwV3d *pointLocalSpace); + +extern void +_rwD3D9VSGetRadiusInLocalSpace(RwReal radiusWorldSpace, + RwReal *radiusLocalSpace); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/d3d9vertexshader.h ---*/ + +/***************************************************************************** + Global Defines & Enums + */ + +#define RWD3D9VSCONST_TRANSFORM_OFFSET 0 +#define RWD3D9VSCONST_AMBIENT_OFFSET 4 +#define RWD3D9VSCONST_LIGHTS_OFFSET 5 + +typedef enum rwD3D9VertexShaderEffectType +{ + rwD3D9VERTEXSHADEREFFECT_NONE = 0, + rwD3D9VERTEXSHADEREFFECT_BUMPMAP = 1, + rwD3D9VERTEXSHADEREFFECT_ENVMAP, + rwD3D9VERTEXSHADEREFFECT_BUMPENVMAP, + rwD3D9VERTEXSHADEREFFECT_DUAL, + rwD3D9VERTEXSHADEREFFECT_DUALREPLICATE, + rwD3D9VERTEXSHADEREFFECT_UVANIM, + rwD3D9VERTEXSHADEREFFECT_DUALUVANIM, + rwD3D9VERTEXSHADEREFFECT_NORMALMAP, + rwD3D9VERTEXSHADEREFFECT_NORMALENVMAP, + rwD3D9VERTEXSHADEREFFECT_CUBEMAP, + rwD3D9VERTEXSHADEREFFECT_BUMPCUBEMAP, + + rwD3D9VERTEXSHADEREFFECT_MAX = (1 << 6), + +} rwD3D9VertexShaderEffectType; + + +typedef enum rwD3D9VertexShaderFogMode +{ + rwD3D9VERTEXSHADERFOG_NONE = 0, + rwD3D9VERTEXSHADERFOG_LINEAR = 1, + rwD3D9VERTEXSHADERFOG_EXP, + rwD3D9VERTEXSHADERFOG_EXP2, + + rwD3D9VERTEXSHADERFOG_MAX +} rwD3D9VertexShaderFogMode; + +/****************************************************************************** + Global Types + */ + +#if !defined(DOXYGEN) + +/* This struct is used to specify the required functionality of the vertex shader */ +typedef struct _rpD3D9VertexShaderDescriptor +{ + RwUInt8 numDirectionalLights : 4; + RwUInt8 numPointLights : 4; + RwUInt8 numSpotLights : 4; + RwUInt8 numTexCoords : 4; + + RwUInt8 morphing : 1; + RwUInt8 numWeights : 3; + RwUInt8 prelit : 1; + RwUInt8 normals : 1; + RwUInt8 normalizeNormals : 1; + RwUInt8 modulateMaterial : 1; + RwUInt8 fogMode : 2; + RwUInt8 effect : 6; + +} _rpD3D9VertexShaderDescriptor; + +/* + * Offsets for the required vertex shader constants. + * The combined transposed matrix world-view-projection is always at offset 0. + * The ambient is always at offset 4. + * The first light is always at offset 5. + * 0xFF indicates that the specified constant is not used. + */ +typedef struct _rpD3D9VertexShaderDispatchDescriptor +{ + RwUInt8 offsetMaterialColor; + RwUInt8 offsetFogRange; + RwUInt8 offsetEffect; + RwUInt8 offsetMorphingCoef; + RwUInt8 offsetBoneMatrices; + RwUInt8 pad[3]; + +} _rpD3D9VertexShaderDispatchDescriptor; + +#endif /* !defined(DOXYGEN) */ + +/* + * Vertex shader pipeline callbacks + */ + +typedef struct RxD3D9ResEntryHeader RxD3D9ResEntryHeader; +typedef struct RxD3D9InstanceData RxD3D9InstanceData; +typedef struct RpMaterial RpMaterial; + +/* Initialize shared components of "desc" and to prepare internal render data */ + +typedef RwBool (*_rxD3D9VertexShaderInstanceCallBack)(void *object, + RxD3D9ResEntryHeader *resEntryHeader, + RwBool reinstance); + +typedef void (*_rxD3D9VertexShaderBeginCallBack)(void *object, + RwUInt32 type, + _rpD3D9VertexShaderDescriptor *desc); + +/* _rwD3D9VSSetActiveWorldMatrix MUST be called before using this two callbacks */ + +typedef RwV4d * (*_rxD3D9VertexShaderLightingCallBack)(void *object, + RwUInt32 type, + RwV4d *shaderConstantPtr, + _rpD3D9VertexShaderDescriptor *desc); + +typedef void *(*_rxD3D9VertexShaderGetMaterialShaderCallBack)(const RpMaterial *material, + _rpD3D9VertexShaderDescriptor *desc, + _rpD3D9VertexShaderDispatchDescriptor *dispatch); + + +typedef void (*_rxD3D9VertexShaderMeshRenderCallBack)(RxD3D9ResEntryHeader *resEntryHeader, + RxD3D9InstanceData *instancedMesh, + const _rpD3D9VertexShaderDescriptor *desc, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +typedef void (*_rxD3D9VertexShaderEndCallBack)(void *object, + RwUInt32 type, + _rpD3D9VertexShaderDescriptor *desc); + +/***************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +/* + * This function frees the vertex shaders cache. + */ +extern void +_rpD3D9VertexShaderCachePurge(void); + +/* + * This function returns the vertex shader that supports the "desc" operations + * and fills the info on the "dispatch" variable. + */ +extern void * +_rpD3D9GetVertexShader(const _rpD3D9VertexShaderDescriptor *desc, + _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern RwUInt32 +_rpD3D9GetNumConstantsUsed(const _rpD3D9VertexShaderDescriptor *desc); + +/* Vertex shader pipeline functions */ +extern void +_rxD3D9VertexShaderDefaultBeginCallBack(void *object, + RwUInt32 type, + _rpD3D9VertexShaderDescriptor *desc); + +extern RwV4d * +_rxD3D9VertexShaderDefaultLightingCallBack(void *object, + RwUInt32 type, + RwV4d *shaderConstantPtr, + _rpD3D9VertexShaderDescriptor *desc); + +extern void * +_rxD3D9VertexShaderDefaultGetMaterialShaderCallBack(const RpMaterial *material, + _rpD3D9VertexShaderDescriptor *desc, + _rpD3D9VertexShaderDispatchDescriptor *dispatch); +extern void +_rxD3D9VertexShaderDefaultMeshRenderCallBack(RxD3D9ResEntryHeader *resEntryHeader, + RxD3D9InstanceData *instancedMesh, + const _rpD3D9VertexShaderDescriptor *desc, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern void +_rxD3D9VertexShaderDefaultEndCallBack(void *object, + RwUInt32 type, + _rpD3D9VertexShaderDescriptor *desc); + +/* Useful vertex shader functions */ +extern void +_rpD3D9VertexShaderUpdateLightsColors(RwV4d *shaderConstantPtr, + const _rpD3D9VertexShaderDescriptor *desc, + RwReal ambientCoef, + RwReal diffuseCoef); + +extern void +_rpD3D9VertexShaderUpdateMaterialColor(const RwRGBA *color, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern void +_rpD3D9VertexShaderUpdateFogData(const _rpD3D9VertexShaderDescriptor *desc, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); +extern void +_rpD3D9VertexShaderUpdateMorphingCoef(RwReal morphingCoef, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern void +_rpD3DVertexShaderSetUVAnimMatrix(RwMatrix *matrix, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern void +_rpD3D9VertexShaderSetEnvMatrix(RwFrame *frame, + const _rpD3D9VertexShaderDescriptor *desc, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +extern void +_rpD3D9VertexShaderSetBumpMatrix(RwFrame *frame, + RwReal factor, + const _rpD3D9VertexShaderDispatchDescriptor *dispatch); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/nodeD3D9WorldSectorAllInOne.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * +RxNodeDefinitionGetD3D9WorldSectorAllInOne(void); + +#ifdef RWD3D9_USE_VERTEXSHADER_PIPELINE +extern RxNodeDefinition * +RxNodeDefinitionGetD3D9VertexShaderWorldSectorAllInOne(void); +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/nodeD3D9AtomicAllInOne.h ---*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * +RxNodeDefinitionGetD3D9AtomicAllInOne(void); + +#ifdef RWD3D9_USE_VERTEXSHADER_PIPELINE +extern RxNodeDefinition * +RxNodeDefinitionGetD3D9VertexShaderAtomicAllInOne(void); +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/bamateri.h ---*/ + +/* + * Handling surface materials + * Materials describe how things are to appear when rendered + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + +/**************************************************************************** + Global Types + */ + + +typedef struct RpMaterialChunkInfo RpMaterialChunkInfo; +typedef struct RpMaterialChunkInfo _rpMaterial; + +#if (!defined(DOXYGEN)) +struct RpMaterialChunkInfo +{ + RwInt32 flags; /* Material flags - unused currently - + * for future expansion */ + RwRGBA color; /* Color of material. */ + RwInt32 unused; /* Not used */ + RwBool textured; /* Are we textured? */ + RwSurfaceProperties surfaceProps;/* Surface properties */ +}; +#endif /* (!defined(DOXYGEN)) */ + +#if (!defined(RwMaterialAssign)) +#define RwMaterialAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwMaterialAssign)) */ + +/** + * \ingroup rpmaterial + * \struct RpMaterial + * Material object. This should be + * considered an opaque type. Use the RpMaterial API functions to access. + */ +typedef struct RpMaterial RpMaterial; + +#if (!defined(DOXYGEN)) +struct RpMaterial +{ + RwTexture *texture; /**< texture */ + RwRGBA color; /**< color */ + RxPipeline *pipeline; /**< pipeline */ + RwSurfaceProperties surfaceProps; /**< surfaceProps */ + RwInt16 refCount; /* C.f. rwsdk/world/bageomet.h:RpGeometry */ + RwInt16 pad; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpmaterial + * \ref RpMaterialCallBack + * represents the function called from \ref RpGeometryForAllMaterials and + * \ref RpWorldForAllMaterials for all materials referenced by polygons in a + * given geometry. This function should return a pointer to the current + * material to indicate success. The callback may return NULL to terminate + * further callbacks on the materials. + * + * \param material Pointer to the current material + * \param data Pointer to developer-defined data structure. + * + * \return Pointer to the current material, or NULL to terminate further callbacks. + */ +typedef RpMaterial *(*RpMaterialCallBack)(RpMaterial *material, void *data); + +/**************************************************************************** + refCount++), (_material)) + +#define RpMaterialAddRefVoidMacro(_material) \ +MACRO_START \ +{ \ + (_material)->refCount++; \ +} \ +MACRO_STOP + + +#define RpMaterialSetColorMacro(_material, _color) \ + (RwRGBAAssign(&((_material)->color), (_color)), (_material)) + +#define RpMaterialGetColorMacro(_material) \ + (&((_material)->color)) + +#define RpMaterialSetSurfacePropertiesMacro(_material, _surfProps) \ + (RwSurfacePropertiesAssign(&((_material)->surfaceProps), \ + (_surfProps)), (_material)) + +#define RpMaterialSetSurfacePropertiesVoidMacro(_material, _surfProps) \ +MACRO_START \ +{ \ + RwSurfacePropertiesAssign(&((_material)->surfaceProps), \ + (_surfProps)); \ +} \ +MACRO_STOP + +#define RpMaterialGetSurfacePropertiesMacro(_material) \ + (&((_material)->surfaceProps)) + +#define RpMaterialGetTextureMacro(_material) \ + ((_material)->texture) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMaterialAddRef(_material) \ + RpMaterialAddRefMacro(_material) + +#define RpMaterialSetColor(_material, _color) \ + RpMaterialSetColorMacro(_material, _color) + +#define RpMaterialGetColor(_material) \ + RpMaterialGetColorMacro(_material) + +#define RpMaterialSetSurfaceProperties(_material, _surfProps) \ + RpMaterialSetSurfacePropertiesMacro(_material, _surfProps) + +#define RpMaterialGetSurfaceProperties(_material) \ + RpMaterialGetSurfacePropertiesMacro(_material) + +#define RpMaterialGetTexture(_material) \ + RpMaterialGetTextureMacro(_material) + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern void RpMaterialSetFreeListCreateParams( RwInt32 blockSize, + RwInt32 numBlocksToPrealloc ); + +/* Creating, destroying and referencing materials */ +extern RpMaterial *RpMaterialCreate(void); +extern RwBool RpMaterialDestroy(RpMaterial *material); +extern RpMaterial *RpMaterialClone(RpMaterial *material); + +/* Textures */ +extern RpMaterial *RpMaterialSetTexture(RpMaterial *material, RwTexture *texture); + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RpMaterial *RpMaterialAddRef(RpMaterial *material); + +/* Textures */ +extern RwTexture *RpMaterialGetTexture(const RpMaterial *material); + +/* Setting and getting colors */ +extern RpMaterial *RpMaterialSetColor(RpMaterial *material, const RwRGBA *color); +extern const RwRGBA *RpMaterialGetColor(const RpMaterial *material); + +/* Setting and getting surface properties */ +extern RpMaterial * +RpMaterialSetSurfaceProperties(RpMaterial *material, + const RwSurfaceProperties *surfaceProperties); + +extern const RwSurfaceProperties * +RpMaterialGetSurfaceProperties(const RpMaterial *material); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/* Attaching toolkits */ +extern RwInt32 RpMaterialRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpMaterialRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpMaterialSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpMaterialSetStreamRightsCallBack(RwUInt32 pluginID, + RwPluginDataChunkRightsCallBack rightsCB); +extern RwInt32 RpMaterialGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpMaterialValidatePlugins(const RpMaterial *material); + +/* Binary format */ +extern RwUInt32 RpMaterialStreamGetSize(const RpMaterial *material); +extern RpMaterial *RpMaterialStreamRead(RwStream *stream); +extern const RpMaterial *RpMaterialStreamWrite(const RpMaterial *material, RwStream *stream); +extern RpMaterialChunkInfo * +_rpMaterialChunkInfoRead(RwStream *stream, + RpMaterialChunkInfo *materialChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpMaterialChunkInfoRead(stream, materialChunkInfo, bytesRead) \ + _rpMaterialChunkInfoRead(stream, materialChunkInfo, bytesRead) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/bamatlst.h ---*/ +/**************************************************************************** + Global Types + */ + +typedef struct RpMaterialList RpMaterialList; + +#if (!defined(DOXYGEN)) +struct RpMaterialList +{ + RpMaterial **materials; + RwInt32 numMaterials; + RwInt32 space; +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define rpMaterialListGetNumMaterials(mlist) ((mlist)->numMaterials) + +/* Setting up and destroying material lists */ +extern RpMaterialList *_rpMaterialListInitialize(RpMaterialList *matList); +extern RpMaterialList *_rpMaterialListDeinitialize(RpMaterialList *matList); + +/* Accessing material lists */ +extern RpMaterial ** _rpMaterialListAlloc(RwUInt32 count); +extern RpMaterial *_rpMaterialListGetMaterial(const RpMaterialList *matList, + RwInt32 matIndex); +extern RpMaterialList * _rpMaterialListSetSize(RpMaterialList * matList, + RwInt32 size); +extern RpMaterialList *_rpMaterialListCopy(RpMaterialList *matListOut, + const RpMaterialList *matListIn); +extern RwInt32 _rpMaterialListAppendMaterial(RpMaterialList *matList, + RpMaterial *material); +extern RwInt32 _rpMaterialListFindMaterialIndex(const RpMaterialList *matList, + const RpMaterial *material); + +/* Binary format */ +extern RwUInt32 _rpMaterialListStreamGetSize(const RpMaterialList *matList); +extern RpMaterialList *_rpMaterialListStreamRead(RwStream *stream, + RpMaterialList *matList); +extern const RpMaterialList *_rpMaterialListStreamWrite(const RpMaterialList *matList, + RwStream *stream); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define rpMaterialListInitialize(_matList) \ + _rpMaterialListInitialize(_matList) + +#define rpMaterialListDeinitialize(_matList) \ + _rpMaterialListDeinitialize(_matList) + +#define rpMaterialListGetMaterial(_matList, _matIndex) \ + _rpMaterialListGetMaterial(_matList, _matIndex) + +#define rpMaterialListCopy(_matListOut, _matListIn) \ + _rpMaterialListCopy(_matListOut, _matListIn) + +#define rpMaterialListAppendMaterial(_matList, _material) \ + _rpMaterialListAppendMaterial(_matList, _material) + +#define rpMaterialListStreamRead(_stream, _matList) \ + _rpMaterialListStreamRead(_stream, _matList) + +#define rpMaterialListStreamWrite(_matList, _stream) \ + _rpMaterialListStreamWrite(_matList, _stream) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/bamesh.h ---*/ + +/* + * + * Purpose: Provide construction and enumeration facilities for meshes. + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + +#define RPMESHGLOBAL(var) \ + (RWPLUGINOFFSET(rpMeshGlobals, \ + RwEngineInstance, \ + meshModule.globalsOffset)->var) + +#define rwPRIMTYPEOR \ + (rwPRIMTYPELINELIST | \ + rwPRIMTYPEPOLYLINE | \ + rwPRIMTYPETRILIST | \ + rwPRIMTYPETRISTRIP | \ + rwPRIMTYPETRIFAN | \ + rwPRIMTYPEPOINTLIST) + +#define rpMESHHEADERPRIMTYPEOR \ + (0 /* rpMESHHEADERTRILIST*/ | \ + rpMESHHEADERTRISTRIP | \ + rpMESHHEADERTRIFAN | \ + rpMESHHEADERLINELIST | \ + rpMESHHEADERPOLYLINE | \ + rpMESHHEADERPOINTLIST) + +/**************************************************************************** + Global variables + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwModuleInfo meshModule; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/**************************************************************************** + Global types + */ + +/* + * typedef for header structure listing all meshes + * constituting a single RpGeometry or RpWorldSector + */ +typedef struct RpMeshHeader RpMeshHeader; + +/** + * \ingroup rpmesh + * \ref RpMeshHeaderFlags + * represents the different types of mesh. + * \see RpMeshHeader + */ +enum RpMeshHeaderFlags +{ + /* NOTE: trilists are denoted by absence of any other + * primtype flags, so be careful that you test: + * (triListFlag == (flags&triListFlag)) + * or: + * (0 == (flags&rpMESHHEADERPRIMMASK)) + * and not: + * (flags&triListFlag) + */ + rpMESHHEADERTRISTRIP = 0x0001, /**< Render as tristrips */ + rpMESHHEADERTRIFAN = 0x0002, /**< On PlayStation 2 these will be converted to trilists */ + rpMESHHEADERLINELIST = 0x0004, /**< Render as linelists */ + rpMESHHEADERPOLYLINE = 0x0008, /**< On PlayStation 2 these will be converted to linelists */ + rpMESHHEADERPOINTLIST = 0x0010, /**< Pointlists are supported only if rendered by + * custom pipelines; there is no default RenderWare + * way to render pointlists. */ + + rpMESHHEADERPRIMMASK = 0x00FF, /**< All bits reserved for specifying primitive type */ + rpMESHHEADERUNINDEXED = 0x0100, /**< Topology is defined implicitly by vertex + * order, ergo the mesh contains no indices */ + rpMESHHEADERFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/* + * Typedef for RpMeshHeaderFlags enumeration + * representing the different types of mesh + */ +typedef enum RpMeshHeaderFlags RpMeshHeaderFlags; + +typedef struct rpMeshGlobals rpMeshGlobals; + +#if (!defined(DOXYGEN)) +struct rpMeshGlobals +{ + RwInt16 nextSerialNum; + RwFreeList *triStripListEntryFreeList; + RwUInt8 meshFlagsToPrimType[rpMESHHEADERPRIMTYPEOR]; + RwUInt8 primTypeToMeshFlags[rwPRIMTYPEOR]; +}; +#endif /* (!defined(DOXYGEN)) */ + +typedef struct RpBuildMeshTriangle RpBuildMeshTriangle; + +/** + * \ingroup rpmesh + * \struct RpBuildMeshTriangle + * This type represents an array of indices into + * the object vertex array. Used during the construction + * of tristrips. + * + * See API functions + * \see RpBuildMeshGeneratePreprocessTriStrip + * \see RpBuildMeshGenerateExhaustiveTriStrip + * \see RpBuildMeshGenerateTrivialTriStrip + * \see RpBuildMeshGenerateDefaultTriStrip + * and + * \see RpMeshSetTriStripMethod + * \see RpMeshGetTriStripMethod + */ +struct RpBuildMeshTriangle +{ + RwUInt16 vertIndex[3]; /**< indices into object vertex + * array. */ + RpMaterial *material; /**< pointer to material used to + * render the mesh. */ + RwUInt16 matIndex; /**< unique index for material used */ + RwUInt16 textureIndex; /**< unique index for texture used */ + RwUInt16 rasterIndex; /**< unique index for raster used */ + RwUInt16 pipelineIndex;/**< unique index for pipeline used */ +}; + +typedef struct RpBuildMesh RpBuildMesh; + +/** + * \ingroup rpmesh + * \struct RpBuildMesh + * This type represents a mesh ready for tri stripping. + * + * See API functions + * \see RpBuildMeshGeneratePreprocessTriStrip + * \see RpBuildMeshGenerateExhaustiveTriStrip + * \see RpBuildMeshGenerateTrivialTriStrip + * \see RpBuildMeshGenerateDefaultTriStrip + * and + * \see RpMeshSetTriStripMethod + * \see RpMeshGetTriStripMethod + */ +struct RpBuildMesh +{ + RwUInt32 triangleBufferSize; /**< number of triangles + * space has been allocated + * for. */ + RwUInt32 numTriangles; /**< number of triangles to be + * tristripped. */ + RpBuildMeshTriangle *meshTriangles; /**< pointer to build mesh + * triangles. */ +}; + +typedef struct RpMesh RpMesh; + +/** + * \ingroup rpmesh + * \struct RpMesh + * This type represents a single polygon mesh. + * A mesh is defined as a collection of triangles derived from an RpGeometry + * or RpWorldSector which have a common material. + * + * See API functions \see RpGeometryForAllMeshes and + * \see RpWorldSectorForAllMeshes and + * the corresponding function callback types: + */ +struct RpMesh +{ + RxVertexIndex *indices; /**< vertex indices defining the mesh */ + RwUInt32 numIndices; /**< number of vertices in mesh */ + RpMaterial *material; /**< pointer to material used to + * render the mesh. */ +}; + +/** + * \ingroup rpmesh + * \struct RpMeshHeader + * Header for all meshes that constitute a single RpGeometry or RpWorldSector + */ +struct RpMeshHeader +{ + RwUInt32 flags; /**< \see RpMeshHeaderFlags */ + RwUInt16 numMeshes; /**< Number of meshes in object */ + RwUInt16 serialNum; /**< Determine if mesh has changed + * since last instance */ + RwUInt32 totalIndicesInMesh; /**< Total triangle index + * count in all meshes + */ + RwUInt32 firstMeshOffset; /**< Offset in bytes from end this + * structure RpMeshHeader + * to the first mesh + */ +}; + +/** + * \ingroup rpmesh + * \ref RpMeshCallBack is the callback + * function supplied to \ref RpGeometryForAllMeshes and + * \ref RpWorldSectorForAllMeshes for all meshes in a given geometry. + * + * This function should return a pointer to the current mesh to indicate + * success. The callback may return NULL to terminate further callbacks + * on the meshes. + * + * \param mesh Pointer to the current mesh, supplied by + * iterator. + * \param meshHeader Pointer to the meshes header + * \param data Pointer to developer-defined data structure. + * + * \return Returns a pointer to the current mesh if successful or NULL + * if an error occurred. + */ +typedef RpMesh *(*RpMeshCallBack) (RpMesh * mesh, + RpMeshHeader * meshHeader, + void *pData); + +/**************************************************************************** + Function prototypes + */ + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMeshHeaderGetPrimType(_mshHdr) \ + ( (RwPrimitiveType)RPMESHGLOBAL(meshFlagsToPrimType)[(_mshHdr)->flags & \ + rpMESHHEADERPRIMMASK] ) + +#define RpMeshHeaderSetPrimType(_mshHdr, _prmTyp) \ + ( (_mshHdr)->flags = \ + ((_mshHdr)->flags & ~rpMESHHEADERPRIMMASK) | \ + (rpMESHHEADERPRIMMASK & \ + RPMESHGLOBAL(primTypeToMeshFlags)[(_prmTyp) & \ + rpMESHHEADERPRIMMASK]), \ + (_mshHdr) ) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Opening and closing module */ +extern void *_rpMeshOpen(void *instance, RwInt32 offset, + RwInt32 size); +extern void *_rpMeshClose(void *instance, RwInt32 offset, + RwInt32 size); + +extern RwInt16 _rpMeshGetNextSerialNumber(void); + +/* Create a build mesh with nothing in */ +extern RpBuildMesh *_rpBuildMeshCreate(RwUInt32 bufferSize); + +/* Destroy a build mesh */ +extern RwBool _rpBuildMeshDestroy(RpBuildMesh * mesh); + +/* Destroy a build mesh */ +extern RwBool _rpMeshDestroy(RpMeshHeader * mesh); + +/* Add a triangle to a mesh */ +extern RpBuildMesh *_rpBuildMeshAddTriangle(RpBuildMesh * mesh, + RpMaterial * material, + RwInt32 vert1, + RwInt32 vert2, + RwInt32 vert3, + RwUInt16 matIndex, + RwUInt16 textureIndex, + RwUInt16 rasterIndex, + RwUInt16 pipelineIndex); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +/* Get primtype from a mesh header */ +extern RwPrimitiveType RpMeshHeaderGetPrimType(RpMeshHeader * + meshHeader); + +/* Set primtype for a mesh header */ +extern RpMeshHeader *RpMeshHeaderSetPrimType(RpMeshHeader * + meshHeader, + RwPrimitiveType + primType); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* Enumerate meshes within a mesh header */ +extern RpMeshHeader *_rpMeshHeaderForAllMeshes(RpMeshHeader * + meshHeader, + RpMeshCallBack + fpCallBack, + void *pData); + +/* Mesh serialisation functions */ +extern RwStream *_rpMeshWrite(const RpMeshHeader * meshHeader, + const void *object, + RwStream * stream, + const RpMaterialList * matList); +extern RpMeshHeader *_rpMeshRead(RwStream * stream, + const void *object, + const RpMaterialList * matList); +extern RwInt32 _rpMeshSize(const RpMeshHeader *meshHeader, + const void *object); +/* Mesh header create/destroy functions */ +extern void _rpMeshHeaderDestroy(RpMeshHeader * meshHeader); +extern RpMeshHeader * _rpMeshHeaderCreate(RwUInt32 size); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/bameshop.h ---*/ + +/**************************************************************************** + Defines + */ + +#define RPTRISTRIPPOLYGONMAXEDGES 3 + +/** + * \ingroup rpmesh + * \ref RpTriStripMeshCallBack is the callback to generate triangle strips + * when the triangle stripped geometries or world sectors are unlocked. + * + * \param buildMesh pointer to the mesh which the triangle strip will be + * generated from. + * \param data pointer to user-supplied data to pass to the callback + * function. + * + * \return a pointer to the constructed mesh header. + * + */ +typedef RpMeshHeader * +(*RpTriStripMeshCallBack) (RpBuildMesh *buildMesh, void *data); + + + +/**************************************************************************** + Global types + */ + +typedef struct RpTriStripEdge RpTriStripEdge; + +typedef struct RpTriStripPolygon RpTriStripPolygon; +/** + * \ingroup rpmesh + * \struct RpTriStripPolygon + * This type represents a polygon. + * + * \see RpTriStripPolygonFollowStrip + * \see RpBuildMeshGenerateTriStrip + * \see RpTriStripMeshTunnel + */ +struct RpTriStripPolygon +{ + RwLLLink inEndLink; /**< link for list of polygons joined by fewer than + 2 strip edges */ + RwLLLink inUsedLink; /**< link for list of used polygons */ + RwLLLink inFreeLink; /**< link for list of free polygons */ + RwUInt32 numEdges; /**< number of edges */ + RpTriStripEdge *edges[RPTRISTRIPPOLYGONMAXEDGES]; /**< polygon edges */ + RxVertexIndex vertIndex[RPTRISTRIPPOLYGONMAXEDGES]; /**< polygon vertex + indices */ + RwUInt32 testFrame; /**< used to prevent a tri-strip being counted by + the cost function more than once */ +}; + +/** + * \ingroup rpmesh + * \struct RpTriStripEdge + * This type represents a polygon edge which may be part of a tri-strip. + * + * \see RpTriStripPolygonFollowStrip + * \see RpBuildMeshGenerateTriStrip + * \see RpTriStripMeshTunnel + */ +struct RpTriStripEdge +{ + RwLLLink inUsedLink; /**< link for list of used edges */ + RwLLLink inFreeLink; /**< link for list of free edges */ + RpTriStripPolygon *poly1; /**< first polygon including this edge */ + RpTriStripPolygon *poly2; /**< second polygon including this edge or NULL + if this edge is only included in one */ + RxVertexIndex vert1; /**< index of first vertex of edge */ + RxVertexIndex vert2; /**< index of second vertex of edge */ + RwBool strip; /**< TRUE if the edge is part of a tri-strip */ +}; + +typedef struct RpTriStripMesh RpTriStripMesh; +/** + * \ingroup rpmesh + * \struct RpTriStripMesh + * This type represents a mesh and the tri-strips it contains. + * + * \see RpBuildMeshGenerateTriStrip + * \see RpTriStripMeshTunnel + */ +struct RpTriStripMesh +{ + RwUInt32 numPolygons; /**< the number of polygons in the mesh */ + RwLinkList polygonEndList; /**< linked list of polygons joined by fewer + than 2 strip edges. */ + RwLinkList polygonUsedList; /**< linked list of used polygons */ + RwLinkList polygonFreeList; /**< linked list of free polygons */ + RwLinkList edgeUsedList; /**< linked list of used edges */ + RwLinkList edgeFreeList; /**< linked list of free edges */ +}; + +/** + * \ingroup rpmesh + * \ref RpTriStripMeshStripCallBack represents the callback function to + * tri-strip a mesh. + * + * \param mesh Pointer to the mesh to tri-strip. + * \param data Pointer to user-supplied data. + * + * \return Returns a pointer to the current mesh if successful or NULL if an + * error occurred. + */ +typedef RpTriStripMesh * +(*RpTriStripMeshStripCallBack) (RpTriStripMesh *mesh, void *data); + +typedef struct RpTriStripData RpTriStripData; +/** + * \ingroup rpmesh + * \struct RpTriStripData + * This type represents the data required by the + * \ref RpBuildMeshGenerateTriStrip function to tri-strip a mesh. This data must + * be the user-supplied data passed into RpMeshSetTriStripMethod when using + * \ref RpBuildMeshGenerateTriStrip. + * + * \see RpMeshGetTriStripMethod + * \see RpMeshSetTriStripMethod + * \see RpBuildMeshGenerateTriStrip + * \see RpTriStripMeshTunnel + */ +struct RpTriStripData +{ + RwBool ignoreWinding; /**< TRUE to ignore winding order */ + RpTriStripMeshStripCallBack stripCB; /**< callback to tri-strip mesh */ + void *data; /**< data to supply to callback */ +}; + +/** + * \ingroup rpmesh + * \ref RpTriStripCostCallBack represents the callback function used by the + * tunnelling tri-stripper to determine the cost of a tri-strip. + * + * \param startPolygon Pointer to polygon at the start of the tri-strip. + * \param testFrame Value that must be written to the testFrame of all + * polygons in the tri-strip + * \param data Pointer to user-supplied data. + * + * \return Returns the cost of the tri-strip. + */ +typedef RwUInt32 +(*RpTriStripCostCallBack) (RpTriStripPolygon *startPolygon, RwUInt32 testFrame, void *data); + +typedef struct RpTriStripTunnelData RpTriStripTunnelData; +/** + * \ingroup rpmesh + * \struct RpTriStripTunnelData + * This type represents the data required by the + * \ref RpTriStripMeshTunnel function to tri-strip a mesh. This data must + * be the user-supplied data in the RpTriStripData structure passed into + * \ref RpMeshSetTriStripMethod as the user-supplied data when using + * \ref RpTriStripMeshTunnel. + * + * \see RpMeshGetTriStripMethod + * \see RpMeshSetTriStripMethod + * \see RpBuildMeshGenerateTriStrip + * \see RpTriStripMeshTunnel + * \see RpTriStripDefaultCost + */ +struct RpTriStripTunnelData +{ + RwReal quality; /**< Values between 0.1 and 0.5 tend to be fairly quick but + don't always give the best results. Values greater than 0.5 tend to + give good results useful for final artwork but can take much longer. + Large values e.g. 5 allow the length limit to be the limiting factor + instead. */ + RwUInt32 lengthLimit; /**< The maximum tunnel length to use. Values between + 10 and 50 tend to be fairly quick but don't always give the best + results. Values greater than 50 tend to give good results for final + artwork but can take much longer. Large values e.g. 10000 allow the + quality to be the limiting factor. */ + RpTriStripCostCallBack costCB; /**< callback to determine tri-strip cost */ + void *data; /**< data to supply to callbacks */ +}; + + + +/**************************************************************************** + Global Variables + */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Tri-strip manipulating functions */ +extern RpTriStripPolygon * +RpTriStripPolygonFollowStrip(RpTriStripPolygon *curr, RpTriStripPolygon *prev); + +/* Callback strip costing functions */ +extern RwUInt32 +RpTriStripDefaultCost(RpTriStripPolygon *startPolygon, RwUInt32 testFrame, + void *data); + +/* Callback mesh stripping functions */ +extern RpTriStripMesh * +RpTriStripMeshTunnel(RpTriStripMesh *mesh, void *data); + +extern RpTriStripMesh * +RpTriStripMeshQuick(RpTriStripMesh *mesh, void *data); + +/* New callback mesh generating function */ +extern RpMeshHeader * +RpBuildMeshGenerateTriStrip(RpBuildMesh *buildMesh, void *data); + +/* Old callback mesh generating functions. Probably obsolete */ +extern RpMeshHeader * +RpBuildMeshGenerateTrivialTriStrip(RpBuildMesh *buildMesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateDefaultTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGeneratePreprocessTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateExhaustiveTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateDefaultIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +extern RpMeshHeader * +RpBuildMeshGeneratePreprocessIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateExhaustiveIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +/* Functions to set and get the global mesh tri-strip algorithm */ +extern RwBool +RpMeshSetTriStripMethod(RpTriStripMeshCallBack callback, void *data); + +extern RwBool +RpMeshGetTriStripMethod(RpTriStripMeshCallBack *callback, void **data); + + +extern RpMeshHeader * +_rpTriListMeshGenerate(RpBuildMesh *buildMesh, void *data); + +/* + * Optimise the mesh ordering + * (sort on material and place transparent materials last) + */ +extern RpMeshHeader * +_rpMeshOptimise(RpBuildMesh *buildmesh, RwUInt32 flags); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#define _rpTriStripMeshTrivialGenerate(_buildMesh, _data) \ + RpBuildMeshGenerateTrivialTriStrip(_buildMesh, _data) + +#define _rpTriStripMeshDefaultGenerate(_buildmesh, _data) \ + RpBuildMeshGenerateDefaultTriStrip(_buildmesh, _data) + +#define _rpTriStripMeshPreprocessGenerate(_buildmesh, _data) \ + RpBuildMeshGeneratePreprocessTriStrip(_buildmesh, _data) + +#define _rpTriStripMeshExhaustiveGenerate(_buildmesh, _data) \ + RpBuildMeshGenerateExhaustiveTriStrip(_buildmesh, _data) + +#define _rpMeshSetTristripMethod(_callback, _data) \ + RpMeshSetTriStripMethod(_callback, _data) + +#define _rpMeshGetTristripMethod(_callback, _data) \ + RpMeshGetTriStripMethod(_callback, _data) + + + +/*--- Automatically derived from: C:/daily/rwsdk/world/bageomet.h ---*/ + +/* + * Handling atomic's geometry + * Geometry describe objects, and are the building blocks for atomics + * + * Copyright (c) 1998 Criterion Software Ltd. +*/ + + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpGEOMETRY 8 + +/** + * \ingroup rpgeometry + * RpGeometryFlag + * Geometry type flags + * + * When creating a geometry, these flags can be OR'ed together to + * specify the format along with the rpGEOMETRYTEXCOORDSETS(n) macro if more + * than two sets of texture coordinates are required. See \ref RpGeometryCreate + * for more details. + * + * \see RpGeometryCreate(). + */ +enum RpGeometryFlag +{ + rpGEOMETRYTRISTRIP = 0x00000001, /**boundingSphere), (_sphere)), (_mt)) + +#define RpMorphTargetGetBoundingSphereMacro(_mt) \ + (&((_mt)->boundingSphere)) + +#define RpGeometryGetNumMorphTargetsMacro(_geometry) \ + ((_geometry)->numMorphTargets) + +#define RpGeometryGetMorphTargetMacro(_geometry, _index) \ + (&((_geometry)->morphTarget[(_index)])) + +#define RpGeometryGetPreLightColorsMacro(_geometry) \ + ((_geometry)->preLitLum) + +#define RpGeometryGetVertexTexCoordsMacro(_geometry, _uvIndex) \ + ((_geometry)->texCoords[(_uvIndex) - 1]) + +#define RpGeometryGetNumTexCoordSetsMacro(_geometry) \ + ((_geometry)->numTexCoordSets) + +#define RpGeometryGetNumVerticesMacro(_geometry) \ + ((_geometry)->numVertices) + +#define RpMorphTargetGetVerticesMacro(_mt) \ + ((_mt)->verts) + +#define RpMorphTargetGetVertexNormalsMacro(_mt) \ + ((_mt)->normals) + +#define RpGeometryGetTrianglesMacro(_geometry) \ + ((_geometry)->triangles) + +#define RpGeometryGetNumTrianglesMacro(_geometry) \ + ((_geometry)->numTriangles) + +#define RpGeometryGetMaterialMacro(_geometry, _num) \ + (((_geometry)->matList.materials)[(_num)]) + +#define RpGeometryGetNumMaterialsMacro(_geometry) \ + ((_geometry)->matList.numMaterials) + +#define RpGeometryGetFlagsMacro(_geometry) \ + ((_geometry)->flags) + +#define RpGeometrySetFlagsMacro(_geometry, _flags) \ + (((_geometry)->flags = (_flags)), (_geometry)) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMorphTargetSetBoundingSphere(_geometry, _sphere) \ + RpMorphTargetSetBoundingSphereMacro(_geometry, _sphere) + +#define RpMorphTargetGetBoundingSphere(_geometry) \ + RpMorphTargetGetBoundingSphereMacro(_geometry) + +#define RpGeometryGetNumMorphTargets(_geometry) \ + RpGeometryGetNumMorphTargetsMacro(_geometry) + +#define RpGeometryGetMorphTarget(_geometry, _index) \ + RpGeometryGetMorphTargetMacro(_geometry, _index) + +#define RpGeometryGetPreLightColors(_geometry) \ + RpGeometryGetPreLightColorsMacro(_geometry) + +#define RpGeometryGetVertexTexCoords(_geometry, _uvIndex) \ + RpGeometryGetVertexTexCoordsMacro(_geometry, _uvIndex) + +#define RpGeometryGetNumTexCoordSets(_geometry) \ + RpGeometryGetNumTexCoordSetsMacro(_geometry) + +#define RpGeometryGetNumVertices(_geometry) \ + RpGeometryGetNumVerticesMacro(_geometry) + +#define RpMorphTargetGetVertices(_mt) \ + RpMorphTargetGetVerticesMacro(_mt) + +#define RpMorphTargetGetVertexNormals(_mt) \ + RpMorphTargetGetVertexNormalsMacro(_mt) + +#define RpGeometryGetTriangles(_geometry) \ + RpGeometryGetTrianglesMacro(_geometry) + +#define RpGeometryGetNumTriangles(_geometry) \ + RpGeometryGetNumTrianglesMacro(_geometry) + +#define RpGeometryGetMaterial(_geometry, _num) \ + RpGeometryGetMaterialMacro(_geometry, _num) + +#define RpGeometryGetNumMaterials(_geometry) \ + RpGeometryGetNumMaterialsMacro(_geometry) + +#define RpGeometryGetFlags(_geometry) \ + RpGeometryGetFlagsMacro(_geometry) + +#define RpGeometrySetFlags(_geometry, _flags) \ + RpGeometrySetFlagsMacro(_geometry, _flags) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Transforms geometry morph target vertices */ + +extern RpGeometry * +RpGeometryTransform(RpGeometry *geometry, + const RwMatrix *matrix); + +/* Create geometry for a 'space' marker */ + +extern RpGeometry * +RpGeometryCreateSpace(RwReal radius); + +/* Morph targets - Accessing geometry contents */ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RpMorphTarget * +RpMorphTargetSetBoundingSphere(RpMorphTarget *morphTarget, + const RwSphere *boundingSphere); + +extern RwSphere * +RpMorphTargetGetBoundingSphere(RpMorphTarget *morphTarget); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpMorphTarget * +RpMorphTargetCalcBoundingSphere(const RpMorphTarget *morphTarget, + RwSphere *boundingSphere); + +extern RwInt32 +RpGeometryAddMorphTargets(RpGeometry *geometry, + RwInt32 mtcount); + +extern RwInt32 +RpGeometryAddMorphTarget(RpGeometry *geometry); + +extern RpGeometry * +RpGeometryRemoveMorphTarget(RpGeometry *geometry, + RwInt32 morphTarget); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpGeometryGetNumMorphTargets(const RpGeometry *geometry); + +extern RpMorphTarget * +RpGeometryGetMorphTarget(const RpGeometry *geometry, + RwInt32 morphTarget); + +extern RwRGBA * +RpGeometryGetPreLightColors(const RpGeometry *geometry); + +extern RwTexCoords * +RpGeometryGetVertexTexCoords(const RpGeometry *geometry, + RwTextureCoordinateIndex uvIndex); + +extern RwInt32 +RpGeometryGetNumTexCoordSets(const RpGeometry *geometry); + +extern RwInt32 +RpGeometryGetNumVertices (const RpGeometry *geometry); + +extern RwV3d * +RpMorphTargetGetVertices(const RpMorphTarget *morphTarget); + +extern RwV3d * +RpMorphTargetGetVertexNormals(const RpMorphTarget *morphTarget); + +extern RpTriangle * +RpGeometryGetTriangles(const RpGeometry *geometry); + +extern RwInt32 +RpGeometryGetNumTriangles(const RpGeometry *geometry); + +extern RpMaterial * +RpGeometryGetMaterial(const RpGeometry *geometry, + RwInt32 matNum); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpGeometry * +RpGeometryTriangleSetVertexIndices(const RpGeometry *geometry, + RpTriangle *triangle, + RwUInt16 vert1, + RwUInt16 vert2, + RwUInt16 vert3); + +extern RpGeometry * +RpGeometryTriangleSetMaterial(RpGeometry *geometry, + RpTriangle *triangle, + RpMaterial *material); + +extern const RpGeometry * +RpGeometryTriangleGetVertexIndices(const RpGeometry *geometry, + const RpTriangle *triangle, + RwUInt16 *vert1, + RwUInt16 *vert2, + RwUInt16 *vert3); + +extern RpMaterial * +RpGeometryTriangleGetMaterial(const RpGeometry *geometry, + const RpTriangle *triangle); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpGeometryGetNumMaterials(const RpGeometry *geometry); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RpGeometry * +RpGeometryForAllMaterials(RpGeometry *geometry, + RpMaterialCallBack fpCallBack, + void *pData); + +/* Accessing the inards of geometry */ +extern RpGeometry * +RpGeometryLock(RpGeometry *geometry, + RwInt32 lockMode); + +extern RpGeometry * +RpGeometryUnlock(RpGeometry *geometry); + +extern const RpGeometry * +RpGeometryForAllMeshes(const RpGeometry *geometry, + RpMeshCallBack fpCallBack, + void *pData); + +/* Creation and destruction */ +extern RpGeometry * +RpGeometryCreate(RwInt32 numVert, + RwInt32 numTriangles, + RwUInt32 format); + +extern RwBool +RpGeometryDestroy(RpGeometry *geometry); + +extern RpGeometry * +RpGeometryAddRef(RpGeometry *geometry); + +/* Attaching toolkits */ +extern RwInt32 +RpGeometryRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpGeometryRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RpGeometrySetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpGeometryGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RpGeometryValidatePlugins(const RpGeometry *geometry); + +/* Binary format */ +extern RwUInt32 +RpGeometryStreamGetSize(const RpGeometry *geometry); + +extern const RpGeometry * +RpGeometryStreamWrite(const RpGeometry *geometry, + RwStream *stream); + +extern RpGeometry * +RpGeometryStreamRead(RwStream *stream); + +extern RpGeometryChunkInfo * +_rpGeometryChunkInfoRead(RwStream *stream, + RpGeometryChunkInfo *geometryChunkInfo, + RwInt32 *bytesRead); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +/* Flags */ +extern RwUInt32 +RpGeometryGetFlags(const RpGeometry *geometry); + +extern RpGeometry * +RpGeometrySetFlags(RpGeometry *geometry, + RwUInt32 flags); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define rpGeometryAddRef(_geometry) \ + RpGeometryAddRef(_geometry) + +#define RpGeometryChunkInfoRead(stream, geometryChunkInfo, bytesRead) \ + _rpGeometryChunkInfoRead(stream, geometryChunkInfo, bytesRead) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/basector.h ---*/ + +/* + * Handling atomic sectors + * Atomic sectors are use to divide up the world into manageable portions + * + * Copyright (c) 1998 Criterion Software Ltd. +*/ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpWorldSector 0xff /* Not a true 'type'! */ + +#define rpMINDISTANCEBETWEENVERTICES (RwReal)(0.0001) + +#define RPV3DFROMVERTEXNORMAL(v, n) \ + (v).x = (((RwReal)((n).x)) * ( (RwReal)(1.0/128))); \ + (v).y = (((RwReal)((n).y)) * ( (RwReal)(1.0/128))); \ + (v).z = (((RwReal)((n).z)) * ( (RwReal)(1.0/128))) + +#define RPVERTEXNORMALFROMRWV3D(n, v) \ + { \ + RwFixed naTmp[3]; \ + \ + naTmp[0] = RwRealToFixed((v).x); \ + naTmp[1] = RwRealToFixed((v).y); \ + naTmp[2] = RwRealToFixed((v).z); \ + \ + if (naTmp[0] >= RwIntToFixed(1)) \ + { \ + naTmp[0] = RwIntToFixed(1)-1; \ + } \ + if (naTmp[0] <= RwIntToFixed(-1)) \ + { \ + naTmp[0] = RwIntToFixed(-1)+1; \ + } \ + if (naTmp[1] >= RwIntToFixed(1)) \ + { \ + naTmp[1] = RwIntToFixed(1)-1; \ + } \ + if (naTmp[1] <= RwIntToFixed(-1)) \ + { \ + naTmp[1] = RwIntToFixed(-1)+1; \ + } \ + if (naTmp[2] >= RwIntToFixed(1)) \ + { \ + naTmp[2] = RwIntToFixed(1)-1; \ + } \ + if (naTmp[2] <= RwIntToFixed(-1)) \ + { \ + naTmp[2] = RwIntToFixed(-1)+1; \ + } \ + \ + (n).x = (RwInt8)(naTmp[0]>>9); \ + (n).y = (RwInt8)(naTmp[1]>>9); \ + (n).z = (RwInt8)(naTmp[2]>>9); \ + } + +/**************************************************************************** + Global types + */ + +typedef struct RpVertexNormal RpVertexNormal; + +#if (!defined(DOXYGEN)) +struct RpVertexNormal +{ + RwInt8 x; + RwInt8 y; + RwInt8 z; + RwUInt8 pad; /* pad character to force alignment */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpworldsector + * \struct RpWorldSector + * World Sector object. This should be + * considered an opaque type. Use the RpWorldSector API functions to access. + */ +typedef struct RpWorldSector RpWorldSector; + +#if (!defined(DOXYGEN)) +struct RpWorldSector +{ + RwInt32 type; + + RpTriangle *triangles; /* Triangles */ + + RwV3d *vertices; /* Vertex positions */ + RpVertexNormal *normals; /* Vertex normals */ + + RwTexCoords *texCoords[rwMAXTEXTURECOORDS]; /* Texture coordinates */ + + RwRGBA *preLitLum; /* Pre lit luminances */ + + /* Pointer to memory allocated for vertex and poly pointers */ + RwResEntry *repEntry; + + /* Atomics in this sectors */ + /* The pointers are frigged so they look like they are pointing to + Atomics when they are pointing to here */ + RwLinkList collAtomicsInWorldSector; /* Coll priority */ + + /* Lights in an atomic sector */ + RwLinkList lightsInWorldSector; + + /* Outer bounding box of sector based on BSP planes */ + RwBBox boundingBox; + + /* Bounding box tightly enclosing geometry */ + RwBBox tightBoundingBox; + + /* The mesh which groups same material triangles together */ + RpMeshHeader *mesh; + + /* The WorldSector object pipeline for this WorldSector */ + RxPipeline *pipeline; + + /* Material list window base + * (triangles in a given sector can "see" + * the 256 materials from + * MatList[matListWindowBase] -> MatList[matListWindowBase + 255]) + */ + RwUInt16 matListWindowBase; + + RwUInt16 numVertices; /* Num vertices */ + RwUInt16 numTriangles; /* Num triangles */ + RwUInt16 pad; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpworldsector + * \ref RpWorldSectorCallBack + * represents the function called from \ref RpWorldForAllWorldSectors, + * \ref RpAtomicForAllWorldSectors and \ref RpLightForAllWorldSectors for all + * world sectors in a given world or world sectors a given atomic or light lies + * in. This function should return a pointer to the current world sector to + * indicate success. The callback may return NULL to terminate further + * callbacks on the atomic or light. + * + * \param sector Pointer to the current world sector + * \param data Pointer to developer-defined data structure. + * + * \return Pointer to the current world sector. + * + */ +typedef RpWorldSector *(*RpWorldSectorCallBack)(RpWorldSector *worldSector, void *data); + +typedef struct RpSector RpSector; + +#if (!defined(DOXYGEN)) +struct RpSector +{ + RwInt32 type; +}; + +/* NOTE: The left and right pointers can point to an RpPlaneSector or + * an RpWorldSector + * This is determined what the type is via the type value + */ + +typedef struct RpPlaneSector RpPlaneSector; + +struct RpPlaneSector +{ + RwInt32 type; + + RwReal value; + RpSector *leftSubTree; /* Sector 'left' (less) of the plane */ + RpSector *rightSubTree; /* Sector 'right' (more) of the plane */ + RwReal leftValue; + RwReal rightValue; +}; +#endif /* (!defined(DOXYGEN)) */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwPluginRegistry sectorTKList; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/**************************************************************************** + macro/inline functionality + */ + +#define RpWorldSectorGetBBoxMacro(_sector) \ + (&((_sector)->boundingBox)) + +#define RpWorldSectorGetTightBBoxMacro(_sector) \ + (&((_sector)->tightBoundingBox)) + +#define RpWorldSectorGetNumVerticesMacro(_sector) \ + ((_sector)->numVertices) + +#define RpWorldSectorGetNumTrianglesMacro(_sector) \ + ((_sector)->numTriangles) + +#define RpWorldSectorGetTrianglesMacro(_sector) \ + ((_sector)->triangles) + +#define RpWorldSectorGetVerticesMacro(_sector) \ + ((_sector)->vertices) + +#if ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) + +#define RpWorldSectorGetBBox(_sector) \ + RpWorldSectorGetBBoxMacro(_sector) + +#define RpWorldSectorGetTightBBox(_sector) \ + RpWorldSectorGetTightBBoxMacro(_sector) + +#define RpWorldSectorGetNumTriangles(_sector) \ + RpWorldSectorGetNumTrianglesMacro(_sector) + +#define RpWorldSectorGetNumVertices(_sector) \ + RpWorldSectorGetNumVerticesMacro(_sector) + +#define RpWorldSectorGetTriangles(_sector) \ + RpWorldSectorGetTrianglesMacro(_sector) + +#define RpWorldSectorGetVertices(_sector) \ + RpWorldSectorGetVerticesMacro(_sector) + +#endif /* ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) */ + +/* Backward compatibility */ +#define RpWorldSectorGetNumPolygons(_sector) \ + RpWorldSectorGetNumTriangles(_sector) + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Instancing and deinstancing sectors */ +extern RpWorldSector * RpWorldSectorRender(RpWorldSector *worldSector); + +extern const RpWorldSector *RpWorldSectorForAllMeshes(const RpWorldSector *sector, + RpMeshCallBack fpCallBack, + void *pData); + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RwInt32 RpWorldSectorGetNumTriangles(const RpWorldSector *Sector); +extern RwInt32 RpWorldSectorGetNumVertices(const RpWorldSector *Sector); + +extern const RwV3d * +RpWorldSectorGetVertices(const RpWorldSector *sector); + +extern const RpTriangle * +RpWorldSectorGetTriangles(const RpWorldSector *sector); + +extern const RwBBox *RpWorldSectorGetBBox(const RpWorldSector *sector); +extern const RwBBox *RpWorldSectorGetTightBBox(const RpWorldSector *sector); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* Plugins */ +extern RwInt32 RpWorldSectorRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpWorldSectorRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpWorldSectorSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpWorldSectorSetStreamRightsCallBack(RwUInt32 pluginID, + RwPluginDataChunkRightsCallBack rightsCB); +extern RwInt32 RpWorldSectorGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpWorldSectorValidatePlugins(const RpWorldSector *sector); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/balight.h ---*/ + +/* + * Lighting 3D objects. + * Lights are used to illuminate atomics and worlds + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + + +/**************************************************************************** + Defines + */ + +/* Binary Light */ +typedef struct RpLightChunkInfo RpLightChunkInfo; +typedef struct RpLightChunkInfo _rpLight; + +#if (!defined(DOXYGEN)) +struct RpLightChunkInfo +{ + RwReal radius; /**< radius */ + RwReal red; /**< red */ + RwReal green; /**< green */ + RwReal blue; /**< blue */ + RwReal minusCosAngle; /**< minusCosAngle */ + RwUInt32 typeAndFlags; /**< typeAndFlags */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/* Type ID */ +#define rpLIGHT 3 + +/* Beyond this the lights must be positioned */ +#define rpLIGHTPOSITIONINGSTART 0x80 + +/** + * \ingroup rplight + * \ref RpLightType are + * light sub types. This type represents the different + * types of light source that can be created using the API function \ref RpLightCreate. + * Note that lights of types rpLIGHTPOINT, rpLIGHTSPOT and rpLIGHTSPOTSOFT have linear + * intensity fall-off with distance from the source, reducing to zero at the light's radius:*/ +enum RpLightType +{ + rpNALIGHTTYPE = 0, + + /* These don't take part in the tie mechanism (no position) */ + rpLIGHTDIRECTIONAL, /**radius) + +#define RpLightGetColorMacro(_light) \ + (&((_light)->color)) + +#define RpLightSetFrameMacro(_light, _frame) \ + (rwObjectHasFrameSetFrame((_light), (_frame)), (_light)) + +#define RpLightGetFrameMacro(_light) \ + ((RwFrame *)rwObjectGetParent((_light))) + +#define RpLightGetTypeMacro(_light) \ + ((RpLightType)rwObjectGetSubType((_light))) + +#define RpLightSetFlagsMacro(_light, _flags) \ + ((rwObjectSetFlags((_light), (_flags))), (_light)) + +#define RpLightGetFlagsMacro(_light) \ + (rwObjectGetFlags((_light))) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpLightGetRadius(_light) \ + RpLightGetRadiusMacro(_light) + +#define RpLightGetColor(_light) \ + RpLightGetColorMacro(_light) + +#define RpLightSetFrame(_light, _frame) \ + RpLightSetFrameMacro(_light, _frame) + +#define RpLightGetFrame(_light) \ + RpLightGetFrameMacro(_light) + +#define RpLightGetType(_light) \ + RpLightGetTypeMacro(_light) + +#define RpLightSetFlags(_light, _flags) \ + RpLightSetFlagsMacro(_light, _flags) + +#define RpLightGetFlags(_light) \ + RpLightGetFlagsMacro(_light) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwReal RpLightGetRadius(const RpLight *light); +extern const RwRGBAReal *RpLightGetColor(const RpLight *light); +extern RpLight *RpLightSetFrame(RpLight *light, RwFrame *frame); +extern RwFrame *RpLightGetFrame(const RpLight *light); +extern RpLightType RpLightGetType(const RpLight *light); +extern RpLight *RpLightSetFlags(RpLight *light, RwUInt32 flags); +extern RwUInt32 RpLightGetFlags(const RpLight *light); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* API Functions */ +extern void RpLightSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); +extern RpLight *RpLightCreate(RwInt32 type); +extern RwBool RpLightDestroy(RpLight *light); +extern RpLight *RpLightSetRadius(RpLight *light, RwReal radius); +extern RpLight *RpLightSetColor(RpLight *light, const RwRGBAReal *color); +extern RwReal RpLightGetConeAngle(const RpLight *light); +extern RpLight *RpLightSetConeAngle(RpLight * ight, RwReal angle); +extern RwUInt32 RpLightStreamGetSize(const RpLight *light); +extern RpLight *RpLightStreamRead(RwStream *stream); +extern const RpLight *RpLightStreamWrite(const RpLight *light, + RwStream *stream); +extern RpLightChunkInfo *_rpLightChunkInfoRead(RwStream *stream, + RpLightChunkInfo *lightChunkInfo, + RwInt32 *bytesRead); + +/* Attaching toolkits */ +extern RwInt32 RpLightRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpLightRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpLightSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpLightGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpLightValidatePlugins(const RpLight * light); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpLightChunkInfoRead(stream, lightChunkInfo, bytesRead) \ + _rpLightChunkInfoRead(stream, lightChunkInfo, bytesRead) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d9/D3D9lights.h ---*/ +/* + * typedef for struct RpD3D9AttenuationParams + */ +typedef struct RpD3D9AttenuationParams RpD3D9AttenuationParams; +/** + * \ingroup rplightd3d9 + * \struct RpD3D9AttenuationParams + * This type represents the attenuation model of a spot or point light. + */ +struct RpD3D9AttenuationParams +{ + RwReal constant; /**< Constant attenuation coefficient */ + RwReal linear; /**< Linear attenuation coefficient */ + RwReal quadratic; /**< Quadratic attenuation coefficient */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void +RpD3D9LightSetAttenuationParams(RpLight *light, + const RpD3D9AttenuationParams *params); + +extern void +RpD3D9LightGetAttenuationParams(const RpLight *light, + RpD3D9AttenuationParams *params); + +extern RwBool +_rwD3D9LightsOpen(void); + +extern RwBool +_rwD3D9LightsGlobalEnable(RpLightFlag flags); + +extern RwBool +_rwD3D9LightDirectionalEnable(RpLight *light); + +extern RwBool +_rwD3D9LightLocalEnable(RpLight *light); + +extern void +_rwD3D9LightsEnable(RwBool enable, RwUInt32 type); + +extern void +_rwD3D9LightsClose(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/baclump.h ---*/ + +/* + * Clump and atomic handling. + * Clumps and atomics are the movable rendered objects in the world + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + + +/**************************************************************************** + Defines + */ + +/****************************** Object type ID ******************************/ + +/* Type IDs */ + +#define rpATOMIC 1 +#define rpCLUMP 2 + +/* Interpolator flags */ +enum RpInterpolatorFlag +{ + rpINTERPOLATORDIRTYINSTANCE = 0x01, + rpINTERPOLATORDIRTYSPHERE = 0x02, + rpINTERPOLATORNOFRAMEDIRTY = 0x04, + rpINTERPOLATORFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpInterpolatorFlag rpInterpolatorFlag; + +/** + * \ingroup rpatomic + * The bit-field type RpAtomicFlag specifies the options available for + * controlling the behavior of atomics. See API function \ref RpAtomicSetFlags. + * + * \see RpAtomicSetFlags + * \see RpAtomicGetFlags + * \see RpWorldSectorForAllCollisionAtomics + */ + +enum RpAtomicFlag +{ + rpATOMICCOLLISIONTEST = 0x01, /**renderCallBack(_atomic)) + +#define RpAtomicGetGeometryMacro(_atomic) \ + ((_atomic)->geometry) + +#if (!defined(RpAtomicSetRenderCallBackMacro)) + +/* NB "RpAtomicSetRenderCallBack(atom++, callback)" will break it */ +#define RpAtomicSetRenderCallBackMacro(_atomic, _callback) \ +MACRO_START \ +{ \ + (_atomic)->renderCallBack = (_callback); \ + if (!(_atomic)->renderCallBack) \ + { \ + (_atomic)->renderCallBack = AtomicDefaultRenderCallBack; \ + } \ +} \ +MACRO_STOP + +#endif /* (!defined(RpAtomicSetRenderCallBackMacro)) */ + +#define RpAtomicGetRenderCallBackMacro(_atomic) \ + ((_atomic)->renderCallBack) + +#define RpAtomicGetInterpolatorMacro(_atomic) \ + (&((_atomic)->interpolator)) + +#define RpInterpolatorGetStartMorphTargetMacro(_intrp) \ + ((_intrp)->startMorphTarget) + +#define RpInterpolatorGetEndMorphTargetMacro(_intrp) \ + ((_intrp)->endMorphTarget) + +#define RpInterpolatorGetValueMacro(_intrp) \ + ((_intrp)->position) + +#define RpInterpolatorGetScaleMacro(_intrp) \ + ((_intrp)->time) + +/* NB "RpInterpolatorSetStartMorphTarget(interp++, target)" will break it */ +#define RpInterpolatorSetStartMorphTargetMacro(_intrp, _target, _atomic)\ + ((_intrp)->startMorphTarget = (RwInt16) (_target), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetEndMorphTarget(interp++, target)" will break it */ +#define RpInterpolatorSetEndMorphTargetMacro(_intrp, _target, _atomic) \ + ((_intrp)->endMorphTarget = (RwInt16) (_target), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetValue(interp++, value)" will break it */ +#define RpInterpolatorSetValueMacro(_intrp, _value, _atomic) \ + ((_intrp)->position = (_value), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetScale(interp++, *(scale++))" will break it */ +#define RpInterpolatorSetScaleMacro(_intrp, _scale, _atomic) \ + ((_intrp)->time = (_scale), \ + (_intrp)->recipTime = (RwReal) (1.0) / (_scale), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +#define RpAtomicGetClumpMacro(_atomic) \ + ((_atomic)->clump) + +/* NB "RpAtomicGetBoundingSphere(atomic++)" will break it */ +#define RpAtomicGetBoundingSphereMacro(_atomic) \ + ((((_atomic)->interpolator.flags & rpINTERPOLATORDIRTYSPHERE)? \ + _rpAtomicResyncInterpolatedSphere(_atomic), 0: 0), \ + &((_atomic)->boundingSphere)) +#define RpAtomicGetFrameMacro(_atomic) \ + ((RwFrame *) rwObjectGetParent(_atomic)) + +/* NB "RpClumpSetFrame(clump++, frame)" will break it */ +#if (!defined(RpClumpSetFrameMacro)) +#define RpClumpSetFrameMacro(_clump, _frame) \ + (rwObjectSetParent(_clump, _frame), \ + (_clump)) +#endif /* (!defined(RpClumpSetFrameMacro)) */ + +#if (!defined(RpClumpSetFrameVoidMacro)) +#define RpClumpSetFrameVoidMacro(_clump, _frame) \ +MACRO_START \ +{ \ + rwObjectSetParent(_clump, _frame); \ +} \ +MACRO_STOP +#endif /* (!defined(RpClumpSetFrameVoidMacro)) */ + +#define RpClumpGetFrameMacro(_clump) \ + ((RwFrame *) rwObjectGetParent(_clump)) + +/* NB "RpAtomicSetFlags(atomic++, flags)" will break it */ +#if (!defined(RpAtomicSetFlagsMacro)) +#define RpAtomicSetFlagsMacro(_atomic, _flags) \ + (rwObjectSetFlags(_atomic, _flags), \ + (_atomic)) +#endif /* (!defined(RpAtomicSetFlagsMacro)) */ + +#define RpAtomicGetFlagsMacro(_atomic) \ + (rwObjectGetFlags(_atomic)) + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RpAtomicRender(_atomic) \ + RpAtomicRenderMacro(_atomic) + +#define RpAtomicGetGeometry(_atomic) \ + RpAtomicGetGeometryMacro(_atomic) + +#define RpAtomicSetRenderCallBack(_atomic, _callback) \ + RpAtomicSetRenderCallBackMacro(_atomic, _callback) + +#define RpAtomicGetRenderCallBack(_atomic) \ + RpAtomicGetRenderCallBackMacro(_atomic) + +#define RpAtomicGetInterpolator(_atomic) \ + RpAtomicGetInterpolatorMacro(_atomic) + +#define RpInterpolatorGetStartMorphTarget(_intrp) \ + RpInterpolatorGetStartMorphTargetMacro(_intrp) + +#define RpInterpolatorGetEndMorphTarget(_intrp) \ + RpInterpolatorGetEndMorphTargetMacro(_intrp) + +#define RpInterpolatorGetValue(_intrp) \ + RpInterpolatorGetValueMacro(_intrp) + +#define RpInterpolatorGetScale(_intrp) \ + RpInterpolatorGetScaleMacro(_intrp) + +#define RpInterpolatorSetStartMorphTarget(_intrp, _target, _atomic) \ + RpInterpolatorSetStartMorphTargetMacro(_intrp, _target, _atomic) + +#define RpInterpolatorSetEndMorphTarget(_intrp, _target, _atomic) \ + RpInterpolatorSetEndMorphTargetMacro(_intrp, _target, _atomic) + +#define RpInterpolatorSetValue(_intrp, _value, _atomic) \ + RpInterpolatorSetValueMacro(_intrp, _value, _atomic) + +#define RpInterpolatorSetScale(_intrp, _scale, _atomic) \ + RpInterpolatorSetScaleMacro(_intrp, _scale, _atomic) + +#define RpAtomicGetClump(_atomic) \ + RpAtomicGetClumpMacro(_atomic) + +#define RpAtomicGetBoundingSphere(_atomic) \ + RpAtomicGetBoundingSphereMacro(_atomic) + +#define RpAtomicGetFrame(_atomic) \ + RpAtomicGetFrameMacro(_atomic) + +#define RpClumpSetFrame(_clump, _frame) \ + RpClumpSetFrameMacro(_clump, _frame) + +#define RpClumpGetFrame(_clump) \ + RpClumpGetFrameMacro(_clump) + +#define RpAtomicSetFlags(_atomic, _flags) \ + RpAtomicSetFlagsMacro(_atomic, _flags) + +#define RpAtomicGetFlags(_atomic) \ + RpAtomicGetFlagsMacro(_atomic) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern void +RpAtomicSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern void +RpClumpSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +/* Macro version of RpAtomicSetRenderCallBack needs this */ +extern RpAtomic * +AtomicDefaultRenderCallBack(RpAtomic * atomic); + +extern void +_rpAtomicResyncInterpolatedSphere(RpAtomic * atomic); + +extern const RwSphere * +RpAtomicGetWorldBoundingSphere(RpAtomic * atomic); + +/* Enumeration */ +extern RpClump * +RpClumpForAllAtomics(RpClump * clump, + RpAtomicCallBack callback, + void *pData); + +extern RpClump * +RpClumpForAllLights(RpClump * clump, + RpLightCallBack callback, + void *pData); + +extern RpClump * +RpClumpForAllCameras(RpClump * clump, + RwCameraCallBack callback, + void *pData); + +/* Frames */ +extern RpAtomic * +RpAtomicSetFrame(RpAtomic * atomic, + RwFrame * frame); + +/* Create a space marking clump */ +extern RpClump * +RpClumpCreateSpace(const RwV3d * position, + RwReal radius); + +/* Instancing and rendering */ +extern RpClump * +RpClumpRender(RpClump * clump); + +extern RpClump * +RpClumpRemoveAtomic(RpClump * clump, + RpAtomic * atomic); + +extern RpClump * +RpClumpAddAtomic(RpClump * clump, + RpAtomic * atomic); + +extern RpClump * +RpClumpRemoveLight(RpClump * clump, + RpLight * light); + +extern RpClump * +RpClumpAddLight(RpClump * clump, + RpLight * light); + +extern RpClump * +RpClumpRemoveCamera(RpClump * clump, + RwCamera * camera); + +extern RpClump * +RpClumpAddCamera(RpClump * clump, + RwCamera * camera); + +/* Creation and destruction of clumps */ +extern RwBool +RpClumpDestroy(RpClump * clump); + +extern RpClump * +RpClumpCreate(void); + +extern RpClump * +RpClumpClone(RpClump * clump); + +/* Creation and destruction of atomics*/ +extern RwBool +RpAtomicDestroy(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicClone(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicCreate(void); + +/* Setting and getting geometry for an atomic */ +extern RpAtomic * +RpAtomicSetGeometry(RpAtomic * atomic, + RpGeometry * geometry, + RwUInt32 flags); + +/* Frustum callbacks */ +extern RpClump * +RpClumpSetCallBack(RpClump * clump, + RpClumpCallBack callback); + +extern RpClumpCallBack +RpClumpGetCallBack(const RpClump * clump); + +/* The number of atomics in a clump */ +extern RwInt32 +RpClumpGetNumAtomics(RpClump * clump); + +extern RwInt32 +RpClumpGetNumLights(RpClump * clump); + +extern RwInt32 +RpClumpGetNumCameras(RpClump * clump); + +/* Light and camera extensions */ +extern RpClump * +RpLightGetClump(const RpLight *light); + +extern RpClump * +RwCameraGetClump(const RwCamera *camera); + +/* Binary format */ +extern RwUInt32 +RpAtomicStreamGetSize(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicStreamRead(RwStream * stream); + +extern RpAtomic * +RpAtomicStreamWrite(RpAtomic * atomic, + RwStream * stream); + +extern RwUInt32 +RpClumpStreamGetSize(RpClump * clump); + +extern RpClump * +RpClumpStreamRead(RwStream * stream); + +extern RpClump * +RpClumpStreamWrite(RpClump * clump, + RwStream * stream); + +extern RpClumpChunkInfo * +_rpClumpChunkInfoRead(RwStream * stream, + RpClumpChunkInfo * clumpChunkInfo, + RwInt32 * bytesRead); + +/* Attaching toolkits */ +extern RwInt32 +RpAtomicRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpClumpRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpAtomicRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack + readCB, + RwPluginDataChunkWriteCallBack + writeCB, + RwPluginDataChunkGetSizeCallBack + getSizeCB); + +extern RwInt32 +RpAtomicSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpAtomicSetStreamRightsCallBack(RwUInt32 pluginID, + RwPluginDataChunkRightsCallBack rightsCB); + +extern RwInt32 +RpClumpRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RpClumpSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpAtomicGetPluginOffset(RwUInt32 pluginID); + +extern RwInt32 +RpClumpGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RpAtomicValidatePlugins(const RpAtomic * atomic); + +extern RwBool +RpClumpValidatePlugins(const RpClump * clump); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwFrame * +RpAtomicGetFrame(const RpAtomic * atomic); + +extern RwFrame * +RpClumpGetFrame(const RpClump * clump); + +extern RpClump * +RpClumpSetFrame(RpClump * clump, + RwFrame * frame); + +/* Flags */ +extern RpAtomic * +RpAtomicSetFlags(RpAtomic * atomic, + RwUInt32 flags); + +extern RwUInt32 +RpAtomicGetFlags(const RpAtomic * atomic); + +extern RwSphere * +RpAtomicGetBoundingSphere(RpAtomic * atomic); + +extern RwInt32 +RpInterpolatorGetEndMorphTarget(const RpInterpolator * interpolator); + +extern RwInt32 +RpInterpolatorGetStartMorphTarget(const RpInterpolator * interpolator); + +extern RwReal +RpInterpolatorGetValue(const RpInterpolator * interpolator); + +extern RwReal +RpInterpolatorGetScale(const RpInterpolator * interpolator); + +extern RpInterpolator * +RpInterpolatorSetEndMorphTarget(RpInterpolator * interpolator, + RwInt32 morphTarget, + RpAtomic * atomic); + +extern RpInterpolator * +RpInterpolatorSetStartMorphTarget(RpInterpolator * interpolator, + RwInt32 morphTarget, + RpAtomic * atomic); + +extern RpInterpolator * +RpInterpolatorSetValue(RpInterpolator * interpolator, + RwReal value, + RpAtomic *atomic); + +extern RpInterpolator * +RpInterpolatorSetScale(RpInterpolator * interpolator, + RwReal scale, + RpAtomic *atomic); + +extern RpAtomic * +RpAtomicRender(RpAtomic * atomic); + +/* Building clumps */ +extern RpClump * +RpAtomicGetClump(const RpAtomic * atomic); + +extern RpInterpolator * +RpAtomicGetInterpolator(RpAtomic * atomic); + +extern RpGeometry * +RpAtomicGetGeometry(const RpAtomic * atomic); + +extern void +RpAtomicSetRenderCallBack(RpAtomic * atomic, + RpAtomicCallBackRender callback); + +extern RpAtomicCallBackRender +RpAtomicGetRenderCallBack(const RpAtomic * atomic); + +#endif + +/* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +extern RwBool RpAtomicInstance(RpAtomic *atomic); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpClumpChunkInfoRead(stream, clumpChunkInfo, bytesRead) \ + _rpClumpChunkInfoRead(stream, clumpChunkInfo, bytesRead) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/baworld.h ---*/ + +/* + * World handling. + * World give objects scope, and provide a mechanism for + * efficiency static object rendering. + * + * Copyright (c) 1998 Criterion Software Ltd. + * + */ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpWORLD 7 + +/* RpWorld private flags (in RwObject) */ +enum RpWorldPrivateFlag +{ + rpWORLDSINGLEMALLOC = 0x01, + rpWORLDPRIVATEFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpWorldPrivateFlag RpWorldPrivateFlag; + +/** + * \ingroup rpworldsub + * The bit-field type \ref RpWorldFlag specifies the options available + * for creating the static geometry component of a world (see API function \ref RpWorldSetFlags): + */ +enum RpWorldFlag +{ + rpWORLDTRISTRIP = 0x01, /**boundingBox)) + +#define _rpWorldGetOriginMacro(_world) \ + (&((_world)->worldOrigin)) + +#define RpWorldGetNumMaterialsMacro(_world) \ + ((_world)->matList.numMaterials) + +#define RpWorldGetMaterialMacro(_world, _num) \ + (((_world)->matList.materials)[(_num)]) + +#define RpWorldGetNumClumpsMacro(_world) \ + ((_world)->numClumpsInWorld) + +#define RpWorldSetRenderOrderMacro(_world, _renderOrder) \ + (((_world)->renderOrder = _renderOrder), (_world)) + +#define RpWorldGetRenderOrderMacro(_world) \ + ((_world)->renderOrder) + +#define RpWorldSetFlagsMacro(_world, _flags) \ + (((_world)->flags = (_flags)), (_world)) + +#define RpWorldGetFlagsMacro(_world) \ + ((_world)->flags) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpWorldGetBBox(_world) \ + RpWorldGetBBoxMacro(_world) + +#define _rpWorldGetOrigin(_world) \ + _rpWorldGetOriginMacro(_world) + +#define RpWorldGetNumMaterials(_world) \ + RpWorldGetNumMaterialsMacro(_world) + +#define RpWorldGetMaterial(_world, _num) \ + RpWorldGetMaterialMacro(_world, _num) + +#define RpWorldGetNumClumps(_world) \ + RpWorldGetNumClumpsMacro(_world) + +#define RpWorldSetRenderOrder(_world, _renderOrder) \ + RpWorldSetRenderOrderMacro(_world, _renderOrder) + +#define RpWorldGetRenderOrder(_world) \ + RpWorldGetRenderOrderMacro(_world) + +#define RpWorldSetFlags(_world, _flags) \ + RpWorldSetFlagsMacro(_world, _flags) + +#define RpWorldGetFlags(_world) \ + RpWorldGetFlagsMacro(_world) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Global types + */ + +/** + * \ingroup rpworldsub + * + * A pluginID is a unique identifiers for a plugin. This is a list of the IDs for + * RpWorld plugin, which is not just one plugin, but a collection of plugins + * that extend RenderWare Graphics Core. See \ref RwEngineRegisterPlugin + * + */ +enum RwCriterionWorldID +{ + /* Guard value that should not be used. */ + rwID_NAWORLDID = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x00), + + /* The valid plugin IDs */ + /**< RpMaterial pluginID */ + rwID_MATERIALMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x01), + /**< RpMesh pluginID */ + rwID_MESHMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x02), + /**< RpGeometry pluginID */ + rwID_GEOMETRYMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x03), + /**< RpClump pluginID */ + rwID_CLUMPMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x04), + /**< RpLight pluginID */ + rwID_LIGHTMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x05), + /* Not used */ + rwID_COLLISIONMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x06), + /**< RpWorld pluginID */ + rwID_WORLDMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x07), + /* Not used */ + rwID_RANDOMMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x08), + /**< PluginID for RpWorld's objects */ + rwID_WORLDOBJMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x09), + /**< RpWorldSector pluginID */ + rwID_SECTORMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x0A), + /**< Binary RpWorld pluginID */ + rwID_BINWORLDMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x0B), + /**< RpWorld pipeline pluginID */ + rwID_WORLDPIPEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x0D), + /**< Binary RpMesh pluginID */ + rwID_BINMESHPLUGIN = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x0E), + /**< RpWorld device pluginID */ + rwID_RXWORLDDEVICEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x0F), + /**< PluginID for platform specific serialization data */ + rwID_NATIVEDATAPLUGIN = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x10), + /**< \if xbox Vertex format pluginID \endif */ + /**< \if gcn Vertex format pluginID \endif */ + rwID_VERTEXFMTPLUGIN = MAKECHUNKID(rwVENDORID_CRITERIONWORLD, 0x11), + rwCRITERIONWORLDIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCriterionWorldID RwCriterionWorldID; + +/** + * \ingroup rpworldsub + * \ref RpWorldRenderOrder + * represents the options available for + * the rendering order of world sectors in the camera's view frustum (see + * API function \ref RpWorldSetRenderOrder). + */ +enum RpWorldRenderOrder +{ + rpWORLDRENDERNARENDERORDER = 0, + rpWORLDRENDERFRONT2BACK, /**pipeline = _pipeline), _world ) + +#define RpWorldGetSectorPipelineMacro(_world, _pipeline) \ + ( (*(_pipeline) = (_world)->pipeline), _world ) + +#define RpWorldSectorSetPipelineMacro(_sector, _pipeline) \ + ( ((_sector)->pipeline = _pipeline), _sector ) + +#define RpWorldSectorGetPipelineMacro(_sector, _pipeline) \ + ( (*(_pipeline) = (_sector)->pipeline), _sector ) + +#define RpAtomicGetDefaultPipelineMacro() \ + (RXPIPELINEGLOBAL(currentAtomicPipeline)) + +#define RpAtomicSetPipelineMacro(_atomic, _pipeline) \ + ( ((_atomic)->pipeline = _pipeline), _atomic ) + +#define RpAtomicGetPipelineMacro(_atomic, _pipeline) \ + ( (*(_pipeline) = (_atomic)->pipeline), _atomic ) + +#define RpMaterialGetDefaultPipelineMacro() \ + (RXPIPELINEGLOBAL(currentMaterialPipeline)) + +#define RpMaterialSetPipelineMacro(_material, _pipeline) \ + ( ((_material)->pipeline = _pipeline), _material ) + +#define RpMaterialGetPipelineMacro(_material, _pipeline) \ + ( (*(_pipeline) = (_material)->pipeline), _material ) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpWorldGetDefaultSectorPipeline RpWorldGetDefaultSectorPipelineMacro +#define RpWorldSetSectorPipeline RpWorldSetSectorPipelineMacro +#define RpWorldGetSectorPipeline RpWorldGetSectorPipelineMacro +#define RpWorldSectorSetPipeline RpWorldSectorSetPipelineMacro +#define RpWorldSectorGetPipeline RpWorldSectorGetPipelineMacro + +#define RpAtomicGetDefaultPipeline RpAtomicGetDefaultPipelineMacro +#define RpAtomicSetPipeline RpAtomicSetPipelineMacro +#define RpAtomicGetPipeline RpAtomicGetPipelineMacro + +#define RpMaterialGetDefaultPipeline RpMaterialGetDefaultPipelineMacro +#define RpMaterialSetPipeline RpMaterialSetPipelineMacro +#define RpMaterialGetPipeline RpMaterialGetPipelineMacro + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxPipeline *RpWorldSetDefaultSectorPipeline(RxPipeline *pipeline); +extern RxPipeline *RpAtomicSetDefaultPipeline(RxPipeline *pipeline); +extern RxPipeline *RpMaterialSetDefaultPipeline(RxPipeline *pipeline); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RxPipeline *RpWorldGetGenericSectorPipeline(void); +extern RxPipeline *RpWorldGetDefaultSectorPipeline(void); +extern RpWorld *RpWorldSetSectorPipeline(RpWorld *world, + RxPipeline *pipeline); +extern RpWorld *RpWorldGetSectorPipeline(RpWorld *world, + RxPipeline **pipeline); +extern RpWorldSector *RpWorldSectorSetPipeline(RpWorldSector *sector, + RxPipeline *pipeline); +extern RpWorldSector *RpWorldSectorGetPipeline(RpWorldSector *sector, + RxPipeline **pipeline); + +extern RxPipeline *RpAtomicGetGenericPipeline(void); +extern RxPipeline *RpAtomicGetDefaultPipeline(void); +extern RpAtomic *RpAtomicSetPipeline(RpAtomic *atomic, + RxPipeline *pipeline); +extern const RpAtomic *RpAtomicGetPipeline(const RpAtomic *const atomic, + RxPipeline **pipeline); + +extern RxPipeline *RpMaterialGetGenericPipeline(void); +extern RxPipeline *RpMaterialGetDefaultPipeline(void); +extern RpMaterial *RpMaterialSetPipeline(RpMaterial *material, + RxPipeline *pipeline); +extern RpMaterial *RpMaterialGetPipeline(RpMaterial *material, + RxPipeline **pipeline); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpGeometry *RpGeometryIsCorrectlySorted(const RpGeometry * geometry, + RwBool * result); +extern RpGeometry *RpGeometrySortByMaterial(const RpGeometry * geometry, + RpGeometrySortByMaterialCallBack callback); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* LEGACY-SUPPORT macros */ +#define RpWorldSetDefaultSectorInstancePipeline RpWorldSetDefaultSectorPipeline +#define RpWorldGetDefaultSectorInstancePipeline RpWorldGetDefaultSectorPipeline +#define RpWorldSetSectorInstancePipeline RpWorldSetSectorPipeline +#define RpWorldGetSectorInstancePipeline RpWorldGetSectorPipeline +#define RpWorldSectorSetInstancePipeline RpWorldSectorSetPipeline +#define RpWorldSectorGetInstancePipeline RpWorldSectorGetPipeline + +#define RpAtomicGetDefaultInstancePipeline RpAtomicGetDefaultPipeline +#define RpAtomicSetDefaultInstancePipeline RpAtomicSetDefaultPipeline +#define RpAtomicSetInstancePipeline RpAtomicSetPipeline +#define RpAtomicGetInstancePipeline RpAtomicGetPipeline + +#define RpMaterialSetDefaultRenderPipeline RpMaterialSetDefaultPipeline +#define RpMaterialGetDefaultRenderPipeline RpMaterialGetDefaultPipeline +#define RpMaterialSetRenderPipeline RpMaterialSetPipeline +#define RpMaterialGetRenderPipeline RpMaterialGetPipeline + + +/*--- Automatically derived from: C:/daily/rwsdk/world/baworobj.h ---*/ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void RpTieSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); +extern void RpLightTieSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +/* Adding and removing cameras to/from the world */ +extern RpWorld *RpWorldRemoveCamera(RpWorld *world, RwCamera *camera); +extern RpWorld *RpWorldAddCamera(RpWorld *world, RwCamera *camera); +extern RpWorld *RwCameraGetWorld(const RwCamera *camera); + +/* Adding and removing atomics to/from the world */ +extern RpWorld *RpWorldRemoveAtomic(RpWorld *world, RpAtomic *atomic); +extern RpWorld *RpWorldAddAtomic(RpWorld *world, RpAtomic *atomic); +extern RpWorld *RpAtomicGetWorld(const RpAtomic *atomic); + +/* Adding and removing clumps to/from the world */ +extern RpWorld *RpWorldAddClump(RpWorld *world, RpClump *clump); +extern RpWorld *RpWorldRemoveClump(RpWorld *world, RpClump *clump); +extern RpWorld *RpClumpGetWorld(const RpClump *clump); + +/* Adding and removing lights to/from the world */ +extern RpWorld *RpWorldAddLight(RpWorld *world, RpLight *light); +extern RpWorld *RpWorldRemoveLight(RpWorld *world, RpLight *light); +extern RpWorld *RpLightGetWorld(const RpLight *light); + +/* Finding whats in the view frustum */ +extern RwCamera *RwCameraForAllClumpsInFrustum(RwCamera *camera, void *data); +extern RwCamera *RwCameraForAllAtomicsInFrustum(RwCamera *camera, + RpAtomicCallBack callback, + void *data); +extern RwCamera *RwCameraForAllSectorsInFrustum(RwCamera *camera, + RpWorldSectorCallBack callBack, + void *pData); + +/* Enumeration involving the world sectors */ +extern RpLight *RpLightForAllWorldSectors(RpLight *light, + RpWorldSectorCallBack callback, + void *data); +extern RpAtomic *RpAtomicForAllWorldSectors(RpAtomic *atomic, + RpWorldSectorCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllAtomics(RpWorldSector *sector, + RpAtomicCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllCollisionAtomics(RpWorldSector *sector, + RpAtomicCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllLights(RpWorldSector *sector, + RpLightCallBack callback, + void *data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/babinwor.h ---*/ +/**************************************************************************** + Global types + */ + +/* Binary Representation + * + */ +typedef struct RpWorldChunkInfoSector RpWorldSectorChunkInfo; +typedef struct RpWorldChunkInfoSector _rpWorldSector; + +#if (!defined(DOXYGEN)) +struct RpWorldChunkInfoSector +{ + RwInt32 matListWindowBase; + RwInt32 numTriangles; + RwInt32 numVertices; + RwV3d inf; + RwV3d sup; + RwBool collSectorPresent; /* unused but retains same struct size */ + RwBool unused; +}; + + +typedef struct RpPlaneSectorChunkInfo RpPlaneSectorChunkInfo; +typedef struct RpPlaneSectorChunkInfo _rpPlaneSector; + +struct RpPlaneSectorChunkInfo +{ + RwInt32 type; + RwReal value; + RwBool leftIsWorldSector; + RwBool rightIsWorldSector; + RwReal leftValue; + RwReal rightValue; +}; + +typedef struct RpWorldChunkInfo RpWorldChunkInfo; +typedef struct RpWorldChunkInfo _rpWorld; + +struct RpWorldChunkInfo +{ + RwBool rootIsWorldSector; + + RwV3d invWorldOrigin; + + RwInt32 numTriangles; + RwInt32 numVertices; + RwInt32 numPlaneSectors; + RwInt32 numWorldSectors; + RwInt32 colSectorSize; + + RwInt32 format; /* Flags about the world */ + + /* Added in 34003 */ + RwBBox boundingBox; +}; + +typedef struct rpWorldChunkInfo34000 rpWorldChunkInfo34000; + +struct rpWorldChunkInfo34000 +{ + RwBool rootIsWorldSector; + + RwV3d invWorldOrigin; + + RwSurfaceProperties surfaceProps; + + RwInt32 numTriangles; + RwInt32 numVertices; + RwInt32 numPlaneSectors; + RwInt32 numWorldSectors; + RwInt32 colSectorSize; + + RwInt32 format; /* Flags about the world */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Binary format */ +extern RwUInt32 RpWorldStreamGetSize(const RpWorld *world); +extern RpWorld *RpWorldStreamRead(RwStream *stream); +extern const RpWorld *RpWorldStreamWrite(const RpWorld *world, + RwStream *stream); +extern RpWorldSectorChunkInfo * +_rpWorldSectorChunkInfoRead(RwStream *stream, + RpWorldSectorChunkInfo *worldSectorChunkInfo, + RwInt32 *bytesRead); +extern RpPlaneSectorChunkInfo * +_rpPlaneSectorChunkInfoRead(RwStream *stream, + RpPlaneSectorChunkInfo *planeSectorChunkInfo, + RwInt32 *bytesRead); +extern RpWorldChunkInfo * +_rpWorldChunkInfoRead(RwStream *stream, + RpWorldChunkInfo *worldChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpWorldSectorChunkInfoRead(stream, worldSectorChunkInfo, bytesRead) \ + _rpWorldSectorChunkInfoRead(stream, worldSectorChunkInfo, bytesRead) + +#define RpPlaneSectorChunkInfoRead(stream, planeSectorChunkInfo, bytesRead) \ + _rpPlaneSectorChunkInfoRead(stream, planeSectorChunkInfo, bytesRead) + +#define RpWorldChunkInfoRead(stream, worldChunkInfo, bytesRead) \ + _rpWorldChunkInfoRead(stream, worldChunkInfo, bytesRead) + +#endif /* RPWORLD_H */ diff --git a/includes/rwsdk/rpworld.rpe b/includes/rwsdk/rpworld.rpe new file mode 100644 index 0000000..080eefa --- /dev/null +++ b/includes/rwsdk/rpworld.rpe @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionWorld +{ + + +E_RP_WORLD_INVSPHERE, + +E_RP_WORLD_INVINTERSECTION, + +E_RP_WORLD_MATRANGE, + +E_RP_WORLD_CLUMPINWORLD, + +E_RP_WORLD_CLUMPNOTINWORLD, + +E_RP_WORLD_ATOMICNOFRAME, + +E_RP_WORLD_TOOMANYVERTICES, + + e_rwdb_CriterionWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionWorld e_rwdb_CriterionWorld; + + diff --git a/includes/rwsdk/rt2d.h b/includes/rwsdk/rt2d.h new file mode 100644 index 0000000..f24c871 --- /dev/null +++ b/includes/rwsdk/rt2d.h @@ -0,0 +1,1047 @@ +/* + * Data structures for 2d toolkit + * + * Copyright (c) Criterion Software Limited + */ + +/*************************************************************************** + * * + * Module : rt2d.h * + * * + * Purpose : * + * * + **************************************************************************/ + +#ifndef RT2D_H +#define RT2D_H + +/** + * \defgroup rt2d Rt2d + * \ingroup 2dtools + * + * 2D Rendering Toolkit for RenderWare. + */ + +/** + * \defgroup rt2ddatatypes Data Types + * \ingroup rt2d + * + * Basic Data Types + */ + +/** + * \defgroup rt2dsub Rt2d + * \ingroup rt2d + * + * Rt2d functions + */ + +/** + * \defgroup rt2dbrush Rt2dBrush + * \ingroup rt2d + * + * Brush functions + */ + +/** + * \defgroup rt2dctm Rt2dCTM + * \ingroup rt2d + * + * Current Transformation Matrix (CTM) + */ + +/** + * \defgroup rt2ddevice Rt2dDevice + * \ingroup rt2d + * + * Camera device functions + */ + +/** + * \defgroup rt2dfont Rt2dFont + * \ingroup rt2d + * + * Font functions + */ + +/** + * \defgroup rt2dobject Rt2dObject + * \ingroup rt2d + * + * Objects + */ + +/** + * \defgroup rt2dobjectstring Rt2dObjectString + * \ingroup rt2d + * + * String functions + */ + +/** + * \defgroup rt2dpath Rt2dPath + * \ingroup rt2d + * + * Path functions + */ + +/** + * \defgroup rt2dpickregion Rt2dPickRegion + * \ingroup rt2d + * + * Pick regions + */ + +/** + * \defgroup rt2dscene Rt2dScene + * \ingroup rt2d + * + * Scenes + */ + +/** + * \defgroup rt2dshape Rt2dShape + * \ingroup rt2d + * + * Shapes + */ + +/** + * \defgroup rt2drwv2d RwV2d + * \ingroup rt2d + * + * Rt2d plugin directly extends the Core Library's RwV2d API functions. + */ + +/**************************************************************************** + Includes + */ + +#include "rpworld.h" +#include "rt2d.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +#define Rt2dBrushSetWidthMacro(_brush, _width) \ + ( ( (_brush)->halfwidth = ((_width) * 0.5f) ), (_brush) ) + +#define Rt2dBrushGetWidthMacro(_brush) \ + ( (_brush)->halfwidth * 2.0f ) + +#define Rt2dCTMReadMacro(_result) \ + (RwMatrixCopy((_result), _rt2dCTMGet()), (_result)) + +#if defined (GCN_DRVMODEL_H) + #define VERTEXCACHESIZE 64 +#else + #define VERTEXCACHESIZE 256 +#endif + + +/**************************************************************************** + Global Types + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * rt2dShadeParameters + * typedef for a structure describing Shade Parameters + */ +typedef struct rt2dShadeParameters rt2dShadeParameters; + +/* + * + * rt2dShadeParameters + * describes Shade Parameters + */ + +#if (!defined(DOXYGEN)) +struct rt2dShadeParameters +{ + RwRGBAReal col; /* col */ + RwV2d uv; /* uv */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rt2ddatatypes + * \struct Rt2dBrush + * Brush object. + * This should be considered an opaque type. + * Use Rt2dBrush API functions to access. + */ +typedef struct Rt2dBrush Rt2dBrush; + +/* + * Rt2dBrush + * structure describing a Brush + */ +#if (!defined(DOXYGEN)) +struct Rt2dBrush +{ + rt2dShadeParameters top; + rt2dShadeParameters dtop; + rt2dShadeParameters bottom; + rt2dShadeParameters dbottom; + RwRGBA colorCache; + RwInt32 flag; + RwTexture *texture; + RpMaterial *material; + RwReal halfwidth; + RwInt32 refCount; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rt2ddatatypes + * \struct Rt2dPath + * Path object. + * This should be considered an opaque type. + * Use Rt2dPath API functions to access. + */ +typedef struct Rt2dPath Rt2dPath; + +/** + * \ingroup rt2ddatatypes + * \struct Rt2dFont + * Font object. + * This should be considered an opaque type. + * Use Rt2dFont API functions to access. + */ +typedef struct Rt2dFont Rt2dFont; + +/* + * typedef used for referencing a spot in a font dictionary + */ +typedef struct _rt2dFontDictionaryNode _rt2dFontDictionaryNode; + + +typedef struct Rt2dBBox Rt2dBBox; +/** +* \ingroup rt2ddatatypes + * \struct Rt2dBBox + * structure describing a Bounding Box + */ +struct Rt2dBBox +{ + RwReal x; /**< x-coordinate of lower-left corner */ + RwReal y; /**< y-coordinate of lower-left corner */ + RwReal w; /**< Width */ + RwReal h; /**< Height */ +}; + +/** + * \ingroup rt2ddatatypes + * \struct Rt2dObject + * Structure describing a 2d Object + * This should be considered an opaque type. + * Use Rt2dObject, Rt2dScene, Rt2dShape, Rt2dPickRegion or Rt2dObjectString + * API functions to access. + */ +typedef struct Rt2dObject Rt2dObject; + +/* + * typedef for a structure describing a scene of shapes (opaque) + */ +typedef struct _rt2dScene _rt2dScene; + +/* + * typedef for a structure describing the depth of an object + */ +typedef struct _rt2dDepthOfObject _rt2dDepthOfObject; + +#if (!defined(DOXYGEN)) +/* + * typedef for a structure describing the depth of an object + */ +struct _rt2dDepthOfObject +{ + Rt2dObject *object; + RwInt32 depth; +}; + +/* + * structure describing a scene of shapes + */ +struct _rt2dScene +{ + RwSList *objects; /* collection of objects in scene */ + RwInt32 objectCount; /* number of objects */ + RwSList *depths; /* depths for depthsort */ + RwBool isDirtyDepths; /* depthsort needs updating */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/* + * typedef for a structure describing a shape (opaque) + */ +typedef struct _rt2dShape _rt2dShape; + +#if (!defined(DOXYGEN)) +typedef struct _rt2dShapeRep _rt2dShapeRep; +struct _rt2dShapeRep +{ + RwSList *nodes; /* individual stroked/filled regions of the shape */ + RwUInt32 refCount; /* number of shapes referencing this rep */ + RpGeometry *geometry; /* Shareable geometry */ +}; + +extern _rt2dShapeRep * +_rt2dShapeRepCreate(RwInt32 nodeCount); + +extern RwBool +_rt2dShapeRepDestroy(_rt2dShapeRep *); + +extern RwUInt32 +_rt2dShapeRepAddRef(_rt2dShapeRep *); + +typedef struct _rt2dSceneResourcePool _rt2dSceneResourcePool; +struct _rt2dSceneResourcePool +{ + _rt2dShapeRep **shapeReps; + RwUInt32 numShapeReps; +}; + +extern RwBool +_rt2dSceneResourcePoolFindShapeRep(const _rt2dSceneResourcePool * pool, + const _rt2dShapeRep * rep, RwInt32 * npIndex); + +struct _rt2dShape +{ + _rt2dShapeRep *rep; + RwRGBA *colorCache; /* Shape's color cache */ + RpAtomic *atomic; /* Atomic repn */ +}; + +/* + * typedef for a structure describing a pick region that can be tested for point inclusion (opaque) + */ +typedef struct _rt2dPickRegion _rt2dPickRegion; + +/* + * structure describing a pick region that can be tested for point inclusion + */ +struct _rt2dPickRegion +{ + Rt2dPath *path; /* path that defines region for testing */ + Rt2dBBox bbox; /* bounding box of path */ + RwMatrix transformation; + /* ivnert transformation used to place the pick region */ +}; + +/* + * structure describing a renderable text string + */ + +struct _rt2dObjectString +{ + RwChar *textString; /* Text string to be rendered */ + Rt2dBrush *brush; /* Brush to be used to draw text */ + RwInt32 maxLength; /* Maximum string length before reallocation, excluding null */ + RwReal height; /* Font rendering Height */ + _rt2dFontDictionaryNode *font; /* Dictionary node identifying font to be used */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/* + * typedef for a renderable string + */ +typedef struct _rt2dObjectString _rt2dObjectString; +/** + * \ingroup rt2ddatatypes + * \ref Rt2dObjectTypeEnum + * enumeration describing types of Rt2dObject + */ +enum Rt2dObjectTypeEnum { + rt2DOBJECTTYPEOBJECT=0, /** +#include "rt2danim.rpe" /* automatically generated header file */ +#include "rt2d.h" +#include "rpcriter.h" +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define RT2D_BUTTON_MAX_STATES 4 +#define RT2D_BUTTON_MAX_STATE_TRANSITIONS 32 + +/* Button state flags. */ + +#define rt2dANIMBUTTONSTATEPICKREGION 0x0001 +#define rt2dANIMBUTTONSTATEUP 0x0002 +#define rt2dANIMBUTTONSTATEDOWN 0x0004 +#define rt2dANIMBUTTONSTATEOVER 0x0008 + +#define rt2dANIMBUTTONSTATEIDLETOOVERUP 0x0010 +#define rt2dANIMBUTTONSTATEOVERUPTOIDLE 0x0020 +#define rt2dANIMBUTTONSTATEOVERUPTOOVERDOWN 0x0040 +#define rt2dANIMBUTTONSTATEOVERDOWNTOOVERUP 0x0080 +#define rt2dANIMBUTTONSTATEOVERDOWNTOOUTDOWN 0x0100 +#define rt2dANIMBUTTONSTATEOUTDOWNTOOVERDOWN 0x0200 +#define rt2dANIMBUTTONSTATEOUTDOWNTOIDLE 0x0400 +#define rt2dANIMBUTTONSTATEIDLETOOVERDOWN 0x0800 +#define rt2dANIMBUTTONSTATEOVERDOWNTOIDLE 0x1000 + + +/* Mask to separate trans state in state flag. */ +#define rt2dANIMBUTTONSTATEMASK \ + (rt2dANIMBUTTONSTATEPICKREGION | \ + rt2dANIMBUTTONSTATEPICKUP | \ + rt2dANIMBUTTONSTATEPICKDOWN | \ + rt2dANIMBUTTONSTATEPICKOVER) + +/* Basic enumerations */ + +/** + * \ingroup rt2dmessage + * \ref Rt2dMessageType, this type represents the different types of + * messages that are available. + */ + +enum Rt2dMessageType +{ + rt2dMESSAGETYPENULL = 0, /**< Empty message. */ + rt2dMESSAGETYPEPLAY, /**< Play animation. */ + rt2dMESSAGETYPESTOP, /**< Stop animation. */ + rt2dMESSAGETYPENEXTFRAME, /**< Advance to next frame. */ + rt2dMESSAGETYPEPREVFRAME, /**< Rewind to previouse frame. */ + rt2dMESSAGETYPEGOTOFRAME, /**< Advance to frame by index. */ + rt2dMESSAGETYPEGOTOLABEL, /**< Advance to frame by label. */ + rt2dMESSAGETYPEGETURL, /**< Get URL */ + rt2dMESSAGETYPEDOACTION, /* Perform action. */ + rt2dMESSAGETYPEFOREIGN, /**< Application specific message. */ + rt2dMESSAGETYPEMOUSEMOVETO, /**< Move mouse. */ + rt2dMESSAGETYPEMOUSEBUTTONSTATE, /**< Mouse button up or down. */ + rt2dMESSAGETYPESPECIALTELLTARGET, /* Change target while queueing */ + rt2dMESSAGETYPEBUTTONBYLABEL, /**< Mouse button transition by label */ + rt2dMESSAGETYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum Rt2dMessageType Rt2dMessageType; + +/** + * \ingroup rt2dstringlabel + * \ref Rt2dStringLabelType, this type represents the different types of + * object that can be labelled in the maestro's label table. + */ + +enum Rt2dStringLabelType +{ + rt2dANIMLABELTYPENONE = 0, + rt2dANIMLABELTYPEANIM, /**< Animation label. */ + rt2dANIMLABELTYPEFRAME, /**< Frame or cel label. */ + rt2dANIMLABELTYPEBUTTON, /**< Button label. */ + rt2dANIMLABELTYPEFOREIGN, /**< Application specific. */ + rt2dANIMLABELTYPESHAPE, /**< Shape label. */ + rt2dANIMLABELTYPEURL, /**< URL label. */ + rt2dANIMLABELTYPEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum Rt2dStringLabelType Rt2dStringLabelType; + +/* Basic animation structures */ + +/** + * \ingroup rt2danimsub + * \struct Rt2dAnimProps + * Structure describing the current state of a scene. + * This should be considered an opaque type. Use the + * Rt2dAnim API functions to access. + */ +typedef struct Rt2dAnimProps Rt2dAnimProps; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameList + * Structure describing an entire list of keyframes + * This should be considered an opaque type. Use the + * Rt2dKeyFrameList API functions to access. + */ +typedef struct Rt2dKeyFrameList Rt2dKeyFrameList; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameSet + * structure describing a set of keyframe actions to be applied to a 2D object. + * This should be considered an opaque type. Use the + * Rt2dAnim API functions to access. + */ +typedef struct Rt2dKeyFrameSet Rt2dKeyFrameSet; + +/** + * \ingroup rt2danimsub + * \struct Rt2dAnimObjectUpdate + * Structure describing an unoptimized update to an object + * This should be considered an opaque type. Use the + * Rt2dAnim API functions to access. + */ +typedef struct Rt2dAnimObjectUpdate Rt2dAnimObjectUpdate; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameTransform + * Structure describing a transform change to a 2d object. + * This should be considered an opaque type. Use the + * Rt2dAnim API functions to access. + */ +typedef struct Rt2dKeyFrameTransform Rt2dKeyFrameTransform; + +/* + * Typedef for struct Rt2dKeyFrameColor describing a color + * change to a 2d object. + */ +typedef struct Rt2dKeyFrameColor Rt2dKeyFrameColor; + +/* + * Structure describing a displayable or depth change to a 2d object. + */ +typedef struct Rt2dKeyFrameShow Rt2dKeyFrameShow; + +/* + * Structure describing a morph change to a 2d object. + */ +typedef struct Rt2dKeyFrameMorph Rt2dKeyFrameMorph; + +/** + * \ingroup rt2danimsub + * \struct Rt2dAnim + * Structure describing a 2d animation. + * This should be considered an opaque type. Use the + * Rt2dAnim API functions to access. + */ +typedef struct Rt2dAnim Rt2dAnim; + +/** + * \ingroup rt2dbutton + * \struct Rt2dButton + * Structure describing a button. + * This should be considered an opaque type. Use the + * Rt2dButton API functions to access. + */ +typedef struct Rt2dButton Rt2dButton; + +/** + * \ingroup rt2dcel + * \struct Rt2dCel + * Structure describing a cel. + * This should be considered an opaque type. Use the + * Rt2dCel API functions to access. + */ +typedef struct Rt2dCel Rt2dCel; + +/** + * \ingroup rt2dcel + * \struct Rt2dCelList + * Structure describing a cel list. + * This should be considered an opaque type. Use the + * Rt2dCel API functions to access. + */ +typedef struct Rt2dCelList Rt2dCelList; + +/** + * \ingroup rt2dmaestro + * \struct Rt2dMaestro + * Structure describing a maestro. + * This should be considered an opaque type. Use the + * Rt2dMaestro API functions to access. + */ +typedef struct Rt2dMaestro Rt2dMaestro; + +/* + * Structure describing a message. + */ +typedef struct Rt2dMessage Rt2dMessage; + +/** + * \ingroup rt2dmessage + * \struct Rt2dMessageList + * Structure describing a message. + * This should be considered an opaque type. Use the + * Rt2dMessage API functions to access. + */ +typedef struct Rt2dMessageList Rt2dMessageList; + +/** + * \ingroup rt2dstringlabel + * \struct Rt2dStringLabel + * Structure used to store and access named data, either internal or user. + * A type and a name may be used to access internal and user data. + * + * This should be considered an opaque type. Use the + * Rt2dStringLabel API functions to access. + */ +typedef struct Rt2dStringLabel Rt2dStringLabel; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrame + * structure describing a transforming action + */ +struct Rt2dKeyFrameTransform +{ + RwMatrix matrix; /**< Transform to be applied */ /*64*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameColor + * Structure describing a color + * change to a 2d object. + */ +struct Rt2dKeyFrameColor +{ + RwRGBAReal color; /**< Color value for a keyframe */ /*16*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameShow + * Structure describing a show/hide change and a depth change to a 2d object. + */ +struct Rt2dKeyFrameShow +{ + RwBool show; /**< visibility flag */ /*4*/ + RwInt32 depth; /**< Depth order (reverse-z) */ /*4*/ + RwUInt8 pad1[8]; /**< Alignment padding */ /*8*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameMorph + * Structure describing a morph change to a 2d object. + */ +struct Rt2dKeyFrameMorph +{ + Rt2dObject *source; /**< start object */ /*4*/ + Rt2dObject *destination; /**< end object */ /*4*/ + RwReal alpha; /**< interpolation value (0.0f-1.0f) */ /*4*/ + RwInt32 pad1; /**< Alignment padding */ /*4*/ +}; + +/** + * \ingroup rt2dmessage + * \struct Rt2dMessage + * Structure describing a message. A message must have a valid message type, (\ref Rt2dMessageType) + * and animation index. The animation index identifies which animation the message applies to. + * A -1 indicates the currently active animation. A message can have none, one or two additional + * \ref RwInt32 parameters, depending on the message type. + */ +struct Rt2dMessage +{ + RwUInt32 messageType; /**< message identifier + (\ref Rt2dMessageType) */ + RwInt32 index; /**< animation to apply any + actions to */ + RwInt32 intParam1; /**< first param (message dependant) */ + RwInt32 intParam2; /**< second param (message dependant) */ +}; + +#define _rt2dMessageGetMessageTypeMacro(_message) \ + ((_message)->messageType); + +#define _rt2dMessageSetMessageTypeMacro(_message, _messageType) \ + ((_message)->messageType = (_messageType)); + +#define _rt2dMessageGetIndexMacro(_message) \ + ((_message)->index); + +#define _rt2dMessageSetIndexMacro(_message, _index) \ + ((_message)->index = (_index)); + +#define _rt2dMessageSetParamMacro(_message, _param1, _param2) \ +MACRO_START \ +{ \ + ((_message)->intParam1 = (_param1)); \ + ((_message)->intParam2 = (_param2)); \ +} \ +MACRO_STOP + +#define _rt2dMessageGetParamMacro(_message, _param1, _param2) \ +MACRO_START \ +{ \ + (*(_param1) = (_message)->intParam1); \ + (*(_param2) = (_message)->intParam2); \ +} \ +MACRO_STOP + +/* + * structure containing label information. The entityType identifies the type + * of the label. The label's name is stored as an index + * in common storage area. The entityType and name of the label are used as keys + * during a search. Additional internal and user data can be stored with the + * label. + */ + +#if (!defined(DOXYGEN)) +struct Rt2dStringLabel +{ + RwUInt32 entityType; /* type of the label + (see Rt2dStringLabelType) */ + RwInt32 nameIndex; /* index of name in internal data + area */ + void *internalData; /* internal data */ + void *userData; /* customizable data */ + +}; + +#endif /* (!defined(DOXYGEN)) */ + +#define _rt2dStringLabelGetStringLabelTypeMacro(_strLabel) \ + ((_strLabel)->entityType) + +#define _rt2dStringLabelSetStringLabelTypeMacro(_strLabel, _entityType) \ + ((_strLabel)->entityType = (_entityType)) + +#define _rt2dStringLabelGetNameIndexMacro(_strLabel) \ + ((_strLabel)->nameIndex) + +#define _rt2dStringLabelSetNameIndexMacro(_strLabel, _index) \ + ((_strLabel)->nameIndex = (_index)) + +#define _rt2dStringLabelGetInternalDataMacro(_strLabel) \ + ((_strLabel)->internalData) + +#define _rt2dStringLabelSetInternalDataMacro(_strLabel, _internalData) \ + ((_strLabel)->internalData = (_internalData)) + +#define _rt2dStringLabelGetUserDataMacro(_strLabel) \ + ((_strLabel)->userData) + +#define _rt2dStringLabelSetUserDataMacro(_strLabel, _userData) \ + ((_strLabel)->userData = (_userData)) + +/* + * structure containing cel information. The name of the cel is stored as an + * index into a label table. The buttons in the cel are stored as indices. These + * reference a list of buttons held by the cel's parent maestro. Any messages + * to be process when the cel is active is stored as index into the parent's + * maestro's message storage area. + */ + +#if (!defined(DOXYGEN)) +struct Rt2dCel +{ + RwInt32 strLabelIndex; /* Frame label */ + RwInt32 celIndex; /* Frame number */ + RwSList *buttonIndices; /* List of buttons active in + this frame */ + RwInt32 messageListIndex; /* Messages to be posted after + displaying this frame */ +}; + +#endif /* (!defined(DOXYGEN)) */ + +#define _rt2dCelGetStringLabelIndexMacro(_cel) \ + ((_cel)->strLabelIndex); + +#define _rt2dCelSetStringLabelIndexMacro(_cel, _index) \ + ((_cel)->strLabelIndex = (_index)); + +#define _rt2dCelGetCelIndexMacro(_cel) \ + ((_cel)->celIndex); + +#define _rt2dCelSetCelIndexMacro(_cel, _index) \ + ((_cel)->celIndex = (_index)); + +#define _rt2dCelGetMessageListIndexMacro(_cel) \ + ((_cel)->messageListIndex); + +#define _rt2dCelSetMessageListIndexMacro(_cel, _index) \ + ((_cel)->messageListIndex = (_index)); + +/* Callback typedefs */ + +typedef Rt2dAnim *(*Rt2dAnimCallBack)(Rt2dAnim *object, + Rt2dAnimProps *props, + void *data); +/** + * \ingroup rt2danimsub + * \ref Rt2dKeyFrameListCallBack + * This typedef defines a callback function to apply to a frame list. + * + * \param anim Pointer to the animation + * \param props Pointer to the props that the animation acts upon + * \param keyframeList The key frame list + * \param keyframeListTime The key frame list time + * \param data User defined data + * + * \return return value is ignored + */ +typedef Rt2dKeyFrameList *(Rt2dKeyFrameListCallBack)( + Rt2dAnim *anim, + Rt2dAnimProps *props, + Rt2dKeyFrameList *keyframeList, + RwReal keyframeListTime, + void *data); + +/** + * \ingroup rt2danimsub + * \ref Rt2dAnimOnEndReachedCallBack + * This typedef defines a callback function called at the end of an animation. + * + * \param anim Pointer to the animation ending + * \param props Pointer to the props that the animation acts upon + * \param remainingDeltaTime Remaining time + * + * \return return value is ignored + */ +typedef Rt2dAnim *(*Rt2dAnimOnEndReachedCallBack)(Rt2dAnim *anim, + Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +/** + * \ingroup rt2dmaestro + * \ref Rt2dMaestroAnimationsCallBack + * \ref Rt2dMaestroAnimationsCallBack represents the function called from + * \ref Rt2dMaestroForAllAnimations for all animations in the maestro. + * This function + * should return the current maestro to indicate success. The callback may + * return NULL to terminate further callbacks on the maestro. + * + * \param maestro Pointer to parent maestro. + * \param anim Pointer to the animation. + * \param props Pointer to the anim's props. + * \param pData Pointer to private data. + * + * \return Pointer to the maestro. + */ + +typedef Rt2dMaestro *(*Rt2dMaestroAnimationsCallBack) + (Rt2dMaestro *maestro, Rt2dAnim *anim, Rt2dAnimProps *props, void * pData); + +/** + * \ingroup rt2dmessage + * \ref Rt2dMessageHandlerCallBack represents the function called from + * \ref Rt2dMaestroProcessMessages for all messages in the maestro's + * process message queue. The maestro does not filter any messages. The + * handler may process or ignore any messages it is given. + * + * This function should return the current message to indicate success. The + * callback may return NULL to terminate further callbacks on the maestro. + * + * \param maestro Pointer to parent maestro. + * \param message Pointer to the message. + * + * \return Pointer to the message. + */ + +typedef Rt2dMessage *(*Rt2dMessageHandlerCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message); + +/* Message streaming call backs. */ + +typedef RwInt32 +(*Rt2dMessageStreamGetSizeCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message); + +typedef Rt2dMessage * +(*Rt2dMessageStreamReadCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message, RwStream *stream); + +typedef Rt2dMessage * +(*Rt2dMessageStreamWriteCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message, RwStream *stream); + +/* + * Data access macros. + */ + +/* + * Toolkit-level initialization / finalization + */ +/* + * INITIALIZE + */ +extern void +Rt2dAnimOpen(void); + +extern void +Rt2dAnimClose(void); + +extern void +Rt2dAnimSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +/* + * Rt2dAnim + */ + +/* General */ + +extern Rt2dAnimOnEndReachedCallBack +Rt2dAnimSetOnEndReachedCallBack(Rt2dAnimOnEndReachedCallBack callback); + +extern Rt2dAnimOnEndReachedCallBack +Rt2dAnimGetOnEndReachedCallBack(void); + + +extern Rt2dAnim * +Rt2dAnimOnEndReachedCallBackLoop(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +extern Rt2dAnim * +Rt2dAnimOnEndReachedCallBackStop(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +extern void +Rt2dMessageQueueSetDefaultSize(RwUInt32 size); + +/* Management */ +extern Rt2dAnim * +Rt2dAnimCreate(void); + +extern RwBool +Rt2dAnimDestroy(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimLock(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimUnlock(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimAddKeyFrameList(Rt2dAnim *anim, + Rt2dKeyFrameList *keyframeList, + RwReal time); + + +extern Rt2dAnim * +Rt2dAnimCopy(Rt2dAnim *srcAnim, Rt2dAnimProps *srcProps); + +/* Streaming */ +extern RwUInt32 +Rt2dAnimStreamGetSize( Rt2dAnim *anim, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamRead(RwStream *stream, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamReadTo(RwStream *dest, + RwStream *stream, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamWrite(Rt2dAnim *anim, RwStream *stream, + Rt2dAnimProps *data); + +/* Playback */ +extern RwBool +Rt2dAnimIsInterpolated(Rt2dAnim *anim); + +extern Rt2dAnim * +Rt2dAnimSetInterpolate(Rt2dAnim *anim, RwBool interpolate); + +extern Rt2dAnim * +Rt2dAnimReset(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimSetDeltaTimeScale(Rt2dAnim *anim, RwReal timeScale); + +extern Rt2dAnim * +Rt2dAnimAddDeltaTime(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal deltaTime); + +extern Rt2dAnim * +Rt2dAnimAddDeltaFrameIndex(Rt2dAnim *anim, Rt2dAnimProps *props, + RwInt32 deltaFrame); + +extern Rt2dAnim * +Rt2dAnimTimeUpdate(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimGotoKeyFrameListByTime(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal time); + +extern Rt2dAnim * +Rt2dAnimGotoKeyFrameListByIndex(Rt2dAnim *anim, Rt2dAnimProps *props, + RwInt32 frameIndex); + +/* Utilities */ +extern Rt2dAnim * +Rt2dAnimForAllKeyFrameLists(Rt2dAnim *anim, Rt2dKeyFrameListCallBack callBack, + Rt2dAnimProps *props, void *data); + +/* Interrogation */ +extern RwInt32 +Rt2dAnimGetNumberOfKeyFrames(Rt2dAnim *anim); + +extern Rt2dKeyFrameList * +Rt2dAnimGetKeyFrameListByIndex(Rt2dAnim *anim, RwUInt32 frameIndex); + +extern RwReal +Rt2dAnimGetCurrentTime(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetFinalKeyFrameListTime(Rt2dAnim *anim); + +extern RwInt32 +Rt2dAnimGetPrevFrameIndex(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetPrevFrameTime(Rt2dAnim *anim); + +extern RwInt32 +Rt2dAnimGetNextFrameIndex(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetNextFrameTime(Rt2dAnim *anim); + +/* KeyFrameList Management */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListCreate(Rt2dAnimProps *props); + +extern RwBool +Rt2dKeyFrameListDestroy(Rt2dKeyFrameList *keyframeList); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListLock(Rt2dKeyFrameList *keyframeList, Rt2dAnimProps *props); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListUnlock(Rt2dKeyFrameList *keyframeList, + Rt2dAnimProps *props); + +extern Rt2dKeyFrameList* +Rt2dKeyFrameListAddUpdateObject(Rt2dKeyFrameList *keyframeList, + Rt2dAnimObjectUpdate *update); + +/* KeyFrameList Streaming */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListStreamRead(RwStream *stream); + +extern RwUInt32 +Rt2dKeyFrameListStreamGetSize(Rt2dKeyFrameList *keyframeList); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListStreamWrite(Rt2dKeyFrameList *keyframeList, + RwStream *stream); + +/* KeyFrameList Playback */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListAdvance(Rt2dKeyFrameList *keyframeList, + Rt2dAnimProps *props); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListApply(Rt2dKeyFrameList *keyframeList, Rt2dAnimProps *props, + RwReal alpha); + +/* KeyFrameList edition object */ +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateCreate(Rt2dObject *object); + +extern RwBool +Rt2dAnimObjectUpdateDestroy(Rt2dAnimObjectUpdate *update); + +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateClear(Rt2dAnimObjectUpdate *update); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetTransform(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameTransform *transform); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetColorOffs(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameColor *colorOffs); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetColorMult(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameColor *colorMult); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetShow(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameShow *show); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetMorph(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameMorph *morph); + +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateSetObject(Rt2dAnimObjectUpdate *update, + Rt2dObject *object); + +/* Props management */ +extern Rt2dAnimProps * +Rt2dAnimPropsCreate(Rt2dObject *scene); + +extern RwBool +Rt2dAnimPropsDestroy(Rt2dAnimProps *props); + +/* + * Rt2dButton + */ + +extern Rt2dMaestro * +Rt2dMaestroAddButton(Rt2dMaestro *maestro, RwInt32 strLabelIdx, RwInt32 objectIdx, + RwUInt32 stateFlag, RwInt32 *actionListIdx, + RwInt32 *index); + +/* + * Rt2dCel & Rt2dCelList + */ + +extern Rt2dCel * +Rt2dCelCreate(Rt2dMaestro *maestro, + const RwChar *name, + RwInt32 celIndex, RwInt32 messageListIndex); + +extern Rt2dCelList * +Rt2dCelListCreate( void ); + +extern RwBool +Rt2dCelDestroy(Rt2dMaestro *maestro, Rt2dCel *cel); + +extern Rt2dCel * +Rt2dCelAddButtonIndex(Rt2dCel * cel, RwInt32 buttonIndex, RwInt32 *index); + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dCelGetStringLabelIndex(_cel) \ + _rt2dCelGetStringLabelIndexMacro((_cel)); + +#define Rt2dCelSetStringLabelIndex(_cel, _index) \ + _rt2dCelSetStringLabelIndexMacro((_cel), (_index)); + +#define Rt2dCelGetCelIndex(_cel) \ + _rt2dCelGetCelIndexMacro((_cel)); + +#define Rt2dCelSetCelIndex(_cel, _index) \ + _rt2dCelSetCelIndexMacro((_cel), (_index)); + +#define Rt2dCelGetMessageListIndex(_cel) \ + _rt2dCelGetMessageListIndexMacro((_cel)); + +#define Rt2dCelSetMessageListIndex(_cel, _index) \ + _rt2dCelSetMessageListIndexMacro((_cel), (_index)); + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwInt32 +Rt2dCelGetStringLabelIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetStringLabelIndex(Rt2dCel *cel, RwInt32 index); + +extern RwInt32 +Rt2dCelGetCelIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetCelIndex(Rt2dCel *cel, RwInt32 index); + +extern RwInt32 +Rt2dCelGetMessageListIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetMessageListIndex(Rt2dCel *cel, RwInt32 index); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwBool +Rt2dCelListDestroy(Rt2dCelList *celList); + +extern Rt2dCelList * +Rt2dCelListLock(Rt2dCelList *celList); + +extern Rt2dCelList * +Rt2dCelListUnlock(Rt2dCelList * celList); + +extern Rt2dCelList * +Rt2dCelListCopy(Rt2dCelList *srcCelList); + +extern Rt2dCelList * +Rt2dCelListAddCel(Rt2dCelList *celList, Rt2dCel *cel, RwInt32 *index); + +extern Rt2dCelList * +Rt2dCelListCelGetStringLabelIndex(Rt2dCelList *celList, RwInt32 celIndex, RwInt32 *index); + +extern Rt2dCelList * +Rt2dCelListCelButtonGetDisplayVersion(Rt2dMaestro *maestro, Rt2dCelList * celList, + RwInt32 celIndex, RwInt32 celButtonIndex, RwInt32 *index); + +/* + * Rt2dMaestro + */ +extern Rt2dMaestro * +Rt2dMaestroCreate(void); + +extern RwBool +Rt2dMaestroDestroy(Rt2dMaestro *maestro); + +extern RwUInt32 +Rt2dMaestroStreamGetSize(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroStreamRead(Rt2dMaestro *maestro, RwStream *stream); + +extern Rt2dMaestro * +Rt2dMaestroStreamWrite(Rt2dMaestro *maestro, RwStream *stream); + +extern Rt2dMaestro * +Rt2dMaestroForAllAnimations(Rt2dMaestro *maestro, + Rt2dMaestroAnimationsCallBack callback, void *data); + +extern Rt2dMaestro * +Rt2dMaestroForAllVisibleAnimations(Rt2dMaestro *maestro, + Rt2dMaestroAnimationsCallBack callback, void *data); + +extern Rt2dMaestro * +Rt2dMaestroAddAnimations(Rt2dMaestro *maestro, + RwInt32 parent, RwInt32 posInParentScene, + Rt2dAnim *anim, Rt2dAnimProps *animProps, Rt2dCelList *celList, + RwInt32 *index); + +extern Rt2dAnim * +Rt2dMaestroGetAnimationsByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dAnimProps * +Rt2dMaestroGetAnimPropsByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroUpdateAnimations(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroAddDeltaTime(Rt2dMaestro *maestro, RwReal deltaTime); + +extern Rt2dMaestro * +Rt2dMaestroLock(Rt2dMaestro * maestro); + +extern Rt2dMaestro * +Rt2dMaestroUnlock(Rt2dMaestro *maestro); + +extern Rt2dObject * +Rt2dMaestroGetScene(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetScene(Rt2dMaestro *maestro, Rt2dObject *scene); + +extern Rt2dObject * +Rt2dMaestroGetAnimSceneByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroRender(Rt2dMaestro *maestro); + +extern Rt2dBBox * +Rt2dMaestroGetBBox(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetBBox(Rt2dMaestro *maestro, Rt2dBBox *bbox); + + +/* + * Message & Message handlers. + */ +extern Rt2dMessageHandlerCallBack +Rt2dMaestroGetMessageHandler(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetMessageHandler(Rt2dMaestro *maestro, Rt2dMessageHandlerCallBack handler); + +extern Rt2dMaestro * +Rt2dMaestroAddMessageList(Rt2dMaestro *maestro, + Rt2dMessage *message, RwInt32 num, RwInt32 *index); + +extern Rt2dMaestro * +Rt2dMaestroPostMessages(Rt2dMaestro *maestro, Rt2dMessage *message, RwInt32 num); + +extern Rt2dMaestro * +Rt2dMaestroProcessMessages(Rt2dMaestro *maestro); + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dMessageGetMessageType(_message) \ + _rt2dMessageGetMessageTypeMacro((_message)); + +#define Rt2dMessageSetMessageTypeMacro(_message, _messageType) \ + _rt2dMessageSetMessageTypeMacro((_message), (_messageType)); + +#define Rt2dMessageGetIndex(_message) \ + _rt2dMessageGetIndexMacro((_message)); + +#define Rt2dMessageSetIndex(_message, _index) \ + _rt2dMessageSetIndexMacro((_message), (_index)); + +#define Rt2dMessageSetParam(_message, _param1, _param2) \ + _rt2dMessageSetParamMacro((_message), (_param1), (_param2)); + +#define Rt2dMessageGetParam(_message, _param1, _param2) \ + _rt2dMessageGetParamMacro((_message), (_param1), (_param2)); + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern Rt2dMessageType +Rt2dMessageGetMessageType(Rt2dMessage *message); + +extern void +Rt2dMessageSetMessageType(Rt2dMessage *message, Rt2dMessageType messageType); + +extern RwInt32 +Rt2dMessageGetIndex(Rt2dMessage *message); + +extern void +Rt2dMessageSetIndex(Rt2dMessage *message, RwInt32 index); + +extern void +Rt2dMessageGetParam(Rt2dMessage *message, RwInt32 *param1, RwInt32 *param2); + +extern void +Rt2dMessageSetParam(Rt2dMessage *message, RwInt32 param1, RwInt32 param2); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* + * Default message handler. + */ +extern Rt2dMessage * +Rt2dMessageHandlerDefaultCallBack(Rt2dMaestro *maestro, Rt2dMessage *message); + + +/* + * Labels. + */ +extern Rt2dStringLabel * +Rt2dMaestroFindStringLabel(Rt2dMaestro *maestro, + Rt2dStringLabelType entityType, const RwChar *lookupName, + RwInt32 *index); + +extern Rt2dStringLabel * +Rt2dMaestroGetStringLabelByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroAddStringLabel(Rt2dMaestro *maestro, + Rt2dStringLabelType entityType, const RwChar *name, + void *internalData, RwInt32 *index); + +extern const RwChar * +Rt2dMaestroGetStringLabelName(Rt2dMaestro *maestro, + Rt2dStringLabel *strLabel); + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dStringLabelGetStringLabelType(_strLabel) \ + _rt2dStringLabelGetStringLabelTypeMacro((_strLabel)) + +#define Rt2dStringLabelSetStringLabelType(_strLabel, _entityType) \ + _rt2dStringLabelSetStringLabelTypeMacro((_strLabel), (_entityType)) + +#define Rt2dStringLabelGetNameIndex(_strLabel) \ + _rt2dStringLabelGetNameIndexMacro((_strLabel)) + +#define Rt2dStringLabelSetNameIndex(_strLabel, _index) \ + _rt2dStringLabelSetNameIndexMacro((_strLabel), (_index)) + +#define Rt2dStringLabelGetInternalData(_strLabel) \ + _rt2dStringLabelGetInternalDataMacro((_strLabel)) + +#define Rt2dStringLabelSetInternalData(_strLabel, _internalData) \ + _rt2dStringLabelSetInternalDataMacro((_strLabel), (_internalData)) + +#define Rt2dStringLabelGetUserData(_strLabel) \ + _rt2dStringLabelGetUserDataMacro((_strLabel)) + +#define Rt2dStringLabelSetUserData(_strLabel, _userData) \ + _rt2dStringLabelSetUserDataMacro((_strLabel), (_userData)) + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern Rt2dStringLabelType +Rt2dStringLabelGetStringLabelType(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetStringLabelType(Rt2dStringLabel *strLabel, + Rt2dStringLabelType entityType); + +extern RwInt32 +Rt2dStringLabelGetNameIndex(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetNameIndex(Rt2dStringLabel *strLabel, RwInt32 index); + +extern void * +Rt2dStringLabelGetInternalData(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetInternalData(Rt2dStringLabel *strLabel, void *internalData); + +extern void * +Rt2dStringLabelGetUserData(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetUserData(Rt2dStringLabel *strLabel, void *userData); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + + + +/* + * Cels & Cel Lists + */ +extern Rt2dCelList * +Rt2dMaestroGetCelListByIndex(Rt2dMaestro *maestro, RwInt32 index); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RT2DANIM_H*/ diff --git a/includes/rwsdk/rt2danim.rpe b/includes/rwsdk/rt2danim.rpe new file mode 100644 index 0000000..26006c1 --- /dev/null +++ b/includes/rwsdk/rt2danim.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_Criterion2DAnim +{ + + + + e_rwdb_Criterion2DAnimLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_Criterion2DAnim e_rwdb_Criterion2DAnim; + + diff --git a/includes/rwsdk/rtanim.h b/includes/rwsdk/rtanim.h new file mode 100644 index 0000000..f26e8a5 --- /dev/null +++ b/includes/rwsdk/rtanim.h @@ -0,0 +1,654 @@ +#ifndef RTANIM_H +#define RTANIM_H + +#include /* automatically generated header file */ + +#define rtANIMSTREAMCURRENTVERSION 0x100 + +/* Doxygen plugin groups. */ + +/** + * \defgroup rtanim RtAnim + * \ingroup animtools + * + * Animation Toolkit for RenderWare Graphics. + */ + +/** + * \ingroup rtanim + * Typedef for struct \ref RtAnimAnimation. + */ +typedef struct RtAnimAnimation RtAnimAnimation; + +/* + * The following CallBacks are needed for each interpolation scheme. + * See RtAnimInterpolatorInfo. + */ + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameApplyCallBack + * defines a callback function for converting + * an interpolated animation keyframe into the required result. + * + * \param result Void pointer to store the output of the conversion. + * \param voidIFrame Void pointer to the keyframe and should be cast + * to the interpolated keyframe type this callback + * is for. + */ +typedef void (*RtAnimKeyFrameApplyCallBack) (void *result, void *voidIFrame); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameBlendCallBack + * defines a callback function for blending between two + * interpolated keyframes by the given blend factor. This is used for + * blending the states of two different \ref RtAnimInterpolator objects. + * The \ref RtAnimKeyFrameInterpolateCallBack is used for interpolating + * actual animation keyframes into an interpolated frame. + * + * \param voidOut Void pointer to store the output of the blend. + * \param voidIn1 Void pointer containing the first input + * interpolated keyframe. + * \param voidIn2 Void pointer containing the second input + * interpolated keyframe. + * \param alpha \ref RwReal containing the blend factor. + */ +typedef void (*RtAnimKeyFrameBlendCallBack) (void *voidOut, void *voidIn1, + void *voidIn2, RwReal alpha); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameInterpolateCallBack + * defines a callback function for interpolating between two + * animation keyframes according to the given time. The output is + * an interpolated frame object residing in an \ref RtAnimInterpolator + * and will usually have the same structure as the keyframe apart from + * the header data (\ref RtAnimInterpFrameHeader). + * + * \param voidOut Void pointer for the output of the interpolation. + * \param voidIn1 Void pointer containing the first input keyframe. + * \param voidIn2 Void pointer containing the second input keyframe. + * \param time \ref RwReal containing the time at which to interpolate. + * \param customData Void pointer to the custom data associated with this + * animation + */ +typedef void (*RtAnimKeyFrameInterpolateCallBack) (void *voidOut, void *voidIn1, + void *voidIn2, RwReal time, + void *customData); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameAddCallBack + * defines a callback function for adding two interpolated + * keyframes together. This is used when adding the states of two + * \ref RtAnimInterpolator objects, such as when adding a delta animation + * to a base animation. + * + * \param voidOut Void pointer for the output interpolated frame. + * \param voidIn1 Void pointer containing the first input + * interpoalted keyframe. + * \param voidIn2 Void pointer containing the second input + * interpolated keyframe. + */ +typedef void (*RtAnimKeyFrameAddCallBack) (void *voidOut, void *voidIn1, + void *voidIn2); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameMulRecipCallBack + * defines a callback function for multiplying a keyframe + * by the inverse of another keyframe. This is used for creating delta + * animations. + * + * \param voidFrame Void pointer for the keyframe to be modified. + * \param voidStart Void pointer for the start keyframe to take the reciprocal of. + */ +typedef void (*RtAnimKeyFrameMulRecipCallBack) + (void *voidFrame, void *voidStart); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameStreamReadCallBack + * defines a callback function for reading in keyframes + * from an \ref RwStream for the given animation. + * + * \param stream Pointer to the \ref RwStream to read the keyframes from. + * \param animation Pointer to the \ref RtAnimAnimation to read the keyframes into. + * + * \return Pointer to the \ref RtAnimAnimation. + */ +typedef RtAnimAnimation * (*RtAnimKeyFrameStreamReadCallBack) + (RwStream *stream, RtAnimAnimation *animation); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameStreamWriteCallBack + * defines a callback function for writing keyframes from the + * given animation to an \ref RwStream. + * + * \param animation Pointer to the \ref RtAnimAnimation to write out from. + * \param stream Pointer to the \ref RwStream to write the keyframes to. + * + * \return \ref RwBool, TRUE if successful. + */ +typedef RwBool (*RtAnimKeyFrameStreamWriteCallBack) + (const RtAnimAnimation *animation, RwStream *stream); + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameStreamGetSizeCallBack + * defines a callback function for calculating the binary stream + * size of keyframe data within an animation. + * + * \param animation Pointer to the \ref RtAnimAnimation to calculate sizes from. + * + * \return \ref RwInt32 containing the size, in bytes, of the keyframe data. + */ +typedef RwInt32 (*RtAnimKeyFrameStreamGetSizeCallBack) + (const RtAnimAnimation *animation); + +/** + * \ingroup rtanim + * \ref RtAnimInterpolatorInfo + * Typedef for struct \ref RtAnimInterpolatorInfo + */ +typedef struct RtAnimInterpolatorInfo RtAnimInterpolatorInfo; + +/** + * \ingroup rtanim + * \struct RtAnimInterpolatorInfo + * This structure is used to hold information for a keyframe interpolation scheme. + * + * \see RtAnimRegisterInterpolationScheme + * \see RtAnimGetInterpolatorInfo + */ +struct RtAnimInterpolatorInfo +{ + RwInt32 typeID; + /**< The ID of the interpolation scheme. */ + RwInt32 interpKeyFrameSize; + /**< Size, in bytes, of the interpolated keyframe structure. */ + RwInt32 animKeyFrameSize; + /**< Size, in bytes, of the animation keyframe structure. */ + RtAnimKeyFrameApplyCallBack keyFrameApplyCB; + /**< Pointer to a function that converts a keyframe to the needed + * format. This function is never called from the \ref rtanim + * toolkit (as the toolit doesn't know the data layout of the + * results) but is stored to ease the creation of overloaded + * interpolators. */ + RtAnimKeyFrameBlendCallBack keyFrameBlendCB; + /**< Pointer to a function that blends between two + * interpolated keyframes, for the purpose of blending + * between the states of two \ref RtAnimInterpolator objects. */ + RtAnimKeyFrameInterpolateCallBack keyFrameInterpolateCB; + /**< Pointer to a function that interpolates between two keyframes + * for a given time in between. */ + RtAnimKeyFrameAddCallBack keyFrameAddCB; + /**< Pointer to a function that adds two interpolated keyframes + * for the purpose of adding the states of two + * \ref RtAnimInterpolator objects. */ + RtAnimKeyFrameMulRecipCallBack keyFrameMulRecipCB; + /**< Pointer to a function that multiplies a keyframe by the + * reciprocal of another. */ + RtAnimKeyFrameStreamReadCallBack keyFrameStreamReadCB; + /**< Pointer to a function that reads the keyframes from a stream + * for a given animation. */ + RtAnimKeyFrameStreamWriteCallBack keyFrameStreamWriteCB; + /**< Pointer to a function that writes the keyframes to a stream for + * a given animation. */ + RtAnimKeyFrameStreamGetSizeCallBack keyFrameStreamGetSizeCB; + /**< Pointer to a function that returns the binary stream size of + * the keyframes for a given animation. */ + RwInt32 customDataSize; + /**< Amount of custom data required per animation. */ +}; + + +/** + * \ingroup rtanim + * \struct RtAnimAnimation + * A keyframed animation consists of an array of keyframe structures, + * along with some flags and a duration. + * + * The keyframes should be presented in the order they are needed + * to animate forwards through time. That is, the next keyframe + * at some point in the sequence should correspond to the node whose + * previous two keyframes are next to expire as an interpolation + * pair. + * + * Put another way, the correct ordering can be achieved by sorting + * an unordered keyframe array using the following primary and secondary + * sort keys: + * + * - time of previous keyframe for node + * - node index + * + * An example is shown in the following diagram, where each vertical bar + * indicates a keyframe point in time. The position of the keyframe + * within the animation sequence is shown by an index to the left of + * each bar. + * + * \verbatim + + t=0 t=duration + node 0 kf0..| kf3.......| kf8....| kf10....| + node 1 kf1..| kf4...| kf6........| kf11....| + node 2 kf2..| kf5.....| kf7..| kf9.........| + + \endverbatim + * + * Each node MUST have an initial keyframe at time = 0.0, and a terminal + * keyframe at time = duration of the animation. + * + * Pointers link all of the keyframes for a particular node backwards + * through time in a list. + * + * \see RtAnimAnimationCreate + */ +struct RtAnimAnimation +{ + RtAnimInterpolatorInfo *interpInfo; + /**< Pointer to interpolation scheme information */ + RwInt32 numFrames; + /**< Number of keyframes in the animation */ + RwInt32 flags; + /**< Specifies details about animation, + * relative translation modes etc. */ + RwReal duration; + /**< Duration of animation in seconds */ + void *pFrames; + /**< Pointer to the animation keyframes */ + void *customData; + /**< Pointer to custom data for this animation */ +}; + +/** + * \ingroup rtanim + * \ref RtAnimKeyFrameHeader + * Typedef for struct RtAnimKeyFrameHeader + */ +typedef struct RtAnimKeyFrameHeader RtAnimKeyFrameHeader; + +/** + * \ingroup rtanim + * \struct RtAnimKeyFrameHeader + * holds header information for a keyframe. All keyframe structures used with + * the overloadable interpolation system should start with this data. + * + * \see RtAnimRegisterInterpolationScheme + */ +struct RtAnimKeyFrameHeader +{ + void *prevFrame; + /**< Previous keyframe for particular hierarchy node */ + RwReal time; + /**< Time at keyframe */ +}; + +/** + * \ingroup rtanim + * \ref RtAnimInterpFrameHeader + * Typedef for struct RtAnimInterpFrameHeader + */ +typedef struct RtAnimInterpFrameHeader RtAnimInterpFrameHeader; + +/** + * \ingroup rtanim + * \struct RtAnimInterpFrameHeader + * is the header for an interpolated animation frame, intermediate + * between a keyframe pair. This structure is intentionally the same size as an + * \ref RtAnimKeyFrameHeader, so that an interpolated frame and key frame data + * block can be otherwise identical. It relies on the + * fact that the prevFrame and time fields of a keyframe header are not + * relevant to an interpolated frame. These fields should therefore not be + * be modified by a custom keyframe interpolator. + * + * \see RtAnimRegisterInterpolationScheme + */ +struct RtAnimInterpFrameHeader +{ + RtAnimKeyFrameHeader *keyFrame1; + /**< Pointer to the first of the current pair of keyframes in + the associated \ref RtAnimAnimation */ + RtAnimKeyFrameHeader *keyFrame2; + /**< Pointer to the second of the current pair of keyframes in + the associated \ref RtAnimAnimation */ +}; + +/** + * \ingroup rtanim + * \ref RtAnimInterpolator + * Typedef for struct \ref RtAnimInterpolator + */ +typedef struct RtAnimInterpolator RtAnimInterpolator; + +/** + * \ingroup rtanim + * \ref RtAnimCallBack + * defines a callback function for use with the + * \ref RtAnimInterpolatorSetAnimCallBack and + * \ref RtAnimInterpolatorSetAnimLoopCallBack functions. + * + * \param animInstance + * A pointer to the \ref RtAnimInterpolator structure. + * + * \param data Void pointer for user-defined data. + * You can use this to pass your own data + * structure(s) to the callback function. + * + * \see RtAnimInterpolatorSetAnimCallBack + * \see RtAnimInterpolatorSetAnimLoopCallBack + * + */ + +typedef RtAnimInterpolator * (*RtAnimCallBack) + (RtAnimInterpolator *animInstance, + void *data); + +/** + * \ingroup rtanim + * \struct RtAnimInterpolator + * holds the current state for a particular instance of an animation, + * corresponding to a specific point in time. + * + * The current interpolated keyframes are stored in an array after the + * end of this structure. For advanced use, these may be accessed + * using the macro rtANIMGETINTERPFRAME(interpolator, nodeIndex) + * which takes a pointer to the interpolator and the node index + * for the interpolated keyframe required. + * + * \see \ref RtAnimInterpolatorCreate + * \see \ref RtAnimInterpolatorDestroy + * \see \ref RtAnimInterpolatorSetCurrentAnim + * \see \ref RtAnimInterpolatorGetCurrentAnim + * \see \ref RtAnimInterpolatorSetKeyFrameCallBacks + * \see \ref RtAnimInterpolatorSetAnimLoopCallBack + * \see \ref RtAnimInterpolatorSetAnimCallBack + * \see \ref RtAnimInterpolatorCopy + * \see \ref RtAnimInterpolatorSubAnimTime + * \see \ref RtAnimInterpolatorAddAnimTime + * \see \ref RtAnimInterpolatorSetCurrentTime + * \see \ref RtAnimCallBack + */ +struct RtAnimInterpolator +{ + RtAnimAnimation *pCurrentAnim; + /**< Current \ref RtAnimAnimation applied */ + RwReal currentTime; + /**< Current animation time */ + void *pNextFrame; + /**< Next animation keyframe to be played */ + RtAnimCallBack pAnimCallBack; + /**< Animation callback function pointer */ + void *pAnimCallBackData; + /**< Animation callback function user data */ + RwReal animCallBackTime; + /**< Trigger time for callback function */ + RtAnimCallBack pAnimLoopCallBack; + /**< Animation loop callback function pointer */ + void *pAnimLoopCallBackData; + /**< Animation loop callback function data */ + RwInt32 maxInterpKeyFrameSize; + /**< Maximum size of interpolated keyframes + * usable on this animation (set at creation + * time) */ + RwInt32 currentInterpKeyFrameSize; + /**< Size of interpolated keyframes in the current + * animation scheme */ + RwInt32 currentAnimKeyFrameSize; + /**< Size of animation keyframes in the current + * animation scheme */ + RwInt32 numNodes; + /**< Number of nodes driven by the animation */ + RwBool isSubInterpolator; + /**< Internal use */ + RwInt32 offsetInParent; + /**< Internal use */ + RtAnimInterpolator *parentAnimation; + /**< Internal use */ + + RtAnimKeyFrameApplyCallBack keyFrameApplyCB; + /**< Internal use */ + RtAnimKeyFrameBlendCallBack keyFrameBlendCB; + /**< Internal use */ + RtAnimKeyFrameInterpolateCallBack keyFrameInterpolateCB; + /**< Internal use */ + RtAnimKeyFrameAddCallBack keyFrameAddCB; + /**< Internal use */ +}; + +/* Access to array of interpolated frames occupying a block of memory + * after the end of the RtAnimInterpolator structure. + */ +#define rtANIMGETINTERPFRAME( anim, nodeIndex ) \ + ( (void *)( ( (RwUInt8 *)&(anim[1]) + \ + ((nodeIndex) * \ + anim->currentInterpKeyFrameSize) ) ) ) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Engine functions */ +extern void +RtAnimAnimationFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwBool +RtAnimInitialize(void); + +extern RwBool +RtAnimRegisterInterpolationScheme(RtAnimInterpolatorInfo *interpolatorInfo); + +extern RtAnimInterpolatorInfo * +RtAnimGetInterpolatorInfo(RwInt32 typeID); + +/* RtAnimAnimation */ +extern RtAnimAnimation * +RtAnimAnimationCreate(RwInt32 typeID, + RwInt32 numFrames, + RwInt32 flags, + RwReal duration); + +extern RwBool +RtAnimAnimationDestroy(RtAnimAnimation *animation); + +extern RtAnimAnimation * +RtAnimAnimationRead(const RwChar * filename); + +extern RwBool +RtAnimAnimationWrite(const RtAnimAnimation *animation, + const RwChar * filename); + +extern RtAnimAnimation * +RtAnimAnimationStreamRead(RwStream *stream); + +extern RwBool +RtAnimAnimationStreamWrite(const RtAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RtAnimAnimationStreamGetSize(const RtAnimAnimation *animation); + +extern RwUInt32 +RtAnimAnimationGetNumNodes(const RtAnimAnimation *animation); + +#ifdef RWDEBUG + +extern RwInt32 +RtAnimAnimationGetTypeID(RtAnimAnimation *animation); + +#else /* RWDEBUG */ + +#define RtAnimAnimationGetTypeID(animation) \ + (animation->interpInfo->typeID) + +#endif /* RWDEBUG */ + +/* RtAnimInterpolator */ +extern RtAnimInterpolator * +RtAnimInterpolatorCreate(RwInt32 numNodes, + RwInt32 maxInterpKeyFrameSize); + +extern void +RtAnimInterpolatorDestroy(RtAnimInterpolator *anim); + +extern RwBool +RtAnimInterpolatorSetCurrentAnim(RtAnimInterpolator *animI, + RtAnimAnimation *anim); + + +#ifdef RWDEBUG + +extern RtAnimAnimation * +RtAnimInterpolatorGetCurrentAnim(RtAnimInterpolator *animI); + +#else /* RWDEBUG */ + +#define RtAnimInterpolatorGetCurrentAnim(animI) \ + ((animI)->pCurrentAnim) + +#endif /* RWDEBUG */ + + +extern RwBool +RtAnimInterpolatorSetKeyFrameCallBacks(RtAnimInterpolator *anim, + RwInt32 keyFrameTypeID); + + +extern void +RtAnimInterpolatorSetAnimLoopCallBack(RtAnimInterpolator *anim, + RtAnimCallBack callBack, + void *data ); + +extern void +RtAnimInterpolatorSetAnimCallBack(RtAnimInterpolator *anim, + RtAnimCallBack callBack, + RwReal time, + void *data ); + +extern RwBool +RtAnimInterpolatorCopy(RtAnimInterpolator *outAnim, + RtAnimInterpolator *inAnim); + +extern RwBool +RtAnimInterpolatorSubAnimTime(RtAnimInterpolator *anim, + RwReal time); + +extern RwBool +RtAnimInterpolatorAddAnimTime(RtAnimInterpolator *anim, + RwReal time); + +extern RwBool +RtAnimInterpolatorSetCurrentTime(RtAnimInterpolator *anim, + RwReal time); + +extern RwBool +RtAnimAnimationMakeDelta(RtAnimAnimation *animation, + RwInt32 numNodes, + RwReal time); + + +extern RwBool +RtAnimInterpolatorBlend(RtAnimInterpolator *outAnim, + RtAnimInterpolator *inAnim1, + RtAnimInterpolator *inAnim2, + RwReal alpha); + +extern RwBool +RtAnimInterpolatorAddTogether(RtAnimInterpolator *outAnim, + RtAnimInterpolator *inAnim1, + RtAnimInterpolator *inAnim2); + +#define RtAnimKeyFrameApplyMacro(anim, out, in) \ +MACRO_START \ +{ \ + (anim)->keyFrameApplyCB((out), (in)); \ +} \ +MACRO_STOP + + +#define RtAnimKeyFrameInterpolateMacro(anim, out, in1, in2, time) \ +MACRO_START \ +{ \ + (anim)->keyFrameInterpolateCB((out), (in1), (in2), (time), (anim->pCurrentAnim->customData)); \ +} \ +MACRO_STOP + +#define RtAnimKeyFrameBlendMacro(anim, out, in1, in2, fAlpha) \ +MACRO_START \ +{ \ + (anim)->keyFrameBlendCB((out), (in1), (in2), (fAlpha)); \ +} \ +MACRO_STOP + +#define RtAnimKeyFrameAddTogetherMacro(anim, out, in1, in2) \ +MACRO_START \ +{ \ + (anim)->keyFrameAddCB((out), (in1), (in2)); \ +} \ +MACRO_STOP + + + +#ifdef RWDEBUG +extern void +RtAnimKeyFrameApply(RtAnimInterpolator *animation, + void *result, void *iFrame); + +extern void +RtAnimKeyFrameInterpolate(RtAnimInterpolator *animation, + void *out, void *in1, + void *in2, RwReal time); + +extern void +RtAnimKeyFrameBlend(RtAnimInterpolator *animation, + void *out, + void *in1, + void *in2, + RwReal alpha); + +extern void +RtAnimKeyFrameAddTogether(RtAnimInterpolator *animation, + void *out, void *in1, void *in2); + +#else /* RWDEBUG */ +#define RtAnimKeyFrameApply(animation, out, in) \ + RtAnimKeyFrameApplyMacro(animation, out, in) + +#define RtAnimKeyFrameInterpolate(animation, out, in1, in2, time) \ + RtAnimKeyFrameInterpolateMacro(animation, out, in1, in2, time) + +#define RtAnimKeyFrameBlend(animation, out, in1, in2, alpha) \ + RtAnimKeyFrameBlendMacro(animation, out, in1, in2, alpha) + +#define RtAnimKeyFrameAddTogether(animation, out, in1, in2) \ + RtAnimKeyFrameAddTogetherMacro(animation, out, in1, in2) + +#endif /* RWDEBUG */ + +extern RtAnimInterpolator * +RtAnimInterpolatorCreateSubInterpolator( + RtAnimInterpolator *parentAnim, + RwInt32 startNode, + RwInt32 numNodes, + RwInt32 maxInterpKeyFrameSize); + +extern RwBool +RtAnimInterpolatorBlendSubInterpolator(RtAnimInterpolator *outAnim, + RtAnimInterpolator *inAnim1, + RtAnimInterpolator *inAnim2, + RwReal alpha); + +extern RwBool +RtAnimInterpolatorAddSubInterpolator(RtAnimInterpolator *outAnim, + RtAnimInterpolator *mainAnim, + RtAnimInterpolator *subAnim); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTANIM_H */ diff --git a/includes/rwsdk/rtanim.rpe b/includes/rwsdk/rtanim.rpe new file mode 100644 index 0000000..87c5ce3 --- /dev/null +++ b/includes/rwsdk/rtanim.rpe @@ -0,0 +1,514 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionAnim +{ + + +E_RT_ANIM_INTERP_IDINUSE, + +E_RT_ANIM_INTERP_BLOCKFULL, + +E_RT_ANIM_INTERP_IDUNKNOWN, + + e_rwdb_CriterionAnimLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionAnim e_rwdb_CriterionAnim; + + diff --git a/includes/rwsdk/rtbary.h b/includes/rwsdk/rtbary.h new file mode 100644 index 0000000..a26133e --- /dev/null +++ b/includes/rwsdk/rtbary.h @@ -0,0 +1,169 @@ +/*************************************************************************** + * * + * Module : rtbary.h * + * * + * Purpose : Barycentric operations * + * * + **************************************************************************/ + +#ifndef RTBARY_H +#define RTBARY_H + +/** + * \defgroup rtbary RtBary + * \ingroup mathtools + * + * Barycentric Toolkit for RenderWare. + */ + + +/**************************************************************************** + Includes + */ + +#include + +#include /* automatically generated header file */ + +#if (!defined(BARY_EPSILON)) +#define BARY_EPSILON (((RwReal)1)/((RwReal)(1<<10))) +#endif /* (!defined(BARY_EPSILON)) */ + +#define WithinEpsilonOfZero(_x, _epsilon) \ + ((-(_epsilon) < (_x)) && ((_x) < (_epsilon))) + +/**************************************************************************** + Global types + */ + +/** + * \ingroup rtbary + * \ref RtBaryV4d + * typedef for the 4 element homogeneous row of a transform matrix mapping + * a point from Cartesian space to the barycentric space defined by a triangle. + */ +typedef RwReal RtBaryV4d[4]; + +/** + * \ingroup rtbary + * \ref RtBaryTransform + * typedef for the 4x4 homogeneous transform matrix mapping a point + * from Cartesian space to the barycentric space defined by a triangle. + */ +typedef RtBaryV4d RtBaryTransform[4]; + +/**************************************************************************** + Defines + */ + +#define RtBaryV3dFromWeightsMacro(_out, _b, _v0, _v1, _v2) \ +MACRO_START \ +{ \ + (_out)->x = (RwReal)( ((_v0)->x * (_b)[0]) + \ + ((_v1)->x * (_b)[1]) + \ + ((_v2)->x * (_b)[2]) ); \ + (_out)->y = (RwReal)( ((_v0)->y * (_b)[0]) + \ + ((_v1)->y * (_b)[1]) + \ + ((_v2)->y * (_b)[2]) ); \ + (_out)->z = (RwReal)( ((_v0)->z * (_b)[0]) + \ + ((_v1)->z * (_b)[1]) + \ + ((_v2)->z * (_b)[2]) ); \ +} \ +MACRO_STOP + +#define RtBaryWeightsFromV3dMacro(_out, _m, _in) \ +MACRO_START \ +{ \ + (_out)[0] = ( (_m)[0][0] * (_in)->x + \ + (_m)[1][0] * (_in)->y + \ + (_m)[2][0] * (_in)->z + \ + (_m)[3][0] ); \ + (_out)[1] = ( (_m)[0][1] * (_in)->x + \ + (_m)[1][1] * (_in)->y + \ + (_m)[2][1] * (_in)->z + \ + (_m)[3][1] ); \ + (_out)[2] = ( (_m)[0][2] * (_in)->x + \ + (_m)[1][2] * (_in)->y + \ + (_m)[2][2] * (_in)->z + \ + (_m)[3][2] ); \ + (_out)[3] = ( (_m)[0][3] * (_in)->x + \ + (_m)[1][3] * (_in)->y + \ + (_m)[2][3] * (_in)->z + \ + (_m)[3][3] ); \ +} \ +MACRO_STOP + +#define RtBaryWeightsFromEdgeMacro(_out, _m, _in) \ +MACRO_START \ +{ \ + (_out)[0] = ( (_m)[0][0] * (_in)->x + \ + (_m)[1][0] * (_in)->y + \ + (_m)[2][0] * (_in)->z ); \ + (_out)[1] = ( (_m)[0][1] * (_in)->x + \ + (_m)[1][1] * (_in)->y + \ + (_m)[2][1] * (_in)->z ); \ + (_out)[2] = ( (_m)[0][2] * (_in)->x + \ + (_m)[1][2] * (_in)->y + \ + (_m)[2][2] * (_in)->z ); \ + (_out)[3] = ( (_m)[0][3] * (_in)->x + \ + (_m)[1][3] * (_in)->y + \ + (_m)[2][3] * (_in)->z ); \ +} \ +MACRO_STOP + + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtBaryV3dFromWeights(_out, _b, _v0, _v1, _v2) \ + RtBaryV3dFromWeightsMacro(_out, _b, _v0, _v1, _v2) + +#define RtBaryWeightsFromV3d(_out, _m, _in) \ + RtBaryWeightsFromV3dMacro(_out, _m, _in) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void +RtBaryNormalize(RtBaryTransform bary); + +extern RwBool +RtBaryGetTransform(RtBaryTransform m, + RwReal * const area, + const RwV3d * const v0, + const RwV3d * const v1, + const RwV3d * const v2); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtBaryV3dFromWeights(RwV3d * const out, + const RtBaryV4d weights, + const RwV3d * const v0, + const RwV3d * const v1, + const RwV3d * const v2); + +extern void +RtBaryWeightsFromV3d(RtBaryV4d out, + RtBaryTransform mat, + const RwV3d * const in); + +extern void +RtBaryWeightsFromEdge(RtBaryV4d out, + RtBaryTransform mat, + const RwV3d * const in); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTBARY_H */ diff --git a/includes/rwsdk/rtbary.rpe b/includes/rwsdk/rtbary.rpe new file mode 100644 index 0000000..31c5a0e --- /dev/null +++ b/includes/rwsdk/rtbary.rpe @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBary +{ + + + + e_rwdb_CriterionBaryLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBary e_rwdb_CriterionBary; + + diff --git a/includes/rwsdk/rtbezpat.h b/includes/rwsdk/rtbezpat.h new file mode 100644 index 0000000..f25f5ce --- /dev/null +++ b/includes/rwsdk/rtbezpat.h @@ -0,0 +1,396 @@ +/* + * Data structures for rtbezpat toolkit + * Copyright (c) Criterion Software Limited + */ + +#if (!defined(RTBEZPAT_H)) +#define RTBEZPAT_H + +/** + * \defgroup rtbezpatch RtBezPat + * \ingroup mathtools + * + * The Bezier Patch Toolkit is a group of functions that support the way + * RenderWare processes patches. + */ + +typedef struct RtBezierV4d RtBezierV4d; + +/** + * \ingroup rtbezpatch + * \struct RtBezierV4d + * This type represents 4d points and vectors specified by + * the (x, y, z, w) coordinates of a 4d point or + * the (x, y, z, w) components of a 4d vector. + */ +struct RtBezierV4d +{ + RwReal x; + /**< X value */ + RwReal y; + /**< Y value */ + RwReal z; + /**< Z value */ + RwReal w; + /**< W value */ +}; + +/** + * \ingroup rtbezpatch + * \ref RtBezierRow + * typedef for a row of vectors. + * RtBezierRow is an array of 4 vectors + */ +typedef RtBezierV4d RtBezierRow[4]; + +/** + * \ingroup rtbezpatch + * \ref RtBezierMatrix + * typedef for a matrix of 4*4 vectors. + * RtBezierMatrix is an array of 4 rows. + */ +typedef RtBezierRow RtBezierMatrix[4]; + +/* + * Bernstein polynomials; + */ + +#define RtBern03(_u, _cu) ( (_cu) * (_cu) * (_cu) ) +#define RtBern13(_u, _cu) ( 3 * (_u) * (_cu) * (_cu) ) +#define RtBern23(_u, _cu) ( 3 * (_u) * (_u) * (_cu) ) +#define RtBern33(_u, _cu) ( (_u) * (_u) * (_u) ) + +#define RtBezierQuadSample3dMacro(_out, _P, _u, _v) \ +MACRO_START \ +{ \ + const RtBezierV4d * const P0 = &(_P)[0][0]; \ + const RtBezierV4d * const P1 = &(_P)[1][0]; \ + const RtBezierV4d * const P2 = &(_P)[2][0]; \ + const RtBezierV4d * const P3 = &(_P)[3][0]; \ + const RwReal _pu = (_u); \ + const RwReal _cu = ((RwReal)1) - _pu; \ + const RwReal B03u = RtBern03(_pu,_cu); \ + const RwReal B13u = RtBern13(_pu,_cu); \ + const RwReal B23u = RtBern23(_pu,_cu); \ + const RwReal B33u = RtBern33(_pu,_cu); \ + const RwReal _pv = (_v); \ + const RwReal _cv = ((RwReal)1) - _pv; \ + const RwReal B03v = RtBern03(_pv,_cv); \ + const RwReal B13v = RtBern13(_pv,_cv); \ + const RwReal B23v = RtBern23(_pv,_cv); \ + const RwReal B33v = RtBern33(_pv,_cv); \ + RtBezierRow A; \ + \ + A[0].x = B03u*P0[0].x + B13u*P1[0].x + B23u*P2[0].x + B33u*P3[0].x; \ + A[0].y = B03u*P0[0].y + B13u*P1[0].y + B23u*P2[0].y + B33u*P3[0].y; \ + A[0].z = B03u*P0[0].z + B13u*P1[0].z + B23u*P2[0].z + B33u*P3[0].z; \ + A[1].x = B03u*P0[1].x + B13u*P1[1].x + B23u*P2[1].x + B33u*P3[1].x; \ + A[1].y = B03u*P0[1].y + B13u*P1[1].y + B23u*P2[1].y + B33u*P3[1].y; \ + A[1].z = B03u*P0[1].z + B13u*P1[1].z + B23u*P2[1].z + B33u*P3[1].z; \ + A[2].x = B03u*P0[2].x + B13u*P1[2].x + B23u*P2[2].x + B33u*P3[2].x; \ + A[2].y = B03u*P0[2].y + B13u*P1[2].y + B23u*P2[2].y + B33u*P3[2].y; \ + A[2].z = B03u*P0[2].z + B13u*P1[2].z + B23u*P2[2].z + B33u*P3[2].z; \ + A[3].x = B03u*P0[3].x + B13u*P1[3].x + B23u*P2[3].x + B33u*P3[3].x; \ + A[3].y = B03u*P0[3].y + B13u*P1[3].y + B23u*P2[3].y + B33u*P3[3].y; \ + A[3].z = B03u*P0[3].z + B13u*P1[3].z + B23u*P2[3].z + B33u*P3[3].z; \ + \ + (_out)->x = A[0].x*B03v + A[1].x*B13v + A[2].x*B23v + A[3].x*B33v; \ + (_out)->y = A[0].y*B03v + A[1].y*B13v + A[2].y*B23v + A[3].y*B33v; \ + (_out)->z = A[0].z*B03v + A[1].z*B13v + A[2].z*B23v + A[3].z*B33v; \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepU3dMacro(_row) \ +MACRO_START \ +{ \ + (_row)[0].x += (_row)[1].x; \ + (_row)[0].y += (_row)[1].y; \ + (_row)[0].z += (_row)[1].z; \ + \ + (_row)[1].x += (_row)[2].x; \ + (_row)[1].y += (_row)[2].y; \ + (_row)[1].z += (_row)[2].z; \ + \ + (_row)[2].x += (_row)[3].x; \ + (_row)[2].y += (_row)[3].y; \ + (_row)[2].z += (_row)[3].z; \ + \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepU4dMacro(_row) \ +MACRO_START \ +{ \ + (_row)[0].x += (_row)[1].x; \ + (_row)[0].y += (_row)[1].y; \ + (_row)[0].z += (_row)[1].z; \ + (_row)[0].w += (_row)[1].w; \ + \ + (_row)[1].x += (_row)[2].x; \ + (_row)[1].y += (_row)[2].y; \ + (_row)[1].z += (_row)[2].z; \ + (_row)[1].w += (_row)[2].w; \ + \ + (_row)[2].x += (_row)[3].x; \ + (_row)[2].y += (_row)[3].y; \ + (_row)[2].z += (_row)[3].z; \ + (_row)[2].w += (_row)[3].w; \ + \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepV3dMacro(_mat) \ +MACRO_START \ +{ \ + RtBezierV4d * const m0 = &(_mat)[0][0]; \ + RtBezierV4d * const m1 = &(_mat)[1][0]; \ + RtBezierV4d * const m2 = &(_mat)[2][0]; \ + RtBezierV4d * const m3 = &(_mat)[3][0]; \ + \ + /* (_row) 0 */ \ + m0[0].x += m1[0].x; \ + m0[0].y += m1[0].y; \ + m0[0].z += m1[0].z; \ + \ + m0[1].x += m1[1].x; \ + m0[1].y += m1[1].y; \ + m0[1].z += m1[1].z; \ + \ + m0[2].x += m1[2].x; \ + m0[2].y += m1[2].y; \ + m0[2].z += m1[2].z; \ + \ + m0[3].x += m1[3].x; \ + m0[3].y += m1[3].y; \ + m0[3].z += m1[3].z; \ + \ + /* (_row) 1 */ \ + m1[0].x += m2[0].x; \ + m1[0].y += m2[0].y; \ + m1[0].z += m2[0].z; \ + \ + m1[1].x += m2[1].x; \ + m1[1].y += m2[1].y; \ + m1[1].z += m2[1].z; \ + \ + m1[2].x += m2[2].x; \ + m1[2].y += m2[2].y; \ + m1[2].z += m2[2].z; \ + \ + m1[3].x += m2[3].x; \ + m1[3].y += m2[3].y; \ + m1[3].z += m2[3].z; \ + \ + /* (_row) 2 */ \ + m2[0].x += m3[0].x; \ + m2[0].y += m3[0].y; \ + m2[0].z += m3[0].z; \ + \ + m2[1].x += m3[1].x; \ + m2[1].y += m3[1].y; \ + m2[1].z += m3[1].z; \ + \ + m2[2].x += m3[2].x; \ + m2[2].y += m3[2].y; \ + m2[2].z += m3[2].z; \ + \ + m2[3].x += m3[3].x; \ + m2[3].y += m3[3].y; \ + m2[3].z += m3[3].z; \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepV4dMacro(_mat) \ +MACRO_START \ +{ \ + RtBezierV4d * const m0 = &(_mat)[0][0]; \ + RtBezierV4d * const m1 = &(_mat)[1][0]; \ + RtBezierV4d * const m2 = &(_mat)[2][0]; \ + RtBezierV4d * const m3 = &(_mat)[3][0]; \ + \ + /* (_row) 0 */ \ + m0[0].x += m1[0].x; \ + m0[0].y += m1[0].y; \ + m0[0].z += m1[0].z; \ + m0[0].w += m1[0].w; \ + \ + m0[1].x += m1[1].x; \ + m0[1].y += m1[1].y; \ + m0[1].z += m1[1].z; \ + m0[1].w += m1[1].w; \ + \ + m0[2].x += m1[2].x; \ + m0[2].y += m1[2].y; \ + m0[2].z += m1[2].z; \ + m0[2].w += m1[2].w; \ + \ + m0[3].x += m1[3].x; \ + m0[3].y += m1[3].y; \ + m0[3].z += m1[3].z; \ + m0[3].w += m1[3].w; \ + \ + /* (_row) 1 */ \ + m1[0].x += m2[0].x; \ + m1[0].y += m2[0].y; \ + m1[0].z += m2[0].z; \ + m1[0].w += m2[0].w; \ + \ + m1[1].x += m2[1].x; \ + m1[1].y += m2[1].y; \ + m1[1].z += m2[1].z; \ + m1[1].w += m2[1].w; \ + \ + m1[2].x += m2[2].x; \ + m1[2].y += m2[2].y; \ + m1[2].z += m2[2].z; \ + m1[2].w += m2[2].w; \ + \ + m1[3].x += m2[3].x; \ + m1[3].y += m2[3].y; \ + m1[3].z += m2[3].z; \ + m1[3].w += m2[3].w; \ + \ + /* (_row) 2 */ \ + m2[0].x += m3[0].x; \ + m2[0].y += m3[0].y; \ + m2[0].z += m3[0].z; \ + m2[0].w += m3[0].w; \ + \ + m2[1].x += m3[1].x; \ + m2[1].y += m3[1].y; \ + m2[1].z += m3[1].z; \ + m2[1].w += m3[1].w; \ + \ + m2[2].x += m3[2].x; \ + m2[2].y += m3[2].y; \ + m2[2].z += m3[2].z; \ + m2[2].w += m3[2].w; \ + \ + m2[3].x += m3[3].x; \ + m2[3].y += m3[3].y; \ + m2[3].z += m3[3].z; \ + m2[3].w += m3[3].w; \ +} \ +MACRO_STOP + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +extern void +RtBezierQuadControlFit3d(RtBezierMatrix B, + RtBezierMatrix P); + +extern void +RtBezierQuadBernsteinWeight3d(RtBezierMatrix W, + RtBezierMatrix B); + +extern void +RtBezierQuadBernsteinWeight4d(RtBezierMatrix W, + RtBezierMatrix B); + +extern void +RtBezierQuadPointDifference3d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal PointU, + RwReal PointV, + RwReal StepU, + RwReal stepV); + +extern void +RtBezierQuadPointDifference4d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal PointU, + RwReal PointV, + RwReal StepU, + RwReal stepV); + +extern void +RtBezierQuadOriginDifference3d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal stepU, + RwReal setpV); + +extern void +RtBezierQuadOriginDifference4d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal stepU, + RwReal setpV); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtBezierQuadSample3d(RwV3d * out, + RtBezierMatrix B, + RwReal u, + RwReal v); + +extern void RtBezierQuadDifferenceStepU3d(RtBezierRow row); +extern void RtBezierQuadDifferenceStepU4d(RtBezierRow row); + +extern void RtBezierQuadDifferenceStepV3d(RtBezierMatrix mat); +extern void RtBezierQuadDifferenceStepV4d(RtBezierMatrix mat); + + +#else /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#define RtBezierQuadSample3d(_out, _P, _u, _v) \ + RtBezierQuadSample3dMacro(_out, _P, _u, _v) + +#define RtBezierQuadDifferenceStepU3d(_row) \ + RtBezierQuadDifferenceStepU3dMacro(_row) + +#define RtBezierQuadDifferenceStepU4d(_row) \ + RtBezierQuadDifferenceStepU4dMacro(_row) + +#define RtBezierQuadDifferenceStepV3d(_mat) \ + RtBezierQuadDifferenceStepV3dMacro(_mat) + +#define RtBezierQuadDifferenceStepV4d(_mat) \ + RtBezierQuadDifferenceStepV4dMacro(_mat) + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +/* + * + */ + +extern void +RtBezierTriangleControlFit3d(RtBezierMatrix T, RtBezierMatrix P); + +extern void +RtBezierQuadFromTriangle(RtBezierMatrix Q, RtBezierMatrix T); + +extern void +RtBezierQuadTangent(RtBezierMatrix D, + RwReal theta, + RtBezierMatrix P); + +extern void +RtBezierQuadTangentPair(RtBezierMatrix Dt, + RtBezierMatrix Dp, + RwReal theta, + RtBezierMatrix P); + +extern void +RtBezierQuadGetNormals(RtBezierMatrix N, + RtBezierMatrix B); + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) + +extern void +_rtBezierGnuPlot(RtBezierMatrix B, + RwChar * name, + RwChar * title); + +#else /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#define _rtBezierGnuPlot(B, name, title) /* No-op */ + +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* (!defined(RTBEZPAT_H)) */ diff --git a/includes/rwsdk/rtbezpat.rpe b/includes/rwsdk/rtbezpat.rpe new file mode 100644 index 0000000..44732d2 --- /dev/null +++ b/includes/rwsdk/rtbezpat.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBEZPATCH +{ + + + + e_rwdb_CriterionBEZPATCHLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBEZPATCH e_rwdb_CriterionBEZPATCH; + + diff --git a/includes/rwsdk/rtbmp.h b/includes/rwsdk/rtbmp.h new file mode 100644 index 0000000..c3bb5c9 --- /dev/null +++ b/includes/rwsdk/rtbmp.h @@ -0,0 +1,51 @@ + +/*************************************************************************** + * * + * Module : rtBMP.h * + * * + * Purpose : Load BMP format files * + * * + **************************************************************************/ + +#ifndef RTBMP_H +#define RTBMP_H + +/** + * \defgroup rtbmp RtBMP + * \ingroup imageconversiontools + * + * BMP Image Format Toolkit for RenderWare. + * + * See also http://www.daubnet.com/formats/BMP.html + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtbmp.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtBMPImageWrite(RwImage * image, + const RwChar * imageName); +extern RwImage *RtBMPImageRead(const RwChar * imageName); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTBMP_H */ diff --git a/includes/rwsdk/rtbmp.rpe b/includes/rwsdk/rtbmp.rpe new file mode 100644 index 0000000..1d614e3 --- /dev/null +++ b/includes/rwsdk/rtbmp.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBMP +{ + + + + e_rwdb_CriterionBMPLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBMP e_rwdb_CriterionBMP; + + diff --git a/includes/rwsdk/rtcharse.h b/includes/rwsdk/rtcharse.h new file mode 100644 index 0000000..6c7a390 --- /dev/null +++ b/includes/rwsdk/rtcharse.h @@ -0,0 +1,111 @@ +/* + * + * Data structures for the charse toolkit + */ + +/*************************************************************************** + * * + * Module : rtcharse.h * + * * + * Purpose : Charset handling * + * * + **************************************************************************/ + +#ifndef RTCHARSE_H +#define RTCHARSE_H + +/** + * \defgroup rtcharset RtCharset + * \ingroup 2dtools + * + * Character Set/Foot Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include + +/**************************************************************************** + Global Types + */ + +/* RWPUBLIC */ + +typedef struct RtCharsetDesc RtCharsetDesc; + +/** + * \ingroup rtcharset + * \struct RtCharsetDesc + * Holds information about a character set. + */ +struct RtCharsetDesc +{ + RwInt32 width; + /**< Pixel-width of each character. */ + RwInt32 height; + /**< Pixel-height of each character. */ + RwInt32 width_internal; + /**< Pixel-width used internally, this is usually width+1 to add a border */ + RwInt32 height_internal; + /**< Pixel-height used internally, this is usually height+1 to add a border */ + RwInt32 count; + /**< Number of characters in the set. */ + RwInt32 tilewidth; + /**< Width of raster in characters. */ + RwInt32 tileheight; + /**< Height of raster in characters. */ + +}; + +/** + * \ingroup rtcharset + * \ref RtCharset + * typedef for a structure defining a character set (opaque). + * \see RtCharsetCreate + */ +typedef RwRaster RtCharset; + +/* RWPUBLICEND */ + +/**************************************************************************** + Function prototypes + */ + +/* RWPUBLIC */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool RtCharsetOpen(void); +extern void RtCharsetClose(void); + +extern RtCharset *RtCharsetPrint(RtCharset * charSet, + const RwChar * string, + RwInt32 x, RwInt32 y); +extern RtCharset *RtCharsetPrintBuffered(RtCharset * charSet, + const RwChar * string, + RwInt32 x, RwInt32 y, + RwBool hideSpaces); +extern RwBool RtCharsetBufferFlush(void); + +extern RtCharset *RtCharsetSetColors(RtCharset * charSet, + const RwRGBA * foreGround, + const RwRGBA * backGround); +extern RtCharset *RtCharsetGetDesc(RtCharset * charset, + RtCharsetDesc * desc); + +extern RtCharset *RtCharsetCreate(const RwRGBA * foreGround, + const RwRGBA * backGround); +extern RwBool RtCharsetDestroy(RtCharset * charSet); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTCHARSE_H */ diff --git a/includes/rwsdk/rtcharse.rpe b/includes/rwsdk/rtcharse.rpe new file mode 100644 index 0000000..c06317b --- /dev/null +++ b/includes/rwsdk/rtcharse.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionCharset +{ + + + + e_rwdb_CriterionCharsetLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionCharset e_rwdb_CriterionCharset; + + diff --git a/includes/rwsdk/rtcmpkey.h b/includes/rwsdk/rtcmpkey.h new file mode 100644 index 0000000..fe76e48 --- /dev/null +++ b/includes/rwsdk/rtcmpkey.h @@ -0,0 +1,187 @@ +/****************************************** + * * + * RenderWare(TM) Graphics Library * + * * + ******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + +/*************************************************************************** + * * + * Module : rtcmpkey.h * + * * + * Purpose : Hierarchical animation compressed keyframe system * + * * + **************************************************************************/ + +#ifndef RTCMPKEY_H +#define RTCMPKEY_H + + +/**************************************************************************** + Includes + */ + +#include +#include + +#include +#include + +/** + * \defgroup rtcmpkey RtCmpKey + * \ingroup animtools + * + * Keyframe system supporting compressed matrix animation + */ + +#define rtANIMCOMPRESSEDKEYFRAMETYPEID 0x2 + +/* + * typedef for struct RtCompressedKeyFrame. + */ +typedef struct RtCompressedKeyFrame RtCompressedKeyFrame; + +/** + * \ingroup rtcmpkey + * \struct RtCompressedKeyFrame + * A structure representing data for a compressed keyframe. Sequences of + * such keyframes in an \ref RtAnimAnimation defines the animation of each + * node in a hierarchy. + * + * Based on \ref RtAnimKeyFrameHeader. + */ +struct RtCompressedKeyFrame +{ + RtCompressedKeyFrame *prevFrame; /**< Pointer to the previous keyframe */ + RwReal time; /**< Time at keyframe */ + RwUInt16 qx; /**< Compressed rotation quat.imag.x at keyframe */ + RwUInt16 qy; /**< Compressed rotation quat.imag.y at keyframe */ + RwUInt16 qz; /**< Compressed rotation quat.imag.z at keyframe */ + RwUInt16 qr; /**< Compressed rotation quat.real at keyframe */ + RwUInt16 tx; /**< Compressed translation x at keyframe */ + RwUInt16 ty; /**< Compressed translation y at keyframe */ + RwUInt16 tz; /**< Compressed translation z at keyframe */ +}; + +/** + * \ingroup rtcmpkey + * \ref RtCompressedInterpKeyFrame + * typedef for RtCompressedInterpKeyFrame. Matches \ref RpHAnimInterpFrame. + */ +typedef RpHAnimInterpFrame RtCompressedInterpKeyFrame; + +/* + * typedef for struct RtCompressedKeyFrameCustomData. + */ +typedef struct RtCompressedKeyFrameCustomData RtCompressedKeyFrameCustomData; + +/** + * \ingroup rtcmpkey + * \struct RtCompressedKeyFrameCustomData + * A structure representing additional custom data for a compressed animation. + * This data represents offsets and scalars to decompress translation values. + * + */ +struct RtCompressedKeyFrameCustomData +{ + RwV3d offset; /**< Offset to center all translation values around 0,0 */ + RwV3d scalar; /**< Scalar to normalize translation values */ + /* Note: This structure is used for streaming; please take care while + modifying */ +}; + +#if (!defined(DOXYGEN)) + +/* Internal use only */ +typedef union RtCompressedKeyFloatIntTag +{ + float f; + int i; +} RtCompressedKeyFloatInt; + +#endif /* (!defined(DOXYGEN)) */ + +#define RtCompressedKeyFrameDecompressFloat(I, O) \ +do \ +{ \ + RtCompressedKeyFloatInt tmp; \ + tmp.i = (int)((I) & 0x8000)<<16; \ + if ((I) & 0x7fff) \ + { \ + tmp.i |= ((int)((I) & 0x7800)<<12) + 0x38000000; \ + tmp.i |= (int)((I) & 0x07ff)<<12; \ + } \ + (O) = tmp.f; \ +} \ +while(0) + +/*--- Plugin API Functions ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwUInt16 +RtCompressedKeyFrameCompressFloat(RwReal I); + +extern void +RtCompressedKeyFrameApply(void *matrix, void *voidIFrame); + +extern void +RtCompressedKeyFrameInterpolate(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal time, + void *customData); + +extern void +RtCompressedKeyFrameBlend(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal alpha); + +extern RtAnimAnimation * +RtCompressedKeyFrameStreamRead(RwStream *stream, + RtAnimAnimation *animation); + +extern RwBool +RtCompressedKeyFrameStreamWrite(const RtAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RtCompressedKeyFrameStreamGetSize(const RtAnimAnimation *animation); + +extern void +RtCompressedKeyFrameMulRecip(void *voidFrame, void *voidStart); + +extern void +RtCompressedKeyFrameAdd(void *voidOut, + void *voidIn1, + void *voidIn2); + +extern RwBool +RtCompressedKeyFrameRegister(void); + +extern RtAnimAnimation * +RtCompressedKeyConvertFromStdKey(RtAnimAnimation *stdkeyanim); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTCMPKEY_H */ diff --git a/includes/rwsdk/rtcmpkey.rpe b/includes/rwsdk/rtcmpkey.rpe new file mode 100644 index 0000000..71fa7f3 --- /dev/null +++ b/includes/rwsdk/rtcmpkey.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionCmpKey +{ + + + + e_rwdb_CriterionCmpKeyLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionCmpKey e_rwdb_CriterionCmpKey; + + diff --git a/includes/rwsdk/rtdict.h b/includes/rwsdk/rtdict.h new file mode 100644 index 0000000..d9dc900 --- /dev/null +++ b/includes/rwsdk/rtdict.h @@ -0,0 +1,304 @@ +#ifndef RTDICT_H +#define RTDICT_H + +#include /* automatically generated header file */ + +/* Doxygen plugin groups. */ + +/** + * \defgroup rtdict RtDict + * \ingroup dictionarytools + * + * Dictionary Toolkit for RenderWare Graphics. + */ + + +/**************************************************************************** + Includes + */ + +#include + +/* RWPUBLIC */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef _RWDLL +#define RTDICTSCHEMADECLARE(schema) extern __declspec(dllimport) RtDictSchema schema; +#else +#define RTDICTSCHEMADECLARE(schema) extern RtDictSchema schema; +#endif + +/** + * \ingroup rtdict + * Typedef for struct \ref RtDictSchema. + */ +typedef struct RtDictSchema RtDictSchema; + +/** + * \ingroup rtdict + * Typedef for struct \ref RtDict. + */ +typedef struct RtDict RtDict; + +/** + * \ingroup rtdict + * Typedef for dictionary entries + */ +typedef void *RtDictEntryType; + +/** + * \ingroup rtdict + * Typedef for dictionary entries + */ +typedef const void *RtDictEntryConstType; + +/** + * \ingroup rtdict + * The following callbacks are needed for each dictionary schema. + * See \ref RtDictSchema. + * + * + * \ref RtDictEntryAddRefCallBack + * defines a callback function for registering that the caller has a + * reference to a particular entry. + * + * \param Entry the entry of which to increment the reference count + * + * \return The entry + */ +typedef void *(RtDictEntryAddRefCallBack)(RtDictEntryType entry); + +/** + * \ingroup rtdict + * \ref RtDictEntryDestroyCallBack + * defines a callback function for destroying an entry in the dictionary. + * + * \param entry The entry to be destroyed + * + * \return Unused, \ref RwBool to match most RenderWare object destruction + * functions + */ +typedef RwBool (RtDictEntryDestroyCallBack)(RtDictEntryType entry); + +/** + * \ingroup rtdict + * \ref RtDictEntryGetNameCallBack + * defines a callback function to get the name of an entry in the + * dictionary. + * + * \param Entry The entry + * + * \return A pointer to the name + */ +typedef const RwChar *(RtDictEntryGetNameCallBack)(RtDictEntryConstType entry); + +/** + * \ingroup rtdict + * \ref RtDictEntryStreamGetSizeCallBack + * gets the streamable size of an entry in the dictionary. + * + * \param entry The entry + * + * \return The size of the entry when streamed + */ +typedef RwUInt32 (RtDictEntryStreamGetSizeCallBack)(RtDictEntryConstType entry); + +/** + * \ingroup rtdict + * \ref RtDictEntryStreamReadCallBack + * reads a new entry from a stream. This function + * should return a pointer to a freshly allocated and initialized entry, + * with a nominal reference count of 1 (which will be assigned to the + * dictionary). + * + * \param stream The stream to read from + * + * \return A pointer to the new entry on success; NULL on failure. + */ +typedef RtDictEntryType (RtDictEntryStreamReadCallBack)(RwStream *stream); + +/** + * \ingroup rtdict + * \ref RtDictStreamReadCompatibilityCallBack + * enables older dictionaries to be retrofitted to use the new generic + * dictionary code. This callback is for internal use. + * + * \param stream The stream to read from + * + * \return A pointer to the new dictionary on success; NULL on failure. + */ +typedef RtDict *(RtDictStreamReadCompatibilityCallBack)(RwStream *stream); + +/** + * \ingroup rtdict + * \ref RtDictEntryStreamWriteCallBack + * writes an entry of the dictionary to a stream. + * + * \param entry The entry to write + * \param stream The stream to write to + * + * \return The entry on success; NULL on failure. + */ +typedef const RtDictEntryType (RtDictEntryStreamWriteCallBack)(RtDictEntryConstType entry, RwStream *stream); + + +/** + * The following callbacks are used by utility functions that work with dictionaries + * See \ref RtDictSchema and \ref RtDict. + */ + +/** + * \ingroup rtdict + * \ref RtDictCallBack + * is to be applied to each dictionary in a \ref RtDictSchema. + * + * \param dictionary The dictionary to apply the callback to + * \param data User supplied data + * + * \return The dictionary the callback was applied to. + * \see RtDictSchemaForAllDictionaries + */ +typedef RtDict *(RtDictCallBack)(RtDict *dictionary, void *data); + +/** + * \ingroup rtdict + * \ref RtDictEntryCallBack + * is to be applied to each entry in a dictionary. + * + * \param entry The entry to apply the callback to + * \param data User supplied data + * + * \return The entry the callback was applied to. + * \see RtDictForAllEntries + */ +typedef RtDictEntryType (RtDictEntryCallBack)(RtDictEntryType entry, void *data); + +/** + * \ingroup rtdict + * \struct RtDict + * A container of objects; objects which may be obtained by name. A dictionary + * is always created and managed via a schema object, \ref RtDictSchema. + * + * \see RtDictSchema + * \see RtDictSchemaCreateDict + * \see RtDictSchemaStreamReadDict + */ +struct RtDict +{ + RtDictSchema *schema; + /**< The schema that defines the layout of the dictionary. */ + RwSList *entries; + /**< The entries held within the dictionary. */ +}; + +/** + * \ingroup rtdict + * \struct RtDictSchema + * Defines the layout and management functions for a dictionary, or set of + * dictionaries. Maintains a 'current' dictionary for each layout. Provides a + * way of creating, or streaming in, dictionaries. + * + * \see RtDict + */ +struct RtDictSchema +{ + const RwChar *name; + /**< Name of the schema. Handy for debugging. */ + RwUInt32 dictChunkType; + /**< Chunk type of the dictionary in a stream */ + RwUInt32 entryChunkType; + /**< Chunk type of the dictionary entries in a stream */ + RwUInt32 compatibilityVersion; + /**< Used for inner version checking when streaming in dictionaries. If + *< the dictionary's version is less than this, \ref streamReadCompatibilityCB + *< will be used for reading in the contents. */ + RwSList *dictionaries; + /**< List of dictionaries that have been created using this layout */ + RtDict *current; + /**< Current dictionary of this layout type */ + RtDictEntryAddRefCallBack *addRefCB; + /**< Callback used to register that the dictionary has a reference to an entry */ + RtDictEntryDestroyCallBack *destroyCB; + /**< Callback used to register that the dictionary no longer has a reference to an entry */ + RtDictEntryGetNameCallBack *getNameCB; + /**< Callback used to obtain the name of an entry */ + RtDictEntryStreamGetSizeCallBack *streamGetSizeCB; + /**< Callback used to obtain the size of an entry */ + RtDictEntryStreamReadCallBack *streamReadCB; + /**< Callback used to stream in an entry */ + RtDictStreamReadCompatibilityCallBack *streamReadCompatibilityCB; + /**< Callback used to stream in an old version of the dictionary. For internal use; may be set to NULL */ + RtDictEntryStreamWriteCallBack *streamWriteCB; + /**< Callback used to stream out an entry */ +}; + +/* Dictionary schema functions */ +extern RtDictSchema * +RtDictSchemaInit(RtDictSchema *schema); + +extern RwBool +RtDictSchemaDestruct(RtDictSchema *schema); + +extern RtDict * +RtDictSchemaStreamReadDict(RtDictSchema *schema, RwStream *stream); + +extern RtDict * +RtDictSchemaCreateDict(RtDictSchema *schema); + +extern RtDictSchema * +RtDictSchemaAddDict(RtDictSchema *schema, RtDict *dict); + +extern RtDictSchema * +RtDictSchemaRemoveDict(RtDictSchema *schema, RtDict *dict); + +extern RwBool +RtDictSchemaForAllDictionaries(RtDictSchema *schema, RtDictCallBack *callback, RtDictEntryType data); + +extern RtDict * +RtDictSchemaGetCurrentDict(RtDictSchema *schema); + +extern RtDictSchema * +RtDictSchemaSetCurrentDict(RtDictSchema *schema, RtDict *dict); + +/* Dictionary functions */ +extern RwBool +RtDictDestroy(RtDict *dictionary); + +extern RtDictEntryType +RtDictAddEntry(RtDict *dictionary, RtDictEntryType entry); + +extern RtDictEntryType +RtDictFindNamedEntry(RtDict *dictionary, const RwChar *name); + +extern const RtDict * +RtDictForAllEntries(const RtDict *dictionary, RtDictEntryCallBack *callBack, RtDictEntryType data); + +extern RtDict * +RtDictRemoveEntry(RtDict *dictionary, RtDictEntryType entry); + +extern const RtDict * +RtDictStreamWrite(const RtDict *dictionary, RwStream *stream); + +extern RwUInt32 +RtDictStreamGetSize(const RtDict *dictionary); + +/* RWPUBLICEND */ + +/* Stealth */ +extern RtDict * +_rtDictSchemaInitDict(RtDictSchema *schema, RtDict *dictionary); + +extern RwBool +_rtDictDestruct(RtDict *dictionary); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* RTDICT_H */ diff --git a/includes/rwsdk/rtdict.rpe b/includes/rwsdk/rtdict.rpe new file mode 100644 index 0000000..e374fc3 --- /dev/null +++ b/includes/rwsdk/rtdict.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionDICT +{ + + + + e_rwdb_CriterionDICTLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionDICT e_rwdb_CriterionDICT; + + diff --git a/includes/rwsdk/rtfsyst.h b/includes/rwsdk/rtfsyst.h new file mode 100644 index 0000000..f29a0cd --- /dev/null +++ b/includes/rwsdk/rtfsyst.h @@ -0,0 +1,1025 @@ + +#ifndef RTFS_H +#define RTFS_H + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ + +/*---- start: ./rtfsyst.h----*/ +#ifndef RTFSYST_H +#define RTFSYST_H + +/** + * \defgroup rtfsdatatypes Data Types + * \ingroup rtfsyst + * + * RenderWare File System Data Types. + */ +/**************************************************************************** + * File System Header + ***************************************************************************/ +/** + * \ingroup rtfsdatatypes + * \ref RTFS_MAX_NAME_LENGTH is the maximum length of a file system name. The + * file system name passed to any OS specific file system must not exceed + * RTFS_MAX_NAME_LENGTH (please refer to the OS specific documentation for + * more information). + */ +#define RTFS_MAX_NAME_LENGTH 5 /* File system name length */ +#define RTFS_DEFAULTFILEPRIORITY 2 + +/* Verbose Function for debug messages */ +#ifdef RTFSYSVERBOSE +#define RtFileSystemVerboseMessage(f, m) RwDebugSendMessage(rwDEBUGMESSAGE,f,m) +#else +#define RtFileSystemVerboseMessage(f, m) +#endif + +/**************************************************************************** + * Enumerations + */ +/** + * \ingroup rtfsdatatypes + * \ref RtFileAccessFlag + * File Access Flags. + */ +enum RtFileAccessFlag +{ + RTFILE_ACCESS_OPEN_READ = 0x1, /**< Flag specifying that a file will + be opened in read mode. */ + RTFILE_ACCESS_OPEN_WRITE = 0x2, /**< Flag specifying that a file will + be opened in write mode.*/ + RTFILE_ACCESS_OPEN_CREATE = 0x4, /**< Flag specifying that a file will + be created if it does not exist.*/ + RTFILE_ACCESS_OPEN_APPEND = 0x8, /**< Flag specifying that all write + will be appended to the file. */ + RTFILE_ACCESS_OPEN_ASYNC = 0x10, /**< Flag specifying that all write + will be appended to the file. */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFILE_ACCESS_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileAccessFlag RtFileAccessFlag; + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemStatus + * File System Status Codes. + */ +enum RtFileSystemStatus +{ + RTFS_STATUS_NOTREADY = 0x01, /**< The file system is not ready. */ + RTFS_STATUS_READY, /**< The file system is ready to accept + commands. */ + RTFS_STATUS_DOOROPEN, /**< The drive door is detected as being + open. */ + RTFS_STATUS_NOMEDIA, /**< There is no disc in the drive. */ + RTFS_STATUS_WRONGMEDIA, /**< The wrong disc is in the drive. */ + RTFS_STATUS_RETRYING, /**< The filesystem is having problems + completing an operation. */ + RTFS_STATUS_FATAL, /**< Fatal Error */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFS_STATUS_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileSystemStatus RtFileSystemStatus; + +/** + * \ingroup rtfsdatatypes + * \ref RtFileError + * File Error Codes. + */ +enum RtFileError +{ + RTFILE_ERROR_NOERROR = 0x01, /**< The last operation completed + successfully. */ + RTFILE_ERROR_FILESYSTEM, /**< The last operation failed because of a + file system error. */ + RTFILE_ERROR_FILE, /**< The last operation failed because of + an internal error with this file. */ + RTFILE_ERROR_DISKFULL, /**< The last write operation failed + because the disk was full. */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFILE_ERROR_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileError RtFileError; + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemError + * File System Error Codes. + */ +enum RtFileSystemError +{ + RTFS_ERROR_NOERROR = 0x01, /**< No error */ + RTFS_ERROR_TOOMANYFILESYSTEMS, /**< Too many file systems have been + registered (set during file system + initialization). */ + RTFS_ERROR_FILENOTFOUND, /**< File not found error (set during a + file open operation).*/ + RTFS_ERROR_WRITEPROTECTED, /**< Write protected device (set during a + file open operation).*/ + RTFS_ERROR_FILENAMETOOLONG, /**< File name is too long (set during a + file open operation).*/ + RTFS_ERROR_FILESYSTEMNAMEINUSE, /**< The file system name is already in use + (set during file system + initialization). */ + RTFS_ERROR_FILESYSTEMDEVICENAMEREGISTERED, /**< A file system has already + been registered for this + device name */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFS_ERROR_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileSystemError RtFileSystemError; + +/** + * \ingroup rtfsdatatypes + * \ref RtFSFileOperation + * File System Operations. These are passed to the outstanding operation + * callback for each asynchronous operation. + */ +enum RtFSFileOperation +{ + RTFS_FILEOP_NONE = 0x01, /**< There are no outstanding operations. */ + RTFS_FILEOP_OPEN, /**< Notifies an open operation. */ + RTFS_FILEOP_CLOSE, /**< Notifies an close operation. */ + RTFS_FILEOP_SEEK, /**< Notifies a seek operation. */ + RTFS_FILEOP_READ, /**< Notifies a read operation. */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFS_FILEOP_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT + +}; +typedef enum RtFSFileOperation RtFSFileOperation; + + + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSeekMethod + * File System Seek Method. + */ +enum RtFileSeekMethod +{ + RTFILE_POS_BEGIN = 0x01, /**< Seek from the start of the file. */ + RTFILE_POS_CURRENT, /**< Seek from the current file pointer + position. */ + RTFILE_POS_END, /**< Seek from the end of the file. */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFILE_POS_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileSeekMethod RtFileSeekMethod; + +/** + * \ingroup rtfsdatatypes + * \ref RtFileStatus + * File System Status. + */ +enum RtFileStatus +{ + RTFILE_STATUS_CLOSED = 0x01, /**< The file is not in use. */ + RTFILE_STATUS_READY, /**< The file is ready to accept + commands. */ + RTFILE_STATUS_BUSY, /**< The file is performing an operation.*/ + RTFILE_STATUS_ERROR, /**< The last command did not complete + successfully, use GetLastError to + determine the error. However, the + file is ready to accept commands. */ + RTFILE_STATUS_OPENING, /**< The file is in the process of being + opened */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFILE_STATUS_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileStatus RtFileStatus; + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemCallBackCode represents the file system callback codes. + * + * \see RtFileSystemSetCallBack + */ +enum RtFileSystemCallBackCode +{ + RTFS_CALLBACKCODE_FSREGISTER = 0x01, /**< File system registration + callback code. This callback + will be triggered when a file + system is registered + successfully. This typically + happens during a call to + \ref RtFSManagerRegister. */ + RTFS_CALLBACKCODE_FSUNREGISTER, /**< File system unregistration + callback code. This callback + will be triggered when a file + system is unregistered. This + typically happens during a + call to + \ref RtFSManagerUnregister. + */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFS_CALLBACKCODE_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFileSystemCallBackCode RtFileSystemCallBackCode; + +/**************************************************************************** + * Forward declaration (Typedef) + */ +typedef struct RtFileSystem RtFileSystem; +typedef struct RtFile RtFile; + +typedef struct _rtInt64 _rtInt64; + +/** + * \ingroup rtfsdatatypes + * \struct _rtInt64 + * 64-bit type used by compilers that have no 64-bit support. + */ +struct _rtInt64 +{ + RwInt32 low; /**< Low part of the 64-bit number */ + RwInt32 high; /**< High part of the 64-bit number */ +}; + +typedef union RtInt64 RtInt64; + +/** + * \ingroup rtfsdatatypes + * \struct RtInt64 + * 64-bit integer type. + */ +union RtInt64 +{ +#ifdef SKY + RWALIGN(RwInt64 supportValue, 16); /**< Used by compilers with 64-bit support */ + RWALIGN(_rtInt64 noSupportValue, 16);/**< Used by compilers with no 64-bit support*/ +#else /* SKY */ + RwInt64 supportValue; /**< Used by compilers with 64-bit support */ + _rtInt64 noSupportValue;/**< Used by compilers with no 64-bit support*/ +#endif /* SKY */ +}; + +/**************************************************************************** + * Function Pointer Typedefs + */ + +/** + * \ingroup rtfsdatatypes + * \ref RtFileOpenFunc + * represents the function used to open a specific file in a defined file + * system. + * + * \param fs The file system on which this file will be opened. + * \param file The file object used to open the file. + * \param filename Name of the file. + * \param flags Flags used to open the file. + * \return An error if the open operation failed, or RTFS_ERROR_NOERROR on + * success. + */ +typedef RtFileSystemError (*RtFileOpenFunc) ( RtFileSystem *fs, + RtFile *file, + const RwChar *filename, + RwUInt32 flags); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileCloseFunc + * represents the function used to close a specific file in a defined file + * system. + * + * \param file The file object used to open the file. + */ +typedef void (*RtFileCloseFunc) ( RtFile *file ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileReadFunc + * represents the function used to read a file. + * + * \param file The file object used to open the file. + * \param pBuffer The buffer used to read the file. + * \param nBytes The number of bytes to used to read the file. + * \return The number of bytes read. + */ +typedef RwUInt32 (*RtFileReadFunc) ( RtFile *file, + void *pBuffer, + RwUInt32 nBytes ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileWriteFunc + * represents the function used to write to a file. + * + * \param file The file object used to write to the file. + * \param pBuffer The buffer used to read the file to the file. + * \param nBytes The number of bytes used to write to the file. + * \return Returns The number of bytes written to the file. + */ +typedef RwUInt32 (*RtFileWriteFunc) ( RtFile *file, + const void *pBuffer, + RwUInt32 nBytes ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSetPositionFunc + * represents the function used to set the pointer position in a file. + * + * \param file The file object . + * \param nOffset File offset. + * \param fPosition Position to calculate the actual offset from. + * \ref RtFile + * \ref RtFileSeekMethod + * \return The new file position + */ +typedef RtInt64 (*RtFileSetPositionFunc) ( RtFile *file, + RwInt32 nOffset, + RtFileSeekMethod fPosition); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSyncFunc + * represents the function used to determine whether an operation is complete + * (blocking if necessary). + * + * \param file The file object used. + * \param block TRUE if blocking, FALSE otherwise. + * \ref RtFile + * \return The file status + * + * \see RtFileStatus + */ +typedef RtFileStatus (*RtFileSyncFunc) ( RtFile *file, RwBool block ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileAbortFunc + * represents the function used to cancel any outstanding asynchronous + * operation as rapidly as possible. + * + * \param file The file object used. + * \return TRUE if successful, FALSE otherwise. + */ +typedef RwBool (*RtFileAbortFunc) ( RtFile *file ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileEofFunc + * represents the function used to determine whether the file pointer is at the + * end of the file. + * + * \param file The file object used. + * \return TRUE if EOF, FALSE otherwise. + */ +typedef RwBool (*RtFileEofFunc) ( RtFile *file ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetFileFunc + * represents the function used to get a file object from a specific file + * system.

+ * This function must be implemented by any custom file system. + * + * \param fs The file system to get the file from (note that there may. + * be several of the same file systems registered, with different + * names and device names). + * \param index Index from which to get the object. + * \return A pointer to an available RtFile object, NULL otherwise. + */ +typedef RtFile * (*RtFileSystemGetFileFunc) ( RtFileSystem *fs, + RwUInt32 index ); +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetDeviceNameFunc + * represents the function used to get a specific device name from a file + * system.

+ * This function must be implemented by any custom file system. + * + * \param fs The file system to get the file from (note that there may. + * be several of the same file systems registered, with different + * names and device names). + * \return The device name. + */ +typedef RwChar * (*RtFileSystemGetDeviceNameFunc) ( RtFileSystem *fs ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileGetStatusFunc + * returns the status of this file system. This is used in asynchronous mode. + * + * \return The file system status. + */ +typedef RtFileStatus (*RtFileGetStatusFunc) ( RtFile *file ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileExistsFunc + * represents the function used to determine whether a file exists.

+ * This function must be implemented by any custom file system. + * + * \param fs The file system on which to check whether the file + * exists. + * \param fileName Name of the file to check. + * \return TRUE if the file exists, FALSE otherwise + */ +typedef RwBool (*RtFileExistsFunc) ( RtFileSystem *fs, + const RwChar *fileName ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemCloseFunc + * represents the function used to close a file system.
+ * This function must be implemented by any custom file system. + * + * \param fs The file system to close. + */ +typedef void (*RtFileSystemCloseFunc) ( RtFileSystem *fs ); + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemCallBack + * is the generic file system callback function prototype. + * The file system currently allows you to set a callback + * that will be triggered on file system registration and + * unregistration (see \ref RtFileSystemCallBackCode). + * + * \param fsName The file system name. + */ +typedef void (*RtFileSystemCallBack) ( RwChar *fsName ); + +/** + * \ingroup rtfsmdatatypes + * \ref RtFSFileOpCallBack + * represents the generic function prototype for a file system manager + * file operation callback. + * + * \param file File handle. + * \param size File size. + * \param status File status. + * \param fileOp Current outstanding file operation. + * \param data Optional data passed back to the callback. + */ +typedef void (*RtFSFileOpCallBack)( void *file, + RwUInt32 size, + RwUInt32 status, + RtFSFileOperation fileOp, + void *data ); + + +/**************************************************************************** + * Structure Definition + */ + +typedef struct rtFileSystemCallBacks rtFileSystemCallBacks; + +#if !defined(DOXYGEN) + +/* + * rtfsdatatypes + * RtFileSystemCallBacks + * File System Callbacks. + */ +struct rtFileSystemCallBacks +{ + RtFileSystemCallBack registerCallBack; /**< Triggered on successful + file system registration. */ + RtFileSystemCallBack unregisterCallBack; /**< Triggered on successful + file system unregistration.*/ +}; +#endif + +typedef struct RtFileSystemFileFunctionTable RtFileSystemFileFunctionTable; +/** + * \ingroup rtfsdatatypes + * \struct RtFileSystemFileFunctionTable + * The file system function table contains all the file operations a file + * system can perform. + */ +struct RtFileSystemFileFunctionTable +{ + RtFileOpenFunc open; /**< Open method triggered + when opening a file. */ + RtFileCloseFunc close; /**< Close method triggered + when closing a file. */ + RtFileReadFunc read; /**< Read method triggered + when reading from a file.*/ + RtFileWriteFunc write; /**< Write method triggered + when writing to a file. */ + RtFileSetPositionFunc setPosition; /**< SetPosition method + triggered when setting a + file pointer position. */ + RtFileSyncFunc sync; /**< Sync method that must be + called when using an + asynchronous operation.*/ + RtFileAbortFunc abort; /**< Abort method called when + an operation needs to be + aborted. */ + RtFileEofFunc isEOF; /**< EOF method called when + checking for the end of a + file. */ + RtFileGetStatusFunc getStatus; /**< GetStatus triggered when + the current status of a + file needs to be known. */ + RtFileExistsFunc fExists; /**< ANSI-C file system + specific file exists. */ +}; + +/** + * \ingroup rtfsdatatypes + * \struct RtFile + * This is the base file object used by the file system. + */ +struct RtFile +{ + RtInt64 length; /**< The length of this file.*/ + RtInt64 position; /**< The file pointer + position.*/ + RtInt64 initialPos ;/**< File position before a + read. Internal use.*/ + + RwBool isAsync; /**< Has this file been + opened in asynchronous + mode (TRUE if yes, + FALSE otherwise). */ + RwInt32 priority; /**< The file priority. */ + RtFileStatus status; /**< The current status of + this file. */ + RtFileError error; /**< The error code + corresponding to a + possible error that + occured on this file. */ + RtFSFileOperation outstandingFileOp; /**< This is the current + asynchronous operation + being executed. */ + RwUInt32 outstandingSize; /**< Size passed back to + the outstanding + callback */ + RtFSFileOpCallBack outstandingCB; /**< Callback triggered + when the outstanding + operation completes.*/ + void *oustandingCBData; /**< Data passed back to + the outstanding + callback */ + RtFileSystem *fileSystem; /**< The file system this file + belongs to. */ +}; + +/** + * \ingroup rtfsdatatypes + * \struct RtFileSystem + * This is the generic file system object. Each file system is handled by the + * file system manager. + */ +struct RtFileSystem +{ + RwSLLink *next; /**< Pointer to next file + system in the file + system list. */ + RwInt32 maxNbOpenFiles; /**< Maximum number of + concurrently opened + files. */ + RtFileSystemStatus status; /**< File system status */ + RwChar *deviceName; /**< User defined file + system device name.*/ + RwBool defaultToAsync; /**< If TRUE, default all + operations to asynchronous, + use \ref + RtFileSystemDefaultToAsync + to set this variable. */ + + RtFileSystemGetFileFunc fsGetObject; /**< Get a file object + from this file system + (to be implemented by + each custom file + system). */ + RtFileSystemCloseFunc fsClose; /**< Perform some file + system specific free + operations. */ + RtFileSystemGetDeviceNameFunc fsGetDeviceName; /**< Return the actual + device name, i.e. not + the user defined one + for this file system.*/ + rtFileSystemCallBacks CallBacks; /**< File system callbacks.*/ + RtFileSystemFileFunctionTable fsFileFunc; /**< File system file + function table. */ + RwChar name[RTFS_MAX_NAME_LENGTH];/**< File system + name \see + RTFS_MAX_NAME_LENGTH. */ +}; + +/**************************************************************************** + * Function Prototypes + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern RtFileSystemError +_rtFSInit( RtFileSystem *fs, + RwInt32 maxNbFiles, + RwChar fsName[RTFS_MAX_NAME_LENGTH], + RwChar *deviceName ); + + +extern const RwChar * +_rtGetFileNameFromDeviceName( const RwChar *fileName ); + +extern RwChar * +_rtFSBuildFileName( RwChar *buffer, + RwInt32 bufferLength, + const RwChar *driveName, + const RwChar *filePath, + RwChar separator); + +extern RwBool +_rtFSFileExists( RtFileSystem *fs, const RwChar *fileName ); + +extern RwBool +_rtFSIsEOF( RtFile *file ); + +extern RwBool +RtFileSystemSetCallBack( RtFileSystem *fs, + RtFileSystemCallBackCode cbCode, + RtFileSystemCallBack CallBack ); + +extern RtFileSystemCallBack +RtFileSystemGetCallBack( RtFileSystem *fs, RtFileSystemCallBackCode cbCode ); + +extern void +_rtFileSystemTriggerCallBack( RtFileSystem *fs, RtFileSystemCallBackCode cbCode ); + +extern RtFileSystemError +RtFileSystemSetDeviceName( RtFileSystem *fs, RwChar *deviceName ); + +extern RwChar * +RtFileSystemGetDeviceName( RtFileSystem *fs ); + +extern void +RtFileSystemDefaultToAsync( RtFileSystem *fs, RwBool isAsync ); + +extern RwBool +RtFileSystemIsDefaultedToAsync( RtFileSystem *fs ); + +extern RtFileSystemStatus +RtFileSystemGetStatus( RtFileSystem *fs ); + +extern void +RtFileSystemSetOustandingOpCallback( RtFile *file, + RtFSFileOpCallBack CallBack, + void *CallBackData); + +extern void +rtFSTriggerFileOustandingOpCallback( RtFile *file ); + + +#if (defined(WIN32) || defined(MACOS)) +#define _GetPosition(_file) \ + (((RtFile *)_file)->position.noSupportValue.low) +#define _GetSize(_file) \ + (((RtFile *)_file)->length.noSupportValue.low) +#else +#define _GetPosition(_file) \ + (((RtFile *)_file)->position.supportValue) +#define _GetSize(_file) \ + (((RtFile *)_file)->length.supportValue) +#endif + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetFilePosition returns the file position as a RwInt32. + * _file must be a pointer to a valid RtFile. + */ +#define RtFileSystemGetFilePosition(_file) _GetPosition(_file) +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetFileSize returns the file size as a RwInt32. + * _file must be a pointer to a valid RtFile. + */ +#define RtFileSystemGetFileSize(_file) _GetSize(_file) + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetFileLastError returns the last set file error. + * _file must be a pointer to a valid RtFile. + */ +#define RtFileSystemGetFileLastError(_file) (((RtFile *)_file)->error) + +/** + * \ingroup rtfsdatatypes + * \ref RtFileSystemGetFileStatus returns the current file status. + * _file must be a pointer to a valid RtFile. + */ +#define RtFileSystemGetFileStatus(_file) (((RtFile *)_file)->status) + +#ifdef __cplusplus +} +#endif /* cplusplus */ + +#endif /* FSYSTEM_H */ + +/*---- end: ./rtfsyst.h----*/ +/*---- start: ./rtfsmgr.h----*/ + +#define LASTERROR (_rtGetFSManager()->lastError) +#define RTFSMAN_UNLIMITED_NUM_FS -1 + +/**************************************************************************** + * Typedefs + */ + +/** + * \ingroup rtfsmdfatatypes + * \ref RtFSManagerCallBackCode flags that specify the callback to set + * A RtFSManagerCallBackCode is passed to the \ref RtFSManagerSetCallBack + * function. + * + * \see RtFSManagerSetCallBack + */ +enum RtFSManagerCallBackCode +{ + RTFSM_CALLBACKCODE_ERROR = 0x01, /**< This represents the Callback + that will trigger the error + callback. The file system + manager error callback is + triggered when a file system + manager error occurs. This + generally happen during + registration or when trying to + open a file.*/ + RTFSM_CALLBACKCODE_ERROR_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFSManagerCallBackCode RtFSManagerCallBackCode; + +/** + * \ingroup rtfsmdatatypes + * \ref RtFSManagerError + * File System Manager Error Codes + */ +enum RtFSManagerError +{ + RTFSM_ERROR_NOERROR = 0x01, /**< No file system manager error. */ + RTFSM_ERROR_INSTALL, /**< Install to RenderWare error. */ + RTFSM_ERROR_UNINSTALL, /**< Uninstall from RenderWare error. */ + RTFSM_ERROR_INVALIDFS, /**< Invalid file system specified. */ + RTFSM_ERROR_NOTREGISTRABLE, /**< Can't register the file system. */ + RTFSM_ERROR_NOFS, /**< There is no file system associated + with the file name passed. */ + RTFSM_ERROR_FSNAMEINUSE, /**< The file system name is already in + use. */ + RTFSM_ERROR_TOOMANYOPENFILES, /**< The file system manager has reported + that too many files were opened on + the current file system. */ + /* Ensures sizeof(enum) == sizeof(RwInt32)) */ + RTFSM_ERROR_TYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RtFSManagerError RtFSManagerError; + +/** + * \ingroup rtfsmdatatypes + * \ref RtFSManagerCallBack + * represents the generic function prototype for a file system manager + * callback.
+ * + * \param err Error code specifying the error that occured. + */ +typedef void (*RtFSManagerCallBack) ( RtFSManagerError err ); + +typedef struct FSManagerCallBacks FSManagerCallBacks; + +#if !defined(DOXYGEN) +/* + * RtFSManagerCallBacks + * File system manager callbacks. + */ +struct FSManagerCallBacks +{ + RtFSManagerCallBack errorCallBack; /* A file system manager error + occured. */ +}; + +typedef struct RtFSManager RtFSManager; + + +/* + * Generic File system manager object. + * This file system allows for an arbitrary or set number of file systems. + * This is deterrmined by the maxNbFS parameter passed to RtFSManagerOpen. + */ +struct RtFSManager +{ + RwSingleList fs; /**< Single link list containing the + file systems this manager is + managing */ + RwInt32 maxNbFS; /**< Maximum number of file systems + this manager can manage */ + RwInt32 curNbFS; /**< Current number of file systems + this manager is managing */ + RwBool isOpened; /**< Specify whether the file system + manager is opened or not. */ + RtFSManagerError lastError; /**< Last error */ + FSManagerCallBacks CallBacks; /**< File system manager callbacks */ +}; +#endif +/**************************************************************************** + * Function Prototypes + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void * +RwFopen( const RwChar * name, + const RwChar * access); + +extern RwInt32 +RwFclose(void *fptr); + +extern size_t +RwFread( void *addr, + size_t size, + size_t count, + void *fptr); + +extern size_t +RwFwrite( const void *addr, size_t size, size_t count, void *fptr); + +extern RwInt32 +RwFseek( void *fptr, + long offset, + RwInt32 origin); + +extern RwChar * +RwFgets( RwChar *buffer, RwInt32 maxLen, void *fptr); + +extern RwInt32 +RwFputs( const RwChar * buffer, void *fptr ); + +extern RwInt32 +RwFeof( void *fptr ); + +extern RwBool +RwFexist( const RwChar * name ); + +extern RwInt32 +RwFtell( void *fptr ); + +extern RwBool +RwFAsyncCancel( RtFile *fptr ); + +extern RwBool +RtFSManagerOpen( RwInt32 maxNbFS ); + +extern void +RtFSManagerClose( void ); + +extern RwBool +RtFSManagerSetCallBack( RtFSManagerCallBackCode cbCode, + RtFSManagerCallBack CallBack); + +extern RwBool +RtFSManagerRegister( RtFileSystem *fs ); + +extern void +RtFSManagerUnregister( RtFileSystem *fs ); + +extern RtFileSystem * +RtFSManagerGetFileSystemFromName( RwChar *fsName ); + +extern RtFile * +RtFSManagerFOpen( const RwChar *filename, + RtFileAccessFlag access, + RtFSFileOpCallBack CallBack, + void *CallBackData ); + +extern RtFileSystem * +RtFSManagerGetFileSystemFromFileName( const RwChar *fileName ); + +extern void +RtFSManagerSetDefaultFileSystem( RtFileSystem *fs ); + +extern RtFileSystem * +RtFSManagerGetDefaultFileSystem( void ); + +extern void +RtFSManagerSyncAllFilesOnFileSystem( RtFileSystem *fs ); + +extern void +RtFSManagerSyncAllFiles( void ); + +extern RtFSManagerError +RtFSManagerGetLastError( void ); + +extern RwBool +_rtFSManagerIsNewFSRegistrable( void ); + +extern RwBool +_rtFSManagerIsFSNameInUse( RwChar *fsName ); + +extern RtFileSystem * +_rtGetFileSystemFromDeviceName( const RwChar *deviceName ); + +extern RtFile * +_rtFSManagerFOpenOnFS( RtFileSystem *fs, + const RwChar * name, + RtFileAccessFlag access, + RtFSFileOpCallBack CallBack, + void *CallBackData ); + +RtFSManager * +_rtGetFSManager( void ); + +RwUInt32 +TkFSManagerGetValue(RtInt64 value); + +/** + * \ingroup rtfsmdatatypes + * \ref RtFSManagerGetLastError returns the last file system manager error. + */ +#define RtFSManagerGetLastError() LASTERROR + + +#ifdef __cplusplus +} +#endif /* cplusplus */ + +/*---- end: ./rtfsmgr.h----*/ + +/*---- start: ./win/fsystplatform.h----*/ +/*---- start: ./win/rtfswin.h----*/ + +/** + * \defgroup rtfswin Windows + * \ingroup rtfsyst + * + * The Windows file system allows for synchronous and asynchronous file + * operations to be performed. This file system uses a driver internal + * read and write bufferring system. + */ + +/** + * \defgroup rtfswindatatypes Data Types + * \ingroup rtfswin + * + * Windows File System Data Types. + */ +#include + +#define WIN_FS_MAX_PATH_LENGTH 256 +#define WIN_SECTOR_SIZE 512 + +typedef struct RtWinFile RtWinFile; +/** + * \ingroup rtfswindatatypes + * \struct RtWinFile + * File object used by the Windows file system. It describes the current state + * of a specific file on the Windows file system. + */ +struct RtWinFile +{ + RtFile file; /**< Parent \ref RtFile object. */ + HANDLE fp; /**< Windows file handle. */ + OVERLAPPED overlap; /**< Structure for dealing with asynchronous + file loading. */ + HANDLE eventHandle; /**< Event handle for dealing with asynchronous + file loading. */ +}; + +typedef struct RtWinFileSystem RtWinFileSystem; +/** + * \ingroup rtfswindatatypes + * \struct RtWinFileSystem + * This represents the Windows file system. The Windows file system + * contains a number of Windows specific files. This number is specified + * during the initialization (see \ref RtWinFSystemInit). + */ +struct RtWinFileSystem +{ + RtFileSystem wfs; /**< Parent \ref RtFileSystem object. */ + RtWinFile *files; /**< Windows file system files. */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +RtFileSystem * +RtWinFSystemInit( RwInt32 maxNbOpenFiles, RwChar *deviceName, RwChar *fileSystemName ); + +#ifdef __cplusplus +} +#endif /* cplusplus */ + +/*---- end: ./win/rtfswin.h----*/ + +extern CRITICAL_SECTION section; + +#define RTFS_INITIALIZE_INTERRUPT_HANDLING InitializeCriticalSection(§ion) +#define RTFS_DISABLE_INTERRUPT EnterCriticalSection(§ion) +#define RTFS_ENABLE_INTERRUPT LeaveCriticalSection(§ion) +#define RTFS_SHUTDOWN_INTERRUPT_HANDLING DeleteCriticalSection(§ion) + +/*---- end: ./win/fsystplatform.h----*/ + +#endif /* RTFS_H */ + + diff --git a/includes/rwsdk/rtfsyst.rpe b/includes/rwsdk/rtfsyst.rpe new file mode 100644 index 0000000..c33c8a6 --- /dev/null +++ b/includes/rwsdk/rtfsyst.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionFS +{ + + + + e_rwdb_CriterionFSLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionFS e_rwdb_CriterionFS; + + diff --git a/includes/rwsdk/rtgcond.h b/includes/rwsdk/rtgcond.h new file mode 100644 index 0000000..51638fd --- /dev/null +++ b/includes/rwsdk/rtgcond.h @@ -0,0 +1,401 @@ +/* + * File : rtgcond.h + * + * Abstract : Allows geometric (vertex and polygon) and attribute + * (uvs, prelights, etc.) operations in a simple function independent + * manner. + * + * Author: Adam James + * + * Copyright (c) 2002 Criterion Software Ltd. + */ + +#ifndef RTGCOND_H +#define RTGCOND_H + +/**************************************************************************** + Includes + */ +#include "rwcore.h" + +#define GCONDR1TOL 0.0001f /* Geometry within this tolerance is touching */ +#define GCONDZERO 0.005f /* Virtual zero for results of cross products, for example */ + +#if (!defined(DOXYGEN)) + +typedef struct GCondLimits GCondLimits; +struct GCondLimits +{ + RwReal min; + RwReal max; +}; + +typedef struct GCondUVLimits GCondUVLimits; +struct GCondUVLimits +{ + GCondLimits u; + GCondLimits v; +}; + +typedef struct GCondMaterialData GCondMaterialData; +struct GCondMaterialData +{ + GCondUVLimits uvLimits[rwMAXTEXTURECOORDS]; +}; + +#define GCONDGETMATERIALDATA(material) \ + ((GCondMaterialData *) \ + (((RwUInt8 *)material)+ \ + GCondMaterialDataOffset)) + +#define GCONDGETCONSTMATERIALDATA(material) \ + ((const GCondMaterialData *) \ + (((const RwUInt8 *)material)+ \ + GCondMaterialDataOffset)) + +#endif /* (!defined(DOXYGEN)) */ + +/* RWPUBLIC */ + +/** + * \defgroup rtgcond RtGCond + * \ingroup basicgeometry + * + * Geometry Conditioning toolkit for RenderWare Graphics. + */ + +/**************************************************************************** + Global types + */ + +/** + * \ingroup rtgcond + * \ref RtGCondFlag + * + * An enumeration of geometry attribute flags. + */ +typedef enum +{ + rtGCONDNORMALS = 0x01, /** |0-1|1-2|2-3| -> |0 3| + */ + + RwReal polyNormalsThreshold; /**< fractional range which polygons normal area have to fall within to be welded, -1.0f disables the test */ + RwReal polyUVsThreshold; /**< fractional range which polygons uv area have to fall within to be welded, -1.0f disables the test */ + RwReal polyPreLitsThreshold; /**< fractional range which polygons prelit area have to fall within to be welded, -1.0f disables the test */ + + RwInt32 decimationMode; /**< Controls the way edge decimation proceeds, 1 is default, 2 is alternative */ + + RwInt32 decimationPasses; + /**< Determines the number of passes through the geometry looking for + * opportunities to weld polygon pairs + */ + + RwInt32 convexPartitioningMode; + /**< Controls the way polygons are subdivided into triangles. Choose one + * of \ref RtWingEdgePartitioning + */ + +}; + +/** + * \ingroup rtgcond + * \ref RtGCondDestroyVertexUserdataCallBack is the type for the callback function + * for vertex destruction, for example, those welded + * + * \param pUserdata A handle to the userdata + * + * \return TRUE on success, FALSE otherwise + * + * \see RtGCondSetUserdataCallBacks + */ +typedef RwBool (*RtGCondDestroyVertexUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtgcond + * \ref RtGCondCloneVertexUserdataCallBack Callback for vertex + * cloning, for example, on unsharing + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdataSrc A handle to the userdata for the source + * + * \return TRUE on success, FALSE otherwise + * + * \see RtGCondSetUserdataCallBacks + */ +typedef RwBool (*RtGCondCloneVertexUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc); + +/** + * \ingroup rtgcond + * \ref RtGCondInterpVertexUserdataCallBack Callback for vertex + * interpolation, for example, sliver removal + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdata1 A handle to the first source + * \param pUserdata2 A handle to the second source + * \param delta The delta between the two sources + * + * \return TRUE on success, FALSE otherwise + * + * \see RtGCondSetUserdataCallBacks + */ +typedef RwBool (*RtGCondInterpVertexUserdataCallBack)(void **pUserdataDst, + void **pUserdata1, void **pUserdata2, RwReal delta); + +/** + * \ingroup rtgcond + * \ref RtGCondDestroyPolygonUserdataCallBack Callback for polygon + * destruction, for example, zero areas + * + * \param pUserdata A handle to the userdata + * + * \return TRUE on success, FALSE otherwise + * + * \see RtGCondSetUserdataCallBacks + */ +typedef RwBool (*RtGCondDestroyPolygonUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtgcond + * \ref RtGCondSplitPolygonUserdataCallBack Callback for polygon + * division, for example, convex partitioning + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdataSrc A handle to the userdata for the source + * + * \return TRUE on success, FALSE otherwise + * + * \see RtGCondSetUserdataCallBacks + */ +typedef RwBool (*RtGCondSplitPolygonUserdataCallBack)(void **pUserdataDst, + void **pUserdataSrc); + +/* + * typedef for struct \ref RtGCondUserdataCallBacks + */ +typedef struct RtGCondUserdataCallBacks RtGCondUserdataCallBacks; + +/** + * \ingroup rtgcond + * \struct RtGCondUserdataCallBacks + * Collection of callbacks + */ +struct RtGCondUserdataCallBacks +{ + RtGCondCloneVertexUserdataCallBack cloneVertexUserdata; /**< Callback on vertex cloning */ + RtGCondInterpVertexUserdataCallBack interpVertexUserdata; /**< Callback on vertex interpolation */ + RtGCondSplitPolygonUserdataCallBack splitPolygonUserdata; /**< Callback on polygon division */ + RtGCondDestroyVertexUserdataCallBack destroyVertexUserdata; /**< Callback on vertex destruction */ + RtGCondDestroyPolygonUserdataCallBack destroyPolygonUserdata; /**< Callback on polygon destruction */ +}; + +typedef struct RtGCondVertex RtGCondVertex; +/** + * \ingroup rtgcond + * \struct RtGCondVertex + * Holds data for each vertex. + * + */ +struct RtGCondVertex +{ + RwV3d position; /**< World space vertex position */ + RwInt32 index; /**< unique id */ + RwV3d normal; /**< World space vertex normal */ + RwRGBA preLitCol; /**< Prelight color */ + RwInt32 matIndex; /**< Vertex material index */ + RwInt32 *brauxIndices; /**< Internal use only. */ + RwInt32 numBrauxIndices; /**< Internal use only. */ + void *pUserData; /**< Pointer to unspecified per vertex user data */ + RwTexCoords texCoords[rwMAXTEXTURECOORDS]; /**< Vertex texture coordinates */ +}; + +typedef struct RtGCondPolygon RtGCondPolygon; +/** + * \ingroup rtgcond + * \struct RtGCondPolygon + * Holds data for each polygon. + * + */ +struct RtGCondPolygon +{ + RwInt32 id; /**< unique id */ + RwInt32 matIndex; /**< The material index */ + + RwInt32 *indices; /**< contiguous list of vertex indices */ + RwInt32 numIndices; /**< number of vertex indices */ + + void *pUserData; /**< Pointer to unspecified per polygon user data */ + void *pInternalData; /**< Internal use only */ +}; + +typedef struct RtGCondGeometryList RtGCondGeometryList; +/** + * \ingroup rtgcond + * \struct RtGCondGeometryList + * Container for vertices and polygons + * + */ +struct RtGCondGeometryList +{ + RpMaterialList matList; /**< Material list */ + RwInt32 numUVs; /**< Number of UV sets in the geometry */ + + RtGCondVertex *vertices; /**< Vertex list */ + RwInt32 numVertices; /**< Number of vertices in list */ + + RtGCondPolygon *polygons; /**< Polygon list */ + RwInt32 numPolygons; /**< Number of polygons in list */ +}; + +typedef void (*RtGCondGeometryConditioningPipeline) (RtGCondGeometryList *geometryList); +extern RtGCondUserdataCallBacks GCUserDataCallBacks; + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +extern void +RtGCondSetUserdataCallBacks(RtGCondCloneVertexUserdataCallBack + cloneVertexUserdataCB, + RtGCondInterpVertexUserdataCallBack + interpVertexUserdataCB, + RtGCondSplitPolygonUserdataCallBack + splitPolygonUserdataCB, + RtGCondDestroyVertexUserdataCallBack + destroyVertexUserdataCB, + RtGCondDestroyPolygonUserdataCallBack + destroyPolygonUserdataCB); + +extern void RtGCondSetGeometryConditioningPipeline( + RtGCondGeometryConditioningPipeline pipeline); +extern RtGCondGeometryConditioningPipeline + RtGCondGetGeometryConditioningPipeline( void ); +extern void RtGCondApplyGeometryConditioningPipeline(RtGCondGeometryList *geometryList); + +/* Pipeline node functions... */ +extern void RtGCondSnapPipelineNode(RtGCondGeometryList *geometryList, RwReal weldThreshold); +extern void RtGCondSnapUVsPipelineNode(RtGCondGeometryList *geometryList, + RwReal weldThreshold); +extern void RtGCondCullZeroAreaPolygonsPipelineNode(RtGCondGeometryList *geometryList, + RwReal areaThreshold); +extern void RtGCondLimitUVsPipelineNode(RtGCondGeometryList * geometryList, + RwReal limitUVMin, RwReal limitUVMax, + RwBool texelLimits); +extern void RtGCondRemapVerticesPipelineNode(RtGCondGeometryList * geometryList); +extern void RtGCondUnshareVerticesOnMaterialBoundariesPipelineNode( + RtGCondGeometryList* geometryList); +extern RwBool RtGCondUnshareVerticesPipelineNode(RtGCondGeometryList *geometryList); +extern void RtGCondRemoveSliversPipelineNode(RtGCondGeometryList* geometryList); +extern void RtGCondRemoveIdenticalPolygonsPipelineNode(RtGCondGeometryList* geometryList); +extern void RtGCondSortVerticesOnMaterialPipelineNode(RtGCondGeometryList * geometryList); +extern RwInt32 *RtGCondWeldVerticesPipelineNode(RtGCondGeometryList *geometryList, + RwReal weldThreshold, + RwReal normalWeldThreshold, RwReal uvThreshold, + RwReal preLitThreshold, RwBool ignoreTextures, + RwBool remap, RwBool implicit, + RwBool averageAttributes); +extern void RtGCondBuildNormalsPipelineNode(RtGCondGeometryList * geometryList); + +/* Supplied pipelines... */ +extern RwBool RtGCondFixAndFilterGeometryPipeline(RtGCondGeometryList *geometryList); +extern RwBool RtGCondDecimateAndWeldGeometryPipeline(RtGCondGeometryList *geometryList); + +/* Allocation functions. */ +extern RwBool RtGCondAllocateVertices(RtGCondGeometryList* geometryList, RwInt32 num); +extern RwBool RtGCondReallocateVertices(RtGCondGeometryList* geometryList, RwInt32 num); +extern RwBool RtGCondAllocatePolygons(RtGCondGeometryList* geometryList, RwInt32 num); +extern RwBool RtGCondReallocatePolygons(RtGCondGeometryList* geometryList, RwInt32 num); +extern RwBool RtGCondAllocateIndices(RtGCondPolygon* polygon, RwInt32 num); +extern RwBool RtGCondReallocateIndices(RtGCondPolygon* polygon, RwInt32 num); + +/* Parameter functions. */ +extern void RtGCondParametersInit(RtGCondParameters* gcParams); +extern void RtGCondParametersSet(RtGCondParameters* gcParams); +extern RtGCondParameters + *RtGCondParametersGet(void); + +/* Utility functions. */ +extern RwBool RtGCondNormalize(RwV3d* vec); +extern RwReal RtGCondLength(RwV3d* vec); +extern RwReal RtGCondAreaOfPolygon(RtGCondGeometryList* geometryList, + RtGCondPolygon* polygon); +extern void _rtGCondCopyVertexInfo(RtGCondVertex* from, RtGCondVertex* to, RwInt32 index); +extern void RtGCondFreeIndices(RtGCondPolygon* polygon); +extern void RtGCondFreeVertices(RtGCondGeometryList* geometryList); +extern void RtGCondFreePolygons(RtGCondGeometryList* geometryList); +extern void _rtGCondDestroyVertexPolygonReference(RtGCondGeometryList* geometryList); +extern void _rtGCondCreateVertexPolygonReference(RtGCondGeometryList* geometryList, + RwInt32* remapper); +extern RwBool RtGCondColinearVertices(RwV3d* v1, RwV3d* v2, RwV3d* v3, + RwBool strictOrder, RwReal tol); +extern RwBool RtGCondVectorsEqual(RwV3d* v1, RwV3d* v2, RwReal tol); +extern void RtGCondGroundUVs(RtGCondGeometryList * geometryList); + +extern RwBool RtGCondInitialize(void); +extern void RtGCondMaterialGetUVLimits(RpMaterial *mat, RwInt32 uvSet, + RwReal *uMin, RwReal *uMax, + RwReal *vMin, RwReal *vMax); +extern void RtGCondMaterialSetUVLimits(RpMaterial *mat, RwInt32 uvSet, + RwReal uMin, RwReal uMax, + RwReal vMin, RwReal vMax); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define _rtImportBuildSectorGetWeldThresholdPositional() \ + _rtGCondGetWeldThresholdPositional() + +#define _rtImportBuildSectorGetWeldThresholdAngular() \ + _rtGCondGetWeldThresholdAngular() + +#define _rtImportBuildSectorSetWeldThresholdPositional(_componentThreshold) \ + _rtGCondSetWeldThresholdPositional(_componentThreshold) + +#define _rtImportBuildSectorSetWeldThresholdAngular(_cosineThreshold) \ + _rtGCondSetWeldThresholdAngular(_cosineThreshold) + +#endif /* RTGCOND_H */ + +/* RWPUBLICEND */ diff --git a/includes/rwsdk/rtgcond.rpe b/includes/rwsdk/rtgcond.rpe new file mode 100644 index 0000000..2301476 --- /dev/null +++ b/includes/rwsdk/rtgcond.rpe @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionGeomCond +{ + + +E_RW_SECTORDEGENERATE, + +E_RW_SECTORINVNOPOLYGONS, + +E_RW_NOPLANE, + +E_RW_SECTORINVPOLY, + +E_RW_SECTORUSED, + +E_RW_MAXBSPDEPTHEXCEEDED, + + + e_rwdb_CriterionGeomCondLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionGeomCond e_rwdb_CriterionGeomCond; + + diff --git a/includes/rwsdk/rtgncpip.h b/includes/rwsdk/rtgncpip.h new file mode 100644 index 0000000..f1f9411 --- /dev/null +++ b/includes/rwsdk/rtgncpip.h @@ -0,0 +1,247 @@ +/* *INDENT-OFF* */ + +/* RWPUBLIC */ + +/**************************************************************************** + * + * File: rwg/rwsdk/tool/gencpipe/rtgncpip.h + * + * Copyright (C) 2002 Criterion Technologies. + * + * Purpose: Toolkit containing generic C rendering pipeline nodes. + * + ****************************************************************************/ + +#if (!defined(_RTGNCPIP_H)) +#define _RTGNCPIP_H + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/**************************************************************************** + global types + */ + +typedef RpLight *RxLight; + + +/* RGBA Interpolation node structures */ +#if (!defined(DOXYGEN)) +struct NodeRGBAInterpData +{ + RwBool rgbaInterpOn; + RxRenderStateVector state; +}; +#endif /* (!defined(DOXYGEN)) */ + +typedef struct NodeRGBAInterpData NodeRGBAInterpData; + +/* UV Interpolation node structures */ +typedef struct RxNodeUVInterpSettings RxNodeUVInterpSettings; + +/** + * \ingroup rtgencpipe + * \struct RxNodeUVInterpSettings + * structure which is the private data of the UV interpolation + * \ref RxPipelineNode. + */ +struct RxNodeUVInterpSettings +{ + RwBool uvInterpOn; /**< Setting this to FALSE will cause the + node to effectively be skipped. */ + RxRenderStateVector state; /**< Used to overwrite the packet's + renderstate so the renderstate of + each submitted pass of triangles can + be set. */ +}; + +/* Cloning node structures */ +typedef struct RxPacketCacheCluster RxPacketCacheCluster; + +/** + * \ingroup rtgencpipe + * \struct RxPacketCacheCluster + * structure containing a cache of an \ref RxCluster's + * within an \ref RxPacketCache + */ +struct RxPacketCacheCluster +{ + RwUInt32 slot; /**< A \ref RwUInt32 index into the \ref RxPacketCache's + * array of RxPacketCacheCluster's */ + RwUInt16 flags; /**< A cache of the original cluster's flags */ + RwUInt16 stride; /**< A cache of the original cluster's stride */ + void *data; /**< A cache of the original cluster's data */ + RwUInt32 numAlloced; /**< A cache of the original cluster's numAlloced */ + RwUInt32 numUsed; /**< A cache of the original cluster's numUsed */ + RxPipelineCluster *clusterRef; /**< A cache of the original cluster's \ref RxPipelineCluster */ +}; +typedef struct RxPacketCache RxPacketCache; + +/** + * \ingroup rtgencpipe + * \struct RxPacketCache + * structure containing a cache of a \ref RxPacket */ +struct RxPacketCache +{ + RwUInt16 packetFlags; /**< A cache of the original packet's flags */ + RwUInt16 pad[1]; /**< Alignment padding */ + RwUInt32 numClusters; /**< The number of present clusters in the + * original packet when it was cloned */ + RwBool lastCloneDone;/**< Once the cache has been cloned by \ref RxPacketCacheClone + * with (lastClone == TRUE), it should not be used again! */ + RwUInt32 pad2[1]; /**< Alignment padding */ + RxPacketCacheCluster clusters[1]; /**< An array of \ref RxPacketCacheCluster's, + * extending beyond 1 element */ +}; + + +typedef struct RxNodeCloneInitData RxNodeCloneInitData; +/** + * \ingroup rtgencpipe + * \struct RxNodeCloneInitData + * structure with which to initialize + * clone a \ref RxNodeDefinition, + * through \ref RxNodeDefinitionCloneCreate and + * set up cloned \ref RxPipelineNode modes, through + * \ref RxPipelineNodeCloneDefineModes */ +struct RxNodeCloneInitData +{ + RwUInt32 numModes; /**< Specifies the number of modes in + which the node should operate */ + RwUInt32 numOutputs; /**< Specifies the number of outputs of this + Clone node, which is also the maximum + number of outputs to which any one mode + may dispatch packets */ + RwUInt32 *modeSizes; /**< Specifies the number of outputs to which + each mode dispatches packets */ + RwUInt32 **modes; /**< An array of numModes pointers to arrays + (of length numOutputs) specifying the + outputs, in order, to which each mode + should dispatch packets (output zero is + the first output) */ +}; + +/** + * \ingroup rtgencpipe + * \struct RxNodeCloneData + * structure which is the private + * data of Clone nodes \ref RxPipelineNode */ +typedef struct RxNodeCloneData RxNodeCloneData; +struct RxNodeCloneData +{ + RwBool optimized; /**< \ref RwBool specifying whether \ref RxPipelineNodeCloneOptimize + * has been run on this \ref RxPipelineNode yet */ + RwUInt32 currentMode; /**< \ref RwUInt32 The current mode of operation */ + RxNodeCloneInitData *data;/**< A pointer to \ref RxNodeCloneInitData data + * specifying the modes of operation */ +}; + +/**************************************************************************** + global prototypes + */ + +extern RxClusterDefinition RxClLights; /* Uses the RxLight type (see above) */ + + +/********************************************************************************* + + Generic Nodes + + *******************************************************************************/ + +extern RxNodeDefinition *RxNodeDefinitionGetAtomicInstance(void); +extern RxNodeDefinition *RxNodeDefinitionGetClipLine(void); +extern RxNodeDefinition *RxNodeDefinitionGetClipTriangle(void); +extern RxNodeDefinition *RxNodeDefinitionGetWorldSectorEnumerateLights(void); +extern RxNodeDefinition *RxNodeDefinitionGetCullTriangle(void); +extern RxNodeDefinition *RxNodeDefinitionGetFastPathSplitter(void); +extern RxNodeDefinition *RxNodeDefinitionGetImmInstance(void); +extern RxNodeDefinition *RxNodeDefinitionGetImmMangleLineIndices(void); +extern RxNodeDefinition *RxNodeDefinitionGetImmMangleTriangleIndices(void); +extern RxNodeDefinition *RxNodeDefinitionGetImmRenderSetup(void); +extern RxNodeDefinition *RxNodeDefinitionGetImmStash(void); +extern RxNodeDefinition *RxNodeDefinitionGetLight(void); +extern RxNodeDefinition *RxNodeDefinitionGetMaterialScatter(void); +extern RxNodeDefinition *RxNodeDefinitionGetPostLight(void); +extern RxNodeDefinition *RxNodeDefinitionGetPreLight(void); +extern RxNodeDefinition *RxNodeDefinitionGetRGBAInterp(void); +extern RxNodeDefinition *RxNodeDefinitionGetUVInterp(void); +extern RxNodeDefinition *RxNodeDefinitionGetScatter(void); +extern RxNodeDefinition *RxNodeDefinitionGetSubmitLine(void); +extern RxNodeDefinition *RxNodeDefinitionGetSubmitTriangle(void); +extern RxNodeDefinition *RxNodeDefinitionGetTransform(void); +extern RxNodeDefinition *RxNodeDefinitionGetAtomicEnumerateLights(void); +extern RxNodeDefinition *RxNodeDefinitionGetWorldSectorInstance(void); +extern RxNodeDefinition *RxNodeDefinitionCloneCreate(RxNodeCloneInitData *data); +extern RwBool RxPipelineNodeCloneDefineModes( + RxPipeline *pipeline, + RxPipelineNode *node, + RxNodeCloneInitData *data); +extern RwBool RxNodeDefinitionCloneDestroy(RxNodeDefinition *def); +extern RwBool RxPipelineNodeCloneOptimize(RxPipeline *pipeline, + RxPipelineNode *node); + + +/********************************************************************************* + + Generic Core Pipes + + *******************************************************************************/ + + +extern RwBool RtGenCPipeCreateGenericIm3DTransformPipeline(void); +extern void RtGenCPipeDestroyGenericIm3DTransformPipeline(void); +extern RwBool RtGenCPipeCreateGenericIm3DRenderPipelines(void); +extern void RtGenCPipeDestroyGenericIm3DRenderPipelines(void); + +extern RxPipeline *RwIm3DGetGenericTransformPipeline(void); +extern RxPipeline *RwIm3DGetGenericRenderPipeline(RwPrimitiveType primType); + + +/********************************************************************************* + + Generic World Pipes + + *******************************************************************************/ + +extern RwBool RtGenCPipeCreateGenericWorldPipelines(void); +extern void RtGenCPipeDestroyGenericWorldPipelines(void); + +#define RpWorldGetGenericSectorPipelineMacro() \ + (RXPIPELINEGLOBAL(genericWorldSectorPipeline)) + +#define RpAtomicGetGenericPipelineMacro() \ + (RXPIPELINEGLOBAL(genericAtomicPipeline)) + +#define RpMaterialGetGenericPipelineMacro() \ + (RXPIPELINEGLOBAL(genericMaterialPipeline)) + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpWorldGetGenericSectorPipeline RpWorldGetGenericSectorPipelineMacro +#define RpAtomicGetGenericPipeline RpAtomicGetGenericPipelineMacro +#define RpMaterialGetGenericPipeline RpMaterialGetGenericPipelineMacro + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* (!defined(_RTGNCPIP_H)) */ + +/* RWPUBLICEND */ + +/* *INDENT-ON* */ diff --git a/includes/rwsdk/rtgncpip.rpe b/includes/rwsdk/rtgncpip.rpe new file mode 100644 index 0000000..f0746e9 --- /dev/null +++ b/includes/rwsdk/rtgncpip.rpe @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionGENCPIPETOOL +{ + + + + e_rwdb_CriterionGENCPIPETOOLLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionGENCPIPETOOL e_rwdb_CriterionGENCPIPETOOL; + + diff --git a/includes/rwsdk/rtimport.h b/includes/rwsdk/rtimport.h new file mode 100644 index 0000000..484f43f --- /dev/null +++ b/includes/rwsdk/rtimport.h @@ -0,0 +1,1302 @@ +/*************************************************************************** + * * + * Module : rtimport.h * + * * + * Purpose : World handling functions. * + * * + **************************************************************************/ + +#ifndef RTIMPORT_H +#define RTIMPORT_H + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) +#define RWMONITOR(_x) RWMESSAGE(_x) +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#if (!defined(RWMONITOR)) +#define RWMONITOR(_x) /* No op */ +#endif /* (!defined(RWMONITOR)) */ + +/** + * \defgroup rtworldimport RtWorldImport + * \ingroup basicgeometry + * + * World Import Toolkit for RenderWare. + */ + +/** + * \defgroup selectors RtWorldImportPartitionSelectors + * \ingroup rtworldimport + * + * The set of provided RtWorldImportPartitionSelectors: + * Selects a good partition by calling one of the + * \ref iterators and then + * one of the \ref evaluators to + * see which is best. + */ + +/** + * \defgroup iterators RtWorldImportPartitionIterators + * \ingroup rtworldimport + * + * The set of provided RtWorldImportPartitionIterators: + * Iterates through a set of candidate partitions, possibly + * using the geometric information in the build sector, or perhaps + * using some other criteria. + */ + +/** + * \defgroup evaluators RtWorldImportPartitionEvaluators + * \ingroup rtworldimport + * + * The set of provided RtWorldImportPartitionEvaluators: + * Uses a combination of statistics, build sector, build status, and + * possibly other criteria to evaluate a partition. While the value + * returned can be any real value, all provided evaluators are return + * lower values for better partitioners, and are in the range [0..1] + * where appropriate + */ + +/** + * \defgroup terminators RtWorldImportPartitionTerminators + * \ingroup rtworldimport + * + * The set of provided RtWorldImportPartitionTerminators: + * Checks given criteria about the statistics, build sector, build status, and + * possibly other criteria to see whether the building process should be + * allowed to terminate, or whether more parititoning is necessary. + */ + +/** + * \defgroup kd RtWorldImportGuideKD + * \ingroup rtworldimport + * + * Tools to manipulate the \ref RtWorldImportGuideKDTree that is used to + * manually build the sectors of a world. + */ + +/** + * \defgroup hints RtWorldImportHints + * \ingroup rtworldimport + * + * Tools to aid the build process by giving hints as to what geometry should + * not be split, and what geometry makes for a good partitioning guide. + */ + +/**************************************************************************** + Includes + */ +#include "rwcore.h" +#include "rpworld.h" +#include "rtgcond.h" +#include "rtimport.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/* Progress callback message types */ +#define rtWORLDIMPORTPROGRESSBSPBUILDSTART 0 +#define rtWORLDIMPORTPROGRESSBSPBUILDUPDATE 1 +#define rtWORLDIMPORTPROGRESSBSPBUILDEND 2 +#define rtWORLDIMPORTPROGRESSBSPCOMPRESSSTART 3 +#define rtWORLDIMPORTPROGRESSBSPCOMPRESSUPDATE 4 +#define rtWORLDIMPORTPROGRESSBSPCOMPRESSEND 5 + +/** + * \ingroup rtworldimport + * \def rtWORLDIMPORTINVALIDPARTITION + * + * This value means that no partition was found, or that the partition was + * invalid or impractical. The value represents infinity. + */ +#define rtWORLDIMPORTINVALIDPARTITION RwRealMAXVAL + + +/**************************************************************************** + Global types + */ +#if (!defined(DOXYGEN)) +typedef struct RtWorldImportVertex RtWorldImportVertex; + +typedef struct RtWorldImportBuildVertex RtWorldImportBuildVertex; + +/* Internal use only */ +typedef union RtWorldImportVertexState RtWorldImportVertexState; + +/* Internal use only */ +union RtWorldImportVertexState +{ + /* clipFlags, two types, first is based on partition only, 2nd is + * also based on partition, but takes overlaps into consideration. i.e. + * number splits is usually higher in clipFlags[0] than [1] */ + RwInt32 clipFlags[2]; /* Internal use only */ + RwInt32 forwardingAddress; /* Internal use only */ + RtWorldImportVertex *vpVert; /* Internal use only */ + RtWorldImportBuildVertex *vpBuildVert; /* Internal use only */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rtworldimport + * \struct RtWorldImportVertex + * Holds data for each vertex in the import world. + * + */ +struct RtWorldImportVertex +{ + RwV3d OC; /**< World space vertex position */ + RwV3d normal; /**< World space vertex normal */ + RwRGBA preLitCol; /**< Vertex Prelight color */ + RwTexCoords texCoords[rwMAXTEXTURECOORDS]; + /**< Vertex texture coordinates */ + RtWorldImportVertexState state; /**< Internal use only */ + RwInt32 matIndex; /**< Vertex material index */ + void *pUserdata; /**< Pointer to unspecified per vertex user data */ +}; + +typedef struct RtWorldImportBuildPolyInfo RtWorldImportBuildPolyInfo; +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildPolyInfo + * + * Information about a polygon + */ +struct RtWorldImportBuildPolyInfo +{ + RwInt16 matIndex; + /**< The material index */ + RwUInt8 clipFlags; + /**< Clipping flags */ + RwUInt8 hasAlpha; + /**< Alpha status */ + void *pUserdata; + /**< Userdata */ +}; + +typedef union RtWorldImportBuildVertexMode RtWorldImportBuildVertexMode; +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildVertexMode + * + * Mode of the vertex. + * + */ +union RtWorldImportBuildVertexMode +{ + RtWorldImportVertex *vpVert; + /**< The vertex */ + RwInt32 index; + /**< The index */ +}; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildVertex + * + * A list of polygons as a list of vertices where the end of poly boundary + * is marked by mode.vpVert == NULL. + * + */ +struct RtWorldImportBuildVertex +{ + RtWorldImportBuildVertexMode mode; + /**< The mode of the element */ + + RtWorldImportBuildPolyInfo pinfo; + /**< we store some poly info in the end marker of a boundary */ +}; + +/* NB Merged RtWorldImportPartition with RtWorldImportBuildClipStatistics because + * there was a unique one-to-one relationship between them, and it made things easier + * just updating one stucture, without having to update both in sequence... + */ + + +typedef struct RtWorldImportBuildClipStatistics RtWorldImportBuildClipStatistics; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildClipStatistics + * + * Holds statistics about a partition or candidate partition during + * the build process. + */ +struct RtWorldImportBuildClipStatistics +{ + RwInt32 numPotentialSplit; + /**< The number of polygons split by the partition, + * disregarding overlaps */ + + RwInt32 numPotentialLeft; + /**< The number of potential polygons and fragments on the + * left of the partition, disregarding overlaps */ + + RwInt32 numPotentialRight; + /**< The number of potential polygons and fragments on the + * right of the partition, disregarding overlaps */ + + + RwInt32 numActualSplit; + /**< The number of polygons split by the partition */ + + RwInt32 numActualLeft; + /**< The number of polygons and fragments on the + * left of the partition */ + + RwInt32 numActualRight; + /**< The number of polygons and fragments on the + * right of the partition */ + + + RwInt32 numMaterialLeft; + /**< The number of materials on the left of the partition */ + + RwInt32 numMaterialRight; + /**< The number of materials on the right of the partition */ + + RwInt32 numMaterialSplits; + /**< The number of materials split by the partition */ + + + RwInt32 numMaterialSector; + /**< The total number of materials in the sector containing + * the partition */ + + + RwReal overlapLeft; + /**< The actual, relative size of the overlap on the left of the partition */ + + RwReal overlapRight; + /**< The actual, relative size of the overlap on the right of the partition */ +}; + +/* + * typedef for struct RtWorldImportPartition + */ +typedef struct RtWorldImportPartition RtWorldImportPartition; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportPartition + * + * A partitioning plane. + */ +struct RtWorldImportPartition +{ + RwInt32 type; + /**< Plane type, i.e. 0,4,8 for being normal to the x,y,z axes respectively. */ + + RwReal value; + /**< The distance of the plane from the origin */ + + RwReal maxLeftValue; + /**< The maximum value of the left face of the overlap. This is derived + * from the maxOverlapPercent value in \ref RtWorldImportParameters + */ + + RwReal maxRightValue; + /**< The maximum value of the right face of the overlap. This is derived + * from the maxOverlapPercent value in \ref RtWorldImportParameters + */ + + RtWorldImportBuildClipStatistics buildStats; + /**< The statistics for the partition */ +}; + +/* + * typedef for struct \ref RtWorldImportGuideKDTree + */ +typedef struct RtWorldImportGuideKDTree RtWorldImportGuideKDTree; + + +/** + * \ingroup rtworldimport + * \struct RtWorldImportGuideKDTree + * Represents the structure of a binary tree with + * no contents per se. It is used to build a BSP in a user specified + * manner instead of using any heuristic. + * + */ +struct RtWorldImportGuideKDTree +{ + RtWorldImportPartition partition; + /**< A partitioning plane */ + + RwBBox bbox; + /**< Bounding box of the sector or super-sector */ + + RtWorldImportGuideKDTree *parent; + /**< Pointer to its parent */ + + RwInt32 order; + /**< Relationship information - 0 for left child, 1 for right child */ + + RtWorldImportGuideKDTree *left; + /**< Left child */ + + RtWorldImportGuideKDTree *right; + /**< Right child */ +}; + +typedef struct _rtWorldImportGuideKDStackElement _rtWorldImportGuideKDStackElement; + +#if (!defined(DOXYGEN)) +struct _rtWorldImportGuideKDStackElement +{ + RwBool terminal; + RtWorldImportGuideKDTree *node; + _rtWorldImportGuideKDStackElement *next; +}; + +typedef struct _rtWorldImportGuideKDStack _rtWorldImportGuideKDStack; + +struct _rtWorldImportGuideKDStack +{ + _rtWorldImportGuideKDStackElement *top; + _rtWorldImportGuideKDStackElement *current; + _rtWorldImportGuideKDStackElement *bottom; +}; +#endif /* (!defined(DOXYGEN)) */ + +/* + * typedef for struct RtWorldImportBuildSector + */ +typedef struct RtWorldImportBuildSector RtWorldImportBuildSector; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildSector + * + * Holds information about the sector that is being subdivided + */ +struct RtWorldImportBuildSector +{ + RwInt32 type; + /**< Sector type (so can handle in an RpWorld) */ + + RtWorldImportVertex *vertices; + /**< A pointer to the list of vertices */ + + RwInt32 numVertices; + /**< The number of vertices */ + + RtWorldImportBuildVertex *boundaries; + /**< A list of boundaries \see RtWorldImportBuildVertex */ + + RwInt32 numBoundaries; + /**< The number of boundaries */ + + RwInt32 numPolygons; + /**< The number of polygons (triangles) */ + + RwBBox boundingBox; + /**< Sector's bounding box */ + + RwReal overlap; + /**< The percentage that the sector overlaps with its neighbor */ + + RwUInt32 maxNumMaterials; + /**< Maximum number of materials in the in the world */ +}; + +/* + * typedef for struct RtWorldImportBuildStatus + */ +typedef struct RtWorldImportBuildStatus RtWorldImportBuildStatus; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildStatus + * World Import Build Status Structure + * Used to store the current tree's build status + */ +struct RtWorldImportBuildStatus +{ + RwInt32 depth; /**< current depth in the tree */ +}; + +typedef struct RwRGBAUInt32 RwRGBAUInt32; + + +/* + * Holds data for each triangle in the import world. + */ +typedef struct RtWorldImportTriangle RtWorldImportTriangle; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportTriangle + * Holds data for each triangle in the import world. + * + * \see RtWorldImportTriangle + */ +struct RtWorldImportTriangle +{ + RwInt32 matIndex; /**< Index into material list */ + RwInt32 vertIndex[3]; /**< Indices into vertex list */ + void *pUserdata; /**< Pointer to unspecified per triangle user data */ +}; + + + + +/* + * typedef for struct RtWorldImportBBoxHintDesc + */ +typedef struct RtWorldImportBBoxHintDesc RtWorldImportBBoxHintDesc; +/** + * \ingroup rtworldimport + * \struct RtWorldImportBBoxHintDesc + * Bounding box hints and (priority) values used to control the world + * sectorization process. + */ +struct RtWorldImportBBoxHintDesc +{ + RwBBox bBox; /**< The (necessarily orthogonal) bounding box */ + RwReal value; /**< The value or priority of the hint (highest is most important) */ +}; + +/* + * typedef for struct RtWorldImportHints + */ +typedef struct RtWorldImportHints RtWorldImportHints; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportHints + * Bounding box hints used to control the world sectorization process. + * \see RtWorldImportHintsSetGroup + */ +struct RtWorldImportHints +{ + RtWorldImportBBoxHintDesc *boundingBoxes; /**< The bounding box hints */ + RwInt32 numBoundingBoxes; /**< The number of bounding box hints */ +}; + + +/** + * \ingroup rtworldimport + * \ref RtWorldImportHintGroup + * + * An enumeration that can be passed to + * \ref RtWorldImportHintsSetGroup and \ref RtWorldImportHintsGetGroup to determine + * whether hints will contribute towards the shield hint group or partition hint group + */ +typedef enum +{ + rtWORLDIMPORTSHIELDHINT = 0, + /**< Hint type shield */ + rtWORLDIMPORTPARTITIONHINT, + /**< Hint type partition */ + + rtWORLDIMPORTFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +} +RtWorldImportHintGroup; + + + + +/* + * typedef for struct \ref RtWorldImportParameters + */ +typedef struct RtWorldImportParameters RtWorldImportParameters; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportParameters + * Parameters used with \ref RtWorldImportCreateWorld. + * They are initialized to default values using \ref RtWorldImportParametersInit. + * + */ +struct RtWorldImportParameters +{ + RwReal worldSectorMaxSize; + /**< The maximum world sector size. */ + RwInt32 maxWorldSectorPolygons; + /**< The maximum number of polygons in a world sector. */ + RwReal maxOverlapPercent; + /**< Total fraction of world sector overlap allowed. */ + RwBool userSpecifiedBBox; + /**< If TRUE allows user to specify minimum bounding-box for the + * world using the userBBox parameter. */ + RwBBox userBBox; + /**< User specified world bounding-box if userSpecifiedBBox is TRUE.*/ + RwBool fixTJunctions; + /**< If TRUE then T-junctions are fixed in the geometry. + * NB: This ONLY fixes T-junctions introduces by the partitioning + * and not those introduced by the artist. + */ + RwInt32 flags; + /**< Conversion flags (see RpWorldFlag). */ + RwInt32 numTexCoordSets; + /**< The number of texture coordinate sets to use. If set to zero, then + * the number is taken from the flags parameter which, for backward + * compatibility, can include the \ref rpWORLDTEXTURED or \ref rpWORLDTEXTURED2 + * flags. These specify one or two sets respectively. */ + RwBool terminatorCheck; + /**< If TRUE the world will be checked for validity during the build process. */ + RwBool calcNormals; + /**< If TRUE the vertex normals are wiped and recalculated (this might also happen + * if conditionGeometry is TRUE). + */ + RwBool conditionGeometry; + /**< If TRUE, any geometry conditioning pipeline that has been set up + * will be called before sectorization + */ +}; + +/* + * typedef for struct RtWorldImport + */ +typedef struct RtWorldImport RtWorldImport; + +/** + * \ingroup rtworldimport + * \struct RtWorldImport + * World Import State Structure + */ +struct RtWorldImport +{ + RpMaterialList matList; /**< Material list */ + RtWorldImportVertex *vertices; /**< Vertex array */ + RwInt32 numVertices; /**< Vertex count */ + + RtWorldImportTriangle *polygons; /**< Triangle array */ + RwInt32 numPolygons; /**< Triangle count */ +}; + +/** + * \ingroup rtworldimport + * \ref RtWorldImportProgressCallBack is the type for the callback function supplied to + * \ref RtWorldImportSetProgressCallBack. + * + * \param msg Message type corresponding to one of the following: + * \li rtWORLDIMPORTPROGRESSBSPBUILDSTART - + * The BSP creation process is about to start. + * The argument value is equal to 0.0. + * \li rtWORLDIMPORTPROGRESSBSPBUILDUPDATE - + * The BSP creation process has finished processing a subsection of + * the world. The argument value is equal to the percentage of the + * world processed up to this point. + * \li rtWORLDIMPORTPROGRESSBSPBUILDEND - + * The BSP creation process has ended. + * The argument value is equal to 100.0. + * \li rtWORLDIMPORTPROGRESSBSPCOMPRESSSTART - + * The BSP compression process is about to start. The argument value + * is equal to 0.0. + * \li rtWORLDIMPORTPROGRESSBSPCOMPRESSUPDATE - + * The BSP compression has finished processing a subsection of the + * world. The argument value is equal to the percentage of the world + * processed up to this point. + * \li rtWORLDIMPORTPROGRESSBSPCOMPRESSEND - + * The BSP compression process has ended. The argument value is equal + * to 100.0. + * + * \param value The percentage of the progress made in either BSP + * building or BSP compression. + * + * \return TRUE to continue BSP processing, FALSE to abort. + * + * \see RtWorldImportSetProgressCallBack + */ +typedef RwBool (*RtWorldImportProgressCallBack)(RwInt32 msg, RwReal value); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportDestroyVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex destruction. + * + * \param pUserdata A handle to the userdata + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportDestroyVertexUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportCloneVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex cloning. + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdataSrc A handle to the userdata for the source + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportCloneVertexUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportInterpVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex interpolation. + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdata1 A handle to the first source + * \param pUserdata2 A handle to the second source + * \param delta The delta between the two sources + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportInterpVertexUserdataCallBack)(void **pUserdataDst, void **pUserdata1, void **pUserdata2, RwReal delta); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportDestroyPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * polygon destruction. + * + * \param pUserdata A handle to the userdata + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportDestroyPolygonUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportSplitPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * polygon division. + * + * \param pUserdataDst A handle to the userdata for the destination + * \param pUserdataSrc A handle to the userdata for the source + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportSplitPolygonUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportSectorSetVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * the setting of the vertex user data. + * + * \param pUserdata A handle to the userdata + * \param sector A pointer to the sector + * \param index Index to the vertex + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportSectorSetVertexUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportSectorSetPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * the setting of the polygon user data. + * + * \param pUserdata A handle to the userdata + * \param sector A pointer to the sector + * \param index Index to the vertex + * + * \return TRUE on success, FALSE otherwise + */ +typedef RwBool (*RtWorldImportSectorSetPolygonUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index); + + + + +/** + * \ingroup rtworldimport + * \ref RtWorldImportTerminationBuildCallBack + * + * A pointer to the function that will be called during the + * build process to determine whether the current sector should + * be subdivided further, or terminated. + * + * \param buildSector A pointer to the Build Sector. + * \param buildStatus A pointer to the Build Status. + * \param pData A point to the unknown additional data + * + * \return TRUE if termination is valid (all criteria have been met, FALSE otherwise + */ +typedef RwBool (*RtWorldImportTerminationBuildCallBack) + (RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + void *pData); + +/** + * \ingroup rtworldimport + * \ref RtWorldImportPartitionBuildCallBack + * + * A pointer to the function that will be called during the + * build process to select a suitable sector partition. + * + * \param buildSector A pointer to the Build Sector. + * \param buildStatus A pointer to the Build Status. + * \param partition A pointer to the partition that is found. + * + * \return The cost value of the partitioner. + */ +typedef RwReal (*RtWorldImportPartitionBuildCallBack) + (RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *pData); + +/* + * typedef for struct \ref RtWorldImportBuildCallBacks + */ +typedef struct RtWorldImportBuildCallBacks RtWorldImportBuildCallBacks; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportBuildCallBacks + * Sectorization callbacks + */ +struct RtWorldImportBuildCallBacks +{ + RtWorldImportPartitionBuildCallBack partitionBuild; + /**< Callback for choosing partition */ + void *partitionUserData; + /**< Partition callback user data */ + RtWorldImportTerminationBuildCallBack terminationBuild; + /**< Callback for termination of further partitioning */ + void *terminationUserData; + /**< Termination callback user data */ +}; + +/* + * typedef for struct \ref RtWorldImportUserdataCallBacks + */ +typedef struct RtWorldImportUserdataCallBacks RtWorldImportUserdataCallBacks; + +/** + * \ingroup rtworldimport + * \struct RtWorldImportUserdataCallBacks + * Bundle of callbacks + */ +struct RtWorldImportUserdataCallBacks +{ + RtWorldImportDestroyVertexUserdataCallBack destroyVertexUserdata; + /**< Callback on vertex destruction */ + RtWorldImportCloneVertexUserdataCallBack cloneVertexUserdata; + /**< Callback on vertex cloning */ + RtWorldImportInterpVertexUserdataCallBack interpVertexUserdata; + /**< Callback on vertex interpolation */ + RtWorldImportDestroyPolygonUserdataCallBack destroyPolygonUserdata; + /**< Callback on polygon destruction */ + RtWorldImportSplitPolygonUserdataCallBack splitPolygonUserdata; + /**< Callback on polygon division */ + RtWorldImportSectorSetVertexUserdataCallBack sectorSetVertexUserdata; + /**< Callback on setting vertex user data */ + RtWorldImportSectorSetPolygonUserdataCallBack sectorSetPolygonUserdata; + /**< Callback on setting polygon user data */ +}; + +/** + * \ingroup rtworldimport + * \ref RtWorldImportBuildPartitionSelector + * + * An enumeration that can be passed to + * \ref RtWorldImportSetStandardBuildPartitionSelector to determine + * whether partitioning will be achieved automatically, using the + * default partition selected, or manually using the \ref RtWorldImportGuideKDTree + */ +typedef enum +{ + rwBUILDPARTITIONSELECTOR_DEFAULT, + /**< Sets the default automated process */ + rwBUILDPARTITIONSELECTOR_GUIDED + /**< Sets the guided manual process */ +} +RtWorldImportBuildPartitionSelector; + + + + +/* Builds overlaps from plane and conversion params */ +#define BuildSectorSetOverlapsMacro(_boundingBox, _partition, _conversionParams) \ +MACRO_START \ +{ \ + RwReal sup = GETCOORD((_boundingBox).sup, (_partition).type); \ + RwReal inf = GETCOORD((_boundingBox).inf, (_partition).type); \ + \ + (_partition).maxLeftValue = \ + (_partition).value + \ + ((sup - (_partition).value) * (_conversionParams).maxOverlapPercent); \ + \ + (_partition).maxRightValue = \ + (_partition).value - \ + ((((_partition).value) - inf) * (_conversionParams).maxOverlapPercent); \ +} \ +MACRO_STOP + +/***************************************************************************** + * Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +_rtImportBuildSectorFindBBox(RtWorldImportBuildSector *buildSector, RwBBox *bbpOut); + +extern void + _rtWorldImportGuideKDCopy(RtWorldImportGuideKDTree *KD, RpSector *spSector, RwInt32 depth); +extern void _rtWorldImportGuideKDStackDestroy(_rtWorldImportGuideKDStack *stack); +extern void +_rtWorldImportGuideKDEncodeAsStack(RtWorldImportGuideKDTree *tree, _rtWorldImportGuideKDStack *stack); + +extern RtWorldImportGuideKDTree *RtWorldImportGuideKDCreate(RwBBox *bbox); +extern RtWorldImportGuideKDTree *RtWorldImportGuideKDAddPartition + (RtWorldImportGuideKDTree *KD, RwInt32 type, RwReal value); +extern void RtWorldImportGuideKDDeletePartition(RtWorldImportGuideKDTree *KD); +extern void RtWorldImportGuideKDDestroy(RtWorldImportGuideKDTree *KD); + +extern RtWorldImportGuideKDTree *RtWorldImportGuideKDWrite( + RtWorldImportGuideKDTree *guideKD, const RwChar *filename); +extern RtWorldImportGuideKDTree * RtWorldImportGuideKDRead( + const RwChar *filename, const RwBBox *bbox); + + +/***************************************************************************** + * PARTITION SELECTORS - These callbacks for used to select a partition + * from a sector. + */ + +extern RwReal +RtWorldImportBalancedCullPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportMaterialCountPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportMaterialSeparatePartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); +extern RwReal +RtWorldImportPartitionHintPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData __RWUNUSED__); + + +extern RwReal +RtWorldImportMaximumOccluderPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportDisjointOccluderPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportLeastCutAndBalancedPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportMaximumExtentPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportCullMiddleSpacePartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportCullEndSpacePartitionSelector(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportCullSpacePartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportHintBBoxPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportGeneralOccluderPartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportBalancedTreePartitionSelector(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +/***************************************************************************** + * PARTITION ITERATORS - These callbacks iterate though a set of partitions + */ + +extern RwBool +RtWorldImportOrthogonalAutoPartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData, + RwInt32* loopCounter); + + +extern RwBool +RtWorldImportRegularIntervalPartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData, + RwInt32* loopCounter); + + +extern RwBool +RtWorldImportMiddleAxisPartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData, + RwInt32 * loopCounter); + + +extern RwBool +RtWorldImportMedianPercentagePartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData, + RwInt32 *loopCounter); + + +extern RwBool +RtWorldImportHintBBoxPartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData, + RwInt32* loopCounter); + +extern RwBool +RtWorldImportHighestVertexAccommodatingPlanePartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void * userData, + RwInt32* loopCounter); + +extern RwBool +RtWorldImportMaterialBoundsPartitionIterator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void *userData, + RwInt32 *loopCounter); + +/***************************************************************************** + * PARTITION EVALUATORS - These callbacks iterate though a set of partitions + */ + +extern RwReal +RtWorldImportFuzzyBalancedPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + + +extern RwReal +RtWorldImportPotentialSplitPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + + +extern RwReal +RtWorldImportBalancedPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + + +extern RwReal +RtWorldImportExtentPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + + +extern RwReal +RtWorldImportOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + + +extern RwReal +RtWorldImportWeightedOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportHintBBoxPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *userData); + +extern RwReal +RtWorldImportVolumeBalancedPartitionEvaluator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportWeightedDisjointOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportMaterialCutsPartitionEvaluator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportMaterialBalancedPartitionEvaluator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportAspectPartitionEvaluator(RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void * userData); + +extern RwReal +RtWorldImportMaterialSeparatorPartitionEvaluator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + RtWorldImportPartition *partition, + void * userData); +/***************************************************************************** + * PARTITION TERMINATORS - These callbacks are used to decide when + * partitioning of a sector should stop + */ +extern RwBool +RtWorldImportNeverPartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * userData); + +extern RwBool +RtWorldImportMaximumLegalPartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus __RWUNUSED__, + void * userData __RWUNUSED__); + +extern RwBool +RtWorldImportDefaultPartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * pData); + + +extern RwBool +RtWorldImportDepthPartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * userData); + + +extern RwBool +RtWorldImportSectorHeightPartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * userData); + +extern RwBool +RtWorldImportSizePartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * userData); + +extern RwBool +RtWorldImportSectorAspectSizePartitionTerminator(RtWorldImportBuildSector * buildSector, + RtWorldImportBuildStatus * buildStatus, + void * userData); + + + + +/* WorldImport hints */ +extern void +RtWorldImportHintsSetGroup(RtWorldImportHints *hints, RtWorldImportHintGroup group); + +extern RtWorldImportHints * +RtWorldImportHintsGetGroup(RtWorldImportHintGroup group); + +extern RtWorldImportHints * +RtWorldImportHintsCreate(void); + +extern RwBool +RtWorldImportHintsDestroy(RtWorldImportHints *hints); + +extern RtWorldImportHints * +RtWorldImportHintsAddBoundingBoxes(RtWorldImportHints *hints, RwInt32 numBoundingBoxes); + +extern void +RtWorldImportMaterialGroupHintGenerator(RtWorldImportBuildSector *buildSector, + RtWorldImportHints *materialGroupHints); + +/* Initializing the conversion structure */ +extern void RtWorldImportParametersInit(RtWorldImportParameters* params); +extern void RtWorldImportParametersSet(RtWorldImportParameters* params); +extern RtWorldImportParameters* RtWorldImportParametersGet(void); + + +extern RpWorld *RtWorldImportCreateWorld(RtWorldImport * + nohsworld, + RtWorldImportParameters + * conversionParams); + +extern RpGeometry * +RtWorldImportCreateGeometry(RtWorldImport * nohsworld, + RtWorldImportParameters * conversionParams); + + +extern RtWorldImport *RtWorldImportCreate(void); + +extern RwBool RtWorldImportDestroy(RtWorldImport * nohsworld); + +extern RtWorldImport *RtWorldImportAddNumVertices(RtWorldImport * + nohsworld, + RwInt32 + numNewVertices); + +extern RtWorldImport *RtWorldImportAddNumTriangles(RtWorldImport * + nohsworld, + RwInt32 + numNewTriangles); + +extern RpMaterial *RtWorldImportGetMaterial(RtWorldImport * + nohsworld, + RwInt32 matInd); + +extern RwInt32 RtWorldImportGetNumVertices(RtWorldImport * nohsworld); + +extern RtWorldImportVertex *RtWorldImportGetVertices(RtWorldImport * + nohsworld); + +extern RwInt32 RtWorldImportGetNumTriangles(RtWorldImport * nohsworld); + +extern RtWorldImportTriangle * +RtWorldImportGetTriangles(RtWorldImport * nohsworld); + + +/* Progress callbacks */ +extern void +RtWorldImportSetProgressCallBack(RtWorldImportProgressCallBack CB); + +extern void +_rtImportWorldSendProgressMessage(RwInt32 msgtype, RwReal value); + +/* Reading and Writing */ + +extern RtWorldImport *RtWorldImportWrite(RtWorldImport * world, + RwChar * filename); + +extern RtWorldImport *RtWorldImportRead(RwChar * filename); + +extern RwInt32 RtWorldImportAddMaterial(RtWorldImport * nohsworld, + RpMaterial * material); + +extern RwInt32 RtWorldImportGetMaterialIndex(RtWorldImport * nohsworld, + RpMaterial * material); + +extern RtWorldImport *RtWorldImportForAllMaterials(RtWorldImport * + nohsworld, + RpMaterialCallBack + fpCallBack, + void *pData); + +extern void +RtWorldImportSetUserdataCallBacks(RtWorldImportDestroyVertexUserdataCallBack + destroyVertexUserdataCB, + RtWorldImportCloneVertexUserdataCallBack + cloneVertexUserdataCB, + RtWorldImportInterpVertexUserdataCallBack + interpVertexUserdataCB, + RtWorldImportSectorSetVertexUserdataCallBack + sectorSetVertexUserdata, + RtWorldImportDestroyPolygonUserdataCallBack + destroyPolygonUserdataCB, + RtWorldImportSplitPolygonUserdataCallBack + splitPolygonUserdataCB, + RtWorldImportSectorSetPolygonUserdataCallBack + sectorSetPolygonUserdata); + +extern void +RtWorldImportSetBuildCallBacks(RtWorldImportPartitionBuildCallBack + partitionBuildCB, + RtWorldImportTerminationBuildCallBack + terminationBuildCB); + +extern void +RtWorldImportSetPartitionStatistics(RtWorldImportBuildSector * buildSector, + RtWorldImportPartition * partition); + +extern void +RtWorldImportSetBuildCallBacksUserData(void *partitionUserData, + void *terminateUserData); + + +extern void +RtWorldImportSetStandardBuildPartitionSelector(RtWorldImportBuildPartitionSelector partitionSelector, void* userData); + + +/* strictly internal use only */ +extern void +_rtImportWorldGetDimensions(RtWorldImport* importWorld, RwReal* min, RwReal* max, RwReal* diagonal); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/* Back compatibility with former hints which only permitted type zero (shield) hints... */ +#define RtWorldImportHintsSet(_hints) \ +RtWorldImportHintsSetGroup(_hints, rtWORLDIMPORTSHIELDHINT); + +#define RtWorldImportHintsGet() \ +RtWorldImportHintsGetGroup(rtWORLDIMPORTSHIELDHINT); + + +#endif /* RTIMPORT_H */ + + + + + + + + + + + + + + + + + + + diff --git a/includes/rwsdk/rtimport.rpe b/includes/rwsdk/rtimport.rpe new file mode 100644 index 0000000..4104b9e --- /dev/null +++ b/includes/rwsdk/rtimport.rpe @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionNoHSWorld +{ + + +E_RW_SECTORDEGENERATE, + +E_RW_SECTORINVNOPOLYGONS, + +E_RW_NOPLANE, + +E_RW_SECTORINVPOLY, + +E_RW_SECTORUSED, + +E_RW_MAXBSPDEPTHEXCEEDED, + + + e_rwdb_CriterionNoHSWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionNoHSWorld e_rwdb_CriterionNoHSWorld; + + diff --git a/includes/rwsdk/rtintsec.h b/includes/rwsdk/rtintsec.h new file mode 100644 index 0000000..6f7821e --- /dev/null +++ b/includes/rwsdk/rtintsec.h @@ -0,0 +1,147 @@ +/*************************************************************************** + * * + * Module : rtintsec.h * + * * + * Purpose : Intersection tests on geometry primitives. * + * * + **************************************************************************/ + +#ifndef RTINTSEC_H +#define RTINTSEC_H + +/** + * \defgroup rtintersection RtIntersection + * \ingroup mathtools + * + * Object Intersection Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include +#include "rtintsec.rpe" /* automatically generated header file */ + + +/**************************************************************************** + Defines + */ + +#define RTINTSECEPSILON (RwReal)(1e-8) +#define RTINTSECEDGEEPS (RwReal)(1e-5) + +#define RtIntersectionLineTriangleMacro(_result, \ + _lineStart, _lineDelta, \ + _v0, _v1, _v2, \ + _distance) \ +MACRO_START \ +{ \ + RwV3d edge1, edge2, tVec, pVec, qVec; \ + RwReal det; \ + \ + /* Find vectors for two edges sharing vert0 */ \ + RwV3dSubMacro(&edge1, (_v1), (_v0)); \ + RwV3dSubMacro(&edge2, (_v2), (_v0)); \ + \ + /* Begin calculating determinant \ + * - also used to calculate U parameter */ \ + RwV3dCrossProductMacro(&pVec, (_lineDelta), &edge2); \ + \ + /* If determinant is \ + * + near zero, ray lies in plane of \ + * triangle \ + * + negative, triangle is backfacing \ + */ \ + det = RwV3dDotProductMacro(&edge1, &pVec); \ + (_result) = (det > RTINTSECEPSILON); \ + \ + if ((_result)) \ + { \ + RwReal lo, hi, u; \ + \ + /* Calculate bounds for parameters with tolerance */ \ + lo = - det*RTINTSECEDGEEPS; \ + hi = det - lo; \ + \ + /* Calculate U parameter and test bounds */ \ + RwV3dSubMacro(&tVec, (_lineStart), (_v0)); \ + u = RwV3dDotProductMacro(&tVec, &pVec); \ + (_result) = (u >= lo && u <= hi); \ + \ + if ((_result)) \ + { \ + RwReal v; \ + \ + /* Calculate V parameter and test bounds */ \ + RwV3dCrossProductMacro(&qVec, &tVec, &edge1); \ + v = RwV3dDotProductMacro((_lineDelta), &qVec); \ + (_result) = (v >= lo && (u + v) <= hi); \ + \ + if ((_result)) \ + { \ + /* Calculate t, \ + * and make sure intersection is in bounds of line */ \ + *(_distance) = RwV3dDotProductMacro(&edge2, &qVec); \ + \ + /* Within bounds of line? */ \ + (_result) = (*(_distance) >= lo && *(_distance) <= hi); \ + \ + if ((_result)) \ + { \ + *(_distance) = ((*(_distance)) / (det)); \ + } \ + } \ + } \ + } \ +} \ +MACRO_STOP + + +/**************************************************************************** + Global Types + */ + + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Line intersections */ +extern RwBool +RtIntersectionLineTriangle(const RwV3d *lineStart, + const RwV3d *lineDelta, + const RwV3d *v0, + const RwV3d *v1, + const RwV3d *v2, + RwReal *distance); + +/* Sphere intersections */ +extern RwBool +RtIntersectionSphereTriangle(const RwSphere *sphere, + const RwV3d *v0, + const RwV3d *v1, + const RwV3d *v2, + RwV3d *normal, + RwReal *distance); + +/* BBox intersections */ +extern RwBool +RtIntersectionBBoxTriangle(const RwBBox *bbox, + const RwV3d *v0, + const RwV3d *v1, + const RwV3d *v2); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTINTSEC_H */ diff --git a/includes/rwsdk/rtintsec.rpe b/includes/rwsdk/rtintsec.rpe new file mode 100644 index 0000000..3b1eb9f --- /dev/null +++ b/includes/rwsdk/rtintsec.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionIntsec +{ + + + + e_rwdb_CriterionIntsecLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionIntsec e_rwdb_CriterionIntsec; + + diff --git a/includes/rwsdk/rtltmap.h b/includes/rwsdk/rtltmap.h new file mode 100644 index 0000000..8cbd85f --- /dev/null +++ b/includes/rwsdk/rtltmap.h @@ -0,0 +1,697 @@ + +/** + * \defgroup rtltmap RtLtMap + * \ingroup lighting + * + * Lightmap Generation Toolkit for RenderWare. + */ + +#ifndef RTLTMAP_H +#define RTLTMAP_H + +/*===========================================================================* + *--- Includes --------------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpltmap.h" + + +/** + * \ingroup rtltmap + * \ref RtLtMapIlluminateSampleCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, for groups of samples in the objects + * currently being illuminated. + * + * For lightmapped objects, samples are grouped on a per-polygon basis and + * for vertex-lit objects, samples are grouped on a per-object basis (see + * \ref RtLtMapObjectFlags). + * + * This callback will receive an array of color values to fill in, each + * representing one sample in the current object - this may correspond to + * a texel in the current object's lightmap or the prelight color of a + * vertex, depending on whether the object is lightmapped and/or vertex-lit. + * It will receive positions (in world-space) for each sample and the normal + * vector (again, in world-space) of each sample (normals are interpolated + * across polygons for non-flat-shaded materials. See \ref RtLtMapMaterialFlags). + * For lightmap samples (not vertex-lighting samples), it will receive + * barycentric coordinates within the current polygon. It will also receive + * a list of RpLights affecting the current object. + * + * The barycentric coordinates may be used, for example, to allow a callback + * to easily import existing lighting data (e.g from previously generated + * lightmaps in a different format, or from an art package with lighting + * functionality). + * + * NOTE: The alpha channel of the RwRGBA results array must NOT be modified. + * These values are used internally and their modification may result in + * unwanted visual artifacts in the resulting lighting solution. + * + * The default RtLtMapIlluminateSampleCallBacks supplied with RtLtMap is + * \ref RtLtMapDefaultSampleCallBack. This callback performs point and area + * lighting (the area lights use are those passed to \ref RtLtMapIlluminate). + * + * \param results A pointer to an array of \ref RwRGBA sample color values + * \param samplePositions A pointer to an array of \ref RwV3d values specifying the + * world-space positions of each of the samples in the results array + * \param baryCoords A pointer to an array of \ref RwV3d values specifying the + * barycentric coordinates (within the current polygon) of + * each of the samples in the results array + * \param numSamples The length of the results, samplePositions, baryCoords and normals arrays + * \param lights An array of pointers to \ref RpLight's affecting the current object + * \param numLights The length of the lights array + * \param normals A pointer to an array of \ref RwV3d values specifying the + * world-space, unit normals of each of the samples in the results array + * + * \return A pointer to the results array on success, NULL otherwise + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + * \see RtLtMapIlluminateProgressCallBack + */ +typedef RwRGBA *(*RtLtMapIlluminateSampleCallBack)(RwRGBA *results, + RwV3d *samplePositions, + RwV3d *baryCoords, + RwUInt32 numSamples, + RpLight **lights, + RwUInt32 numLights, + RwV3d *normals); + +/** + * \ingroup rtltmap + * \ref RtLtMapIlluminateVisCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, to determine the visibility between a + * sample and a light. + * + * This callback is called for all samples in the current + * \ref RtLtMapLightingSession and for each light source which may + * potentially affect each of those samples (this may not be all the + * lights in the scene, as some hierarchical culling is performed). + * Each sample may represent a texel in the current object's lightmap + * or the prelight color of a vertex, depending on whether the object + * is lightmapped and/or vertex-lit (see \ref RtLtMapObjectFlags). + * + * The callback will receive a pointer to the world of the current + * \ref RtLtMapLightingSession (this may be used to perform intersection + * tests), the world-space position of the sample, the world-space + * position of the light, a pointer to a light and a pointer to an + * \ref RwRGBAReal result value. + * + * If the light pointer is NULL, this means that the current light + * is an area light (as opposed to an \ref RpLight), of an internal + * format. The area lights use are those passed to \ref RtLtMapIlluminate. + * + * The callback should return FALSE to signify that the light is wholly + * occluded w.r.t the sample position, otherwise it should return TRUE. + * Partial degrees of (color-frequency-dependent) occlusion may be + * expressed by modifying the RwRGBAReal value. This defaults to bright + * white but may be reduced to signify that the light from the light + * source should be attenuated. This could be used to take into account + * light-filtering objects in the scene (such as colored glass or fog). + * + * The default RtLtMapIlluminateVisCallBack supplied with RtLtMap is + * \ref RtLtMapDefaultVisCallBack. This callback performs visibility + * tests using the line-intersection tests from \ref rtintersection. It tests + * for occlusion by RpWorldSectors and RpAtomics and it respects the + * relevant \ref RtLtMapObjectFlags and \ref RtLtMapMaterialFlags but it + * does not filter light; visibility is determined to be either one or zero. + * + * \param world The world of the current RtLtMapLightingSession + * \param result An RwRGBAReal value to attentuate this light's + * contribution to the current sample + * \param samplePos The world-space positiuon of the sample + * \param lightPos The world-space positiuon of the light + * \param light A pointer to the light (NULL if it is an are light) + * + * \return TRUE if the light is visible from the sample, FALSE if it is occluded + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateSampleCallBack + * \see RtLtMapIlluminateProgressCallBack + */ +typedef RwBool (*RtLtMapIlluminateVisCallBack)(RpWorld *world, + RwRGBAReal *result, + RwV3d *samplePos, + RwV3d *lightPos, + RpLight *light); + +/** + * \ingroup rtltmap + * \ref RtLtMapIlluminateProgressCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, to allow a user to track lighting progress. + * + * The progress callback will be called at several stages during lighting, + * with a different 'message' parameter value used at each stage (see + * \ref RtLtMapProgressMessage). It will be called at the very start of + * lighting (for a given \ref RtLtMapLightingSession), before any samples + * are lit. It will also be called at the very end of lighting, after all + * samples have been lit. It will be called before and after each lighting + * 'slice' (see \ref RtLtMapIlluminate) and also after each group of + * samples have been lit. + * + * For lightmapped objects, samples are grouped on a per-polygon basis and + * for vertex-lit objects, samples are grouped on a per-object basis (see + * \ref RtLtMapObjectFlags). + * + * The progress callback will receive a RwReal value specifying the percentage + * of samples already lit in the current \ref RtLtMapLightingSession (see + * \ref RtLtMapLightingSessionGetNumSamples). + * + * By returning FALSE, the progress callback may cause early termination of + * the current lighting 'slice' (this may be used, for example, to keep + * the time spent lighting each slice fairly constant). + * + * There is no default progress callback supplied with RtLtMap. + * + * \param message A \ref RtLtMapProgressMessage identifying the stage + * of the current call to the progress callback + * \param value The percentage of samples already lit in the + * current \ref RtLtMapLightingSession + * + * \return FALSE to immediately terminate lighting, otherwise TRUE + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateSampleCallBack + * \see RtLtMapIlluminateVisCallBack + */ +typedef RwBool (*RtLtMapIlluminateProgressCallBack)(RwInt32 message, + RwReal value); + + +/** + * \ingroup rtltmap + * \ref RtLtMapLightMapProcessCallBack is the callback to be called, from + * within \ref RtLtMapLightingSessionLightMapProcess, to allow a lightmap + * to be process after a lighting session. + * + * For some platform, the lightmap needs to be converted before it can be + * used during rendering. This function allows a post process operation to + * be performed on the lightmaps before it can be used. + * + * The actual operation is platform specific. + * + * The callback is only called for lightmaps that were updated from the + * last lighting session. + * + * \param lightmap A pointer to the input lightmap data. + * + * \return A pointer to the lightmap on success, NULL otherwise. + * + * \see RtLtMapIlluminate + * \see RtLtMapLightingSessionLightMapProcess + * \see RtLtMapGetLightMapProcessCallBack + * \see RtLtMapSetLightMapProcessCallBack + * \see RtLtMapSkyLightMapMakeDarkMap + */ +typedef RwTexture *(*RtLtMapLightMapProcessCallBack)(RwTexture *lightmap); + + +/** + * \ingroup rtltmap + * \ref RtLtMapProgressMessage is an enumerated type identifying the different + * stages at which the \ref RtLtMapIlluminateProgressCallBack may be called + * from within \ref RtLtMapIlluminate. + * + * \see RtLtMapIlluminateProgressCallBack + * \see RtLtMapIlluminate + */ +enum RtLtMapProgressMessage +{ + rtLTMAPPROGRESSNAMESSAGE = 0, + + rtLTMAPPROGRESSSTART = 1, /**< This is issued at the beginning of + * an incremental lighting session */ + rtLTMAPPROGRESSSTARTSLICE = 2, /**< This is issued at the beginning of every + * slice in an incremental lighting session */ + rtLTMAPPROGRESSUPDATE = 3, /**< This is issued after the lighting of each + * lightmapped triangle or vertex-lit object */ + rtLTMAPPROGRESSENDSLICE = 4, /**< This is issued at the end of every slice + * in an incremental lighting session */ + rtLTMAPPROGRESSEND = 5, /**< This is issued at the end of an + * incremental lighting session */ + + rtLTMAPPROGRESSFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapProgressMessage RtLtMapProgressMessage; + +typedef struct RtLtMapLightingSession RtLtMapLightingSession; +/** + * \ingroup rtltmap + * \struct RtLtMapLightingSession + * The RtLtMapLightingSession structure holds information to be passed to + * \ref RtLtMapIlluminate. It is used to parameterize the lighting process. + * + * The RtLtMapLightingSession structure encapsulates a set of objects and + * keeps track of the proportion of samples, within that set, that have already + * been lit by calls to \ref RtLtMapIlluminate. Each call performs lighting for + * one 'slice' of the whole 'session'. If the camera member is non-NULL, it is + * important that the camera is not moved between lighting slices. + * + * The RtLtMapLightingSession is also passed to + * \ref RtLtMapLightMapsCreate, \ref RtLtMapLightMapsClear, + * \ref RtLtMapLightMapsDestroy and \ref RtLtMapAreaLightGroupCreate, + * though not all of the session structure's member will be used in + * each of these cases. + * + * \see RtLtMapIlluminate + * \see RtLtMapLightMapsCreate + * \see RtLtMapLightMapsClear + * \see RtLtMapLightMapsDestroy + * \see RtLtMapAreaLightGroupCreate + */ +struct RtLtMapLightingSession +{ + RpWorld *world; /**< This world is that in which collisions are performed + * during illumination (for the purposes of lighting + * visibility determination) */ + RwCamera *camera; /**< An optional pointer to a camera. The camera's frustum + * may be used to cull objects and/or triangles from the + * set of those to be processed. */ + RpWorldSector **sectorList; /**< An optional array of \ref RpWorldSector pointers, + * specifying which sectors in the world to light. If + * this is NULL, then all sectors in the world (or those + * inside the optional camera's frustum) will be lit. */ + RwInt32 numSectors; /**< The length of the sectorList array. If this is set to + * '-1' then none of the sectors in the world will be lit. */ + RpAtomic **atomicList; /**< An optional array of \ref RpAtomic pointers, + * specifying which atomics to light. If this is NULL + * then all atomics in the world (or those inside the + * optional camera's frustum) will be lit. */ + RwInt32 numAtomics; /**< The length of the atomicList array. If this is set to + * '-1' then none of the atomics in the world will be lit. */ + RwUInt32 totalSamples;/**< This specifies how many lightmap samples will be lit in + * total for the world specified (this is filled in by + * \ref RtLtMapIlluminate, not the calling function). + */ + RwUInt32 startObj; /**< Lighting for the current slice should begin with this + * object. It is the user's responsibility to increment this + * value after each slice to process the next slice of objects. + */ + RwUInt32 numObj; /**< This specifies how many objects should be processed for the + * current slice. + * If it is set to zero, then all objects will be processed. + */ + RwUInt32 totalObj; /**< This specifies how many objects needs to be processed + * for the current session. + * Internal use only. + */ + + RwUInt32 numTriNVert; /**< Internal use only. */ + RwUInt32 totalTriNVert; /**< Internal use only. */ + RwReal invTotalTriNVert; /**< Internal use only. */ + + RwImage *lightMapImg; /**< Internal use only. */ + RwTexture *lightMap; /**< Internal use only. */ + rpLtMapSampleMap *sampleMap; /**< Internal use only. */ + RwUInt32 superSample; /**< This specifies the supersampling value for this current + * lighting session. */ + RtLtMapIlluminateSampleCallBack sampleCallBack; /**< A \ref RtLtMapIlluminateSampleCallBack + * to use during lighting. If this is left + * NULL, the default callback will be used. */ + RtLtMapIlluminateVisCallBack visCallBack; /**< A \ref RtLtMapIlluminateVisCallBack + * to use during lighting. If this is left + * NULL, the default callback will be used. */ + RtLtMapIlluminateProgressCallBack progressCallBack; /**< A \ref RtLtMapIlluminateProgressCallBack + * to use during lighting. If this is left + * NULL, no progress callback will be used. */ +}; + +/** + * \ingroup rtltmap + * \ref RtLtMapMaterialFlags is an enumerated type specifying the different + * lightmap-related flags which may be applied to materials. These values + * will be taken into consideration within \ref RtLtMapIlluminate. + * + * \see RtLtMapMaterialGetFlags + * \see RtLtMapMaterialSetFlags + * \see RtLtMapMaterialGetAreaLightColor + * \see RtLtMapMaterialSetAreaLightColor + * \see RtLtMapMaterialGetLightMapDensityModifier + * \see RtLtMapMaterialSetLightMapDensityModifier + * \see RtLtMapMaterialGetAreaLightDensityModifier + * \see RtLtMapMaterialSetAreaLightDensityModifier + * \see RtLtMapMaterialSetAreaLightRadiusModifier + * \see RtLtMapMaterialGetAreaLightRadiusModifier + * \see RtLtMapIlluminate + * \see RtLtMapAreaLightGroupCreate + * \see RtLtMapIlluminateVisCallBack + */ +enum RtLtMapMaterialFlags +{ + rtLTMAPMATERIALNAFLAG = 0, + + rtLTMAPMATERIALLIGHTMAP = 1, /**< This material should be lightmapped + * [for non-lightmapped materials within lightmapped objects, + * texel values will be set to (0, 0, 0) (or (255, 255, 255) if + * the rtLTMAPMATERIALAREALIGHT flag is present, so that light- + * emitting textures appear as bright as the light which they are + * emittering) and the mesh may be 'shrunk' in UV-space so as not + * to waste lightmap texels] */ + rtLTMAPMATERIALAREALIGHT = 2, /**< This material is an area light emitter + * (see \ref RtLtMapAreaLightGroupCreate) */ + rtLTMAPMATERIALNOSHADOW = 4, /**< This material does not block light */ + rtLTMAPMATERIALSKY = 8, /**< This material blocks everything but directional + * lights, to allow sky polygons to occlude geometry + * and yet emit directional light (sky or sun light, + * being as if cast from an infinite distance) */ + rtLTMAPMATERIALFLATSHADE = 16, /**< This material will be lit as if flat-shaded + * (polygon normals will be used during illumination) */ + + rtLTMAPMATERIALVERTEXLIGHT = 32, /**< This material will be lit at vertices */ + rtLTMAPMATERIALFLAGFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapMaterialFlags RtLtMapMaterialFlags; + +/** + * \ingroup rtltmap + * RtLtMapObjectFlags is an enumerated type specifying the different + * lightmap-related flags which may be applied to world sectors and + * atomics. These values will be taken into consideration within + * \ref RtLtMapLightMapsCreate and \ref RtLtMapIlluminate. + * + * \see RtLtMapAtomicGetFlags + * \see RtLtMapAtomicSetFlags + * \see RtLtMapWorldSectorGetFlags + * \see RtLtMapWorldSectorSetFlags + * \see RtLtMapLightMapsCreate + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + */ +enum RtLtMapObjectFlags +{ + rtLTMAPOBJECTNAFLAG = 0, + + rtLTMAPOBJECTLIGHTMAP = 1, /**< This object is to be lightmapped */ + rtLTMAPOBJECTVERTEXLIGHT = 2, /**< This object's vertex prelight colors should + be lit within \ref RtLtMapIlluminate. */ + rtLTMAPOBJECTNOSHADOW = 4, /**< This object does not cast shadows (useful, for + example, for moving objects for which dynamic + shadows are to be rendered - such as doors) */ + rtLTMAPOBJECTFLAGFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapObjectFlags RtLtMapObjectFlags; + +/* Area-lighting stuff:* + ***********************/ + + +typedef struct RtLtMapAreaLightGroup RtLtMapAreaLightGroup; + +/** + * \ingroup rtltmap + * \struct RtLtMapAreaLightGroup + * RtLtMapAreaLightGroup is a structure which acts as a container + * for area lights created by a call to \ref RtLtMapAreaLightGroupCreate. + * The containers may be chained and passed to \ref RtLtMapIlluminate. + * Each container has an optional pointer to a RwFrame which is used to + * transform the contained area lights relative to the world of the current + * \ref RtLtMapLightingSession and relative to each other (such that, for + * example, lights from multiple worlds, which are connected by portals, + * or which are composed of atomics and not world sectors, may be used + * within a single call to \ref RtLtMapIlluminate). + * + * \see RtLtMapAreaLightGroupCreate + * \see RtLtMapAreaLightGroupDestroy + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + */ +struct RtLtMapAreaLightGroup +{ + RwSList *meshes; /**< A list of hierarchically-grouped area lights */ + RwFrame *frame; /**< An (optional) pointer to a frame (owned by something else) + * whose LTM specifies the coordinate system of this container, + * relative to the world of the current \ref RtLtMapLightingSession. */ + RtLtMapAreaLightGroup *next; /**< A pointer for chaining are light groups together */ +}; + +/* Area light triangles are grouped by source mesh (this may change) */ +typedef struct LtMapAreaLightMesh LtMapAreaLightMesh; + +#if (!defined(DOXYGEN)) +struct LtMapAreaLightMesh +{ + RwUInt32 flags; /* To hold hierarchical visibility culling flags, + * relevant to the object/triangle *currently* being lit. */ + RpMaterial *material; /* The emitter material, containing color, etc */ + RwSphere sphere; /* Each mesh has an associated center and radius */ + RwReal ROI; /* Centered on the above sphere, the R.O.I. of the + * samples in this mesh (a conservative estimate) */ + RwSList *triangles; /* A list of the area light triangles in this mesh */ +}; + +/* Area light samples are grouped by source triangle */ +typedef struct LtMapAreaLight LtMapAreaLight; +struct LtMapAreaLight +{ + RwUInt16 flags; /* To hold hierarchical visibility culling flags, + * relevant to the object/triangle *currently* being lit. */ + RwUInt16 numSamples; /* Number of area light samples in this triangle */ + RwReal areaPerSample; /* (triangleArea / numSamples) for this triangle */ + RwPlane plane; /* This 'area light' is a triangle, this is its plane. */ + RwSphere sphere; /* This bounds the triangle's points in world-space (it's + * not worth storing 3 points, coarse culling is fine) */ + RwV3d *lights; /* Array of area light sample positions (in world-space) */ +}; +#endif /* (!defined(DOXYGEN)) */ + + +/** + * \ingroup rtltmapps2 + * \ref RtLtMapSkyLumCalcCallBack is the callback to be called, from + * within \ref RtLtMapSkyBaseTextureProcess, to allow a user to select the + * function to process the textures for rendering on the PlayStation 2. + * + * The function is called for each span of a full color image, or for the + * CLUT in a palettised image, to compute the luminance and stores it in + * the alpha component of the texel. + * + * \param scanline A pointer to a scanline of \ref RwRGBA data. + * \param width Width of the scanline, in pixels. + * + * \return A pointer to the scanline on success, NULL otherwise. + * + * \see RtLtMapSkyBaseTextureProcess + * \see RtLtMapSkyLightingSessionBaseTexturesProcess + * \see RtLtMapSkyLightMapMakeDarkMap + * \see RtLtMapSkyLumCalcMaxCallBack + * \see RtLtMapSkyLumCalcSigmaCallBack + * \see RtLtMapSkySetLumCalcCallBack + * \see RtLtMapSkyGetLumCalcCallBack + */ +typedef RwRGBA *(*RtLtMapSkyLumCalcCallBack)(RwRGBA *scanline, + RwUInt32 width ); + + + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Lightmap creation functionality: */ +extern RtLtMapLightingSession * +RtLtMapLightMapsCreate(RtLtMapLightingSession *session, + RwReal density, + RwRGBA *color); + +extern void +RtLtMapLightMapsDestroy(RtLtMapLightingSession *session); +extern RpAtomic * +RtLtMapAtomicLightMapDestroy(RpAtomic *atomic); +extern RpWorldSector * +RtLtMapWorldSectorLightMapDestroy(RpWorldSector *sector); + +extern RwReal +RtLtMapGetVertexWeldThreshold(void); +extern RwBool +RtLtMapSetVertexWeldThreshold(RwReal threshold); + +extern RwUInt32 +RtLtMapLightMapGetDefaultSize(void); +extern RwBool +RtLtMapLightMapSetDefaultSize(RwUInt32 size); + +extern RwUInt32 +RtLtMapAtomicGetLightMapSize(RpAtomic *atomic); +extern RpAtomic * +RtLtMapAtomicSetLightMapSize(RpAtomic *atomic, RwUInt32 size); +extern RwUInt32 +RtLtMapWorldSectorGetLightMapSize(RpWorldSector *sector); +extern RpWorldSector * +RtLtMapWorldSectorSetLightMapSize(RpWorldSector *sector, RwUInt32 size); + +extern RwUInt32 +RtLtMapAtomicGetFlags(RpAtomic *atomic); +extern RpAtomic * +RtLtMapAtomicSetFlags(RpAtomic *atomic, RwUInt32 flags); +extern RwUInt32 +RtLtMapWorldSectorGetFlags(RpWorldSector *sector); +extern RpWorldSector * +RtLtMapWorldSectorSetFlags(RpWorldSector *sector, RwUInt32 flags); + + +/* Lightmap illumination functionality: */ +extern RwInt32 +RtLtMapIlluminate(RtLtMapLightingSession *session, + RtLtMapAreaLightGroup *lights, + RwUInt32 superSample); + +extern RwReal +RtLtMapGetSliverAreaThreshold(void); +extern RwBool +RtLtMapSetSliverAreaThreshold(RwReal threshold); + +extern RwRGBA * +RtLtMapDefaultSampleCallBack(RwRGBA *results, + RwV3d *samplePositions, + RwV3d * baryCoords __RWUNUSED__, + RwUInt32 numSamples, + RpLight **lights, + RwUInt32 numLights, + RwV3d *normals); + +extern RwBool +RtLtMapDefaultVisCallBack(RpWorld *world, + RwRGBAReal *result __RWUNUSED__, + RwV3d *samplePos, + RwV3d *lightPos, + RpLight *light); + +extern void +RtLtMapSetVisCallBackCollisionScalar(RwReal scalar); + +extern RwReal +RtLtMapGetVisCallBackCollisionScalar(void); + +extern RtLtMapLightingSession * +RtLtMapLightingSessionInitialize(RtLtMapLightingSession *session, + RpWorld *world); + +extern RtLtMapLightingSession * +RtLtMapLightingSessionDeInitialize(RtLtMapLightingSession *session); + +extern RwInt32 +RtLtMapLightingSessionGetNumSamples(RtLtMapLightingSession *session); +extern RwInt32 +RtLtMapWorldSectorGetNumSamples(RpWorldSector *sector); +extern RwInt32 +RtLtMapAtomicGetNumSamples(RpAtomic *atomic); + +extern RtLtMapLightingSession * +RtLtMapImagesPurge(RtLtMapLightingSession *session); +extern RpAtomic * +RtLtMapAtomicImagePurge(RpAtomic *atomic); +extern RpWorldSector * +RtLtMapWorldSectorImagePurge(RpWorldSector *sector); + +extern RtLtMapLightingSession * +RtLtMapLightMapsClear(RtLtMapLightingSession *session, RwRGBA *color); +extern RpAtomic * +RtLtMapAtomicLightMapClear(RpAtomic *atomic, RwRGBA *color); +extern RpWorldSector * +RtLtMapWorldSectorLightMapClear(RpWorldSector *sector, RwRGBA *color); + + +/* Material/area-lighting functionality: */ +extern RtLtMapAreaLightGroup * +RtLtMapAreaLightGroupCreate(RtLtMapLightingSession *session, RwReal density); +extern RwBool +RtLtMapAreaLightGroupDestroy(RtLtMapAreaLightGroup *lights); + +extern RwUInt32 +RtLtMapMaterialGetFlags(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetFlags(RpMaterial *material, RwUInt32 flags); + +extern RwReal +RtLtMapMaterialGetLightMapDensityModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetLightMapDensityModifier(RpMaterial *material, RwReal modifier); + +extern RwRGBA +RtLtMapMaterialGetAreaLightColor(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightColor(RpMaterial *material, RwRGBA color); + +extern RwReal +RtLtMapMaterialGetAreaLightDensityModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightDensityModifier(RpMaterial *material, RwReal modifier); + +extern RwReal +RtLtMapMaterialGetAreaLightRadiusModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightRadiusModifier(RpMaterial *material, RwReal modifier); + +extern RwUInt32 +RtLtMapGetMaxAreaLightSamplesPerMesh(void); +extern RwBool +RtLtMapSetMaxAreaLightSamplesPerMesh(RwUInt32 maxSamples); +extern RwReal +RtLtMapGetAreaLightDensityModifier(void); +extern RwBool +RtLtMapSetAreaLightDensityModifier(RwReal modifier); +extern RwReal +RtLtMapGetAreaLightRadiusModifier(void); +extern RwBool +RtLtMapSetAreaLightRadiusModifier(RwReal modifier); +extern RwReal +RtLtMapGetAreaLightErrorCutoff(void); +extern RwBool +RtLtMapSetAreaLightErrorCutoff(RwReal tolerance); + + +/* Texture-saving functionality: */ +extern RwTexDictionary * +RtLtMapTexDictionaryCreate(RtLtMapLightingSession *session); + +extern const RwChar * +RtLtMapGetDefaultPrefixString(void); +extern RwBool +RtLtMapSetDefaultPrefixString(RwChar *string); + +extern RwUInt32 +RtLtMapGetLightMapCounter(void); +extern RwBool +RtLtMapSetLightMapCounter(RwUInt32 value); + +/* Light map process functionality: */ +extern RwBool RtLtMapSetLightMapProcessCallBack(RtLtMapLightMapProcessCallBack cback); +extern RtLtMapLightMapProcessCallBack RtLtMapGetLightMapProcessCallBack( void ); + +extern RtLtMapLightingSession * +RtLtMapLightingSessionLightMapProcess(RtLtMapLightingSession *session); + +/* PS2-specific functionality: */ +extern RwTexture *RtLtMapSkyLightMapMakeDarkMap(RwTexture *lightMap); + +extern RwTexture *RtLtMapSkyBaseTextureProcess(RwTexture *texture); +extern RpAtomic *RtLtMapSkyAtomicBaseTexturesProcess(RpAtomic *atomic); + +extern RpWorldSector * +RtLtMapSkyWorldSectorBaseTexturesProcess(RpWorldSector *sector); + +extern RtLtMapLightingSession * +RtLtMapSkyLightingSessionBaseTexturesProcess(RtLtMapLightingSession *session); + +extern RwRGBA *RtLtMapSkyLumCalcMaxCallBack( RwRGBA *scanline, RwUInt32 width ); +extern RwRGBA *RtLtMapSkyLumCalcSigmaCallBack( RwRGBA *scanline, RwUInt32 width ); +extern RwRGBA *RtLtMapSkyLumResetCallBack( RwRGBA *scanline, RwUInt32 width ); + +extern RwBool RtLtMapSkySetLumCalcCallBack(RtLtMapSkyLumCalcCallBack cback); +extern RtLtMapSkyLumCalcCallBack RtLtMapSkyGetLumCalcCallBack( void ); + +extern RwReal RtLtMapWorldCalculateDensity(RpWorld *world); +extern RwReal RtLtMapAtomicCalculateDensity(RpAtomic *atomic); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTLTMAP_H */ + + diff --git a/includes/rwsdk/rtltmap.rpe b/includes/rwsdk/rtltmap.rpe new file mode 100644 index 0000000..179d57a --- /dev/null +++ b/includes/rwsdk/rtltmap.rpe @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLTMAPTOOL +{ + + + + e_rwdb_CriterionLTMAPTOOLLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLTMAPTOOL e_rwdb_CriterionLTMAPTOOL; + + diff --git a/includes/rwsdk/rtltmapcnv.h b/includes/rwsdk/rtltmapcnv.h new file mode 100644 index 0000000..ce7ca3d --- /dev/null +++ b/includes/rwsdk/rtltmapcnv.h @@ -0,0 +1,541 @@ +/* + * Data structures for Lightmap conversion toolkit + * + * Copyright (c) Criterion Software Limited + */ + +/*************************************************************************** + * * + * Module : rtltmapcnv.h * + * * + * Purpose : * + * * + **************************************************************************/ + +#ifndef RTLTMAPCONVERT_H +#define RTLTMAPCONVERT_H + +/** + * \defgroup rtltmapcnv RtLtMapCnv + * \ingroup lighting + * + * Lightmap Conversion toolkit for RenderWare. + * + */ + +/** + * \ingroup rtltmapcnv + * \page rtltmapcnvoverview RtLtMap Conversion Toolkit Overview + * + * \par Requirements + * \li \b Headers: rwcore.h, rpworld.h, rprandom.h, rpltmap.h, rtltmap.h + * \li \b Libraries: rwcore, rpworld, rpcollis, rprandom, rpltmap, rppvs, rtbary, rtintsec, rtltmap + * \li \b Plugin \b attachments: \ref RpWorldPluginAttach, \ref RpCollisionPluginAttach, + * \ref RpRandomPluginAttach, \ref RpLtMapPluginAttach, \ref RpPVSPluginAttach + * + * \subsection ltmapcnvtoolkitoverview Overview + * + * The \ref rtltmapcnv toolkit contains a set of functions for + * converting lightmaps. This toolkit suppliments \ref rtltmap, a lightmap + * generation toolkit. + * + * Many major modelling packages provide the functionality to generate + * lightmaps. \ref rtltmapcnv provides a set of functionality to postprocess + * these lightmaps into a form that RenderWare can use. + * + * The conversion is a two stage process and is similar to generating lightmaps + * using \ref rtltmap. Firstly, lightmaps need to be allocated and associated + * with objects, and the UV coordinates for the lightmap pass need to be calculated + * (see \ref RtLtMapLightMapsCreate). + * + * Secondly, the imported lightmaps are converted. (see \ref RtLtMapCnvWorldConvert and + * \ref RtLtMapCnvAtomicConvert). This involves re-mapping each triangle lightmap + * in the imported lightmaps to RenderWare's lightmaps. The triangle lightmaps + * can be rescaled and re-oriented during the conversion. As a results, + * the final result may differ from the original. + * + * Lightmaps generated by this toolkit support tristripped geometry + * (unusual for lightmap implementations) and so will render very quickly, + * especially on such platforms as PlayStation 2. A few visual artifacts remain due + * to this tristrip support and the conversion although, in the vast majority + * of cases, they will go unnoticed or easily be worked around. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" +#include "rpusrdat.h" + +#include "rtltmapcnv.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Vars + */ +extern RwChar rtLtMapCnvUVtxUserDataName[]; +extern RwChar rtLtMapCnvVVtxUserDataName[]; +extern RwChar rtLtMapCnvPolyUserDataName[]; + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup rtltmapcnv + * \ref RtLtMapCnvErrorFlags is an enumerated type specifying the different + * errors which may occur during lightmap conversion. The flags are bitfields + * to represent more than one type of error. + */ +enum RtLtMapCnvErrorFlags +{ + rtLTMAPERROR_NONE = ((int)0x00000000), + + rtLTMAPERROR_IMPORTEDUVSOVERONEDOTZERO = ((int)0x00000001),/**< A flag to indicate a UV out of range error. */ + rtLTMAPERROR_GENERATEDLIGHTMAPNOTFOUND = ((int)0x00000002),/**< A flag to indicate a RenderWare lightmap was not found. */ + rtLTMAPERROR_NOGENERATEDLIGHTMAPS = ((int)0x00000004),/**< A flag to indicate no RenderWare lightmaps were found. */ + rtLTMAPERROR_IMPORTEDLIGHTMAPNOTFOUND = ((int)0x00000008),/**< A flag to indicate an imported lightmap was not found. */ + rtLTMAPERROR_NOIMPORTEDLIGHTMAPS = ((int)0x00000010),/**< A flag to indicate no imported lightmaps were found. */ + + RTLTMAPERROR_FORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum RtLtMapCnvErrorFlags RtLtMapCnvErrorFlags; + +typedef struct rtLtMapCnvImageList rtLtMapCnvImageList; + +/** + * \ingroup rtltmapcnv + * \struct rtLtMapCnvImageList + * The rtLtMapCnvImageList is an internal use only data structure for matching the imported lightmap image + * with the RenderWare lightmap texture, referenced by imported lightmap name. + */ +struct rtLtMapCnvImageList +{ + RwTexture *texture; /**< Internal use only. Pointer to RenderWare's lightmap texture. */ + RwImage *image; /**< Internal use only. Pointer to the imported lightmap image. */ + RwChar *name; /**< The name reference of the lightmap. */ + + rtLtMapCnvImageList *next; /**< Next pointer in the list. */ +}; + + +typedef struct RtLtMapCnvWorldSectorData RtLtMapCnvWorldSectorData; + +/** + * \ingroup rtltmapcnv + * \struct RtLtMapCnvWorldSectorData + * The RtLtMapCnvWorldSectorData holds the imported lightmap data required for + * converting to RenderWare format. + * + * The structure stores the imported UV lightmap co-ordinates array and the + * lightmap texture name reference array. + * + * \see RtLtMapCnvWorldSectorCnvDataCreate + * \see RtLtMapCnvWorldSectorCnvDataDestroy + * \see RtLtMapCnvWorldSectorGetUArray + * \see RtLtMapCnvWorldSectorGetVArray + * \see RtLtMapCnvWorldSectorGetTexNameArray + */ +struct RtLtMapCnvWorldSectorData +{ + RpWorldSector *worldSector; /**< The parent world sector pointer. */ + + RpUserDataArray *texName; /**< A data array storing the texture name reference per triangle. */ + RpUserDataArray *vtxU; /**< A data array storing the U lightmap co-ordinate per vertex. */ + RpUserDataArray *vtxV; /**< A data array storing the V lightmap co-ordinate per vertex. */ +}; + + +typedef struct RtLtMapCnvWorldSession RtLtMapCnvWorldSession; + +/** + * \ingroup rtltmapcnv + * \struct RtLtMapCnvWorldSession + * + * The RtLtMapCnvWorldSession structure holds information to be passed to + * \ref RtLtMapCnvWorldConvert. It is used to parameterize the conversion + * process. + * + * \see RtLtMapCnvWorldSectorCnvDataCreate + * \see RtLtMapCnvWorldSectorCnvDataDestroy + * \see RtLtMapCnvWorldConvert + * \see RtLtMapCnvWorldSessionGetRejectionFactor + * \see RtLtMapCnvWorldSessionSetRejectionFactor + * \see RtLtMapCnvWorldSessionGetGreedyRasterization + * \see RtLtMapCnvWorldSessionSetGreedyRasterization + * \see RtLtMapCnvWorldSessionGetImportedLtMapResample + * \see RtLtMapCnvWorldSessionSetImportedLtMapResample + */ +struct RtLtMapCnvWorldSession +{ + RpWorld *world; /**< This is the world whose lightmaps are converted + * during the conversion process. */ + RwUInt32 errorFlag; /**< A flag for returing the error status in the event + * of an error during conversion. */ + + RwInt32 numSector; /**< Internal use only. */ + RtLtMapCnvWorldSectorData *sectorList; /**< Internal use only. */ + + RwUInt32 samplingFactor; /**< Specifies the scaling factor for the RenderWare sample image, + * generated from the imported lightmaps during conversion. */ + RwBool reSampleImportedLightmap; /**< Specifies if the imported lightmap is to be rescaled to the working + * image size. */ + RwBool useGreedyRasterization; /**< Specifies if greedy rasterization is to used. */ + RwReal smallSizeRejectionFactor; /**< Specifies the small triangle rejection threshold. */ + + rtLtMapCnvImageList *headILTM; /**< Internal use only. */ + RwInt32 ILTMCount; /**< Internal use only. */ + + rtLtMapCnvImageList *headRWLTM; /**< Internal use only. */ + RwInt32 RWLTMCount; /**< Internal use only. */ +}; + + +typedef struct RtLtMapCnvAtomicSession RtLtMapCnvAtomicSession; + +/** + * \ingroup rtltmapcnv + * \struct RtLtMapCnvAtomicSession + * + * The RtLtMapCnvAtomicSession structure holds information to be passed to + * \ref RtLtMapCnvAtomicConvert. It is used to parameterize the conversion + * process. + * + * The structure stores the imported UV lightmap co-ordinates array and the + * lightmap texture name reference array. + * + * \see RtLtMapCnvAtomicCnvDataCreate + * \see RtLtMapCnvAtomicCnvDataDestroy + * \see RtLtMapCnvAtomicGetUArray + * \see RtLtMapCnvAtomicGetVArray + * \see RtLtMapCnvAtomicGetTexNameArray + * \see RtLtMapCnvAtomicConvert + * \see RtLtMapCnvAtomicSessionGetRejectionFactor + * \see RtLtMapCnvAtomicSessionSetRejectionFactor + * \see RtLtMapCnvAtomicSessionGetGreedyRasterization + * \see RtLtMapCnvAtomicSessionSetGreedyRasterization + * \see RtLtMapCnvAtomicSessionGetImportedLtMapResample + * \see RtLtMapCnvAtomicSessionSetImportedLtMapResample + */ +struct RtLtMapCnvAtomicSession +{ + RpAtomic *atomic; /**< The atomic whose lightmaps are converted + * during the conversion process. */ + RwUInt32 errorFlag; /**< A flag for returing the error status in the event + * of an error during conversion. */ + + RpGeometry *geometry; /**< Internal use only. */ + + RpUserDataArray *texName; /**< A user data array storing the texture name reference per triangle.*/ + RpUserDataArray *vtxU; /**< A user data array storing the U lightmap co-ordinate per vertex. */ + RpUserDataArray *vtxV; /**< A user data array storing the V lightmap co-ordinate per vertex. */ + + + RwUInt32 samplingFactor; /**< Specifies the scaling factor for the RenderWare sample image, + * generated from the imported lightmaps during conversion. */ + RwBool reSampleImportedLightmap; /**< Specifies if the imported lightmap is to be rescaled to the working + * image size. */ + RwBool useGreedyRasterization; /**< Specifies if greedy rasterization is to used. */ + RwReal smallSizeRejectionFactor; /**< Specifies the small triangle rejection threshold. */ + + rtLtMapCnvImageList *headILTM; /**< Internal use only. */ + RwInt32 ILTMCount; /**< Internal use only. */ + + rtLtMapCnvImageList *headRWLTM; /**< Internal use only. */ + RwInt32 RWLTMCount; /**< Internal use only. */ +}; + +/**************************************************************************** + Defines + */ + +#define RtLtMapCnvAnySetImportedLtMapResampleMacro(ses,resample)\ + ((ses)->reSampleImportedLightmap = (resample)) + +#define RtLtMapCnvAnySetGreedyRasterizationMacro(ses,greedy)\ + ((ses)->useGreedyRasterization = (greedy)) + +#define RtLtMapCnvAnySetRejectionFactorMacro(ses,factor)\ + ((ses)->smallSizeRejectionFactor = (factor)) + +#define RtLtMapCnvAnyGetImportedLtMapResampleMacro(ses)\ + ((ses)->reSampleImportedLightmap) + +#define RtLtMapCnvAnyGetGreedyRasterizationMacro(ses)\ + ((ses)->useGreedyRasterization) + +#define RtLtMapCnvAnyGetRejectionFactorMacro(ses)\ + ((ses)->smallSizeRejectionFactor) + +#define RtLtMapCnvAnySetVtxUVMacro(a,b,c)\ +MACRO_START\ +{\ + RpUserDataArraySetReal((a)->vtxU,(b),(c)->u);\ + RpUserDataArraySetReal((a)->vtxV,(b),(c)->v);\ +}\ +MACRO_STOP + +#define RtLtMapCnvAnyGetVtxUVMacro(data,idx,tex)\ +MACRO_START\ +{\ + tex->u = RpUserDataArrayGetReal((data)->vtxU,(idx));\ + tex->v = RpUserDataArrayGetReal((data)->vtxV,(idx));\ +}\ +MACRO_STOP + +#define RtLtMapCnvAnySetLightMapNameMacro(data,idx,name)\ + RpUserDataArraySetString((data)->texName,(idx),(name));\ + +#define RtLtMapCnvAnyGetLightMapNameMacro(data,idx) \ + (RpUserDataArrayGetString((data)->texName,(idx))) + + +/**************************************************************************** + Function prototypes + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RtLtMapCnvWorldIsConvertible(RpWorld *world); + +extern RtLtMapCnvWorldSession * +RtLtMapCnvWorldSessionCreate(RpWorld *world); + +extern void +RtLtMapCnvWorldSessionDestroy(RtLtMapCnvWorldSession *session); + +extern RwBool +RtLtMapCnvWorldConvert(RtLtMapCnvWorldSession *session, RwUInt32 factor); + +extern RpUserDataArray * +RtLtMapCnvWorldSectorGetTexNameArray(RpWorldSector *ws); + +extern RpUserDataArray * +RtLtMapCnvWorldSectorGetUArray(RpWorldSector *ws); + +extern RpUserDataArray * +RtLtMapCnvWorldSectorGetVArray(RpWorldSector *ws); + +extern RpWorldSector * +RtLtMapCnvWorldSectorCnvDataCreate(RpWorldSector *ws); + +extern RpWorldSector * +RtLtMapCnvWorldSectorCnvDataDestroy(RpWorldSector *ws); + +extern RwBool +RtLtMapCnvAtomicIsConvertible(RpAtomic *atomic); + +extern RtLtMapCnvAtomicSession * +RtLtMapCnvAtomicSessionCreate(RpAtomic *atomic); + +extern void +RtLtMapCnvAtomicSessionDestroy(RtLtMapCnvAtomicSession *session); + +extern RwBool +RtLtMapCnvAtomicConvert(RtLtMapCnvAtomicSession *session, RwUInt32 factor); + +extern RpUserDataArray * +RtLtMapCnvAtomicGetTexNameArray(RpAtomic *atm); + +extern RpUserDataArray * +RtLtMapCnvAtomicGetUArray(RpAtomic *atm); + +extern RpUserDataArray * +RtLtMapCnvAtomicGetVArray(RpAtomic *atm); + +extern RpAtomic * +RtLtMapCnvAtomicCnvDataCreate(RpAtomic *atm); + +extern RpAtomic * +RtLtMapCnvAtomicCnvDataDestroy(RpAtomic *atm); + + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtLtMapCnvWorldSectorSetVtxUV( RtLtMapCnvWorldSectorData *data, + RwInt32 idx, + RwTexCoords *tex); + +extern void +RtLtMapCnvWorldSectorGetVtxUV( RtLtMapCnvWorldSectorData *data, + RwInt32 idx, + RwTexCoords *tex); + +extern void +RtLtMapCnvWorldSectorSetLightMapName( RtLtMapCnvWorldSectorData *data, + RwInt32 idx, + RwChar *name); + +extern RwChar * +RtLtMapCnvWorldSectorGetLightMapName( RtLtMapCnvWorldSectorData *data, + RwInt32 idx); + +extern void +RtLtMapCnvWorldSessionSetImportedLtMapResample( + RtLtMapCnvWorldSession *session, + RwBool resample); +extern RwBool +RtLtMapCnvWorldSessionGetImportedLtMapResample( + RtLtMapCnvWorldSession *session); + + +extern void +RtLtMapCnvWorldSessionSetGreedyRasterization( + RtLtMapCnvWorldSession *session, + RwBool greedy); +extern RwBool +RtLtMapCnvWorldSessionGetGreedyRasterization( + RtLtMapCnvWorldSession *session); + + +extern void +RtLtMapCnvWorldSessionSetRejectionFactor( + RtLtMapCnvWorldSession *session, + RwReal factor); + +extern RwReal +RtLtMapCnvWorldSessionGetRejectionFactor( + RtLtMapCnvWorldSession *session); + +extern void +RtLtMapCnvAtomicSetVtxUV(RtLtMapCnvAtomicSession *session, + RwInt32 idx, + RwTexCoords *tex); + +extern void +RtLtMapCnvAtomicGetVtxUV( RtLtMapCnvAtomicSession *session, + RwInt32 idx, + RwTexCoords *tex); + +extern void +RtLtMapCnvAtomicSetLightMapName( RtLtMapCnvAtomicSession *session, + RwInt32 idx, + RwChar *name); + +extern RwChar * +RtLtMapCnvAtomicGetLightMapName( RtLtMapCnvAtomicSession *session, + RwInt32 idx); + +extern void +RtLtMapCnvAtomicSessionSetImportedLtMapResample( + RtLtMapCnvAtomicSession *session, + RwBool resample); +extern RwBool +RtLtMapCnvAtomicSessionGetImportedLtMapResample( + RtLtMapCnvAtomicSession *session); + + +extern void +RtLtMapCnvAtomicSessionSetGreedyRasterization( + RtLtMapCnvAtomicSession *session, + RwBool greedy); +extern RwBool +RtLtMapCnvAtomicSessionGetGreedyRasterization( + RtLtMapCnvAtomicSession *session); + + +extern void +RtLtMapCnvAtomicSessionSetRejectionFactor( + RtLtMapCnvAtomicSession *session, + RwReal factor); + +extern RwReal +RtLtMapCnvAtomicSessionGetRejectionFactor( + RtLtMapCnvAtomicSession *session); + +#else + +#define RtLtMapCnvWorldSectorSetVtxUV(data,idx,tex)\ + RtLtMapCnvAnySetVtxUVMacro(data,idx,tex) + +#define RtLtMapCnvWorldSectorGetVtxUV(data,idx,tex)\ + RtLtMapCnvAnyGetVtxUVMacro(data,idx,tex) + +#define RtLtMapCnvWorldSectorSetLightMapName(data,idx,name)\ + RtLtMapCnvAnySetLightMapNameMacro(data,idx,name) + +#define RtLtMapCnvWorldSectorGetLightMapName(data,idx)\ + RtLtMapCnvAnyGetLightMapNameMacro(data,idx) + +#define RtLtMapCnvWorldSectorGetLightMapName(data,idx)\ + RtLtMapCnvAnyGetLightMapNameMacro(data,idx) + +#define RtLtMapCnvWorldSessionSetImportedLtMapResample(ses,resample)\ + RtLtMapCnvAnySetImportedLtMapResampleMacro(ses,resample) + +#define RtLtMapCnvWorldSessionSetGreedyRasterization(ses,greedy)\ + RtLtMapCnvAnySetGreedyRasterizationMacro(ses,greedy) + +#define RtLtMapCnvWorldSessionSetRejectionFactor(ses,factor)\ + RtLtMapCnvAnySetRejectionFactorMacro(ses,factor) + +#define RtLtMapCnvWorldSessionGetImportedLtMapResample(ses)\ + RtLtMapCnvAnyGetImportedLtMapResampleMacro(ses) + +#define RtLtMapCnvWorldSessionGetGreedyRasterization(ses)\ + RtLtMapCnvAnyGetGreedyRasterizationMacro(ses) + +#define RtLtMapCnvWorldSessionGetRejectionFactor(ses)\ + RtLtMapCnvAnyGetRejectionFactorMacro(ses) + +#define RtLtMapCnvAtomicSetVtxUV(data,idx,tex)\ + RtLtMapCnvAnySetVtxUVMacro(data,idx,tex) + +#define RtLtMapCnvAtomicGetVtxUV(data,idx,tex)\ + RtLtMapCnvAnyGetVtxUVMacro(data,idx,tex) + +#define RtLtMapCnvAtomicSetLightMapName(data,idx,name)\ + RtLtMapCnvAnySetLightMapNameMacro(data,idx,name) + +#define RtLtMapCnvAtomicGetLightMapName(data,idx)\ + RtLtMapCnvAnyGetLightMapNameMacro(data,idx) + +#define RtLtMapCnvAtomicGetLightMapName(data,idx)\ + RtLtMapCnvAnyGetLightMapNameMacro(data,idx) + +#define RtLtMapCnvAtomicSessionSetImportedLtMapResample(ses,resample)\ + RtLtMapCnvAnySetImportedLtMapResampleMacro(ses,resample) + +#define RtLtMapCnvAtomicSessionSetGreedyRasterization(ses,greedy)\ + RtLtMapCnvAnySetGreedyRasterizationMacro(ses,greedy) + +#define RtLtMapCnvAtomicSessionSetRejectionFactor(ses,factor)\ + RtLtMapCnvAnySetRejectionFactorMacro(ses,factor) + +#define RtLtMapCnvAtomicSessionGetImportedLtMapResample(ses)\ + RtLtMapCnvAnyGetImportedLtMapResampleMacro(ses) + +#define RtLtMapCnvAtomicSessionGetGreedyRasterization(ses)\ + RtLtMapCnvAnyGetGreedyRasterizationMacro(ses) + +#define RtLtMapCnvAtomicSessionGetRejectionFactor(ses)\ + RtLtMapCnvAnyGetRejectionFactorMacro(ses) + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +extern rtLtMapCnvImageList * +_rtLtMapCnvImageCacheGet( const rtLtMapCnvImageList *imglist, + const RwChar *name); + +extern rtLtMapCnvImageList * +_rtLtMapCnvImageCacheAdd( const rtLtMapCnvImageList *imglist, + const RwChar *name); +extern void +_rtLtMapCnvImageCacheDestroy( rtLtMapCnvImageList *imglist); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTLtMapCnv_H */ + diff --git a/includes/rwsdk/rtltmapcnv.rpe b/includes/rwsdk/rtltmapcnv.rpe new file mode 100644 index 0000000..feba464 --- /dev/null +++ b/includes/rwsdk/rtltmapcnv.rpe @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLtMapCnv +{ + + + + e_rwdb_CriterionLtMapCnvLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLtMapCnv e_rwdb_CriterionLtMapCnv; + + diff --git a/includes/rwsdk/rtmipk.h b/includes/rwsdk/rtmipk.h new file mode 100644 index 0000000..6c777b4 --- /dev/null +++ b/includes/rwsdk/rtmipk.h @@ -0,0 +1,58 @@ +/** + * Mipmap K toolkit + */ + +/*************************************************************************** + * * + * Module : rtmipk.h * + * * + * Purpose : To calculate mipmap K values for Sky * + * * + **************************************************************************/ + +#ifndef RTMIPK_H +#define RTMIPK_H + +/** + * \defgroup rtmipk RtMipmapK + * \ingroup mipmapping + * + * PlayStation 2 / Mipmap K Value Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +/* RWPUBLIC */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void RtMipKWorldCalculateKValues(RpWorld *world, RwCamera *camera); +extern void RtMipKClumpCalculateKValues(RpClump *clump, RwCamera *camera); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTMIPK_H */ diff --git a/includes/rwsdk/rtmipk.rpe b/includes/rwsdk/rtmipk.rpe new file mode 100644 index 0000000..b846942 --- /dev/null +++ b/includes/rwsdk/rtmipk.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionMipmapK +{ + + + + e_rwdb_CriterionMipmapKLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionMipmapK e_rwdb_CriterionMipmapK; + + diff --git a/includes/rwsdk/rtnormmap.h b/includes/rwsdk/rtnormmap.h new file mode 100644 index 0000000..c3d35a6 --- /dev/null +++ b/includes/rwsdk/rtnormmap.h @@ -0,0 +1,48 @@ +/*===========================================================================* + *- -* + *- Module : rtnormmap.h -* + *- -* + *- Purpose : Normal Maps toolkit public API -* + *- -* + *===========================================================================*/ + +#if (!defined(RTNORMMAP_H)) +#define RTNORMMAP_H + +/** + * \defgroup rtnormmap RtNormMap + * \ingroup lighting + * + * Normal Maps Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtnormmap.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage * +RtNormMapCreateFromImage(RwImage *image, + RwBool clamp, + RwReal bumpiness); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* (!defined(RTNORMMAP_H)) */ diff --git a/includes/rwsdk/rtnormmap.rpe b/includes/rwsdk/rtnormmap.rpe new file mode 100644 index 0000000..63ce5cf --- /dev/null +++ b/includes/rwsdk/rtnormmap.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionNORMMAP +{ + + + + e_rwdb_CriterionNORMMAPLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionNORMMAP e_rwdb_CriterionNORMMAP; + + diff --git a/includes/rwsdk/rtpick.h b/includes/rwsdk/rtpick.h new file mode 100644 index 0000000..62f564a --- /dev/null +++ b/includes/rwsdk/rtpick.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * * + * Module : rtpick.h * + * * + * Purpose : Utils for picking atomics. * + * * + **************************************************************************/ + +#ifndef RTPICK_H +#define RTPICK_H + +/** + * \defgroup rtpick RtPick + * \ingroup collisiondetection + * + * Picking Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rtpick.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Camera pixel ray */ +extern const RwCamera *RwCameraCalcPixelRay(const RwCamera *camera, + RwLine *line, + const RwV2d *pixel); + +/* Picking atomics */ +extern RpAtomic *RpWorldPickAtomicOnLine(RpWorld *world, + const RwLine *line); +extern RpAtomic *RwCameraPickAtomicOnPixel(const RwCamera *camera, + const RwV2d *pixel); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* RTPICK_H */ diff --git a/includes/rwsdk/rtpick.rpe b/includes/rwsdk/rtpick.rpe new file mode 100644 index 0000000..185f680 --- /dev/null +++ b/includes/rwsdk/rtpick.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPick +{ + + + + e_rwdb_CriterionPickLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPick e_rwdb_CriterionPick; + + diff --git a/includes/rwsdk/rtpitexd.h b/includes/rwsdk/rtpitexd.h new file mode 100644 index 0000000..5a43cca --- /dev/null +++ b/includes/rwsdk/rtpitexd.h @@ -0,0 +1,76 @@ +/*********************************************************************** + * + * Module: rtpitexd.h + * + * Purpose: Platform Independent Texture Dictionaries + * + ***********************************************************************/ + +#if !defined( RTPITEXD_H ) +#define RTPITEXD_H + +/** + * \defgroup rtpitexd RtPITexD + * \ingroup texturedictionaries + * + * Platform Independent Texture Dictionaries + * + */ + + +/* ===================================================================== + * Includes + * ===================================================================== */ +#include "rwcore.h" +#include "rtpitexd.rpe" /* automatically generated */ + + +/* ===================================================================== + * Defines + * ===================================================================== */ + + +/* ===================================================================== + * Module specific type definitions + * ===================================================================== */ + +/* ===================================================================== + * Extern variables + * ===================================================================== */ + + +/* ===================================================================== + * Extern function prototypes + * ===================================================================== */ + +#if defined( __cplusplus ) +extern "C" +{ +#endif /* defined( __cplusplus ) */ + +extern RwPluginRegistry textureTKList; + +/* RWPUBLIC */ + +extern RwUInt32 +RtPITexDictionaryStreamGetSize( const RwTexDictionary *texDict ); + +extern RwTexDictionary * +RtPITexDictionaryStreamRead( RwStream *stream ); + +extern RwTexDictionary * +RtPITexDictionaryStreamWrite( RwTexDictionary *texDict, + RwStream *stream ); + +/* RWPUBLICEND */ + +extern void +_rwImageGammaUnCorrectArrayOfRGBA( RwRGBA * rgbaOut, + RwRGBA * rgbaIn, + RwInt32 numEls ); + +#if defined( __cplusplus ) +} +#endif /* defined( __cplusplus ) */ + +#endif /* !defined( RTPITEXD_H ) */ diff --git a/includes/rwsdk/rtpitexd.rpe b/includes/rwsdk/rtpitexd.rpe new file mode 100644 index 0000000..fe6dbce --- /dev/null +++ b/includes/rwsdk/rtpitexd.rpe @@ -0,0 +1,562 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPITexDict +{ + + + + e_rwdb_CriterionPITexDictLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPITexDict e_rwdb_CriterionPITexDict; + + diff --git a/includes/rwsdk/rtpng.h b/includes/rwsdk/rtpng.h new file mode 100644 index 0000000..4ba8cf0 --- /dev/null +++ b/includes/rwsdk/rtpng.h @@ -0,0 +1,49 @@ + +/*************************************************************************** + * * + * Module : rtPng.h * + * * + * Purpose : Load PNG format files * + * * + **************************************************************************/ + +#ifndef RTPNG_H +#define RTPNG_H + +/** + * \defgroup rtpng RtPNG + * \ingroup imageconversiontools + * + * PNG/Portable Network Graphics Image Format Toolkit for RenderWare. + * + * See also http://www.libpng.org/pub/png/ + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtpng.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtPNGImageWrite(RwImage * image, const RwChar * imageName); +extern RwImage *RtPNGImageRead(const RwChar * imageName); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTPNG_H */ diff --git a/includes/rwsdk/rtpng.rpe b/includes/rwsdk/rtpng.rpe new file mode 100644 index 0000000..0e06670 --- /dev/null +++ b/includes/rwsdk/rtpng.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPNG +{ + + + + e_rwdb_CriterionPNGLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPNG e_rwdb_CriterionPNG; + + diff --git a/includes/rwsdk/rtquat.h b/includes/rwsdk/rtquat.h new file mode 100644 index 0000000..6b7dcfe --- /dev/null +++ b/includes/rwsdk/rtquat.h @@ -0,0 +1,646 @@ +/* + * Data structures for Quaternions + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Hamilton.html + * + * Copyright (c) Criterion Software Limited + */ + +#ifndef RTQUAT_H +#define RTQUAT_H + +/** + * \defgroup rtquat RtQuat + * \ingroup mathtools + * + * Quaternion Toolkit for RenderWare. + * + * See also http://www.gamasutra.com/features/19980703/quaternions_01.htm + */ + +/* + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Hamilton.html + * On 16 October 1843 (a Monday) Hamilton was walking in along the Royal + * Canal with his wife to preside at a Council meeting of the Royal Irish + * Academy. + * + * Although his wife talked to him now and again Hamilton hardly + * heard, for the discovery of the quaternions, the first noncommutative + * algebra to be studied, was taking shape in his mind:- + * + * "And here there dawned on me the notion that we must admit, in + * some sense, a fourth dimension of space for the purpose of calculating + * with triples ... An electric circuit seemed to close, and a spark + * flashed forth." + */ + + +/**************************************************************************** + Includes + */ + +#include +/* renderware */ +#include "rwplcore.h" + +#include "rtquat.rpe" /* automatically generated header file */ + +#define RW_TOL_ORTHONORMAL ((RwReal)0.01) + +/**************************************************************************** + Global Types + */ + + +typedef struct RtQuat RtQuat; +/** + * \ingroup rtquat + * \struct RtQuat + * A structure describing a Quaternion + * +*/ +struct RtQuat +{ + RwV3d imag; /**< The imaginary part(s) */ + RwReal real; /**< The real part */ +}; + + +/**************************************************************************** + Defines + */ + +#define RtQuatInitMacro( result, _x, _y, _z, _w) \ +MACRO_START \ +{ \ + (result)->real = (_w); \ + (result)->imag.x = (_x); \ + (result)->imag.y = (_y); \ + (result)->imag.z = (_z); \ +} \ +MACRO_STOP + +#if (!defined(RtQuatAssignMacro)) +#define RtQuatAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RtQuatAssignMacro)) */ + +#define RtQuatAddMacro( result, q1, q2 ) \ +MACRO_START \ +{ \ + (result)->real = (q1)->real + (q2)->real; \ + RwV3dAddMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ +} \ +MACRO_STOP + +#define RtQuatIncrementRealPartMacro(result, s, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real + s; \ + (result)->imag.x = (q)->imag.x; \ + (result)->imag.y = (q)->imag.y; \ + (result)->imag.z = (q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatDecrementRealPartMacro(result, s, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real - s; \ + (result)->imag.x = (q)->imag.x; \ + (result)->imag.y = (q)->imag.y; \ + (result)->imag.z = (q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatIncrementMacro( result, dq ) \ +MACRO_START \ +{ \ + (result)->real = (result)->real + (dq)->real; \ + RwV3dAddMacro(&(result)->imag, &(result)->imag, &(dq)->imag); \ +} \ +MACRO_STOP + +#define RtQuatSubMacro( result, q1, q2 ) \ +MACRO_START \ +{ \ + (result)->real = (q1)->real - (q2)->real; \ + RwV3dSubMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ +} \ +MACRO_STOP + +#define RtQuatNegateMacro( result, q ) \ +MACRO_START \ +{ \ + (result)->real = -(q)->real; \ + (result)->imag.x = -(q)->imag.x; \ + (result)->imag.y = -(q)->imag.y; \ + (result)->imag.z = -(q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatConjugateMacro( result, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real; \ + (result)->imag.x = -(q)->imag.x; \ + (result)->imag.y = -(q)->imag.y; \ + (result)->imag.z = -(q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatScaleMacro(result, q, scale ) \ +MACRO_START \ +{ \ + (result)->real = (q)->real * scale; \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, scale); \ +} \ +MACRO_STOP + +#define RtQuatModulusSquaredMacro( q ) \ + ((q)->real * (q)->real + \ + RwV3dDotProductMacro(&(q)->imag, &(q)->imag)) + +#define RtQuatModulusMacro( result, q ) \ +MACRO_START \ +{ \ + (result) = RtQuatModulusSquaredMacro(q); \ + rwSqrtMacro(&result, result); \ +} \ +MACRO_STOP + +#define RtQuatMultiplyMacro( result, q1, q2) \ +MACRO_START \ +{ \ + /* \ + * Assumes q1 != result != q2 \ + */ \ + (result)->real = \ + (q1)->real * (q2)->real - \ + RwV3dDotProductMacro(&(q1)->imag,&(q2)->imag); \ + RwV3dCrossProductMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ + RwV3dIncrementScaledMacro(&(result)->imag, &(q2)->imag, (q1)->real); \ + RwV3dIncrementScaledMacro(&(result)->imag, &(q1)->imag, (q2)->real); \ +} \ +MACRO_STOP + +#define RtQuatReciprocalMacro( result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal val = RtQuatModulusSquaredMacro(q); \ + \ + if (val > (RwReal) 0) \ + { \ + val = ((RwReal)1) / val; \ + (result)->real = (q)->real * val; \ + val = -val; \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, val); \ + } \ +} \ +MACRO_STOP + +#define RtQuatSquareMacro( result, q ) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal val = ((RwReal)2) * (q)->real ; \ + \ + (result)->real = \ + (q)->real * (q)->real - \ + RwV3dDotProductMacro(&(q)->imag, &(q)->imag); \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, val); \ +} \ +MACRO_STOP + +#define RtQuatSquareRootMacro( result, q ) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + * other root is of course -result \ + */ \ + RwReal val; \ + \ + RtQuatModulusMacro(val,q); \ + val = ((q)->real + val) * ((RwReal) 0.5); \ + \ + if (val > ((RwReal)0)) \ + { \ + rwSqrtMacro(&val, val); \ + (result)->real = val; \ + val = ((RwReal)0.5) / val; \ + RwV3dScale(&(result)->imag, &(q)->imag, val); \ + } \ + else \ + { \ + result->imag.x = -(q)->real; \ + rwSqrtMacro(&(result->imag.x), result->imag.x); \ + result->imag.y = ((RwReal)0); \ + result->imag.x = ((RwReal)0); \ + result->real = ((RwReal)0); \ + } \ +} \ +MACRO_STOP + +#define RtQuatLogMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + const RwReal mod2 = RtQuatModulusSquaredMacro(q); \ + RwReal sin_b; \ + RwReal radians; \ + RwReal factor; \ + \ + sin_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&sin_b, sin_b); \ + radians = (RwReal) RwATan2(sin_b, (q)->real); \ + factor = (sin_b > (RwReal) 0) ? (((RwReal)radians) / sin_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = ((RwReal) RwLog(mod2)) * ((RwReal) 0.5); \ + \ +} \ +MACRO_STOP + +#define RtQuatExpMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + const RwReal exp_a = (RwReal)RwExp((q)->real); \ + RwReal mod_b; \ + RwReal factor; \ + \ + mod_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&mod_b, mod_b); \ + factor = ( (mod_b > (RwReal) 0) ? \ + (exp_a * ((RwReal)RwSin(mod_b)) / mod_b) : \ + 0 ) ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = exp_a * (RwReal)RwCos(mod_b); \ +} \ +MACRO_STOP + +#define RtQuatPowMacro( result, q, e) \ +MACRO_START \ +{ \ + RtQuat qLog; \ + \ + RtQuatLogMacro(&qLog, q); \ + RtQuatScaleMacro(&qLog, &qLog, e); \ + RtQuatExpMacro(result, &qLog); \ +} \ +MACRO_STOP + +#define RtQuatUnitLogMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal sin_b ; \ + RwReal radians ; \ + RwReal factor ; \ + \ + sin_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&sin_b, sin_b); \ + radians = (RwReal)RwATan2(sin_b, (q)->real); \ + factor = (sin_b > (RwReal) 0) ? (((RwReal)radians) / sin_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = (RwReal)0; \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitExpMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal mod_b; \ + RwReal factor; \ + \ + mod_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&mod_b, mod_b); \ + factor = (mod_b > (RwReal) 0) ? (((RwReal)RwSin(mod_b)) / mod_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = (RwReal)RwCos(mod_b); \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitPowMacro( result, q, e) \ +MACRO_START \ +{ \ + RtQuat qLog; \ + \ + RtQuatUnitLogMacro(&qLog, q); \ + RwV3dScaleMacro(&qLog.imag, &qLog.imag, e); \ + RtQuatUnitExpMacro(result, &qLog); \ +} \ +MACRO_STOP + +#define RtQuatConvertToMatrixMacro(qpQuat, mpMatrix) \ +MACRO_START \ +{ \ + RwReal rS; \ + RwV3d rV; \ + RwV3d rW; \ + RwV3d square; \ + RwV3d cross; \ + \ + rS = ((RwReal) 2) / RtQuatModulusSquaredMacro((qpQuat)); \ + \ + RwV3dScale(&rV, &(qpQuat)->imag, rS); \ + RwV3dScale(&rW, &rV, (qpQuat)->real); \ + \ + square.x = (qpQuat)->imag.x * rV.x; \ + square.y = (qpQuat)->imag.y * rV.y; \ + square.z = (qpQuat)->imag.z * rV.z; \ + \ + cross.x = (qpQuat)->imag.y * rV.z; \ + cross.y = (qpQuat)->imag.z * rV.x; \ + cross.z = (qpQuat)->imag.x * rV.y; \ + \ + (mpMatrix)->right.x = ((RwReal) 1) - (square.y + square.z); \ + (mpMatrix)->right.y = cross.z + rW.z; \ + (mpMatrix)->right.z = cross.y - rW.y; \ + \ + (mpMatrix)->up.x = cross.z - rW.z; \ + (mpMatrix)->up.y = ((RwReal) 1) - (square.z + square.x); \ + (mpMatrix)->up.z = cross.x + rW.x; \ + \ + (mpMatrix)->at.x = cross.y + rW.y; \ + (mpMatrix)->at.y = cross.x - rW.x; \ + (mpMatrix)->at.z = ((RwReal) 1) - (square.x + square.y); \ + \ + /* Set position */ \ + (mpMatrix)->pos.x = ((RwReal) 0); \ + (mpMatrix)->pos.y = ((RwReal) 0); \ + (mpMatrix)->pos.z = ((RwReal) 0); \ + \ + /* Matrix is orthogonal */ \ + rwMatrixSetFlags((mpMatrix), \ + (rwMATRIXTYPEORTHONORMAL & \ + ~rwMATRIXINTERNALIDENTITY) ); \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitConvertToMatrixMacro(qpQuat, mpMatrix) \ +MACRO_START \ +{ \ + const RwReal x = (qpQuat)->imag.x; \ + const RwReal y = (qpQuat)->imag.y; \ + const RwReal z = (qpQuat)->imag.z; \ + const RwReal w = (qpQuat)->real; \ + RwV3d square; \ + RwV3d cross; \ + RwV3d wimag; \ + \ + square.x = x * x; \ + square.y = y * y; \ + square.z = z * z; \ + \ + cross.x = y * z; \ + cross.y = z * x; \ + cross.z = x * y; \ + \ + wimag.x = w * x; \ + wimag.y = w * y; \ + wimag.z = w * z; \ + \ + (mpMatrix)->right.x = 1 - 2 * (square.y + square.z); \ + (mpMatrix)->right.y = 2 * (cross.z + wimag.z); \ + (mpMatrix)->right.z = 2 * (cross.y - wimag.y); \ + \ + (mpMatrix)->up.x = 2 * (cross.z - wimag.z); \ + (mpMatrix)->up.y = 1 - 2 * (square.x + square.z); \ + (mpMatrix)->up.z = 2 * (cross.x + wimag.x); \ + \ + (mpMatrix)->at.x = 2 * (cross.y + wimag.y); \ + (mpMatrix)->at.y = 2 * (cross.x - wimag.x); \ + (mpMatrix)->at.z = (1 - 2 * (square.x + square.y)); \ + \ + /* Set position */ \ + (mpMatrix)->pos.x = ((RwReal) 0); \ + (mpMatrix)->pos.y = ((RwReal) 0); \ + (mpMatrix)->pos.z = ((RwReal) 0); \ + \ + /* Matrix is orthonormal */ \ + rwMatrixSetFlags((mpMatrix), \ + (rwMATRIXTYPEORTHONORMAL & \ + ~rwMATRIXINTERNALIDENTITY) ); \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtQuatInit( result, _x, _y, _z, _w) \ + RtQuatInitMacro( result, _x, _y, _z, _w) + +#define RtQuatAssign( to, from ) \ + RtQuatAssignMacro( to, from ) + +#define RtQuatAdd( result, q1, q2 ) \ + RtQuatAddMacro( result, q1, q2 ) + +#define RtQuatIncrementRealPart(result, s, q) \ + RtQuatIncrementRealPartMacro(result, s, q) + +#define RtQuatDecrementRealPart(result, s, q) \ + RtQuatDecrementRealPartMacro(result, s, q) + +#define RtQuatIncrement( result, dq ) \ + RtQuatIncrementMacro( result, dq ) + +#define RtQuatSub( result, q1, q2 ) \ + RtQuatSubMacro( result, q1, q2 ) + +#define RtQuatNegate( result, q ) \ + RtQuatNegateMacro( result, q ) + +#define RtQuatConjugate( result, q) \ + RtQuatConjugateMacro( result, q) + +#define RtQuatScale(result, q, scale ) \ + RtQuatScaleMacro(result, q, scale ) + +#define RtQuatModulusSquared( q ) \ + RtQuatModulusSquaredMacro( q ) + +#define RtQuatMultiply( result, q1, q2) \ + RtQuatMultiplyMacro( result, q1, q2) + +#define RtQuatReciprocal( result, q) \ + RtQuatReciprocalMacro( result, q) + +#define RtQuatSquare( result, q ) \ + RtQuatSquareMacro( result, q ) + +#define RtQuatSquareRoot( result, q ) \ + RtQuatSquareRootMacro( result, q ) + +#define RtQuatLog( result, q ) \ + RtQuatLogMacro( result, q ) + +#define RtQuatExp( result, q ) \ + RtQuatExpMacro( result, q ) + +#define RtQuatPow( result, q, e ) \ + RtQuatPowMacro( result, q, e ) + +#define RtQuatUnitLog( result, q ) \ + RtQuatUnitLogMacro( result, q ) + +#define RtQuatUnitExp( result, q ) \ + RtQuatUnitExpMacro( result, q ) + +#define RtQuatUnitPow( result, q, e ) \ + RtQuatUnitPowMacro( result, q, e ) + +#define RtQuatConvertToMatrix(qpQuat, mpMatrix) \ + RtQuatConvertToMatrixMacro(qpQuat, mpMatrix) + +#define RtQuatUnitConvertToMatrix(qpQuat, mpMatrix) \ + RtQuatUnitConvertToMatrixMacro(qpQuat, mpMatrix) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RtQuatConvertFromMatrix(RtQuat * const qpQuat, + const RwMatrix * const mpMatrix); + +extern RtQuat * +RtQuatRotate(RtQuat * quat, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combineOp); + +extern const RtQuat * +RtQuatQueryRotate(const RtQuat *quat, + RwV3d * unitAxis, + RwReal * angle); + +extern RwV3d * +RtQuatTransformVectors(RwV3d * vectorsOut, + const RwV3d * vectorsIn, + const RwInt32 numPoints, + const RtQuat *quat); + +extern RwReal +RtQuatModulus(RtQuat * q); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtQuatInit(RtQuat * result, RwReal x, RwReal y, RwReal z, RwReal w); + +extern void +RtQuatAssign(RtQuat * to, RtQuat * from); + +extern void +RtQuatAdd(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatIncrementRealPart(RtQuat * result, RwReal s, RtQuat * q); + +extern void +RtQuatDecrementRealPart(RtQuat * result, RwReal s, RtQuat * q); + +extern void +RtQuatIncrement(RtQuat * result, RtQuat * dq); + +extern void +RtQuatSub(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatNegate(RtQuat * result, RtQuat * q); + +extern void +RtQuatConjugate(RtQuat * result, RtQuat * q); + +extern void +RtQuatScale(RtQuat * result, RtQuat * q, RwReal scale); + +extern RwReal +RtQuatModulusSquared(RtQuat * q); + +extern void +RtQuatMultiply(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatReciprocal(RtQuat * result, RtQuat * q); + +extern void +RtQuatSquare(RtQuat * result, RtQuat * q); + +extern void +RtQuatSquareRoot(RtQuat * result, RtQuat * q); + +extern void +RtQuatLog(RtQuat * result, RtQuat * q); + +extern void +RtQuatExp(RtQuat * result, RtQuat * q); + +extern void +RtQuatPow(RtQuat * result, RtQuat * q, RwReal e); + +extern void +RtQuatUnitLog(RtQuat * result, RtQuat * q); + +extern void +RtQuatUnitExp(RtQuat * result, RtQuat * q); + +extern void +RtQuatUnitPow(RtQuat * result, RtQuat * q, RwReal e); + +extern void +RtQuatConvertToMatrix(const RtQuat * const qpQuat, + RwMatrix * const mpMatrix); + +extern void +RtQuatUnitConvertToMatrix(const RtQuat * const qpQuat, + RwMatrix * const mpMatrix); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* + * Backwards compatibility code + */ + +typedef RtQuat RpQuat; + +#define RpAnimQuatConvertFromMatrix(qpQuat, mpMatrix) \ + RtQuatConvertFromMatrix(qpQuat, mpMatrix) + +#define RpAnimQuatConvertToMatrix(qpQuat,mpMatrix) \ + RtQuatUnitConvertToMatrix(qpQuat,mpMatrix) + + +#endif /* RTQUAT_H */ + diff --git a/includes/rwsdk/rtquat.rpe b/includes/rwsdk/rtquat.rpe new file mode 100644 index 0000000..ecc3f35 --- /dev/null +++ b/includes/rwsdk/rtquat.rpe @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionQuat +{ + + + + e_rwdb_CriterionQuatLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionQuat e_rwdb_CriterionQuat; + + diff --git a/includes/rwsdk/rtras.h b/includes/rwsdk/rtras.h new file mode 100644 index 0000000..4b9150e --- /dev/null +++ b/includes/rwsdk/rtras.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * * + * Module : rtRAS.h * + * * + * Purpose : Load RAS format files * + * * + **************************************************************************/ + +#ifndef RTRAS_H +#define RTRAS_H + +/** + * \defgroup rtras RtRAS + * \ingroup imageconversiontools + * + * RAS/Sun Raster File Format Image Format Toolkit for RenderWare. + * + * See also http://www.sworks.com/hollasch/cgindex/formats/sunraster.html + * + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtras.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtRASImageWrite(RwImage * image, + const RwChar * imageName); +extern RwImage *RtRASImageRead(const RwChar * imageName); + +extern void _rwImageGammaUnCorrectArrayOfRGBA(RwRGBA * rgbaOut, + RwRGBA * rgbaIn, + RwInt32 numEls); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTRAS_H */ diff --git a/includes/rwsdk/rtras.rpe b/includes/rwsdk/rtras.rpe new file mode 100644 index 0000000..e680159 --- /dev/null +++ b/includes/rwsdk/rtras.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRAS +{ + + + + e_rwdb_CriterionRASLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRAS e_rwdb_CriterionRAS; + + diff --git a/includes/rwsdk/rtray.h b/includes/rwsdk/rtray.h new file mode 100644 index 0000000..b2f3d4b --- /dev/null +++ b/includes/rwsdk/rtray.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * * + * Module : rtray.h * + * * + * Purpose : Picking with rays * + * * + **************************************************************************/ + +#ifndef RTRAY_H +#define RTRAY_H + +/** + * \defgroup rtray RtRay + * \ingroup mathtools + * + * Line Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rtray.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + + + /**************************************************************************** + Global Types + */ + + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Line intersections */ +extern RwReal RtLineTriangleIntersectionTest(RwLine *line, RwV3d *normal, + RwV3d *v0, RwV3d *v1, RwV3d *v2); +extern RwBool RtLineSphereIntersectionTest(RwLine *line, + RwSphere *sphere, + RwReal *centerDist); + +/* Line clipping */ +extern RwLine *RtLineClipPlane(RwLine *line, RwPlane *plane); +extern RwLine *RtLineClipBBox(RwLine *line, RwBBox *box); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTRAY_H */ diff --git a/includes/rwsdk/rtray.rpe b/includes/rwsdk/rtray.rpe new file mode 100644 index 0000000..7feb913 --- /dev/null +++ b/includes/rwsdk/rtray.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRay +{ + + + + e_rwdb_CriterionRayLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRay e_rwdb_CriterionRay; + + diff --git a/includes/rwsdk/rtskinsp.h b/includes/rwsdk/rtskinsp.h new file mode 100644 index 0000000..7e40c13 --- /dev/null +++ b/includes/rwsdk/rtskinsp.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * * + * Module : * + * * + * Purpose : * + * * + **************************************************************************/ + +/* RWPUBLIC */ + +#ifndef RTSKINSP_H +#define RTSKINSP_H + +/** + * \defgroup rtskinsplit RtSkinSplit + * \ingroup skinning + * + * Skin Splitting Toolkit for RenderWare Graphics. + */ + +/**************************************************************************** + Includes + */ +#include +#include + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Global variables (across program) + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cpluscplus */ + +extern RpAtomic * +RtSkinSplitAtomicSplitGeometry( RpAtomic *atomic, RwUInt32 boneLimit ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTSKINSP_H */ + +/* RWPUBLICEND */ diff --git a/includes/rwsdk/rtskinsp.rpe b/includes/rwsdk/rtskinsp.rpe new file mode 100644 index 0000000..34558f9 --- /dev/null +++ b/includes/rwsdk/rtskinsp.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionSkinSplit +{ + + + + e_rwdb_CriterionSkinSplitLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionSkinSplit e_rwdb_CriterionSkinSplit; + + diff --git a/includes/rwsdk/rtslerp.h b/includes/rwsdk/rtslerp.h new file mode 100644 index 0000000..5c697f7 --- /dev/null +++ b/includes/rwsdk/rtslerp.h @@ -0,0 +1,262 @@ +/* + * Data Structures for Slerps/Spherical Linear Interpolations + * See also GemsIII/quatspin.c in + * http://www.acm.org/pubs/tog/GraphicsGems/gemsiii.zip + * Copyright (c) Criterion Software Limited + */ + +/*************************************************************************** + * * + * Module : rtslerp.h * + * * + * Purpose : Slerp functionality * + * * + **************************************************************************/ + +#ifndef RTSLERP_H +#define RTSLERP_H + +/** + * \defgroup rtslerp RtSlerp + * \ingroup mathtools + * + * Slerp/Spherical Linear Interpolations Toolkit for RenderWare. + * + * See also http://www.cis.ohio-state.edu/~parent/book/Full.html + */ + +#include "rwcore.h" +#include "rtquat.h" + +/**************************************************************************** + Includes + */ + +#include "rtslerp.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/* Masks for specifying which matrices to store by reference */ +#define rtSLERPREFNONE 0x00 +#define rtSLERPREFSTARTMAT 0x01 +#define rtSLERPREFENDMAT 0x02 +#define rtSLERPREFALL (~rtSLERPREFNONE) + +/**************************************************************************** + Global Types + */ + + +typedef struct RtSlerp RtSlerp; +/** + * \ingroup rtslerp + * \struct RtSlerp + * structure describing a Slerps/Spherical Linear Interpolations. + * See also GemsIII/quatspin.c in + * http://www.acm.org/pubs/tog/GraphicsGems/gemsiii.zip + */ +struct RtSlerp +{ + RwInt32 matRefMask; /**< Which matrices do we NOT own */ + RwMatrix *startMat; /**< The start matrix */ + RwMatrix *endMat; /**< The end matrix */ + RwV3d axis; /**< The axis of rotation for the slerp */ + RwReal angle; /**< The angle (in degrees) between src & dest */ + + /* Though a slerp may be a bad idea and opting for a lerp is better */ + RwBool useLerp; /**< If true, lerps are used. If false, lerps are not used. */ +}; + +/* static frame sequence animation - contains no state */ + + +typedef struct RtQuatSlerpCache RtQuatSlerpCache; +/** + * \ingroup rtslerp + * \struct RtQuatSlerpCache + * structure describing a SlerpCache, + * which should be initialized with \ref RtQuatSetupSlerpCache. + */ +struct RtQuatSlerpCache +{ + RtQuat raFrom; /**< Scaled initial quaternion */ + RtQuat raTo; /**< Scaled final quaternion */ + RwReal omega; /**< Angular displacement in radians */ + RwBool nearlyZeroOm; /**< Flags near-zero angular + displacement*/ +}; + + +typedef struct RtQuatSlerpArgandCache RtQuatSlerpArgandCache; +/** + * \ingroup rtslerp + * \struct RtQuatSlerpArgandCache + * a structure describing + * an Argand SlerpCache which should be + * initialized with \ref RtQuatSetupSlerpArgandCache. + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Argand.html + * Jean Argand was an accountant and amateur mathematician. + * He is famed for his geometrical interpretation of the complex numbers + * where i is interpreted as a rotation through 90. + */ +struct RtQuatSlerpArgandCache +{ + RtQuat logTo; /**< field Logarithm of final quaternion */ + RtQuat logBase; /**< Logarithm of initial relative to final quaternion */ +}; + +#define RtQuatSlerpMacro(qpResult, qpFrom, qpTo, rT, sCache) \ +MACRO_START \ +{ \ + if ((rT) <= ((RwReal) 0)) \ + { \ + /* t is before start */ \ + *(qpResult) = *(qpFrom); \ + } \ + else if (((RwReal) 1) <= (rT)) \ + { \ + \ + /* t is after end */ \ + *(qpResult) = *(qpTo); \ + } \ + else \ + { \ + /* ... so t must be in the interior then */ \ + /* Calc coefficients rSclFrom, rSclTo */ \ + RwReal rSclFrom = ((RwReal) 1) - (rT); \ + RwReal rSclTo = (rT); \ + \ + if (!((sCache)->nearlyZeroOm)) \ + { \ + /* Standard case: slerp */ \ + /* SLERPMESSAGE(("Neither nearly ZERO nor nearly PI")); */ \ + \ + rSclFrom *= (sCache)->omega; \ + RwSinMinusPiToPiMacro(rSclFrom, rSclFrom); \ + rSclTo *= (sCache)->omega; \ + RwSinMinusPiToPiMacro(rSclTo, rSclTo); \ + } \ + \ + /* Calc final values */ \ + RwV3dScaleMacro(&(qpResult)->imag, \ + &(sCache)->raFrom.imag, rSclFrom); \ + RwV3dIncrementScaledMacro(&(qpResult)->imag, \ + &(sCache)->raTo.imag, rSclTo); \ + (qpResult)->real = \ + ((sCache)->raFrom.real * rSclFrom) + \ + ((sCache)->raTo.real * rSclTo); \ + } \ +} \ +MACRO_STOP + +#define RtQuatSlerpArgandMacro(qpResult, qpFrom, qpTo, rT, sArgandCache) \ +MACRO_START \ +{ \ + if ((rT) <= ((RwReal) 0)) \ + { \ + /* t is before start */ \ + *(qpResult) = *(qpFrom); \ + } \ + else if (((RwReal) 1) <= (rT)) \ + { \ + /* t is after end */ \ + *(qpResult) = *(qpTo); \ + } \ + else \ + { \ + RtQuat logBlend; \ + \ + /* ... so t must be in the interior then */ \ + \ + logBlend.imag.x = \ + (sArgandCache)->logBase.imag.x + \ + (rT) * (sArgandCache)->logTo.imag.x; \ + logBlend.imag.y = \ + (sArgandCache)->logBase.imag.y + \ + (rT) * (sArgandCache)->logTo.imag.y; \ + logBlend.imag.z = \ + (sArgandCache)->logBase.imag.z + \ + (rT) * (sArgandCache)->logTo.imag.z; \ + logBlend.real = 0; \ + \ + RtQuatUnitExpMacro((qpResult), &logBlend); \ + \ + } \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtQuatSlerp(qpResult, qpFrom, qpTo, rT, sCache) \ + RtQuatSlerpMacro(qpResult, qpFrom, qpTo, rT, sCache) + +#define RtQuatSlerpArgand(qpResult, qpFrom, qpTo, rT, sArgandCache) \ + RtQuatSlerpArgandMacro(qpResult, qpFrom, qpTo, rT, sArgandCache) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Creating and destroying slerps */ + +extern RtSlerp *RtSlerpCreate(RwInt32 nMatRefMask); + +extern void RtSlerpDestroy(RtSlerp * spSlerp); + +/* setting up a slerp */ +extern RtSlerp *RtSlerpInitialize(RtSlerp * spSlerp, + RwMatrix * mpMat1, + RwMatrix * mpMat2); + +/* Get a matrix */ +extern RwMatrix *RtSlerpGetMatrix(RtSlerp * spSlerp, + RwMatrix * mpResultMat, + RwReal nDelta); + +/* Set if lerp or slerp */ +extern RtSlerp *RtSlerpSetLerp(RtSlerp * spSlerp, + RwBool bUseLerp); + +extern void +RtQuatSetupSlerpCache(RtQuat * qpFrom, + RtQuat * qpTo, + RtQuatSlerpCache * sCache); + +extern void +RtQuatSetupSlerpArgandCache(RtQuat * qpFrom, + RtQuat * qpTo, + RtQuatSlerpArgandCache * sArgandCache); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtQuatSlerp(RtQuat * qpResult, + RtQuat * qpFrom, + RtQuat * qpTo, + RwReal rT, + RtQuatSlerpCache * sCache); + +extern void +RtQuatSlerpArgand(RtQuat * qpResult, + RtQuat * qpFrom, + RtQuat * qpTo, + RwReal rT, + RtQuatSlerpArgandCache * sArgandCache); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTSLERP_H */ + diff --git a/includes/rwsdk/rtslerp.rpe b/includes/rwsdk/rtslerp.rpe new file mode 100644 index 0000000..bbda75c --- /dev/null +++ b/includes/rwsdk/rtslerp.rpe @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionSlerp +{ + + + + e_rwdb_CriterionSlerpLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionSlerp e_rwdb_CriterionSlerp; + + diff --git a/includes/rwsdk/rtsplpvs.h b/includes/rwsdk/rtsplpvs.h new file mode 100644 index 0000000..419717a --- /dev/null +++ b/includes/rwsdk/rtsplpvs.h @@ -0,0 +1,65 @@ + +/*************************************************************************** + * * + * Module : rtsplpvs.h * + * * + * Purpose : To generate pvs data for a world froma spline * + * * + **************************************************************************/ + +#ifndef RTSPLINEPVS_H +#define RTSPLINEPVS_H + +/** + * \defgroup rtsplinepvs RtSplinePVS + * \ingroup pvs + * + * Spline PVS Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" +#include "rpspline.h" + +/* RWPUBLIC */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpWorld * +RtSplinePVSConstruct(RpWorld * world, + RpSpline *spline, RwInt32 samples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +/* for back compatibility */ +#define RtSplinePVSCreate(_world, _raster, _zraster, \ + _mindist, _maxdist, _spline, _samples) \ + RtSplinePVSConstruct(_world, \ + _spline, _samples) + + +#endif /* RTSPLINEPVS_H */ diff --git a/includes/rwsdk/rtsplpvs.rpe b/includes/rwsdk/rtsplpvs.rpe new file mode 100644 index 0000000..c3396d3 --- /dev/null +++ b/includes/rwsdk/rtsplpvs.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionSplinePVS +{ + + + + e_rwdb_CriterionSplinePVSLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionSplinePVS e_rwdb_CriterionSplinePVS; + + diff --git a/includes/rwsdk/rttiff.h b/includes/rwsdk/rttiff.h new file mode 100644 index 0000000..b5d0ec0 --- /dev/null +++ b/includes/rwsdk/rttiff.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * * + * Module : rttiff.h * + * * + * Purpose : Load TIFF format files * + * * + **************************************************************************/ + +#ifndef RWTIFF_H +#define RWTIFF_H + +/** + * \defgroup rttiff RtTIFF + * \ingroup imageconversiontools + * + * TIFF/Tag Image File Format Image Format Toolkit for RenderWare. + * + * See also http://www.libtiff.org + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rttiff.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtTIFFImageRead(const RwChar *imageName); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RWTIFF_H */ diff --git a/includes/rwsdk/rttiff.rpe b/includes/rwsdk/rttiff.rpe new file mode 100644 index 0000000..030a88d --- /dev/null +++ b/includes/rwsdk/rttiff.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTIFF +{ + + + + e_rwdb_CriterionTIFFLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTIFF e_rwdb_CriterionTIFF; + + diff --git a/includes/rwsdk/rttilerd.h b/includes/rwsdk/rttilerd.h new file mode 100644 index 0000000..7cb8f88 --- /dev/null +++ b/includes/rwsdk/rttilerd.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * * + * Module : rttilerd.h * + * * + * Purpose : Tile renderer * + * * + **************************************************************************/ + +#ifndef RTTILERD_H +#define RTTILERD_H + +/** + * \defgroup rttilerender RtTileRender + * \ingroup cameras + * + * Tile renderer - e.g. grabbing screen shots - Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ +#include "rwcore.h" + +#include "rpcriter.h" + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +typedef RwCamera * (*RtTileRenderCallBack)(RwCamera *camera, + RwInt32 x, RwInt32 y, + void *pData); + +typedef RwImage * (*RtTileArchiveCallBack)(RwImage *image, + RwInt32 x, RwInt32 y, + void *pData); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Tile renderer */ + +extern RwCamera * +RtTileRender(RwCamera *camera, + RwInt32 imageWidth, RwInt32 imageHeight, + RwInt32 tileWidth, RwInt32 tileHeight, + RtTileRenderCallBack renderCallBack, + RtTileArchiveCallBack archiveCallBack, + void *pData); + +extern RwImage * +RtTileDefaultArchive(RwImage *image, + RwInt32 x, RwInt32 y, void *pData); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTTILERD_H */ diff --git a/includes/rwsdk/rttilerd.rpe b/includes/rwsdk/rttilerd.rpe new file mode 100644 index 0000000..df49ae6 --- /dev/null +++ b/includes/rwsdk/rttilerd.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTileRend +{ + + + + e_rwdb_CriterionTileRendLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTileRend e_rwdb_CriterionTileRend; + + diff --git a/includes/rwsdk/rttoc.h b/includes/rwsdk/rttoc.h new file mode 100644 index 0000000..0602b68 --- /dev/null +++ b/includes/rwsdk/rttoc.h @@ -0,0 +1,105 @@ +/****************************************************************************** + * * + * Module : rttoc.h * + * * + * Purpose : Table Of Contents (TOC) * + * * + ******************************************************************************/ + +#ifndef RTTOC_H +#define RTTOC_H + +/** + * \defgroup rttoc RtTOC + * \ingroup streaming + * + * Table Of Contents (TOC) - creating a TOC for a stream. + */ + +/****************************************************************************** + Includes + */ +#include "rwcore.h" + +#include "rpcriter.h" + +/****************************************************************************** + Defines + */ + +/****************************************************************************** + Global Types + */ + +typedef struct _rtTOCGUID _rtTOCGUID; +#if (!defined(DOXYGEN)) +struct _rtTOCGUID +{ + RwUInt32 data1; + RwUInt16 data2; + RwUInt16 data3; + RwUInt8 data4[8]; +}; +#endif /* (!defined(DOXYGEN)) */ + +typedef struct RtTOCEntry RtTOCEntry; +/** + * \ingroup rttoc + * \struct RtTOCEntry + * + * A Table Of Contents (TOC) entry structure. + */ +struct RtTOCEntry +{ + RwCorePluginID id; /**< Chunk ID */ + RwUInt32 gid; /**< Game ID */ + RwUInt32 offset; /**< Offset, in bytes, of the entry's \e chunk + * \e header (including the TOC) from the start + * of the file */ + _rtTOCGUID guid; /**< GUID, assigned by the RenderWare Graphics + * exporters */ +}; + +typedef struct RtTOC RtTOC; + +/** + * \ingroup rttoc + * \struct RtTOC + * + * Table Of Contents (TOC) structure. + */ +struct RtTOC +{ + RwInt32 numEntries; /**< Number of entries */ + RtTOCEntry entry[1]; /**< Entry */ +}; + +/****************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Create/Destroy */ +extern RtTOC *RtTOCCreate(RwStream *stream); +extern void RtTOCDestroy(RtTOC *toc); + +/* Access */ +extern RwInt32 RtTOCGetNumEntries(const RtTOC *toc); +extern RtTOCEntry *RtTOCGetEntry(RtTOC *toc, RwInt32 entry); + +/* Serialization */ +extern RwUInt32 RtTOCStreamGetSize(const RtTOC *toc); +extern const RtTOC *RtTOCStreamWrite(RtTOC *toc, RwStream *stream); +extern RtTOC *RtTOCStreamRead(RwStream *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTTOC_H */ + diff --git a/includes/rwsdk/rttoc.rpe b/includes/rwsdk/rttoc.rpe new file mode 100644 index 0000000..41de330 --- /dev/null +++ b/includes/rwsdk/rttoc.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTOC +{ + + + + e_rwdb_CriterionTOCLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTOC e_rwdb_CriterionTOC; + + diff --git a/includes/rwsdk/rtvcat.h b/includes/rwsdk/rtvcat.h new file mode 100644 index 0000000..474095e --- /dev/null +++ b/includes/rwsdk/rtvcat.h @@ -0,0 +1,38 @@ + +/*************************************************************************** + * * + * Module : rtvcat.h * + * * + * Purpose : Tristripping callback for vertex cache aware strips * + * * + **************************************************************************/ + +#ifndef RTVCAT_H +#define RTVCAT_H + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtvcat.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern RpMeshHeader * +RpBuildMeshGenerateCacheAwareTriStrip(RpBuildMesh *buildMesh, + void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* RTVCAT_H */ diff --git a/includes/rwsdk/rtvcat.rpe b/includes/rwsdk/rtvcat.rpe new file mode 100644 index 0000000..a10e674 --- /dev/null +++ b/includes/rwsdk/rtvcat.rpe @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionVextexCacheStrip +{ + + + + e_rwdb_CriterionVextexCacheStripLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionVextexCacheStrip e_rwdb_CriterionVextexCacheStrip; + + diff --git a/includes/rwsdk/rtwing.h b/includes/rwsdk/rtwing.h new file mode 100644 index 0000000..758075a --- /dev/null +++ b/includes/rwsdk/rtwing.h @@ -0,0 +1,201 @@ + +/*************************************************************************** + * * + * Module : rtwing.h * + * * + * Purpose : Winged-edge (half-edge) algorithms * + * * + **************************************************************************/ + +#ifndef RTWING_H +#define RTWING_H + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rtimport.h" +#include "rtgcond.h" + +/* RWPUBLIC */ + + +/**************************************************************************** + Defines + */ + +/** + * \defgroup rtwing RtWing + * \ingroup basicgeometry + * + * Winged edge/half-edge toolkit for RenderWare Graphics. + */ + + +/**************************************************************************** + Typedefs + */ +typedef struct RtWings RtWings; /* container for the faces, vertices and edges */ +typedef struct RtWingFace RtWingFace; +typedef struct RtWingVertex RtWingVertex; +typedef struct RtWingEdge RtWingEdge; + +/** + * \ingroup rtwing + * \struct RtWingFace + * Holds data for each face in the winged edge data structure. + */ +struct RtWingFace +{ + RtWingEdge* edge; /**< pointer to one of the edges */ + RtGCondPolygon* polygonInfo; /**< pointer to RtGCond polygon rep. */ + RwV3d normal; /**< INTERNAL USE ONLY */ + RwReal value; /**< INTERNAL USE ONLY */ +}; + +/** + * \ingroup rtwing + * \struct RtWingVertex + * Holds data for each vertex in the winged edge data structure. + */ +struct RtWingVertex +{ + RtWingEdge* edge; /**< pointer to one of the edges */ + RtGCondVertex* vertexInfo; /**< pointer to RtGCond vertex rep. */ + RwReal value; /**< INTERNAL USE ONLY */ +}; + +/** + * \ingroup rtwing + * \ref RtWingEdgeNeighborRelation + * + * An enumeration that tags an edge with neighbor information to help + * queries and filter operations. + */ +typedef enum +{ + rtWINGEDGENULL = 0, /**< The edge has no neighbor */ + rtWINGEDGECREASE, /**< The edge has a neighbor with mismatching attributes, e.g. face normal or material */ + rtWINGEDGECONTINUOUS, /**< The edge has a neighbor with matching attributes */ + rtWINGEDGEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +} +RtWingEdgeNeighborRelation; + +/** + * \ingroup rtwing + * \ref RtWingEdgePartitioning + * + * An enumeration that provides a value for the convex partitioner. + */ +typedef enum +{ + rtWINGEDGEPARTITIONFAN = 0, /**< Polygon is partitioned to help tri-fanning */ + rtWINGEDGEPARTITIONTACK, /**< Polygon is partitioned to help tri-stripping */ + rtWINGEDGEPARTITIONEAR, /**< Polygon is partitioned successfully if concave */ + rtWINGEDGEPARTITIONFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +} +RtWingEdgePartitioning; + +/** + * \ingroup rtwing + * \ref RtWingDecimationApproach + * + * An enumeration that provides a value for edge decimation. Note, this is only + * a tie-breaker and should not be considered a high control priority. + */ +typedef enum +{ + rtWINGEDGEDECIMATIONFEW = 0, /**< Polygon is partitioned to reduce triangles */ + rtWINGEDGEDECIMATIONSMALL, /**< Polygon is partitioned to reduce size */ + rtWINGEDGEDECIMATIONFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +} +RtWingDecimationApproach; + +/** + * \ingroup rtwing + * \struct RtWingEdge + * Holds data for each edge in the winged edge data structure. + */ +struct RtWingEdge +{ + RtWingEdge* neighbor; /**< pointer to neighbor, if any */ + RtWingEdgeNeighborRelation neighborRelation; /**< relationship info */ + + RtWingVertex* vertex; /**< pointer to vertex */ + RtWingFace* face; /**< pointer to face */ + + RtWingEdge* next; /**< pointer to next edge */ + RtWingEdge* prev; /**< pointer to previous edge (non-manifold requirement) */ + + RwReal value; /**< INTERNAL USE ONLY */ +}; + +/** + * \ingroup rtwing + * \struct RtWings + * Wrapper for wing each faces, edges and vertices. + */ +struct RtWings +{ + RtWingFace* wingFaces; /**< contiguous list of faces */ + RwInt32 wingFacesSize; /**< number of (space allocated for) faces */ + RtWingVertex* wingVertices; /**< contiguous list of vertices */ + RwInt32 wingVerticesSize; /**< number of (space allocated for) vertices */ + RtWingEdge* wingEdges; /**< contiguous list of edges */ + RwInt32 wingEdgesSize; /**< number of (space allocated for) edges */ +}; + +typedef RtWingEdge* +(*RtWingEdgeCallBack) (RtWingEdge* wingEdge, void* userData); +typedef RtWingFace* +(*RtWingFaceCallBack) (RtWingFace* wingFace, void* userData); +typedef RtWingVertex* +(*RtWingVertexCallBack) (RtWingVertex* wingVertex, void* userData); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RtWingFace *RtWingFaceForAllEdges(RtWingFace* wingFace, + RtWingEdgeCallBack callBack, void* userData); +extern RtWingFace *RtWingFaceForAllFaces(RtWingFace* wingFace, + RtWingFaceCallBack callBack, void* userData); +extern RtWingVertex *RtWingVertexForAllEdges(RtWingVertex* wingVertex, + RtWingEdgeCallBack callBack, void* userData); +extern RtWingVertex *RtWingVertexForAllFaces(RtWingVertex* wingVertex, + RtWingFaceCallBack callBack, void* userData); + +void RtWingMatchUVsAndPromoteContinuity(RtWings* wings, + RtGCondGeometryList* geometryList); +void RtWingUpdateInternalRepresentation(RtWingFace* face, RtWingEdge* edge, + RtWingVertex* vertex); + +extern RwBool RtWingCreate(RtWings* wings, RtGCondGeometryList* geometryList); +extern void RtWingEdgeDecimation(RtWings* wings, RtGCondGeometryList *geometryList); +extern void RtWingDestroy(RtWings* wings); +extern void RtWingPartitionPolygon(RtWings* wings, RtWingFace* face, + RtGCondGeometryList* geometryList, + RtWingEdgePartitioning how, RwInt32 ctr); +extern void RtWingConvexPartitioning(RtWings* wings, + RtGCondGeometryList *geometryList, RtWingEdgePartitioning how); +extern RtWingEdge *RtWingReallocateWingEdges(RtWings* wings, RwInt32 extraEdges); +extern RtWingVertex *RtWingReallocateWingVertices(RtWings* wings, + RtGCondGeometryList *geometryList, RwInt32 extraVertices); +extern RtWingFace *RtWingReallocateWingFaces(RtWings* wings, + RtGCondGeometryList *geometryList, RwInt32 extraFaces); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* RTWING_H */ + +/* RWPUBLICEND */ diff --git a/includes/rwsdk/rtwing.rpe b/includes/rwsdk/rtwing.rpe new file mode 100644 index 0000000..8944451 --- /dev/null +++ b/includes/rwsdk/rtwing.rpe @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionWing +{ + + +E_RW_SECTORDEGENERATE, + +E_RW_SECTORINVNOPOLYGONS, + +E_RW_NOPLANE, + +E_RW_SECTORINVPOLY, + +E_RW_SECTORUSED, + +E_RW_MAXBSPDEPTHEXCEEDED, + + + e_rwdb_CriterionWingLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionWing e_rwdb_CriterionWing; + + diff --git a/includes/rwsdk/rtworld.h b/includes/rwsdk/rtworld.h new file mode 100644 index 0000000..727d812 --- /dev/null +++ b/includes/rwsdk/rtworld.h @@ -0,0 +1,85 @@ +/* + * World toolkit. + */ +/*************************************************************************** + * * + * Module : rtworld.h * + * * + * Purpose : World tool helper functions header * + * * + **************************************************************************/ + +#ifndef RTWORLD_H +#define RTWORLD_H + +/** + * \defgroup rtworld RtWorld + * \ingroup basicgeometry + * + * World Import Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rpworld.h" + +#include "rtworld.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/* RWPUBLIC */ +/**************************************************************************** + Global Types + */ + +/* RWPUBLICEND */ + +/**************************************************************************** + Exported globals + */ + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Get the number of various things in the world */ +extern RwInt32 RtWorldGetNumWorldSectors(RpWorld *world); +extern RwInt32 RtWorldGetNumVertices(RpWorld *world); +extern RwInt32 RtWorldGetNumPolygons(RpWorld *world); + +/* Find things out about materials in the world */ +extern RwInt32 RtWorldFindMaterialNum(RpWorld *world, RpMaterial *material); +extern RpMaterial *RtWorldFindMaterialWithTextureName(RpWorld *world, RwChar *name); + +/* Optimisation functions in optimise.c */ +extern RpClump *RtClumpOptimize(RpClump *clump, RwReal dist); +extern RpAtomic *RtAtomicOptimize(RpAtomic *atomic, RwReal dist); + +/* + * This function has been removed, however it still exists as a stealth + * function, _rtGeometryOptimize. + */ +#define RtGeometryOptimize(geometry, dist) (geometry) + +extern RpGeometry *_rtGeometryOptimize(RpGeometry *geometry, RwReal dist); + +/* Import utility functions from imputil.c */ +extern RpGeometry *RtGeometryCalculateVertexNormals(RpGeometry *geometry); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RWTLWRLD_H */ diff --git a/includes/rwsdk/rtworld.rpe b/includes/rwsdk/rtworld.rpe new file mode 100644 index 0000000..7e0f70f --- /dev/null +++ b/includes/rwsdk/rtworld.rpe @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTlWorld +{ + + + + e_rwdb_CriterionTlWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTlWorld e_rwdb_CriterionTlWorld; + + diff --git a/includes/rwsdk/rwcore.h b/includes/rwsdk/rwcore.h new file mode 100644 index 0000000..c48ca88 --- /dev/null +++ b/includes/rwsdk/rwcore.h @@ -0,0 +1,4909 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Thu Feb 12 13:01:34 2004 + * + ************************************************************************/ + +#ifndef RWCORE_H +#define RWCORE_H + +/*--- System Header Files ---*/ +#include "rwplcore.h" + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2resort.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2macros.h ---*/ + +#define RxClusterDecCursorByStride(_cluster, _stride) \ + ((_cluster)->currentData = \ + (void *)(((RwUInt8 *)(_cluster)->currentData) - \ + (_stride))) + +#define RxClusterDecCursor(_cluster) \ + RxClusterDecCursorByStride(_cluster, (_cluster)->stride) + +#define RxClusterIncCursorByStride(_cluster, _stride) \ + ((_cluster)->currentData = \ + (void *)(((RwUInt8 *)(_cluster)->currentData) + \ + (_stride))) + +#define RxClusterIncCursor(_cluster) \ + RxClusterIncCursorByStride(_cluster, (_cluster)->stride) + +#define RxClusterResetCursor(_cluster) \ + ((_cluster)->currentData = (_cluster)->data) + +#define RxClusterGetCursorData(_cluster, _type) \ + ((_type *)(_cluster)->currentData) + +#define RxClusterGetIndexedData(_cluster, _type, _index) \ + ((_type *)(((RwUInt8 *)(_cluster)->data) + (_cluster)->stride*(_index))) + +#define RxClusterGetFreeIndex(_cluster) ( (_cluster)->numUsed++ ) + +#define RxPipelineClusterAssertAttributeSet(_cluster, _attributeSet) \ + RWASSERT( (_cluster)->clusterRef->attributeSet != NULL && \ + rwstrcmp((_cluster)->clusterRef->attributeSet, \ + (_attributeSet)) == 0 ) + +#define RxPipelineNodeParamGetData(_param) \ + ( (_param)->dataParam ) + +#define RxPipelineNodeParamGetHeap(_param) \ + ( (_param)->heap ) + + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2heap.h ---*/ + +#if (defined(RWDEBUG) && (defined(RWMEMDEBUG))) + +#if (!defined(DISABLERWHEAP)) +#define DISABLERWHEAP +#endif /* (!defined(DISABLERWHEAP)) */ + +#endif /* (defined(RWDEBUG) && (defined(RWMEMDEBUG))) */ + +typedef struct rxHeapFreeBlock rxHeapFreeBlock; +typedef struct rxHeapSuperBlockDescriptor rxHeapSuperBlockDescriptor; +typedef struct RxHeap RxHeap; +typedef struct rxHeapBlockHeader rxHeapBlockHeader; + +#if (!defined(DOXYGEN)) +struct rxHeapFreeBlock +{ + RwUInt32 size; + rxHeapBlockHeader *ptr; +}; + +struct rxHeapSuperBlockDescriptor +{ + void *start; + RwUInt32 size; + rxHeapSuperBlockDescriptor *next; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rwcoregeneric + * \struct RxHeap + * structure describing a pipeline execution heap + */ +struct RxHeap +{ + RwUInt32 superBlockSize; /**< Granularity of heap growth */ + rxHeapSuperBlockDescriptor *head; /**< Internally used superblock pointer */ + rxHeapBlockHeader *headBlock; /**< Internally used block pointer */ + rxHeapFreeBlock *freeBlocks; /**< Internally used free blocks pointer */ + RwUInt32 entriesAlloced; /**< Number of entries allocated */ + RwUInt32 entriesUsed; /**< Number of entries used */ + RwBool dirty; /**< Internally used boolean, flags whether + * the heap needs resetting or not. */ +}; + +#if (!defined(DOXYGEN)) +struct rxHeapBlockHeader +{ + /* present in all blocks (used & unused) */ + rxHeapBlockHeader *prev, *next; + RwUInt32 size; + rxHeapFreeBlock *freeEntry; /* (or null) */ + RwUInt32 pad[4]; /* alignment padding to 32 bytes */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/* This wrapper cheaply early-outs when a heap doesn't *need* resetting */ +#define RxHeapReset(heap) \ + ((FALSE == (heap)->dirty) ? (TRUE) : (_rxHeapReset(heap))) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxHeap *RxHeapCreate(RwUInt32 size); +extern void RxHeapDestroy(RxHeap * heap); +extern RwBool _rxHeapReset(RxHeap * heap); +extern void *RxHeapAlloc(RxHeap * heap, RwUInt32 size); +extern void RxHeapFree(RxHeap * heap, void *block); +extern void *RxHeapRealloc(RxHeap * heap, void *block, + RwUInt32 newSize, RwBool allowCopy); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if (defined(DISABLERWHEAP)) + +typedef struct rxHeapMallocTrace rxHeapMallocTrace; +struct rxHeapMallocTrace +{ + rxHeapMallocTrace *next; + rxHeapBlockHeader *block; +}; + +#endif /* (defined(DISABLERWHEAP)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2dep.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2core.h ---*/ + +extern RwInt32 _rxPipelineMaxNodes; +extern RwInt32 _rxHeapInitialSize; +/* LEGACY-SUPPORT MACRO */ +#define _rwRxHeapInitialSize _rxHeapInitialSize + +/* Beneficial padding of PowerPipe types is still being worked out... */ +#define PADCLUSTERSx + + +/************************************************************* + * Global Defines + */ + +#define RWBOOLTOGGLE(bVar) ((bVar == FALSE)?(bVar = TRUE):(bVar = FALSE)) + +/* Both these currently limited due to the use of RwUInt32 bit-fields */ +#define RXNODEMAXCLUSTERSOFINTEREST 32 +#define RXNODEMAXOUTPUTS 32 + +/* Useful (for memory alloc) to limit this during pipeline construction */ +#define RXPIPELINEDEFAULTMAXNODES 64 + +/* + * Cluster flags + */ + +#define rxCLFLAGS_NULL ((RwUInt16) 0x0000U) +#define rxCLFLAGS_CLUSTERVALID ((RwUInt16) 0x0001U) +#define rxCLFLAGS_EXTERNAL ((RwUInt16) 0x0002U) +#define rxCLFLAGS_EXTERNALMODIFIABLE ((RwUInt16) 0x0004U | 0x0002U) +#define rxCLFLAGS_MODIFIED ((RwUInt16) 0x0008U) + +/* + * Packet flags + */ + +#define rxPKFLAGS_NULL ((RwUInt16) 0x0000U) + +/* + * used in input specification + */ + +/** + * \ingroup rwcoregeneric + * \ref RxClusterValidityReq + * Flags specifying the state requirements for + * a \ref RxCluster on entry to a node */ +enum RxClusterValidityReq +{ + rxCLREQ_DONTWANT = 0, /**inputToClusterSlot[(CLIND)]) + +#define RxClusterLockRead(PKT, CLIND) \ + ( (((RwInt32)RXCLSLOT(PKT, CLIND)) == -1) ? \ + ((RxCluster *)NULL) : \ + (RxClusterResetCursor(&PKT->clusters[RXCLSLOT(PKT, CLIND)]), \ + &PKT->clusters[RXCLSLOT(PKT, CLIND)]) ) + +#endif /* !RWDEBUG */ + +extern RxCluster * +RxClusterLockWrite(RxPacket * packet, + RwUInt32 clusterIndex, + RxPipelineNode * node); + +extern void +RxClusterUnlock(RxCluster * cluster); + +extern RwUInt32 +RxPipelineNodeSendConfigMsg(RxPipelineNode * dest, + RwUInt32 msg, + RwUInt32 intparam, + void *ptrparam); + +extern RxPipelineNode * +RxPipelineNodeForAllConnectedOutputs(RxPipelineNode * node, + RxPipeline * pipeline, + RxPipelineNodeOutputCallBack callbackfn, + void *callbackdata); + +/* Cluster attributes api [pipeline construction time] */ + +extern RxPipelineCluster * +RxPipelineNodeGetPipelineCluster(RxPipelineNode *node, + RwUInt32 clustersOfInterestIndex); + +extern RwUInt32 +RxPipelineClusterGetCreationAttributes(RxPipelineCluster *cluster); + +extern RxPipelineCluster * +RxPipelineClusterSetCreationAttributes(RxPipelineCluster *cluster, + RwUInt32 creationAttributes); + +/* Cluster attributes api [pipeline execution time] */ + +extern RwUInt32 +RxClusterGetAttributes(RxCluster *cluster); + +extern RxCluster * +RxClusterSetAttributes(RxCluster *cluster, RwUInt32 attributes); + + +extern void +_rxEmbeddedPacketBetweenPipelines(RxPipeline * fromPipeline, + RxPipeline * toPipeline); + +extern RxPipelineNode * +_rxEmbeddedPacketBetweenNodes(RxPipeline *pipeline, + RxPipelineNode *nodeFrom, + RwUInt32 whichOutput); + +extern RxExecutionContext _rxExecCtxGlobal; + +/* Summary of dispatch rules: + * o nodes that never fetch are safe to dispatch NULL, whether + * nodes above pass them a packet or not + * o if you destroy the packet you can dispatch(NULL,,) + * o if you fetch/create and dispatch(NULL), it doesn't really + * matter - the packet'll get passed on anyway */ + +/* TODO: there's currently no way to prematurely terminate the pipeline + * without doing so as an error condition. You should create an + * enum for the exit code, either RXNODEEXITCONTINUE, RXNODEEXITTERMINATE + * or RXNODEEXTTERMINATEERROR and then test for RXNODEEXITCONTINUE in + * the below macros rather than FALSE. */ + +/* TODO: _packet redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchMacro(_packet, _output, _self) \ +MACRO_START \ +{ \ + RxPipeline *curPipeline = _rxExecCtxGlobal.pipeline; \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RxPipelineNode *nextNode = \ + _rxEmbeddedPacketBetweenNodes(curPipeline, \ + _self, \ + (_output)); \ + if ( nextNode != NULL ) \ + { \ + RwUInt32 exitCode = \ + nextNode->nodeDef->nodeMethods.nodeBody( \ + nextNode, &(_rxExecCtxGlobal.params)); \ + /* Don't overwrite 'error' with 'success' */ \ + if (FALSE == exitCode) _rxExecCtxGlobal.exitCode = exitCode; \ + } \ + } \ + if ( curPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + curPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(curPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +/* TODO: _self redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchToPipelineMacro(_packet, _pipeline, _self) \ +MACRO_START \ +{ \ + RxPipeline *toPipeline = (_pipeline); \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RwUInt32 exitCode; \ + RxPipeline *fromPipeline = _rxExecCtxGlobal.pipeline; /* save */ \ + _rxEmbeddedPacketBetweenPipelines(fromPipeline, \ + toPipeline); \ + _rxExecCtxGlobal.pipeline = toPipeline; /* modify */ \ + exitCode = \ + toPipeline->nodes[0].nodeDef->nodeMethods.nodeBody( \ + &toPipeline->nodes[0], &(_rxExecCtxGlobal.params)); \ + if ( FALSE == exitCode ) _rxExecCtxGlobal.exitCode = exitCode; \ + _rxExecCtxGlobal.pipeline = fromPipeline; /* restore */ \ + } \ + if ( toPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + toPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(toPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +#define rxPacketFetchMacro(_node) \ + ( ((_rxExecCtxGlobal.pipeline)->embeddedPacketState == rxPKST_PENDING) ?\ + ((_rxExecCtxGlobal.pipeline)->embeddedPacketState = rxPKST_INUSE, \ + (_rxExecCtxGlobal.pipeline)->embeddedPacket) : \ + (NULL) ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/d3d9/nodeD3D9SubmitNoLight.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2define.h ---*/ + +/** + * \ingroup rwcoregeneric + * \ref RxNodeOutput + * typedef for a reference to an output of a pipeline node */ +typedef RwUInt32 *RxNodeOutput; + +/** + * \ingroup rwcoregeneric + * \ref RxNodeInput + * typedef for a reference to the input of a pipeline node */ +typedef RxPipelineNode *RxNodeInput; + +/** + * \ingroup rwcoregeneric + * \ref RxLockedPipe + * typedef for a reference to a locked pipeline + */ +typedef RxPipeline RxLockedPipe; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* PIPELINENODE API */ + +extern RxNodeOutput +RxPipelineNodeFindOutputByName(RxPipelineNode *node, + const RwChar *outputname); + +extern RxNodeOutput +RxPipelineNodeFindOutputByIndex(RxPipelineNode *node, + RwUInt32 outputindex); + +extern RxNodeInput +RxPipelineNodeFindInput(RxPipelineNode *node); + +extern RxNodeDefinition * +RxPipelineNodeCloneDefinition(RxPipelineNode *node, + RxClusterDefinition *cluster2add); + +extern RxPipeline * +RxPipelineNodeRequestCluster(RxPipeline *pipeline, + RxPipelineNode *node, + RxClusterDefinition *clusterDef); + +extern RxPipeline * +RxPipelineNodeReplaceCluster(RxPipeline *pipeline, + RxPipelineNode *node, + RxClusterDefinition *oldClusterDef, + RxClusterDefinition *newClusterDef); + +extern void * +RxPipelineNodeGetInitData(RxPipelineNode *node); + +extern void * +RxPipelineNodeCreateInitData(RxPipelineNode *node, + RwUInt32 size); + +/* PIPELINE MANIPULATION API */ + +extern RxPipeline * +RxPipelineClone(RxPipeline *pipeline); + +extern RxPipelineNode * +RxPipelineFindNodeByName(RxPipeline *pipeline, + const RwChar *name, + RxPipelineNode *start, + RwInt32 *nodeIndex); + +extern RxPipelineNode * +RxPipelineFindNodeByIndex(RxPipeline *pipeline, + RwUInt32 nodeindex); + +extern RxLockedPipe * +RxPipelineLock(RxPipeline *pipeline); + +extern RxPipeline * +RxLockedPipeUnlock(RxLockedPipe *pipeline); + + +extern RxLockedPipe * +RxLockedPipeAddFragment(RxLockedPipe *pipeline, + RwUInt32 *firstIndex, + RxNodeDefinition *nodeDef0, + ...); + + +extern RxPipeline * +RxLockedPipeReplaceNode(RxLockedPipe *pipeline, + RxPipelineNode *node, + RxNodeDefinition *nodeDef); + +extern RxPipeline * +RxLockedPipeDeleteNode(RxLockedPipe *pipeline, + RxPipelineNode *node); + + +extern RxPipeline * +RxLockedPipeSetEntryPoint(RxLockedPipe *pipeline, + RxNodeInput in); + + +extern RxPipelineNode * +RxLockedPipeGetEntryPoint(RxLockedPipe *pipeline); + + +extern RxPipeline * +RxLockedPipeAddPath(RxLockedPipe *pipeline, + RxNodeOutput out, + RxNodeInput in); + +extern RxPipeline * +RxLockedPipeDeletePath(RxLockedPipe *pipeline, + RxNodeOutput out, + RxNodeInput in); + + +extern RxPipeline * +RxPipelineInsertDebugNode(RxPipeline *pipeline, + RxPipelineNode *before, + RxPipelineNode *after, + RxNodeDefinition *debugNode); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2altmdl.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9texdic.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9vertexbuffer.h ---*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void +RwD3D9VertexBufferManagerChangeDefaultSize(RwUInt32 defaultSize); + +/* + * To get a pointer to a static vertex buffer + * Use both functions, Create and Destroy, not only Create + */ +extern RwBool +RwD3D9CreateVertexBuffer(RwUInt32 stride, + RwUInt32 size, + void **vertexBuffer, + RwUInt32 *offset); + +extern void +RwD3D9DestroyVertexBuffer(RwUInt32 stride, + RwUInt32 size, + void *vertexBuffer, + RwUInt32 offset); + +/* + * To get a pointer to a Dynamic vertex buffer + * Use both functions, Create and Destroy, not only Create + */ +extern RwBool RwD3D9DynamicVertexBufferCreate(RwUInt32 size, + void **vertexBuffer); + +extern void RwD3D9DynamicVertexBufferDestroy(void *vertexBuffer); + +/* + * To get a temporary pointer to a Dynamic vertex buffer memory + * Don't use with the previous functions because + * it mantains an internal list of dinamic vertex buffers + */ +extern RwBool RwD3D9DynamicVertexBufferLock(RwUInt32 vertexSize, + RwUInt32 numVertex, + void **vertexBufferOut, + void **vertexDataOut, + RwUInt32 *baseIndexOut); + +extern RwBool RwD3D9DynamicVertexBufferUnlock(void *vertexBuffer); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9rendst.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9raster.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9convrt.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d92drend.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/d3d9device.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/ssematml.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/cpuext.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/baraster.h ---*/ + +/**************************************************************************** + Defines + */ + +/** + * \ingroup rwraster + * \ref RwRasterLockMode represents the options available for locking + * a raster so that it may be modified (see API function \ref RwRasterLock). An + * application may wish to write to the raster, read from the raster or + * simultaneously write and read a raster (rwRASTERLOCKWRITE | rwRASTERLOCKREAD). + */ +enum RwRasterLockMode +{ + rwRASTERLOCKWRITE = 0x01, /** + *
  • The pixel color format corresponding to one of the following values: + *
      + *
    • rwRASTERFORMAT1555 + *
    • rwRASTERFORMAT565 + *
    • rwRASTERFORMAT4444 + *
    • rwRASTERFORMATLUM8 + *
    • rwRASTERFORMAT8888 + *
    • rwRASTERFORMAT888 + *
    • rwRASTERFORMAT16 + *
    • rwRASTERFORMAT24 + *
    • rwRASTERFORMAT32 + *
    • rwRASTERFORMAT555 + *
    + * This value may be masked out of the raster format using + * rwRASTERFORMATPIXELFORMATMASK. + *
  • The palette depth if the raster is palettized: + *
      + *
    • rwRASTERFORMATPAL4 + *
    • rwRASTERFORMATPAL8 + *
    + * In these cases, the color format refers to that of the palette. + *
  • Flag rwRASTERFORMATMIPMAP. Set if the raster contains mipmap levels. + *
  • Flag rwRASTERFORMATAUTOMIPMAP. Set if the mipmap levels were generated + * automatically by RenderWare. + * + */ +enum RwRasterFormat +{ + rwRASTERFORMATDEFAULT = 0x0000, /* Whatever the hardware likes best */ + + rwRASTERFORMAT1555 = 0x0100, /**<16 bits - 1 bit alpha, 5 bits red, green and blue */ + rwRASTERFORMAT565 = 0x0200, /**<16 bits - 5 bits red and blue, 6 bits green */ + rwRASTERFORMAT4444 = 0x0300, /**<16 bits - 4 bits per component */ + rwRASTERFORMATLUM8 = 0x0400, /**width) + +#define RwRasterGetHeightMacro(_raster) \ + ((_raster)->height) + +#define RwRasterGetStrideMacro(_raster) \ + ((_raster)->stride) + +#define RwRasterGetDepthMacro(_raster) \ + ((_raster)->depth) + +#define RwRasterGetFormatMacro(_raster) \ + ((((_raster)->cFormat) & (rwRASTERFORMATMASK >> 8)) << 8) + +#define RwRasterGetTypeMacro(_raster) \ + (((_raster)->cType) & rwRASTERTYPEMASK) + +#define RwRasterGetParentMacro(_raster) \ + ((_raster)->parent) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwRasterGetWidth(_raster) \ + RwRasterGetWidthMacro(_raster) + +#define RwRasterGetHeight(_raster) \ + RwRasterGetHeightMacro(_raster) + +#define RwRasterGetStride(_raster) \ + RwRasterGetStrideMacro(_raster) + +#define RwRasterGetDepth(_raster) \ + RwRasterGetDepthMacro(_raster) + +#define RwRasterGetFormat(_raster) \ + RwRasterGetFormatMacro(_raster) + +#define RwRasterGetType(_raster) \ + RwRasterGetTypeMacro(_raster) + +#define RwRasterGetParent(_raster) \ + RwRasterGetParentMacro(_raster) + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Creating destroying rasters */ +extern void RwRasterSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwRaster *RwRasterCreate(RwInt32 width, RwInt32 height, + RwInt32 depth, RwInt32 flags); +extern RwBool RwRasterDestroy(RwRaster * raster); + +/* Pulling info out of raster structure */ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 RwRasterGetWidth(const RwRaster *raster); +extern RwInt32 RwRasterGetHeight(const RwRaster *raster); +extern RwInt32 RwRasterGetStride(const RwRaster *raster); +extern RwInt32 RwRasterGetDepth(const RwRaster *raster); +extern RwInt32 RwRasterGetFormat(const RwRaster *raster); +extern RwInt32 RwRasterGetType(const RwRaster *raster); +extern RwRaster *RwRasterGetParent(const RwRaster *raster); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwRaster *RwRasterGetOffset(RwRaster *raster, + RwInt16 *xOffset, RwInt16 *yOffset); + +extern RwInt32 RwRasterGetNumLevels(RwRaster * raster); + +extern RwRaster *RwRasterSubRaster(RwRaster * subRaster, + RwRaster * raster, RwRect * rect); + +extern RwRaster *RwRasterRenderFast(RwRaster * raster, RwInt32 x, + RwInt32 y); +extern RwRaster *RwRasterRender(RwRaster * raster, RwInt32 x, + RwInt32 y); +extern RwRaster *RwRasterRenderScaled(RwRaster * raster, + RwRect * rect); + +/* Raster rendering context */ +extern RwRaster *RwRasterPushContext(RwRaster * raster); +extern RwRaster *RwRasterPopContext(void); +extern RwRaster *RwRasterGetCurrentContext(void); + +/* Clearing rasters */ +extern RwBool RwRasterClear(RwInt32 pixelValue); +extern RwBool RwRasterClearRect(RwRect * rpRect, + RwInt32 pixelValue); + +/* Displaying rasters */ +extern RwRaster *RwRasterShowRaster(RwRaster * raster, void *dev, + RwUInt32 flags); + +/* Locking and releasing */ +extern RwUInt8 *RwRasterLock(RwRaster * raster, RwUInt8 level, + RwInt32 lockMode); +extern RwRaster *RwRasterUnlock(RwRaster * raster); +extern RwUInt8 *RwRasterLockPalette(RwRaster * raster, + RwInt32 lockMode); +extern RwRaster *RwRasterUnlockPalette(RwRaster * raster); + +/* Attaching toolkits */ +extern RwInt32 RwRasterRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwRasterGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwRasterValidatePlugins(const RwRaster * raster); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/drvmodel.h ---*/ +#ifndef D3D9_DRVMODEL_H +#define D3D9_DRVMODEL_H + +#if (defined(__ICL)) +/* Avoid voluminous + * 'warning #344: typedef name has already been declared (with same type)' + * warnings from MS include files + */ +#pragma warning( disable : 344 ) +#endif /* (defined(__ICL)) */ + + +#if (defined(RWDEBUG)) +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#define ERR_WRAP(A) (_rwRePrintErrorDDD3D((A), __FILE__, __LINE__)) +#endif /* (defined(RWDEBUG)) */ + +#if (!defined(ERR_WRAP)) +#define ERR_WRAP(A) (A) +#endif /* (!defined(ERR_WRAP)) */ + +/**************************************************************************** + Defines + */ + +/* Set true depth information (for fogging, eg) */ +#define RwIm2DVertexSetCameraX(vert, camx) /* Nothing */ +#define RwIm2DVertexSetCameraY(vert, camy) /* Nothing */ +#define RwIm2DVertexSetCameraZ(vert, camz) /* Nothing */ + +#define RwIm2DVertexSetRecipCameraZ(vert, recipz) ((vert)->rhw = recipz) + +#define RwIm2DVertexGetCameraX(vert) (cause an error) +#define RwIm2DVertexGetCameraY(vert) (cause an error) +#define RwIm2DVertexGetCameraZ(vert) (cause an error) +#define RwIm2DVertexGetRecipCameraZ(vert) ((vert)->rhw) + +/* Set screen space coordinates in a device vertex */ +#define RwIm2DVertexSetScreenX(vert, scrnx) ((vert)->x = (scrnx)) +#define RwIm2DVertexSetScreenY(vert, scrny) ((vert)->y = (scrny)) +#define RwIm2DVertexSetScreenZ(vert, scrnz) ((vert)->z = (scrnz)) +#define RwIm2DVertexGetScreenX(vert) ((vert)->x) +#define RwIm2DVertexGetScreenY(vert) ((vert)->y) +#define RwIm2DVertexGetScreenZ(vert) ((vert)->z) + +/* Set texture coordinates in a device vertex */ +#define RwIm2DVertexSetU(vert, texU, recipz) ((vert)->u = (texU)) +#define RwIm2DVertexSetV(vert, texV, recipz) ((vert)->v = (texV)) +#define RwIm2DVertexGetU(vert) ((vert)->u) +#define RwIm2DVertexGetV(vert) ((vert)->v) + +/* Modify the luminance stuff */ +#define RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + (((RwFastRealToUInt32(alpha)) << 24) | \ + ((RwFastRealToUInt32(red)) << 16) | \ + ((RwFastRealToUInt32(green)) << 8) | \ + ((RwFastRealToUInt32(blue))))) + +#define RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + ((((RwUInt32)(alpha)) << 24) | \ + (((RwUInt32)(red)) << 16) | \ + (((RwUInt32)(green)) << 8) | \ + (((RwUInt32)(blue))))) + +#define RwIm2DVertexGetRed(vert) \ + (((vert)->emissiveColor >> 16) & 0xFF) + +#define RwIm2DVertexGetGreen(vert) \ + (((vert)->emissiveColor >> 8) & 0xFF) + +#define RwIm2DVertexGetBlue(vert) \ + ((vert)->emissiveColor & 0xFF) + +#define RwIm2DVertexGetAlpha(vert) \ + (((vert)->emissiveColor >> 24) & 0xFF) + +#define RwIm2DVertexCopyRGBA(dst, src) \ + ((dst)->emissiveColor = (src)->emissiveColor) + +/* Clipper stuff */ + +#define RwIm2DVertexClipRGBA(o, i, n, f) \ +MACRO_START \ +{ \ + const RwInt32 _factor = \ + (RwFastRealToUInt32(i * (RwReal)(255))) & 255; \ + \ + (o)->emissiveColor = \ + (((((RwIm2DVertexGetAlpha(f) - RwIm2DVertexGetAlpha(n)) * \ + _factor) >> 8) + RwIm2DVertexGetAlpha(n)) << 24) | \ + (((((RwIm2DVertexGetRed(f) - RwIm2DVertexGetRed(n)) * \ + _factor) >> 8) + RwIm2DVertexGetRed(n)) << 16) | \ + (((((RwIm2DVertexGetGreen(f) - RwIm2DVertexGetGreen(n)) * \ + _factor) >> 8) + RwIm2DVertexGetGreen(n)) << 8) | \ + (((((RwIm2DVertexGetBlue(f) - RwIm2DVertexGetBlue(n)) * \ + _factor) >> 8) + RwIm2DVertexGetBlue(n))); \ +} \ +MACRO_STOP + +/**************************************************************************** + Global Types + */ + +/* We use RwD3D9Vertex to drive the hardware in 2D mode */ + +/* + * D3D9 vertex structure definition for 2D geometry + */ +#if !defined(RWADOXYGENEXTERNAL) +typedef struct RwD3D9Vertex RwD3D9Vertex; +/** + * \ingroup rwcoredriverd3d9 + * \struct RwD3D9Vertex + * D3D9 vertex structure definition for 2D geometry + */ +struct RwD3D9Vertex +{ + RwReal x; /**< Screen X */ + RwReal y; /**< Screen Y */ + RwReal z; /**< Screen Z */ + RwReal rhw; /**< Reciprocal of homogeneous W */ + + RwUInt32 emissiveColor; /**< Vertex color */ + + RwReal u; /**< Texture coordinate U */ + RwReal v; /**< Texture coordinate V */ +}; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +/* Define types used */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RwIm2DVertex + * Typedef for a RenderWare Graphics Immediate Mode 2D Vertex + */ +typedef RwD3D9Vertex RwIm2DVertex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RxVertexIndex + * + * Typedef for a RenderWare Graphics Powe rPipe Immediate + * Mode Vertex + */ +typedef RwUInt16 RxVertexIndex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RwImVertexIndex + * Typedef for a RenderWare Graphics Immediate Mode Vertex. + */ +typedef RxVertexIndex RwImVertexIndex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \struct RwD3D9Metrics + * Structure containing metrics counters + */ +typedef struct +{ + RwUInt32 numRenderStateChanges; /**< Number of Render States changed */ + RwUInt32 numTextureStageStateChanges; /**< Number of Texture Stage States changed */ + RwUInt32 numSamplerStageStateChanges; /**< Number of Sampler States changed */ + RwUInt32 numMaterialChanges; /**< Number of Material changes */ + RwUInt32 numLightsChanged; /**< Number of Lights changed */ + RwUInt32 numVBSwitches; /**< Number of Vertex Buffer switches */ +} +RwD3D9Metrics; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#endif /* D3D9_DRVMODEL_H */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/d3d9/pip2model.h ---*/ + + + + + +/**************************************************************************** + Global Defines + */ + +#define RXHEAPPLATFORMDEFAULTSIZE (1 << 12) /* 4k */ + +/**************************************************************************** + Global Types + */ + +/* We use D3D9 formats for the instanced versions, to allow hardware T&L */ + +/* + * Typedef for an RxObjSpace3DVertex. + */ +typedef struct RxObjSpace3DVertex RxObjSpace3DVertex; + +/** + * \ingroup cored3d9 + * \struct RxObjSpace3DVertex + * Structure representing object space vertex. + */ +struct RxObjSpace3DVertex +{ + RwV3d objVertex; /**< position */ + RwV3d objNormal; /**< normal */ + RwUInt32 color; /**< emissive color*/ + RwReal u; /**< u */ + RwReal v; /**< v */ +}; + +/* This vertex is non truncatable */ +#define RxObjSpace3DVertexNoUVsNoNormalsSize (sizeof(RxObjSpace3DVertex)) +#define RxObjSpace3DVertexNoUVsSize (sizeof(RxObjSpace3DVertex)) +#define RxObjSpace3DVertexFullSize (sizeof(RxObjSpace3DVertex)) + +/** + * \ingroup cored3d9 + * \ref RxObjSpace3DLitVertex + * Typedef for an RxObjSpace3DLitVertex. + */ +typedef RxObjSpace3DVertex RxObjSpace3DLitVertex; + +/** + * \ingroup cored3d9 + * \ref RwIm3DVertex + * Typedef for an RwIm3DVertex. + */ +typedef RxObjSpace3DLitVertex RwIm3DVertex; + +/* LEGACY-SUPPORT macro */ +/** + * \ingroup cored3d9 + * \ref RxScrSpace2DVertex + * Typedef for an RxScrSpace2DVertex structure + */ +typedef RwIm2DVertex RxScrSpace2DVertex; + +/**************************************************************************** + Object-space 3D unlit vertex macros + */ + +/* Vertex positions */ +#define RxObjSpace3DVertexGetPos(_vert, _pos) \ + (*(_pos) = (_vert)->objVertex) +#define RxObjSpace3DVertexSetPos(_vert, _pos) \ + ((_vert)->objVertex = *(_pos)) + +/* Pre-lighting colours */ +#define RxObjSpace3DVertexGetPreLitColor(_vert, _col) \ +MACRO_START \ +{ \ + (_col)->alpha = (RwUInt8)((_vert)->color >> 24) & 0xFF; \ + (_col)->red = (RwUInt8)((_vert)->color >> 16) & 0xFF; \ + (_col)->green = (RwUInt8)((_vert)->color >> 8) & 0xFF; \ + (_col)->blue = (RwUInt8)((_vert)->color ) & 0xFF; \ +} \ +MACRO_STOP + +#define RxObjSpace3DVertexSetPreLitColor(_vert, _col) \ + ((_vert)->color = (((RwUInt32)(_col)->alpha) << 24) | \ + (((RwUInt32)(_col)->red) << 16) | \ + (((RwUInt32)(_col)->green) << 8) | \ + (((RwUInt32)(_col)->blue) )) + +/* This uses the same slot as color (they are mutually exclusive) */ +#define RxObjSpace3DVertexGetColor RxObjSpace3DVertexGetPreLitColor + +/* Normals */ +#define RxObjSpace3DVertexGetNormal(_vert, _normal) \ + (*(_normal) = (_vert)->objNormal) +#define RxObjSpace3DVertexSetNormal(_vert, _normal) \ + ((_vert)->objNormal = *(_normal)) + +/* Us and Vs */ +#define RxObjSpace3DVertexGetU(_vert) \ + ((_vert)->u) +#define RxObjSpace3DVertexGetV(_vert) \ + ((_vert)->v) +#define RxObjSpace3DVertexSetU(_vert, _imu) \ + ((_vert)->u = (_imu)) +#define RxObjSpace3DVertexSetV(_vert, _imv) \ + ((_vert)->v = (_imv)) + +/**************************************************************************** + Object-space 3D lit vertex macros + */ + +/* Vertex positions */ +#define RxObjSpace3DLitVertexGetPos(_vert, _pos) \ + (*(_pos) = (_vert)->objVertex) +#define RxObjSpace3DLitVertexSetPos(_vert, _pos) \ + ((_vert)->objVertex = *(_pos)) + +/* Vertex colours */ +#define RxObjSpace3DLitVertexGetColor(_vert, _col) \ +MACRO_START \ +{ \ + (_col)->red = ((_vert)->color >> 16) & 0xFF; \ + (_col)->green = ((_vert)->color >> 8) & 0xFF; \ + (_col)->blue = ((_vert)->color ) & 0xFF; \ + (_col)->alpha = ((_vert)->color >> 24) & 0xFF; \ +} \ +MACRO_STOP +#define RxObjSpace3DLitVertexSetColor(_vert, _col) \ + ((_vert)->color = (((RwUInt32)(_col)->alpha) << 24) | \ + (((RwUInt32)(_col)->red) << 16) | \ + (((RwUInt32)(_col)->green) << 8) | \ + (((RwUInt32)(_col)->blue) )) + +/* Us and Vs */ +#define RxObjSpace3DLitVertexGetU(_vert) \ + ((_vert)->u) +#define RxObjSpace3DLitVertexGetV(_vert) \ + ((_vert)->v) +#define RxObjSpace3DLitVertexSetU(_vert, _imu) \ + ((_vert)->u = (_imu)) +#define RxObjSpace3DLitVertexSetV(_vert, _imv) \ + ((_vert)->v = (_imv)) + +/* LEGACY-SUPPORT for old objvert names - NB does NOT guarantee the + * app will work, because the old IM3DVERTEX macros are NOT correctly + * abstracted - 'Get' will return pointers to RwV3ds inside the + * ObjVert, but you can't assume there are any RwV3ds inside an + * opaque vertex type */ + +#define RwIm3DVertexSetU RxObjSpace3DLitVertexSetU +#define RwIm3DVertexSetV RxObjSpace3DLitVertexSetV +#define RwIm3DVertexGetNext(_vert) ((_vert) + 1) + +#define RwIm2DCameraVertexSetU(_devvert, _camvert, _u, _recipz) \ +MACRO_START \ +{ \ + RwReal _uTmp = _u; \ + _camvert->u = _uTmp; \ + RwIm2DVertexSetU(_devvert, _uTmp, _recipz); \ +} \ +MACRO_STOP +#define RwIm2DCameraVertexSetV(_devvert, _camvert, _v, _recipz) \ +MACRO_START \ +{ \ + RwReal _vTmp = _v; \ + _camvert->v = _vTmp; \ + RwIm2DVertexSetV(_devvert, _vTmp, _recipz); \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetPos(_vert, _imx, _imy, _imz) \ +MACRO_START \ +{ \ + (_vert)->objVertex.x = _imx; \ + (_vert)->objVertex.y = _imy; \ + (_vert)->objVertex.z = _imz; \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetNormal(vert, imx, imy, imz) \ +MACRO_START \ +{ \ + RwV3d packed; \ + packed.x = imx; \ + packed.y = imy; \ + packed.z = imz; \ + RxObjSpace3DVertexSetNormal(vert, &packed); \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetRGBA(_vert, _r, _g, _b, _a) \ +MACRO_START \ +{ \ + ((_vert)->color = ((_a) << 24) | \ + ((_r) << 16) | \ + ((_g) << 8) | \ + ((_b))); \ +} \ +MACRO_STOP + +#define RwIm3DVertexGetPos(_vert) (&((_vert)->objVertex)) +#define RwIm3DVertexGetNormal(vert) (&((vert)->objNormal)) + +#define RwIm3DVertexCopyRGBA(_dst, _src) (((_dst)->color) = ((_src)->color)) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2renderstate.h ---*/ + +/** + * \ingroup rwcoregeneric + * RxRenderStateFlag + * Flags used in the \ref RxRenderStateVector structure */ +enum RxRenderStateFlag +{ + rxRENDERSTATEFLAG_TEXTUREPERSPECTIVE = 0x00000001, /**stride = (_stride)), (_image)) + +#define RwImageSetPixelsMacro(_image, _pixels) \ + (((_image)->cpPixels = (_pixels)), (_image)) + +#define RwImageSetPaletteMacro(_image, _palette) \ + (((_image)->palette = (_palette)), (_image)) + +#define RwImageGetWidthMacro(_image) \ + ((_image)->width) + +#define RwImageGetHeightMacro(_image) \ + ((_image)->height) + +#define RwImageGetDepthMacro(_image) \ + ((_image)->depth) + +#define RwImageGetStrideMacro(_image) \ + ((_image)->stride) + +#define RwImageGetPixelsMacro(_image) \ + ((_image)->cpPixels) + +#define RwImageGetPaletteMacro(_image) \ + ((_image)->palette) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwImageSetStride(_image, _stride) \ + RwImageSetStrideMacro(_image, _stride) + +#define RwImageSetPixels(_image, _pixels) \ + RwImageSetPixelsMacro(_image, _pixels) + +#define RwImageSetPalette(_image, _palette) \ + RwImageSetPaletteMacro(_image, _palette) + +#define RwImageGetWidth(_image) \ + RwImageGetWidthMacro(_image) + +#define RwImageGetHeight(_image) \ + RwImageGetHeightMacro(_image) + +#define RwImageGetDepth(_image) \ + RwImageGetDepthMacro(_image) + +#define RwImageGetStride(_image) \ + RwImageGetStrideMacro(_image) + +#define RwImageGetPixels(_image) \ + RwImageGetPixelsMacro(_image) + +#define RwImageGetPalette(_image) \ + RwImageGetPaletteMacro(_image) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* Creating and destroying */ + +extern void RwImageSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern void RwImageFormatSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwImage *RwImageCreate(RwInt32 width, RwInt32 height, + RwInt32 depth); +extern RwBool RwImageDestroy(RwImage * image); + + /* Allocating */ +extern RwImage *RwImageAllocatePixels(RwImage * image); +extern RwImage *RwImageFreePixels(RwImage * image); + + /* Converting images */ +extern RwImage *RwImageCopy(RwImage * destImage, + const RwImage * sourceImage); + + /* Resizing images */ +extern RwImage *RwImageResize(RwImage * image, RwInt32 width, + RwInt32 height); + + /* Producing masks ! */ +extern RwImage *RwImageApplyMask(RwImage * image, + const RwImage * mask); +extern RwImage *RwImageMakeMask(RwImage * image); + + /* Helper functions */ +extern RwImage *RwImageReadMaskedImage(const RwChar * imageName, + const RwChar * maskname); +extern RwImage *RwImageRead(const RwChar * imageName); +extern RwImage *RwImageWrite(RwImage * image, + const RwChar * imageName); + + /* Setting and getting the default path for images */ +extern RwChar *RwImageGetPath(void); +extern const RwChar *RwImageSetPath(const RwChar * path); + /* Fast image path change */ +extern void _rwImageSwapPath(RwChar **path, RwInt32 *size); + + /* Setting */ +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwImage *RwImageSetStride(RwImage * image, RwInt32 stride); +extern RwImage *RwImageSetPixels(RwImage * image, RwUInt8 * pixels); +extern RwImage *RwImageSetPalette(RwImage * image, RwRGBA * palette); + + /* Getting */ +extern RwInt32 RwImageGetWidth(const RwImage * image); +extern RwInt32 RwImageGetHeight(const RwImage * image); +extern RwInt32 RwImageGetDepth(const RwImage * image); +extern RwInt32 RwImageGetStride(const RwImage * image); +extern RwUInt8 *RwImageGetPixels(const RwImage * image); +extern RwRGBA *RwImageGetPalette(const RwImage * image); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + /* Get device dependent pixel value */ +extern RwUInt32 RwRGBAToPixel(RwRGBA * rgbIn, RwInt32 rasterFormat); +extern RwRGBA *RwRGBASetFromPixel(RwRGBA * rgbOut, + RwUInt32 pixelValue, + RwInt32 rasterFormat); + + /* Gamma correction */ +extern RwBool RwImageSetGamma(RwReal gammaValue); +extern RwReal RwImageGetGamma(void); +extern RwImage *RwImageGammaCorrect(RwImage * image); + + /* Adding and removing gamma correction */ +extern RwRGBA *RwRGBAGammaCorrect(RwRGBA * rgb); + + /* Attaching toolkits */ +extern RwInt32 RwImageRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwImageGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwImageValidatePlugins(const RwImage * image); + +extern RwBool RwImageRegisterImageFormat(const RwChar * extension, + RwImageCallBackRead + imageRead, + RwImageCallBackWrite + imageWrite); + + /* Finding an extension for an image to load */ +extern const RwChar *RwImageFindFileType(const RwChar * imageName); + + /* Reading and writing images to streams */ +extern RwInt32 RwImageStreamGetSize(const RwImage * image); +extern RwImage *RwImageStreamRead(RwStream * stream); +extern const RwImage *RwImageStreamWrite(const RwImage * image, + RwStream * stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/palquant.h ---*/ + +/**************************************************************************** + Defines + */ + +#define RWPALQUANT_MAXDEPTH 8 +#define RWPALQUANT_MAXCOLOR (1<raster) + +#define RwTextureAddRefMacro(_tex) \ + (((_tex)->refCount++), (_tex)) + +#define RwTextureAddRefVoidMacro(_tex) \ +MACRO_START \ +{ \ + (_tex)->refCount++; \ +} \ +MACRO_STOP + +#define RwTextureGetNameMacro(_tex) \ + ((_tex)->name) + +#define RwTextureGetMaskNameMacro(_tex) \ + ((_tex)->mask) + +#define RwTextureGetDictionaryMacro(_tex) \ + ((_tex)->dict) + +#define RwTextureSetFilterModeMacro(_tex, _filtering) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREFILTERMODEMASK) | \ + (((RwUInt32)(_filtering)) & rwTEXTUREFILTERMODEMASK)), \ + (_tex)) + +#define RwTextureGetFilterModeMacro(_tex) \ + ((RwTextureFilterMode)((_tex)->filterAddressing & \ + rwTEXTUREFILTERMODEMASK)) + +#define RwTextureSetAddressingMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGMASK) | \ + (((((RwUInt32)(_addressing)) << 8) & rwTEXTUREADDRESSINGUMASK) | \ + ((((RwUInt32)(_addressing)) << 12) & rwTEXTUREADDRESSINGVMASK))), \ + (_tex)) + +#define RwTextureSetAddressingUMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGUMASK) | \ + (((RwUInt32)(_addressing) << 8) & rwTEXTUREADDRESSINGUMASK)), \ + (_tex)) + +#define RwTextureSetAddressingVMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGVMASK) | \ + (((RwUInt32)(_addressing) << 12) & rwTEXTUREADDRESSINGVMASK)), \ + (_tex)) + +#define RwTextureGetAddressingMacro(_tex) \ + (((((_tex)->filterAddressing & rwTEXTUREADDRESSINGUMASK) >> 8) == \ + (((_tex)->filterAddressing & rwTEXTUREADDRESSINGVMASK) >> 12)) ? \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGVMASK) >> 12)) : \ + rwTEXTUREADDRESSNATEXTUREADDRESS) + +#define RwTextureGetAddressingUMacro(_tex) \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGUMASK) >> 8)) + +#define RwTextureGetAddressingVMacro(_tex) \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGVMASK) >> 12)) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwTextureGetRaster(_tex) \ + RwTextureGetRasterMacro(_tex) + +#define RwTextureAddRef(_tex) \ + RwTextureAddRefMacro(_tex) + +#define RwTextureGetName(_tex) \ + RwTextureGetNameMacro(_tex) + +#define RwTextureGetMaskName(_tex) \ + RwTextureGetMaskNameMacro(_tex) + +#define RwTextureGetDictionary(_tex) \ + RwTextureGetDictionaryMacro(_tex) + +#define RwTextureSetFilterMode(_tex, _filtering) \ + RwTextureSetFilterModeMacro(_tex, _filtering) + +#define RwTextureGetFilterMode(_tex) \ + RwTextureGetFilterModeMacro(_tex) + +#define RwTextureSetAddressing(_tex, _addressing) \ + RwTextureSetAddressingMacro(_tex, _addressing) + +#define RwTextureSetAddressingU(_tex, _addressing) \ + RwTextureSetAddressingUMacro(_tex, _addressing) + +#define RwTextureSetAddressingV(_tex, _addressing) \ + RwTextureSetAddressingVMacro(_tex, _addressing) + +#define RwTextureGetAddressing(_tex) \ + RwTextureGetAddressingMacro(_tex) + +#define RwTextureGetAddressingU(_tex) \ + RwTextureGetAddressingUMacro(_tex) + +#define RwTextureGetAddressingV(_tex) \ + RwTextureGetAddressingVMacro(_tex) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* Reading mip maps */ + + /* Setting mip mapping states */ +extern RwBool RwTextureSetMipmapping(RwBool enable); +extern RwBool RwTextureGetMipmapping(void); +extern RwBool RwTextureSetAutoMipmapping(RwBool enable); +extern RwBool RwTextureGetAutoMipmapping(void); + + /* Setting and getting the mipmap generation function */ +extern RwBool +RwTextureSetMipmapGenerationCallBack(RwTextureCallBackMipmapGeneration + callback); +extern RwTextureCallBackMipmapGeneration +RwTextureGetMipmapGenerationCallBack(void); + + /* Setting and getting the mipmap file name generation function */ +extern RwBool +RwTextureSetMipmapNameCallBack(RwTextureCallBackMipmapName callback); +extern RwTextureCallBackMipmapName RwTextureGetMipmapNameCallBack(void); + + /* Generating mipmaps for a raster */ +extern RwBool RwTextureGenerateMipmapName(RwChar * name, + RwChar * maskName, + RwUInt8 mipLevel, + RwInt32 format); +extern RwBool RwTextureRasterGenerateMipmaps(RwRaster * raster, + RwImage * image); + + /* LEGACY-SUPPORT mip mapping */ +extern RwBool _rwTextureSetAutoMipMapState(RwBool enable); +extern RwBool _rwTextureGetAutoMipMapState(void); + + /* Setting and getting the callback function */ +extern RwTextureCallBackRead RwTextureGetReadCallBack(void); +extern RwBool RwTextureSetReadCallBack(RwTextureCallBackRead callBack); + +extern RwTextureCallBackFind RwTextureGetFindCallBack(void); +extern RwBool RwTextureSetFindCallBack(RwTextureCallBackFind callBack); + + /* Texture and mask names */ +extern RwTexture *RwTextureSetName(RwTexture * texture, + const RwChar * name); +extern RwTexture *RwTextureSetMaskName(RwTexture * texture, + const RwChar * maskName); + + /* Creating/destroying dictionaries */ +extern void RwTexDictionarySetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwTexDictionary *RwTexDictionaryCreate(void); +extern RwBool RwTexDictionaryDestroy(RwTexDictionary * dict); + + /* Textures */ +void RwTextureSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwTexture *RwTextureCreate(RwRaster * raster); +extern RwBool RwTextureDestroy(RwTexture * texture); + + /* Setting and getting texture map rasters */ +extern RwTexture *RwTextureSetRaster(RwTexture * texture, + RwRaster * raster); + + /* Dictionary access */ +extern RwTexture *RwTexDictionaryAddTexture(RwTexDictionary * dict, + RwTexture * texture); +extern RwTexture *RwTexDictionaryRemoveTexture(RwTexture * texture); +extern RwTexture *RwTexDictionaryFindNamedTexture(RwTexDictionary * + dict, + const RwChar * name); + + /* Reading a texture */ +extern RwTexture *RwTextureRead(const RwChar * name, + const RwChar * maskName); + + /* Setting the current dictionary */ +extern RwTexDictionary *RwTexDictionaryGetCurrent(void); +extern RwTexDictionary *RwTexDictionarySetCurrent(RwTexDictionary * dict); + + /* Enumerating textures */ +extern const RwTexDictionary *RwTexDictionaryForAllTextures(const + RwTexDictionary + * dict, + RwTextureCallBack + fpCallBack, + void *pData); + + /* Enumerating the texture dictionaries currently in the system */ +extern RwBool RwTexDictionaryForAllTexDictionaries( + RwTexDictionaryCallBack fpCallBack, void *pData); + + + /* Attaching toolkits */ +extern RwInt32 RwTextureRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwTexDictionaryRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy + copyCB); +extern RwInt32 RwTextureGetPluginOffset(RwUInt32 pluginID); +extern RwInt32 RwTexDictionaryGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwTextureValidatePlugins(const RwTexture * texture); +extern RwBool RwTexDictionaryValidatePlugins(const RwTexDictionary * + dict); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +/* Textures */ +extern RwRaster *RwTextureGetRaster(const RwTexture *texture); +extern RwTexture *RwTextureAddRef(RwTexture *texture); + +/* Texture and mask names */ +extern RwChar *RwTextureGetName(RwTexture *texture); +extern RwChar *RwTextureGetMaskName(RwTexture *texture); + +/* Get owner dictionary */ +extern RwTexDictionary *RwTextureGetDictionary(RwTexture *texture); + +/* Filtering */ +extern RwTexture *RwTextureSetFilterMode(RwTexture *texture, + RwTextureFilterMode filtering); + +extern RwTextureFilterMode RwTextureGetFilterMode(const RwTexture *texture); + +/* Addressing */ +extern RwTexture *RwTextureSetAddressing(RwTexture *texture, + RwTextureAddressMode addressing); +extern RwTexture *RwTextureSetAddressingU(RwTexture *texture, + RwTextureAddressMode addressing); +extern RwTexture *RwTextureSetAddressingV(RwTexture *texture, + RwTextureAddressMode addressing); + +extern RwTextureAddressMode RwTextureGetAddressing(const RwTexture *texture); +extern RwTextureAddressMode RwTextureGetAddressingU(const RwTexture *texture); +extern RwTextureAddressMode RwTextureGetAddressingV(const RwTexture *texture); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RwTextureSetAutoMipMapState(_enable) \ + _rwTextureSetAutoMipMapState(_enable) + +#define RwTextureGetAutoMipMapState() \ + _rwTextureGetAutoMipMapState() + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2stdcls.h ---*/ + +/* + * Current: + * + * wait on Simon for instructions to do cluster renaming thing, + * or go thru and change all cluster type names and cluster + * names (add CSL?) + * + */ + +/* CamVerts.csl */ + +/* clip flags */ + +/** + * \ingroup rwcoregeneric + * \ref RwClipFlag + * Flags specifying the clipping status of a vertex + */ +enum RwClipFlag +{ + rwXLOCLIP = 0x01, /**col.red = (r)); \ + ((camvert)->col.green = (g)); \ + ((camvert)->col.blue = (b)); \ + ((camvert)->col.alpha = (a)); \ +} \ +MACRO_STOP + +#define RxCamSpace3DVertexAddRGBA(camvert, r, g, b, a) \ +MACRO_START \ +{ \ + ((camvert)->col.red += (r)); \ + ((camvert)->col.green += (g)); \ + ((camvert)->col.blue += (b)); \ + ((camvert)->col.alpha += (a)); \ +} \ +MACRO_STOP + +/* LEGACY-SUPPORT macros */ +#define RXCAMSPACE3DVERTEXSetRGBA(camvert, r, g, b, a) \ + RxCamSpace3DVertexSetRGBA(camvert, r, g, b, a) +#define RXCAMSPACE3DVERTEXAddRGBA(camvert, r, g, b, a) \ + RxCamSpace3DVertexAddRGBA(camvert, r, g, b, a) + +/* MeshState.csl */ + + +/** + * \ingroup rwcoregeneric + * \ref RxGeometryFlag + * Flags describing geometry properties + */ +enum RxGeometryFlag +{ + rxGEOMETRY_TRISTRIP = 0x01, /**=1000) +# pragma pack(push, 1) +# endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +typedef struct RxVStep RxVStep; +/** + * \ingroup rwcoregeneric + * \struct RxVStep + * Structure used by the RxClVStep cluster. + * To use the step values in the RxClVStep cluster, start at the beginning + * of the RxVStep and vertex arrays and proceed as follows: (a) Process one + * vertex, (b) Skip 'step' vertices, (c) Increment the cursor of the RxClVStep + * cluster. Repeat (a)-(c) until the entire vertex array has been processed. + * If the RxVStep array contains valid data, you should not have to bounds-check + * its cursor. + */ +struct RxVStep +{ + RwUInt8 step; /**< \ref RwUInt8 The number of vertices after the current one + * which can be skipped in lighting and other calculations because, + * for example, they belong only to back-facing triangles */ +}; + +#if (defined(_MSC_VER)) +# if (_MSC_VER>=1000) +# pragma pack(pop) +# endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +/* CamNorms.csl */ +/** + * \ingroup rwcoregeneric + * \ref RxCamNorm + * typedef for \ref RwV3d used by the RxClVStep cluster */ +typedef RwV3d RxCamNorm; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Uses the RxObjSpace3DVertex type (see pipmodel.h) */ +extern RxClusterDefinition RxClObjSpace3DVertices; +/* Uses the RxCamSpace3DVertex type */ +extern RxClusterDefinition RxClCamSpace3DVertices; +/* Uses the RxScrSpace2DVertex type (see pipmodel.h) */ +extern RxClusterDefinition RxClScrSpace2DVertices; +/* Uses the RxInterp type */ +extern RxClusterDefinition RxClInterpolants; +/* Uses the RxMeshStateVector type */ +extern RxClusterDefinition RxClMeshState; +/* Uses the RxRenderStateVector type (p2renderstate.c/h) */ +extern RxClusterDefinition RxClRenderState; +/* Uses the RxVertexIndex type */ +extern RxClusterDefinition RxClIndices; +/* Uses the RxScatter type */ +extern RxClusterDefinition RxClScatter; +/* Uses the RxUV type */ +extern RxClusterDefinition RxClUVs; +/* Uses the RxVStep type */ +extern RxClusterDefinition RxClVSteps; +/* Uses the RwRGBAReal type */ +extern RxClusterDefinition RxClRGBAs; +/* Uses the RxCamNorm type */ +extern RxClusterDefinition RxClCamNorms; + +/* Uses the RxTriPlane type. + * NOTE: this is currently not used in any nodes that ship with the SDK */ +extern RxClusterDefinition RxClTriPlanes; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/baim3d.h ---*/ + +/** + * \ingroup rwim3d + * RwIm3DTransformFlags + * The bit-field type RwIm3DTransformFlags + * specifies options available for controlling execution of the 3D immediate + * mode pipeline (see API function \ref RwIm3DTransform):*/ +enum RwIm3DTransformFlags +{ + rwIM3D_VERTEXUV = 1, /**modelling) +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) +#define RwFrameGetMatrix(_f) RwFrameGetMatrixMacro(_f) +#endif + + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Finding what is attached to a frame */ +extern RwFrame * +RwFrameForAllObjects(RwFrame * frame, + RwObjectCallBack callBack, + void *data); + +/* Matrix operations */ +extern RwFrame * +RwFrameTranslate(RwFrame * frame, + const RwV3d * v, + RwOpCombineType combine); + +extern RwFrame * +RwFrameRotate(RwFrame * frame, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combine); + +extern RwFrame * +RwFrameScale(RwFrame * frame, + const RwV3d * v, + RwOpCombineType combine); + +extern RwFrame * +RwFrameTransform(RwFrame * frame, + const RwMatrix * m, + RwOpCombineType combine); + +extern RwFrame * +RwFrameOrthoNormalize(RwFrame * frame); + +extern RwFrame * +RwFrameSetIdentity(RwFrame * frame); + +/* Cloning */ +extern RwFrame * +RwFrameCloneHierarchy(RwFrame * root); + +/* Destruction */ +extern RwBool +RwFrameDestroyHierarchy(RwFrame * frame); + +/* Building a frame */ +extern RwFrame * +RwFrameForAllChildren(RwFrame * frame, + RwFrameCallBack callBack, + void *data); + +extern RwFrame * +RwFrameRemoveChild(RwFrame * child); + +extern RwFrame * +RwFrameAddChild(RwFrame * parent, RwFrame * child); + +extern RwFrame * +RwFrameAddChildNoUpdate(RwFrame *parent, RwFrame *child); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwFrame * +RwFrameGetParent(const RwFrame * frame); +#endif + +/* Getting the root */ +extern RwFrame * +RwFrameGetRoot(const RwFrame * frame); + +/* Getting Matrices */ +extern RwMatrix * +RwFrameGetLTM(RwFrame * frame); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwMatrix * +RwFrameGetMatrix(RwFrame * frame); +#endif + +/* Elements */ +extern RwFrame * +RwFrameUpdateObjects(RwFrame * frame); + +/* Creating destroying frames */ +extern void +RwFrameSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwFrame * +RwFrameCreate(void); + +extern RwBool +RwFrameDestroy(RwFrame * frame); + +/* Finding a frames state */ +extern RwBool +RwFrameDirty(const RwFrame * frame); + +/* Find the amount of frames in a hierarchy */ +extern RwInt32 +RwFrameCount(RwFrame * frame); + +/* static frame functions */ +extern RwBool +_rwFrameSetStaticPluginsSize(RwInt32 size); + +extern RwBool +_rwFrameInit(RwFrame *frame); + +extern RwBool +_rwFrameDeInit(RwFrame *frame); + +/* Plugins */ +extern RwInt32 +RwFrameRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RwFrameGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RwFrameValidatePlugins(const RwFrame * frame); + +/* Cloning */ +extern RwFrame * +_rwFrameCloneAndLinkClones(RwFrame * root); + +extern +RwFrame * +_rwFramePurgeClone(RwFrame *root); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/batypehf.h ---*/ + +typedef struct RwObjectHasFrame RwObjectHasFrame; +typedef RwObjectHasFrame * (*RwObjectHasFrameSyncFunction)(RwObjectHasFrame *object); + +#if (!defined(DOXYGEN)) +struct RwObjectHasFrame +{ + RwObject object; + RwLLLink lFrame; + RwObjectHasFrameSyncFunction sync; +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Frames */ +extern void _rwObjectHasFrameSetFrame(void *object, RwFrame *frame); +extern void _rwObjectHasFrameReleaseFrame(void *object); + +/* ObjectHASFRAME METHODS */ +#define rwObjectHasFrameInitialize(o, type, subtype, syncFunc) \ +MACRO_START \ +{ \ + rwObjectInitialize(o, type, subtype); \ + ((RwObjectHasFrame *)o)->sync = syncFunc; \ +} \ +MACRO_STOP + +#define rwObjectHasFrameSync(o) \ + ((RwObjectHasFrame *)(o))->sync(o) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compatibility macros */ + +#define rwObjectHasFrameSetFrame(object, frame) \ + _rwObjectHasFrameSetFrame(object, frame) +#define rwObjectHasFrameReleaseFrame(object) \ + _rwObjectHasFrameReleaseFrame(object) + + + +/*--- Automatically derived from: C:/daily/rwsdk/src/basync.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Sync all the dirty frames */ +extern RwBool _rwFrameSyncDirty(void); + +/* Syncing the LTMs in a hierarchy */ +extern void _rwFrameSyncHierarchyLTM(RwFrame *frame); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babintex.h ---*/ +/**************************************************************************** + Global types + */ +typedef struct rpTextureChunkInfo RwTextureChunkInfo; + +#if (!defined(DOXYGEN)) +struct rpTextureChunkInfo +{ + RwTextureFilterMode filtering; + RwTextureAddressMode addressingU; + RwTextureAddressMode addressingV; +}; +#endif /* (!defined(DOXYGEN)) */ + +/* Bit flags defining properties of textures when stream */ +enum RwTextureStreamFlags +{ + rwNATEXTURESTREAMFLAG = 0x00, + rwTEXTURESTREAMFLAGSUSERMIPMAPS = 0x01, + rwTEXTURESTREAMFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwTextureStreamFlags RwTextureStreamFlags; +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Texture binary format */ +extern RwInt32 +RwTextureRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwTextureSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwUInt32 +RwTextureStreamGetSize(const RwTexture *texture); + +extern RwTexture * +RwTextureStreamRead(RwStream *stream); + +extern const RwTexture * +RwTextureStreamWrite(const RwTexture *texture, + RwStream *stream); + +/* Texture dictionary binary format */ +extern RwInt32 +RwTexDictionaryRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwTexDictionarySetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwUInt32 +RwTexDictionaryStreamGetSize(const RwTexDictionary *texDict); + +extern RwTexDictionary +*RwTexDictionaryStreamRead(RwStream *stream); + +extern const RwTexDictionary * +RwTexDictionaryStreamWrite(const RwTexDictionary *texDict, + RwStream *stream); + +extern RwTextureChunkInfo * +_rwTextureChunkInfoRead(RwStream *stream, + RwTextureChunkInfo *textureChunkInfo, + RwInt32 *bytesRead); + +/* Compatibility macro */ + +#define RwTextureChunkInfoRead(_stream, _textureChunkInfo, _bytesRead) \ + _rwTextureChunkInfoRead(_stream, _textureChunkInfo, _bytesRead) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babinfrm.h ---*/ +/**************************************************************************** + Global types + */ + +typedef struct rwFrameList rwFrameList; + +#if (!defined(DOXYGEN)) +struct rwFrameList +{ + RwFrame **frames; + RwInt32 numFrames; +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Global Variables + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Frame binary format */ + +extern void +RwFrameListSetAutoUpdate(RwBool flag); + + +extern RwInt32 +RwFrameRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwFrameSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + + +extern rwFrameList * +_rwFrameListInitialize(rwFrameList *frameList, + RwFrame *frame); + +extern RwBool +_rwFrameListFindFrame(const rwFrameList *frameList, + const RwFrame *frame, + RwInt32 *npIndex); + +extern rwFrameList * +_rwFrameListDeinitialize(rwFrameList *frameList); + +extern RwUInt32 +_rwFrameListStreamGetSize(const rwFrameList *frameList); + +extern rwFrameList * +_rwFrameListStreamRead(RwStream *stream, + rwFrameList *fl); + +extern const rwFrameList * +_rwFrameListStreamWrite(const rwFrameList *frameList, + RwStream *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Comparibility macros */ + +#define rwFrameListInitialize(frameList,frame) \ + _rwFrameListInitialize(frameList,frame) + +#define rwFrameListFindFrame(frameList, frame, index) \ + _rwFrameListFindFrame(frameList, frame, index) + +#define rwFrameListDeinitialize(frameList) \ + _rwFrameListDeinitialize(frameList) + +#define rwFrameListStreamGetSize(frameList) \ + _rwFrameListStreamGetSize(frameList) + +#define rwFrameListStreamRead(stream, fl) \ + _rwFrameListStreamRead(stream, fl) + +#define rwFrameListStreamWrite(frameList, stream) \ + _rwFrameListStreamWrite(frameList, stream) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babbox.h ---*/ +/**************************************************************************** + Global types + */ + +typedef struct RwBBox RwBBox; +/** + * \ingroup rwbbox + * \struct RwBBox + * This type represents a 3D axis-aligned bounding-box + * specified by the positions of two corners which lie on a diagonal. + * Typically used to specify a world bounding-box when the world is created + * + * \param sup Supremum vertex (contains largest values) + * \param inf Infimum vertex (contains smallest values) + * + * \see RpWorldCreate + */ +struct RwBBox +{ + /* Must be in this order */ + RwV3d sup; /**< Supremum vertex. */ + RwV3d inf; /**< Infimum vertex. */ +}; + +#if (!defined(RwBBoxAssign)) +#define RwBBoxAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwBBoxAssign)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern RwBBox *RwBBoxCalculate(RwBBox *boundBox, + const RwV3d *verts, + RwInt32 numVerts); +extern RwBBox *RwBBoxInitialize(RwBBox *boundBox, + const RwV3d *vertex); +extern RwBBox *RwBBoxAddPoint(RwBBox *boundBox, + const RwV3d *vertex); +extern RwBool RwBBoxContainsPoint(const RwBBox *boundBox, + const RwV3d *vertex); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/bacamera.h ---*/ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rwCAMERA 4 + + + +/**************************************************************************** + viewOffset)) + +#define RwCameraSetRasterMacro(_camera, _raster) \ + (((_camera)->frameBuffer = (_raster)), (_camera)) + +#define RwCameraSetRasterVoidMacro(_camera, _raster) \ +MACRO_START \ +{ \ + (_camera)->frameBuffer = (_raster); \ +} \ +MACRO_STOP + +#define RwCameraGetRasterMacro(_camera) \ + ((_camera)->frameBuffer) + +#define RwCameraSetZRasterMacro(_camera, _raster) \ + (((_camera)->zBuffer = (_raster)), (_camera)) + +#define RwCameraSetZRasterVoidMacro(_camera, _raster) \ +MACRO_START \ +{ \ + (_camera)->zBuffer = (_raster); \ +} \ +MACRO_STOP + +#define RwCameraGetZRasterMacro(_camera) \ + ((_camera)->zBuffer) + +#define RwCameraGetNearClipPlaneMacro(_camera) \ + ((_camera)->nearPlane) + +#define RwCameraGetFarClipPlaneMacro(_camera) \ + ((_camera)->farPlane) + +#define RwCameraSetFogDistanceMacro(_camera, _distance) \ + (((_camera)->fogPlane = (_distance)), (_camera)) + +#define RwCameraGetFogDistanceMacro(_camera) \ + ((_camera)->fogPlane) + +#define RwCameraGetCurrentCameraMacro() \ + ((RwCamera *)RWSRCGLOBAL(curCamera)) + +#define RwCameraGetProjectionMacro(_camera) \ + ((_camera)->projectionType) + +#define RwCameraGetViewWindowMacro(_camera) \ + (&((_camera)->viewWindow)) + +#define RwCameraGetViewMatrixMacro(_camera) \ + (&((_camera)->viewMatrix)) + +#define RwCameraSetFrameMacro(_camera, _frame) \ + (_rwObjectHasFrameSetFrame((_camera), (_frame)), (_camera)) + +#define RwCameraSetFrameVoidMacro(_camera, _frame) \ +MACRO_START \ +{ \ + _rwObjectHasFrameSetFrame((_camera), (_frame)); \ +} \ +MACRO_STOP + + +#define RwCameraGetFrameMacro(_camera) \ + ((RwFrame *)rwObjectGetParent((_camera))) + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwCameraGetViewOffset(_camera) \ + RwCameraGetViewOffsetMacro(_camera) + +#define RwCameraSetRaster(_camera, _raster) \ + RwCameraSetRasterMacro(_camera, _raster) + +#define RwCameraGetRaster(_camera) \ + RwCameraGetRasterMacro(_camera) + +#define RwCameraSetZRaster(_camera, _raster) \ + RwCameraSetZRasterMacro(_camera, _raster) + +#define RwCameraGetZRaster(_camera) \ + RwCameraGetZRasterMacro(_camera) + +#define RwCameraGetNearClipPlane(_camera) \ + RwCameraGetNearClipPlaneMacro(_camera) + +#define RwCameraGetFarClipPlane(_camera) \ + RwCameraGetFarClipPlaneMacro(_camera) + +#define RwCameraSetFogDistance(_camera, _distance) \ + RwCameraSetFogDistanceMacro(_camera, _distance) + +#define RwCameraGetFogDistance(_camera) \ + RwCameraGetFogDistanceMacro(_camera) + +#define RwCameraGetCurrentCamera() \ + RwCameraGetCurrentCameraMacro() + +#define RwCameraGetProjection(_camera) \ + RwCameraGetProjectionMacro(_camera) + +#define RwCameraGetViewWindow(_camera) \ + RwCameraGetViewWindowMacro(_camera) + +#define RwCameraGetViewMatrix(_camera) \ + RwCameraGetViewMatrixMacro(_camera) + +#define RwCameraSetFrame(_camera, _frame) \ + RwCameraSetFrameMacro(_camera, _frame) + +#define RwCameraGetFrame(_camera) \ + RwCameraGetFrameMacro(_camera) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup rwcamera + * RwCameraClearMode + * Camera clear flags */ +enum RwCameraClearMode +{ + rwCAMERACLEARIMAGE = 0x1, /**var) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwInt32 _rxPipelineGlobalsOffset; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babincam.h ---*/ +/**************************************************************************** + Global types + */ + +/* Camera stream format */ + +/** + * \ingroup rwcamera + * \ref RwCameraChunkInfo is typedef'd to a structure that holds camera + * data. This should be considered an opaque type. Use the RwCamera + * API functions to access it. + */ + +typedef struct rwStreamCamera RwCameraChunkInfo; +typedef struct rwStreamCamera rwStreamCamera; + +#if (!defined(DOXYGEN)) +struct rwStreamCamera +{ + RwV2d viewWindow; + RwV2d viewOffset; + RwReal nearPlane, farPlane; + RwReal fogPlane; + RwUInt32 projection; +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Camera binary format */ +extern RwInt32 RwCameraRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RwCameraSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwUInt32 RwCameraStreamGetSize(const RwCamera *camera); +extern RwCamera *RwCameraStreamRead(RwStream *stream); +extern const RwCamera *RwCameraStreamWrite(const RwCamera *camera, + RwStream *stream); +extern RwCameraChunkInfo * RwCameraChunkInfoRead(RwStream *stream, + RwCameraChunkInfo *cameraChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWCORE_H */ diff --git a/includes/rwsdk/rwplcore.h b/includes/rwsdk/rwplcore.h new file mode 100644 index 0000000..344e499 --- /dev/null +++ b/includes/rwsdk/rwplcore.h @@ -0,0 +1,6827 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Thu Feb 12 13:01:33 2004 + * + ************************************************************************/ + +#ifndef RWPLCORE_H +#define RWPLCORE_H + +/*--- System Header Files ---*/ +#include +#include +#include +#include + + +/*--- Automatically derived from: C:/daily/rwsdk/os/win/ostypes.h ---*/ +#ifndef WIN_OSTYPES_H +#define WIN_OSTYPES_H + +#define rwLITTLEENDIAN /* This is a little endian machine */ + +typedef long RwFixed; +typedef int RwInt32; +typedef unsigned int RwUInt32; +typedef short RwInt16; +typedef unsigned short RwUInt16; +typedef unsigned char RwUInt8; +typedef signed char RwInt8; + +#ifdef RWUNICODE +typedef wchar_t RwChar; +#else /* RWUNICODE */ +typedef char RwChar; +#endif /* RWUNICODE */ +typedef float RwReal; +typedef RwInt32 RwBool; + +#if defined(_MSC_VER) +typedef __int64 RwInt64; +typedef unsigned __int64 RwUInt64; +#define RWZERO64 ((RwUInt64)0) +#elif defined(__GNUC__) +typedef long long RwInt64; +typedef unsigned long long RwUInt64; +#define RWZERO64 ((RwUInt64)0) +#else /* defined(_MSC_VER) || defined(__GNUC__) */ + +typedef struct _RwUInt64 RwUInt64; +typedef struct _RwInt64 RwInt64; + +/* We'll do it with structures (can't do maths on these, but OK for allocation): */ +#if (!defined(DOXYGEN)) +#ifdef rwBIGENDIAN +struct _RwUInt64 +{ + RwUInt32 top; + RwUInt32 bottom; +}; + +struct _RwInt64 +{ + RwInt32 top; + RwUInt32 bottom; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct _RwUInt64 +{ + RwUInt32 bottom; + RwUInt32 top; +}; + +struct _RwInt64 +{ + RwUInt32 bottom; + RwInt32 top; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ +#endif /* (!defined(DOXYGEN)) */ + +#define RWZERO64 { (RwUInt32)0, (RwUInt32)0 } +#endif /* defined(_MSC_VER) || defined(__GNUC__) */ + +typedef struct _RwUInt128 RwUInt128; +typedef struct _RwInt128 RwInt128; + +/* We'll do it with structures + * (can't do maths on these, but OK for allocation): */ +#if (!defined(DOXYGEN)) +#ifdef rwBIGENDIAN +struct _RwUInt128 +{ + RwUInt64 top; + RwUInt64 bottom; +}; + +struct _RwInt128 +{ + RwInt64 top; + RwUInt64 bottom; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct _RwUInt128 +{ + RwUInt64 bottom; + RwUInt64 top; +}; + +struct _RwInt128 +{ + RwUInt64 bottom; + RwInt64 top; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ +#endif /* (!defined(DOXYGEN)) */ + +#define RWZERO128 { RWZERO64, RWZERO64 } + +/* Limits of types */ +#define RwInt32MAXVAL 0x7FFFFFFF +#define RwInt32MINVAL 0x80000000 +#define RwUInt32MAXVAL 0xFFFFFFFF +#define RwUInt32MINVAL 0x00000000 +#define RwRealMAXVAL (RwReal)(3.40282347e+38) +#define RwRealMINVAL (RwReal)(1.17549435e-38) +#define RwInt16MAXVAL 0x7FFF +#define RwInt16MINVAL 0x8000 +#define RwUInt16MAXVAL 0xFFFF +#define RwUInt16MINVAL 0x0000 + +/* Structure alignment */ +#define RWALIGN(type, x) type /* nothing */ +#define rwMATRIXALIGNMENT sizeof(RwUInt32) +#define rwFRAMEALIGNMENT sizeof(RwUInt32) +#define rwV4DALIGNMENT sizeof(RwUInt32) + +#if (!defined(rwMALLOCALIGNMENT)) +#define rwMALLOCALIGNMENT sizeof(RwUInt32) +#endif /* (!defined(rwMALLOCALIGNMENT) */ + +#if (defined(_MSC_VER)) + +#if (defined(RWVERBOSE)) +#include +#pragma comment (lib , "advapi32.LIB") /* Registry functions */ + +/* + * registry code + */ + +#if (defined(RpWinRegGetDWordValue)) +#undef RpWinRegGetDWordValue +#endif /* (defined(RpWinRegGetDWordValue)) */ + +#define RpWinRegGetDWordValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = ((ERROR_SUCCESS == _status) && (REG_DWORD == _type)); \ + \ + if ((_result)) \ + { \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, \ + (BYTE *) (_val), &_size); \ + (_result) = (ERROR_SUCCESS == _status); \ + } \ +} \ +MACRO_STOP + +#if (defined(RpWinRegGetBinaryValue)) +#undef RpWinRegGetBinaryValue +#endif /* (defined(RpWinRegGetBinaryValue)) */ + +#define RpWinRegGetBinaryValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = \ + ((ERROR_SUCCESS == _status) && \ + (REG_BINARY == _type) && (0 < _size)); \ + \ + if ((_result)) \ + { \ + *(_val) = RwMalloc(sizeof(BYTE) * _size, rwMEMHINTDUR_EVENT); \ + (_result) = (NULL != *(_val)); \ + \ + if ((_result)) \ + { \ + \ + _status = \ + RegQueryValueEx((_hKey), \ + (_name), 0, &_type, \ + (BYTE *) * (_val), &_size); \ + (_result =) (ERROR_SUCCESS == _status); \ + \ + if (!(_result)) \ + { \ + RwFree(*(_val)); \ + *(_val) = NULL; \ + } \ + \ + } \ + \ + } \ +} \ +MACRO_STOP + +#if (defined(RpWinRegGetStringValue)) +#undef RpWinRegGetStringValue +#endif /* (defined(RpWinRegGetStringValue)) */ + +#define RpWinRegGetStringValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = \ + ((ERROR_SUCCESS == _status) && \ + (REG_SZ == _type) && (0 < _size)); \ + \ + if ((_result)) \ + { \ + \ + *(_val) = RwMalloc(sizeof(TCHAR) * _size, rwMEMHINTDUR_EVENT); \ + (_result) = (NULL != *(_val)); \ + \ + if ((_result)) \ + { \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, \ + (BYTE *) * (_val), &_size); \ + (_result) = (ERROR_SUCCESS == _status); \ + \ + if (!(_result)) \ + { \ + RwFree(*(_val)); \ + *(_val) = NULL; \ + } \ + } \ + } \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#define RpWinRegCloseKey(hKey) \ +MACRO_START \ +{ \ + RegCloseKey(hKey); \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#define RpWinRegOpenMachineKey(result) \ +MACRO_START \ +{ \ + static const TCHAR RenderWareKey[] = \ + "Software\\Criterion\\RenderWare"; \ + DWORD disposition; \ + LONG status = \ + RegCreateKeyEx(HKEY_LOCAL_MACHINE, RenderWareKey, 0, \ + REG_NONE, REG_OPTION_NON_VOLATILE, \ + KEY_READ | KEY_WRITE, \ + NULL, &result, &disposition); \ + \ + if (status != ERROR_SUCCESS) \ + { \ + result = NULL; \ + } \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#if (defined(RWGETWINREGDWORD)) +#undef RWGETWINREGDWORD +#endif /* (defined(RWGETWINREGDWORD)) */ + +#define RWGETWINREGDWORD(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetDWordValue(success, hKey, match, \ + &result); \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(RWGETWINREGBINARY)) +#undef RWGETWINREGBINARY +#endif /* (defined(RWGETWINREGBINARY)) */ + +#define RWGETWINREGBINARY(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + result = NULL; \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetBinaryValue(success, hKey, match, \ + &result, NULL); \ + \ + if (!success) \ + result = NULL; \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(RWGETWINREGSTRING)) +#undef RWGETWINREGSTRING +#endif /* (defined(RWGETWINREGSTRING)) */ + +#define RWGETWINREGSTRING(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + result = NULL; \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetStringValue(success, hKey, match, \ + &result); \ + \ + if (!success) \ + result = NULL; \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(_DEBUG)) + +#if (defined(RWREGSETBREAKALLOC)) +#undef RWREGSETBREAKALLOC +#endif /* (defined(RWREGSETBREAKALLOC)) */ + +#define RWREGSETBREAKALLOC(_name) \ +MACRO_START \ +{ \ + char _message[256]; \ + long _lBreakAlloc = -1; \ + \ + RWGETWINREGDWORD(_lBreakAlloc, _name); \ + \ + RWCRTSETBREAKALLOC(_lBreakAlloc); \ + \ + _snprintf(_message, sizeof(_message), \ + "%s(%d): RWCRTSETBREAKALLOC(%ld)\n", \ + __FILE__, __LINE__, \ + _lBreakAlloc); \ + OutputDebugString(_message); \ + \ +} \ +MACRO_STOP + +#if (defined(RWREGSETDEBUGTRACE)) +#undef RWREGSETDEBUGTRACE +#endif /* (defined(RWREGSETDEBUGTRACE)) */ + +#define RWREGSETDEBUGTRACE(_name) \ +MACRO_START \ +{ \ + char _message[256]; \ + long _lDebugtrace = 0; \ + \ + RWGETWINREGDWORD(_lDebugtrace, _name); \ + \ + RwDebugSetTraceState(_lDebugtrace); \ + \ + _snprintf(_message, sizeof(_message), \ + "%s(%d): RwDebugSetTraceState(%ld)\n", \ + __FILE__, __LINE__, \ + _lDebugtrace); \ + OutputDebugString(_message); \ + \ +} \ +MACRO_STOP + +#if (defined(_CRTDBG_FLAGS)) +#undef _CRTDBG_FLAGS +#endif /* (defined(_CRTDBG_FLAGS)) */ + +#define _CRTDBG_FLAGS \ +( _CRTDBG_ALLOC_MEM_DF || /* Turn on the debug heap allocations \ + * and use the memory block identifiers. \ + * This is the only flag that's on by default. */ \ + _CRTDBG_CHECK_ALWAYS_DF || /* Check and validate all memory \ + * on each allocation and deallocation request. \ + * Setting this flag on is what catches the \ + * under and overwrites \ + * so it is very important to \ + * get it turned on. */ \ + _CRTDBG_CHECK_CRT_DF || /* Include _CRT_BLOCK memory allocations \ + * in all leak detection and state differences. */ \ + _CRTDBG_DELAY_FREE_MEM_DF || /* Instead of truly freeing memory, \ + * keep the block allocated and \ + * in the internal heap list. \ + * The blocks are filled with the value0xDD \ + * so you know the memory is freed when \ + * looking at it in the debugger. \ + * By also not freeing the memory, \ + * this can help provide stress \ + * conditions for the program. */ \ + _CRTDBG_LEAK_CHECK_DF) /* Do memory leak checking at \ + * the end of the program. */ + +#endif /* (defined(_DEBUG)) */ +#endif /* (defined(RWVERBOSE)) */ + +#include +/* + * Keep true calls to these functions since + * some x86 runtime libraries do not support _CIpow() etc + */ +#pragma function( acos, asin, cosh, fmod, pow, sinh , tanh ) + +#if (!defined(RWINT32FROMFLOAT)) + +static __inline RwInt32 +int32fromreal(RwReal x) +{ + RwInt16 savemode; + RwInt16 workmode; + RwInt32 res; + + _asm + { + fnstcw savemode ; get fpu mode + fld dword ptr[x] ; load rwreal x + + mov ax,savemode ; put fpu mode in register + or ah,0ch ; or-in truncate mode + + mov workmode,ax ; make ready to set fpu mode + fldcw workmode ; set fpu to truncate mode + fistp dword ptr[res]; store the rwint32eger result + fldcw savemode ; restore fpu mode + } + + return res; +} +#define RwInt32FromRealMacro(x) int32fromreal(x) + +#endif /* (!defined(RWINT32FROMFLOAT)) */ + +#if (!defined(NOASM)) +static __inline RwUInt32 +RwFastRealToUInt32Inline(RwReal x) +{ + RwUInt32 res; + + __asm FLD DWord Ptr[x]; + __asm FISTP DWord Ptr[res]; + + return(res); +} + +#define RwFastRealToUInt32 RwFastRealToUInt32Inline + +#endif /* (defined(NOASM)) */ + +#endif /* (defined(_MSC_VER)) */ + +#endif /* WIN_OSTYPES_H */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bamath.h ---*/ + +/**************************************************************************** + Defines + */ + +#if (!defined(RwInt32FromRealMacro)) +#define RwInt32FromRealMacro(x) \ + ((RwInt32)(x)) +#endif /* (!defined(RwInt32FromRealMacro)) */ + +#if (!defined(RwFastRealToUInt32)) +#define RwFastRealToUInt32(_x) \ + ((RwUInt32)RwInt32FromRealMacro(((RwReal)(_x)))) +#endif /* (!defined(RwFastRealToUInt32)) */ + +/* + * Ensure inclusion of prototypes for single precison maths functions + * e.g. from + * /usr/local/sce/ee/gcc/ee/include/math.h + * /Program Files/Intel/Compiler4.0/include/mathf.h + */ + +#if (defined(__ICL)) + +#if (defined(RWVERBOSE)) + +/* + * See + * http://www.eskimo.com/~scs/C-faq/q11.17.html + */ + +#define _STRINGIFY(X) #X +#define _STRINGIFY_EXP(X) _STRINGIFY(X) + +#pragma message ("Intel Compiler Version " _STRINGIFY_EXP(__ICL) ":" __FILE__ "(" _STRINGIFY_EXP(__LINE__) ")\n") +#pragma comment ( user, "comment:" "Intel Compiler Version " _STRINGIFY_EXP(__ICL) ":" __FILE__ "(" _STRINGIFY_EXP(__LINE__) ")\n") + +#endif /* (defined(RWVERBOSE)) */ + +#if (400 <= __ICL) +#if (defined(__cplusplus)) +#define _INC_MATH +#endif /* (defined(__cplusplus)) */ +#include +#else /* (400 < __ICL) */ +#undef RW_USE_SPF +#endif /* (400 < __ICL) */ + +#endif /* (defined(__ICL)) */ + +#include + +#define _RW_C1 ( (float) 4.1666667908e-02 ) +#define _RW_C2 ( (float)-1.3888889225e-03 ) +#define _RW_C3 ( (float) 2.4801587642e-05 ) +#define _RW_C4 ( (float)-2.7557314297e-07 ) +#define _RW_C5 ( (float) 2.0875723372e-09 ) +#define _RW_C6 ( (float)-1.1359647598e-11 ) +#define _RW_S1 ( (float)-1.6666667163e-01 ) +#define _RW_S2 ( (float) 8.3333337680e-03 ) +#define _RW_S3 ( (float)-1.9841270114e-04 ) +#define _RW_S4 ( (float) 2.7557314297e-06 ) +#define _RW_S5 ( (float)-2.5050759689e-08 ) +#define _RW_S6 ( (float) 1.5896910177e-10 ) +#define _RW_one ( (float) 1.0000000000e+00 ) +#define _RW_pS0 ( (float) 1.6666667163e-01 ) +#define _RW_pS1 ( (float)-3.2556581497e-01 ) +#define _RW_pS2 ( (float) 2.0121252537e-01 ) +#define _RW_pS3 ( (float)-4.0055535734e-02 ) +#define _RW_pS4 ( (float) 7.9153501429e-04 ) +#define _RW_pS5 ( (float) 3.4793309169e-05 ) +#define _RW_pi ( (float) 3.1415925026e+00 ) +#define _RW_pi_tol ( (float) 0.0312500000e+00 ) +#define _RW_pio2_hi ( (float) 1.5707962513e+00 ) +#define _RW_pio2_lo ( (float) 7.5497894159e-08 ) +#define _RW_qS1 ( (float)-2.4033949375e+00 ) +#define _RW_qS2 ( (float) 2.0209457874e+00 ) +#define _RW_qS3 ( (float)-6.8828397989e-01 ) +#define _RW_qS4 ( (float) 7.7038154006e-02 ) + +#define RwCosMinusPiToPiMacro(result, x) \ +MACRO_START \ +{ \ + const float z = x * x; \ + const float r = ( z * (_RW_C1 + \ + z * (_RW_C2 + \ + z * (_RW_C3 + \ + z * (_RW_C4 + \ + z * (_RW_C5 + \ + z * _RW_C6)))))); \ + result = (_RW_one - ((float) 0.5 * z - (z * r ))); \ +} \ +MACRO_STOP + +#define RwSinMinusPiToPiMacro(result, x) \ +do \ +{ \ + const float z = x * x; \ + const float v = z * x; \ + const float r = ( _RW_S2 + \ + z * (_RW_S3 + \ + z * (_RW_S4 + \ + z * (_RW_S5 + \ + z * _RW_S6))) ); \ + result = x + v * (_RW_S1 + z * r); \ +} \ +while(0) + +typedef union _rwIEEEFloatShapeType _rwIEEEFloatShapeType; + +#if (!defined(DOXYGEN)) +union _rwIEEEFloatShapeType +{ + float value; + unsigned int word; +}; +#endif /* (!defined(DOXYGEN)) */ + +#define _RW_GET_FLOAT_WORD(i,d) \ +do { \ + _rwIEEEFloatShapeType gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define _RW_SET_FLOAT_WORD(d,i) \ +do { \ + _rwIEEEFloatShapeType sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +#define RwIEEEACosfMacro(result, x) \ +do \ +{ \ + float z, p, q, r, w, s, c, df; \ + int hx, ix; \ + \ + _RW_GET_FLOAT_WORD(hx, x); \ + ix = hx & 0x7fffffff; \ + if (ix >= 0x3f800000) \ + { /* |x|>=1 */ \ + if (hx > 0) \ + { \ + /* acos(1) = 0 */ \ + result = (0.0); \ + } \ + else \ + { \ + /* acos(-1)= _RW_pi */ \ + result = (_RW_pi + (float) 2.0 * _RW_pio2_lo); \ + } \ + \ + } \ + else if (ix < 0x3f000000) \ + { /* |x| < 0.5 */ \ + if (ix <= 0x23000000) \ + { \ + /*if |x|<2**-57 */ \ + result = (_RW_pio2_hi + _RW_pio2_lo); \ + } \ + else \ + { \ + z = x * x; \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + \ + z * (_RW_qS3 + z * _RW_qS4))); \ + r = p / q; \ + result = (_RW_pio2_hi - (x - (_RW_pio2_lo - x * r))); \ + } \ + \ + } \ + else if (hx < 0) \ + { /* x < -0.5 */ \ + z = (_RW_one + x) * (float) 0.5; \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + z * (_RW_qS3 + z * _RW_qS4))); \ + rwSqrtMacro(&s, z); \ + r = p / q; \ + w = r * s - _RW_pio2_lo; \ + result = (_RW_pi - (float) 2.0 * (s + w)); \ + } \ + else \ + { /* x > 0.5 */ \ + int idf; \ + \ + z = (_RW_one - x) * (float) 0.5; \ + rwSqrtMacro(&s, z); \ + df = s; \ + _RW_GET_FLOAT_WORD(idf, df); \ + _RW_SET_FLOAT_WORD(df, idf & 0xfffff000); \ + c = (z - df * df) / (s + df); \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + z * (_RW_qS3 + z * _RW_qS4))); \ + r = p / q; \ + w = r * s + c; \ + result = ((float) 2.0 * (df + w)); \ + } \ +} \ +while(0) + +#if (defined(RW_USE_SPF)) + +#define RwACos(_x) acosf(_x) +#define RwACosh(_x) acoshf(_x) +#define RwASin(_x) asinf(_x) +#define RwASinh(_x) asinhf(_x) + +#if (!defined(__ICL)) +/* + * No SPF version in + * Program Files/Intel/compilerXXX/include/mathf.h + * of atan2() + */ +#define RwATan2(_x, _y) atan2f(_x, _y) +#endif /* (!defined(__ICL)) */ + +#define RwATan(_x) atanf(_x) +#define RwATanh(_x) atanhf(_x) +#define RwCabs() cabsf() +#define RwCbrt(_x) cbrtf(_x) +#define RwCeil(_x) ceilf(_x) +#define RwCopysign(_x, _y) copysignf(_x, _y) +#define RwCos(_x) cosf(_x) +#define RwCosh(_x) coshf(_x) +#define RwDrem(_x, _y) dremf(_x, _y) +#define RwErfc(_x) erfcf(_x) +#define RwErf(_x) erff(_x) +#define RwExp(_x) expf(_x) +#define RwExpm1(_x) expm1f(_x) +#define RwFinite(_x) finitef(_x) +#define RwIlogb(_x) ilogbf(_x) +#define RwIsinf(_x) isinff(_x) +#define RwIsnan(_x) isnanf(_x) +#define RwFabs(_x) fabsf(_x) +#define RwFloor(_x) floorf(_x) +#define RwFmod(_x, _y) fmodf(_x, _y) +#define RwFrexp(_x, _iptr) frexpf(_x, _iptr) +#define RwGamma(_x) gammaf(_x) +#define RwGammaf_(_x, _iptr) gammaf_r(_x, _iptr) +#define RwHypot(_x, _y) hypotf(_x, _y) +#define RwInfinity() infinityf() +#define RwJ0(_x) j0f(_x) +#define RwJ1(_x) j1f(_x) +#define RwJn(_i, _x) jnf(_i, _x) +#define RwLdexp(_x, _i) ldexpf(_x, _i) +#define RwLgamma(_x) lgammaf(_x) +#define RwLgammaf_(_x, _iptr) lgammaf_r(_x, _iptr) +#define RwLog10(_x) log10f(_x) +#define RwLog1p(_x) log1pf(_x) +#define RwLog(_x) logf(_x) +#define RwModf(_x, _y) modff(_x, _y) +#define RwNan() nanf() +#define RwNextafter(_x, _y) nextafterf(_x, _y) +#define RwPow(_x, _y) powf(_x, _y) +#define RwRemainder(_x, _y) remainderf(_x, _y) +#define RwRint(_x) rintf(_x) +#define RwScalbn(_x, _i) scalbnf(_x, _i) +#define RwSin(_x) sinf(_x) +#define RwSinh(_x) sinhf(_x) +/* rwSqrtMacro/rwInvSqrtMacro are overloaded in drvmodel.h + * (if they are at all) and wrapped as func/macro below */ +#define RwTan(_x) tanf(_x) +#define RwTanh(_x) tanhf(_x) +#define RwY0(_x) y0f(_x) +#define RwY1(_x) y1f(_x) +#define RwYn(_i, _x) ynf(_i, _x) + +#endif /* (defined(RW_USE_SPF)) */ + +#if (!defined(RwACos)) +#define RwACos(_x) acos(_x) +#endif /* (!defined(RwACos)) */ +#if (!defined(RwACosh)) +#define RwACosh(_x) acosh(_x) +#endif /* (!defined(RwACosh)) */ +#if (!defined(RwASin)) +#define RwASin(_x) asin(_x) +#endif /* (!defined(RwASin)) */ +#if (!defined(RwASinh)) +#define RwASinh(_x) asinh(_x) +#endif /* (!defined(RwASinh)) */ +#if (!defined(RwATan2)) +#define RwATan2(_x, _y) atan2(_x, _y) +#endif /* (!defined(RwATan2)) */ +#if (!defined(RwATan)) +#define RwATan(_x) atan(_x) +#endif /* (!defined(RwATan)) */ +#if (!defined(RwATanh)) +#define RwATanh(_x) atanh(_x) +#endif /* (!defined(RwATanh)) */ +#if (!defined(RwCabs)) +#define RwCabs() cabs() +#endif /* (!defined(RwCabs)) */ +#if (!defined(RwCbrt)) +#define RwCbrt(_x) cbrt(_x) +#endif /* (!defined(RwCbrt)) */ +#if (!defined(RwCeil)) +#define RwCeil(_x) ceil(_x) +#endif /* (!defined(RwCeil)) */ +#if (!defined(RwCopysign)) +#define RwCopysign(_x, _y) copysign(_x, _y) +#endif /* (!defined(RwCopysign)) */ +#if (!defined(RwCos)) +#define RwCos(_x) cos(_x) +#endif /* (!defined(RwCos)) */ +#if (!defined(RwCosh)) +#define RwCosh(_x) cosh(_x) +#endif /* (!defined(RwCosh)) */ +#if (!defined(RwDrem)) +#define RwDrem(_x, _y) drem(_x, _y) +#endif /* (!defined(RwDrem)) */ +#if (!defined(RwErfc)) +#define RwErfc(_x) erfc(_x) +#endif /* (!defined(RwErfc)) */ +#if (!defined(RwEr)) +#define RwEr(_x) erf(_x) +#endif /* (!defined(RwEr)) */ +#if (!defined(RwExp)) +#define RwExp(_x) exp(_x) +#endif /* (!defined(RwExp)) */ +#if (!defined(RwExpm1)) +#define RwExpm1(_x) expm1(_x) +#endif /* (!defined(RwExpm1)) */ +#if (!defined(RwFinite)) +#define RwFinite(_x) finite(_x) +#endif /* (!defined(RwFinite)) */ +#if (!defined(RwIlogb)) +#define RwIlogb(_x) ilogb(_x) +#endif /* (!defined(RwIlogb)) */ +#if (!defined(RwIsin)) +#define RwIsin(_x) isinf(_x) +#endif /* (!defined(RwIsin)) */ +#if (!defined(RwIsnan)) +#define RwIsnan(_x) isnan(_x) +#endif /* (!defined(RwIsnan)) */ +#if (!defined(RwFabs)) +#define RwFabs(_x) fabs(_x) +#endif /* (!defined(RwFabs)) */ +#if (!defined(RwFloor)) +#define RwFloor(_x) floor(_x) +#endif /* (!defined(RwFloor)) */ +#if (!defined(RwFmod)) +#define RwFmod(_x, _y) fmod(_x, _y) +#endif /* (!defined(RwFmod)) */ +#if (!defined(RwFrexp)) +#define RwFrexp(_x, _iptr) frexp(_x, _iptr) +#endif /* (!defined(RwFrexp)) */ +#if (!defined(RwGamma)) +#define RwGamma(_x) gamma(_x) +#endif /* (!defined(RwGamma)) */ +#if (!defined(RwGammaf_)) +#define RwGammaf_(_x, _iptr) gammaf_r(_x, _iptr) +#endif /* (!defined(RwGammaf_)) */ +#if (!defined(RwHypot)) +#define RwHypot(_x, _y) hypot(_x, _y) +#endif /* (!defined(RwHypot)) */ +#if (!defined(RwInfinity)) +#define RwInfinity() infinity() +#endif /* (!defined(RwInfinity)) */ +#if (!defined(RwJ0)) +#define RwJ0(_x) j0(_x) +#endif /* (!defined(RwJ0)) */ +#if (!defined(RwJ1)) +#define RwJ1(_x) j1(_x) +#endif /* (!defined(RwJ1)) */ +#if (!defined(RwJn)) +#define RwJn(_i, _x) jn(_i, _x) +#endif /* (!defined(RwJn)) */ +#if (!defined(RwLdexp)) +#define RwLdexp(_x, _i) ldexp(_x, _i) +#endif /* (!defined(RwLdexp)) */ +#if (!defined(RwLgamma)) +#define RwLgamma(_x) lgamma(_x) +#endif /* (!defined(RwLgamma)) */ +#if (!defined(RwLgammaf_)) +#define RwLgammaf_(_x, _iptr) lgammaf_r(_x, _iptr) +#endif /* (!defined(RwLgammaf_)) */ +#if (!defined(RwLog10)) +#define RwLog10(_x) log10(_x) +#endif /* (!defined(RwLog10)) */ +#if (!defined(RwLog1p)) +#define RwLog1p(_x) log1p(_x) +#endif /* (!defined(RwLog1p)) */ +#if (!defined(RwLog)) +#define RwLog(_x) log(_x) +#endif /* (!defined(RwLog)) */ +#if (!defined(RwMod)) +#define RwMod(_x, _y) mod(_x, _y ) +#endif /* (!defined(RwMod)) */ +#if (!defined(RwNan)) +#define RwNan() nan() +#endif /* (!defined(RwNan)) */ +#if (!defined(RwNextafter)) +#define RwNextafter(_x, _y) nextafter(_x, _y) +#endif /* (!defined(RwNextafter)) */ +#if (!defined(RwPow)) +#define RwPow(_x, _y) pow(_x, _y) +#endif /* (!defined(RwPow)) */ +#if (!defined(RwRemainder)) +#define RwRemainder(_x, _y) remainder(_x, _y) +#endif /* (!defined(RwRemainder)) */ +#if (!defined(RwRint)) +#define RwRint(_x) rint(_x) +#endif /* (!defined(RwRint)) */ +#if (!defined(RwScalbn)) +#define RwScalbn(_x, _i) scalbn(_x, _i) +#endif /* (!defined(RwScalbn)) */ +#if (!defined(RwSin)) +#define RwSin(_x) sin(_x) +#endif /* (!defined(RwSin)) */ +#if (!defined(RwSinh)) +#define RwSinh(_x) sinh(_x) +#endif /* (!defined(RwSinh)) */ +#if (!defined(rwSqrt)) +/* NOTE: this is overloaded in drvmodel.h for some targets (SKY2 and XBOX atm) + * [we do in fact do overload w/ sqrtf there, if RW_USE_SPF, + * for D3D8, OpenGL and SoftRas] */ +#define rwSqrt(_result, _x) rwSqrtMacro(_result, _x) +#endif /* (!defined(rwSqrt)) */ +#if (!defined(rwInvSqrt)) +/* NOTE: this is overloaded in drvmodel.h for some targets (SKY2 and XBOX atm) + * [we do in fact do overload w/ (1 / sqrtf) there, if RW_USE_SPF, + * for D3D8, OpenGL and SoftRas] */ +#define rwInvSqrt(_recip, _x) rwInvSqrtMacro(_recip, _x) +#endif /* (!defined(rwInvSqrt)) */ +#if (!defined(RwTan)) +#define RwTan(_x) tan(_x) +#endif /* (!defined(RwTan)) */ +#if (!defined(RwTanh)) +#define RwTanh(_x) tanh(_x) +#endif /* (!defined(RwTanh)) */ +#if (!defined(RwY0)) +#define RwY0(_x) y0(_x) +#endif /* (!defined(RwY0)) */ +#if (!defined(RwY1)) +#define RwY1(_x) y1(_x) +#endif /* (!defined(RwY1)) */ +#if (!defined(RwYn)) +#define RwYn(_i, _x) yn(_i, _x) +#endif /* (!defined(RwYn)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/batypes.h ---*/ + +#include "rwversion.h" + +/* IMPORTANT: + * The following Doxygen comment MUST be copied into RwCore.h, + * so don't move it from here. */ + +#if (!defined(RWFORCEENUMSIZEINT)) +#define RWFORCEENUMSIZEINT ((RwInt32)((~((RwUInt32)0))>>1)) +#endif /* (!defined(RWFORCEENUMSIZEINT)) */ + +/* + * See + * http://www.eskimo.com/~scs/C-faq/q11.17.html + */ + +#define RW_STRINGIFY(X) #X +#define RW_STRINGIFY_EXPANDED(X) RW_STRINGIFY(X) + +/**************************************************************************** + Attributes + */ + +#if (defined(__GNUC__)) + +/* See http://www.gnu.org/software/gcc/onlinedocs/gcc_4.html#SEC91 */ + +#if (!(defined(__cplusplus) || defined(__MWERKS__) || defined(__RWUNUSED__))) +#define __RWUNUSED__ __attribute__ ((unused)) +#endif /* (!(defined(__cplusplus) || defined(__MWERKS__) || defined(__RWUNUSED__))) */ + +#if (!(defined(__RWUNUSEDRELEASE__) || defined(RWVALIDATEPARAM))) +#if (!( defined(__cplusplus) || defined(__MWERKS__) || defined(RWDEBUG))) +#define __RWUNUSEDRELEASE__ __attribute__ ((unused)) +#endif /* (!(defined(__cplusplus) || defined(__MWERKS__) || defined(RWDEBUG))) */ +#endif /* (!(defined(__RWUNUSEDRELEASE__) || defined(RWVALIDATEPARAM))) */ + +#if (!defined(__RWFORMAT__)) +#define __RWFORMAT__(_archetype, _string_index, _first_to_check) \ + __attribute__ ((format (_archetype, _string_index, _first_to_check))) +#endif /* (!defined(__RWFORMAT__)) */ + +#endif /* (defined(__GNUC__)) */ + +#if (!defined(__RWUNUSED__)) +#define __RWUNUSED__ /* No op */ +#endif /* (!defined(__RWUNUSED__)) */ + +#if (!defined(__RWUNUSEDRELEASE__)) +#define __RWUNUSEDRELEASE__ /* No op */ +#endif /* (!defined(__RWUNUSEDRELEASE__)) */ + +#if (!defined(__RWFORMAT__)) +#define __RWFORMAT__(_archetype, _string_index, _first_to_check) /* No op */ +#endif /* (!defined(__RWFORMAT__)) */ + +/**************************************************************************** + Calling conventions + */ + +#if (defined(WIN32)) +#define RWASMCALL __cdecl +#define RWASMAPI(TYPE) TYPE RWASMCALL +#endif /* (defined(WIN32)) */ + +#if (!defined(RWASMCALL)) +#define RWASMCALL /* No op */ +#endif /* (!defined(RWASMCALL)) */ + +#if (!defined(RWASMAPI)) +#define RWASMAPI(TYPE) TYPE +#endif /* (!defined(RWASMAPI)) */ + + +/* Maximum number of nested contexts */ +#define rwMAXPIPECONTEXT 10 + + +/**************************************************************************** + Macro wrappers. These are needed everywhere. + */ + +#ifndef MACRO_START +#define MACRO_START do +#endif /* MACRO_START */ + +#ifndef MACRO_STOP +#define MACRO_STOP while(0) +#endif /* MACRO_STOP */ + +/**************************************************************************** + Types needed everywhere + */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE 0 + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE !FALSE + +/**************************************************************************** + MS VC/C++ Specific + */ + +#if (defined(_MSC_VER)) +#if (_MSC_VER>=1000) + + +/* + * Check for correct compiler version + */ +#define RW_MSC_VER 1200 + +#if (0 && !defined(RW_NO_COMPILER_CHECK)) +#if (_MSC_VER != RW_MSC_VER ) +# pragma message (__FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) "):" "\n This compiler is a different version (" RW_STRINGIFY_EXPANDED(_MSC_VER) ")\n to the compiler used to build the RenderWare product libraries (" RW_STRINGIFY_EXPANDED(RW_MSC_VER) ") \n To turn off this warning please define RW_NO_COMPILER_CHECK " ) +# pragma comment ( user, "comment:" __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) "):" "\n This compiler is a different version (" RW_STRINGIFY_EXPANDED(_MSC_VER) ")\n to the compiler used to build the RenderWare product libraries (" RW_STRINGIFY_EXPANDED(RW_MSC_VER) ") \n To turn off this warning please define RW_NO_COMPILER_CHECK " ) +#endif /* (_MSC_VER != RW_MSC_VER ) */ +#endif /* (0 && !defined(RW_NO_COMPILER_CHECK)) */ + +/* + * Output some compiler messages and object file comments + */ + +#pragma comment ( compiler ) + +#pragma comment ( user, "comment:" __DATE__" " __TIME__ " - " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ")") +#pragma comment ( user, "comment:" " _MSC_VER==" RW_STRINGIFY_EXPANDED(_MSC_VER) "; _M_IX86==" RW_STRINGIFY_EXPANDED(_M_IX86)) +#if (defined(rwLIBRARYCURRENTVERSION)) +#pragma comment ( user, "comment:" "rwLIBRARYCURRENTVERSION:" RW_STRINGIFY_EXPANDED(rwLIBRARYCURRENTVERSION) ) +#endif /* (defined(rwLIBRARYCURRENTVERSION)) */ + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) + +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include + +#pragma message (__DATE__" " __TIME__ " - " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ")" ) +#pragma message ("_MSC_VER==" RW_STRINGIFY_EXPANDED(_MSC_VER) "; _M_IX86==" RW_STRINGIFY_EXPANDED(_M_IX86)) + +#if (defined(rwLIBRARYCURRENTVERSION)) +#pragma message ( "rwLIBRARYCURRENTVERSION:" RW_STRINGIFY_EXPANDED(rwLIBRARYCURRENTVERSION) ) +#endif /* (defined(rwLIBRARYCURRENTVERSION)) */ + +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE) ) */ + +#endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +/*******************/ +/* Primitive types */ +/*******************/ + +/* String construction stuff (gets us UNICODE support) */ +#ifdef RWUNICODE +#define _RWSTRING(x) L ## x +#else /* RWUNICODE */ +#define _RWSTRING(x) x +#endif /* RWUNICODE */ +#define RWSTRING(x) _RWSTRING(x) + +/* NB volatile keyword required for VC5.0 to ensure a reload - AMB */ +typedef union RwSplitBits RwSplitBits; + +#if (!defined(DOXYGEN)) +union RwSplitBits +{ + RwReal nReal; + volatile RwInt32 nInt; + volatile RwUInt32 nUInt; +}; + +typedef struct RwSplitFixed RwSplitFixed; + +#ifdef rwBIGENDIAN +struct RwSplitFixed +{ + RwInt16 integral; + RwUInt16 fractional; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct RwSplitFixed +{ + RwUInt16 fractional; + RwInt16 integral; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ + +typedef union RwUnionReal RwUnionReal; + +union RwUnionReal /* MSB is sign bit in any circumstance */ +{ + RwReal real; /* 4 bytes interpreted as RwReal */ + float floating; /* 4 bytes interpreted as float */ + RwFixed fixed; /* 4 bytes interpreted as 16:16 fixed */ + RwSplitFixed splitfixed; /* 4 bytes interpreted as 16:16 fixed */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/*****************/ + +/* Complex types */ + +/*****************/ + +typedef struct RwV2d RwV2d; +/** + * \ingroup rwv2d + * \struct RwV2d + * This type represents points in a 2D space, such as device + * space, specified by the (x, y) coordinates of the point. + */ +struct RwV2d +{ + RwReal x; /**< X value*/ + RwReal y; /**< Y value */ +}; + +typedef struct RwV3d RwV3d; +/** + * \ingroup rwv3d + * \struct RwV3d + * This type represents 3D points and vectors specified by + * the (x, y, z) coordinates of a 3D point or the (x, y, z) components of a + * 3D vector. + */ +struct RwV3d +{ + RwReal x; /**< X value */ + RwReal y; /**< Y value */ + RwReal z; /**< Z value */ +}; + +typedef RwV3d RwV3D; + +#define RWV4DALIGNMENT(_v4d) \ + (! (((rwV4DALIGNMENT)-1) & ((RwUInt32)(_v4d)))) + + +#if (!defined(DOXYGEN)) + +struct RwV4dTag +{ + RwReal x; /**< X value */ + RwReal y; /**< Y value */ + RwReal z; /**< Z value */ + RwReal w; /**< W value */ +}; + +/* + * RwV4d & RwV4dTag must be different otherwise the alignment + * directive is ignored when compiling under C++ on Visual C + */ +typedef struct RwV4dTag RWALIGN(RwV4d, rwV4DALIGNMENT); + +#else /* (!defined(DOXYGEN)) */ + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwv4d + * \struct RwV4d + * This type represents 4D points and vectors specified by + * the (x, y, z, w) coordinates of a 4D point or the (x, y, z, w) components of a + * 4D vector. + */ +#endif /* RWADOXYGENEXTERNAL */ + +typedef struct RwV4d RWALIGN(RwV4d, rwV4DALIGNMENT); + +#endif /* (!defined(DOXYGEN)) */ + + + +typedef struct RwRect RwRect; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup geometricaltypes + * \struct RwRect + * This type represents a 2D device space rectangle specified + * by the position of the top-left corner (the offset x, y) and its width (w) + * and height (h). + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwRect +{ + RwInt32 x; /**< X value of the top-left corner */ + RwInt32 y; /**< Y value of the top-left corner */ + RwInt32 w; /**< Width of the rectangle */ + RwInt32 h; /**< Height of the rectangle */ +}; + +typedef struct RwSphere RwSphere; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup geometricaltypes + * \struct RwSphere + * This type represents a sphere specified by the position + * of its center and its radius. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwSphere +{ + RwV3d center; /**< Sphere center */ + RwReal radius; /**< Sphere radius */ +}; + +#if (!defined(RwSphereAssign)) +#define RwSphereAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwSphereAssign)) */ + +typedef struct RwLine RwLine; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup geometricaltypes + * \struct RwLine + * This type represents a 3D line specified by the position + * of its start and end points. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwLine +{ + RwV3d start; /**< Line start */ + RwV3d end; /**< Line end */ +}; + +#if (!defined(RwLineAssign)) +#define RwLineAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwLineAssign)) */ + +/* The maximum number of texture coordinates */ +#define rwMAXTEXTURECOORDS 8 +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup fundtypesdatatypes + * RwTextureCoordinateIndex + * This type represents the index for texture coordinates. + */ +#endif /* RWADOXYGENEXTERNAL */ +enum RwTextureCoordinateIndex +{ + rwNARWTEXTURECOORDINATEINDEX = 0, + rwTEXTURECOORDINATEINDEX0, + rwTEXTURECOORDINATEINDEX1, + rwTEXTURECOORDINATEINDEX2, + rwTEXTURECOORDINATEINDEX3, + rwTEXTURECOORDINATEINDEX4, + rwTEXTURECOORDINATEINDEX5, + rwTEXTURECOORDINATEINDEX6, + rwTEXTURECOORDINATEINDEX7, + rwTEXTURECOORDINATEINDEXFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwTextureCoordinateIndex RwTextureCoordinateIndex; + +typedef struct RwTexCoords RwTexCoords; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup fundtypesdatatypes + * \struct RwTexCoords + * This type represents the u and v texture + * coordinates of a particular vertex. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwTexCoords +{ + RwReal u; /**< U value */ + RwReal v; /**< V value */ +}; + + +/* Singley linked list macros. End marked as NULL */ + +typedef struct RwSLLink RwSLLink; /*** RwSLLink ***/ + +#if (!defined(DOXYGEN)) +struct RwSLLink +{ + RwSLLink *next; +}; +#endif /* (!defined(DOXYGEN)) */ + +#define rwSLLinkGetData(link,type,entry) \ + ((type *)(((RwUInt8 *)(link))-offsetof(type,entry))) + +#define rwSLLinkGetConstData(link,type,entry) \ + ((const type *)(((const RwUInt8 *)(link))-offsetof(type,entry))) + +#define rwSLLinkInitialize(linkvar) \ + (linkvar)->next = NULL; + +#define rwSLLinkGetNext(linkvar) \ + ((linkvar)->next) + +typedef struct RwSingleList RwSingleList; + +#if (!defined(DOXYGEN)) +struct RwSingleList +{ + RwSLLink link; +}; +#endif /* (!defined(DOXYGEN)) */ + +#define rwSingleListInitialize(list) \ + (list)->link.next= NULL; +#define rwSingleListEmpty(list) \ + (((list)->link.next)==NULL) +#define rwSingleListAddSLLink(list,linkvar) \ + ( (linkvar)->next = (list)->link.next, \ + (list)->link.next = (linkvar) ) +#define rwSingleListGetFirstSLLink(list) \ + ((list)->link.next) +#define rwSingleListGetTerminator(list) (NULL) + +/* Doubly linked list. End marked as start (its a ring) */ + +typedef struct RwLLLink RwLLLink; /*** RwLLLink ***/ + +#if (!defined(DOXYGEN)) +struct RwLLLink +{ + RwLLLink *next; + RwLLLink *prev; +}; +#endif /* (!defined(DOXYGEN)) */ + +#define rwLLLinkGetData(linkvar,type,entry) \ + ((type *)(((RwUInt8 *)(linkvar))-offsetof(type,entry))) + +#define rwLLLinkGetConstData(linkvar,type,entry) \ + ((const type *)(((const RwUInt8 *)(linkvar))-offsetof(type,entry))) + +#define rwLLLinkGetNext(linkvar) \ + ((linkvar)->next) + +#define rwLLLinkGetPrevious(linkvar) \ + ((linkvar)->prev) + +#define rwLLLinkInitialize(linkvar) \ + ( (linkvar)->prev = (RwLLLink *)NULL, \ + (linkvar)->next = (RwLLLink *)NULL ) + +#define rwLLLinkAttached(linkvar) \ + ((linkvar)->next) + +typedef struct RwLinkList RwLinkList; + +#if (!defined(DOXYGEN)) +struct RwLinkList +{ + RwLLLink link; +}; +#endif /* (!defined(DOXYGEN)) */ + +#define rwLinkListInitialize(list) \ + ( (list)->link.next = ((RwLLLink *)(list)), \ + (list)->link.prev = ((RwLLLink *)(list)) ) +#define rwLinkListEmpty(list) \ + (((list)->link.next) == (&(list)->link)) +#define rwLinkListAddLLLink(list, linkvar) \ + ( (linkvar)->next = (list)->link.next, \ + (linkvar)->prev = (&(list)->link), \ + ((list)->link.next)->prev = (linkvar), \ + (list)->link.next = (linkvar) ) +#define rwLinkListRemoveLLLink(linkvar) \ + ( ((linkvar)->prev)->next = (linkvar)->next, \ + ((linkvar)->next)->prev = (linkvar)->prev ) +#define rwLinkListGetFirstLLLink(list) \ + ((list)->link.next) +#define rwLinkListGetLastLLLink(list) \ + ((list)->link.prev) +#define rwLinkListGetTerminator(list) \ + (&((list)->link)) + +typedef struct RwSurfaceProperties RwSurfaceProperties; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup fundtypesdatatypes + * \struct RwSurfaceProperties + * This type represents the ambient, diffuse and + * specular reflection coefficients of a particular geometry. Each coefficient + * is specified in the range 0.0 (no reflection) to 1.0 (maximum reflection). + * Note that currently the specular element is not used. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwSurfaceProperties +{ + RwReal ambient; /**< ambient reflection coefficient */ + RwReal specular; /**< specular reflection coefficient */ + RwReal diffuse; /**< reflection coefficient */ +}; + +#if (!defined(RwSurfacePropertiesAssign)) +#define RwSurfacePropertiesAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwSurfacePropertiesAssign)) */ + +/********** + * Macros * + **********/ + +/* ANSI C defines the offsetof(type,member) macro; should be in */ + +/* If not, fall back to this: */ +#ifndef offsetof +#define offsetof(type, member) \ + ((size_t)((RwUInt8 *)&((type *) 0)->member - (RwUInt8 *)((type *) 0))) +#endif /* offsetof */ + +/* + * + * Numeric Macros to handle Fixed/Floating point versions of RenderWare + * + */ +#define RWFIX_MIN (1) +#define RWFIX_MAX (0x7fffffff) +#define RwFixedToInt(a) ((a) >> 16) +#define RwFixedToFloat(a) ((float)(((float)(a)) * (1.0f / 65536.0f))) +#define RwFixedToReal(a) ((RwReal)(((RwReal)(a)) * (1.0f / 65536.0f))) +#define RwIntToFixed(a) ((a) << 16) +#define RwRealToFixed(a) (RwInt32FromRealMacro((a) * 65536.0f)) +#define RwRealAbs(a) ((RwReal)((a) >= (RwReal)(0.0) ? (a) : (-(a)))) +#define RwRealMin2(a,b) ((RwReal)( ((a) <= (b)) ? (a) : (b))) +#define RwRealMax2(a,b) ((RwReal)( ((a) >= (b)) ? (a) : (b))) +#define RwRealMin3(a,b,c) RwRealMin2(a,RwRealMin2(b,c)) +#define RwRealMax3(a,b,c) RwRealMax2(a,RwRealMax2(b,c)) + +#ifndef NORWREALSHORTCUT +#define RToFixed RwRealToFixed +#define RAbs RwRealAbs +#define FxToInt RwFixedToInt +#define FxToFloat RwFixedToFloat +#define FxToReal RwFixedToFloat + +#endif + +#ifndef rwPI +#define rwPI ((RwReal)(3.1415926535f)) +#define rwPIOVER2 (rwPI / (RwReal)(2.0f)) +#endif +#define RWRGBALONG(r,g,b,a) \ + ((RwUInt32) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + RwPlane + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + +/* + * typedef for struct RwPlane + */ +typedef struct RwPlane RwPlane; + +#if (!defined(DOXYGEN)) +/* + * This type represents a plane + */ +struct RwPlane +{ + RwV3d normal; /**< Normal to the plane */ + RwReal distance; /**< Distance to plane from origin in normal direction*/ +}; +#endif /* (!defined(DOXYGEN)) */ + +/**************************************************************************** + Defines + */ + +enum RwPlaneType +{ + rwXPLANE = 0, /* These are deliberately multiples of sizeof(RwReal) */ + rwYPLANE = 4, + rwZPLANE = 8, + rwPLANETYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPlaneType RwPlaneType; + +#define rwSECTORATOMIC -1 +#define rwSECTORBUILD -2 /* Only used when building a world */ + +/* vect is a RwV3d, y is the component */ +#define GETCOORD(vect,y) \ + (*(RwReal *)(((RwUInt8 *)(&((vect).x)))+(RwInt32)(y))) +#define GETCONSTCOORD(vect,y) \ + (*(const RwReal *)(((const RwUInt8 *)(&((vect).x)))+(RwInt32)(y))) +#define SETCOORD(vect,y,value) \ + (((*(RwReal *)(((RwUInt8 *)(&((vect).x)))+(RwInt32)(y))))=(value)) +#define SETCONSTCOORD(vect,y,value) \ + (((*(const RwReal *) \ + (((const RwUInt8 *) \ + (&((vect).x)))+(RwInt32)(y))))=(value)) +#define GETCOORDINT(vect,y) \ + (*(RwInt32 *)(((RwUInt8 *)(&((vect).x)))+(y))) +#define GETCONSTCOORDINT(vect,y) \ + (*(const RwInt32 *)(((const RwUInt8 *)(&((vect).x)))+(y))) + + +/** + * \ingroup integertypes + * \page inttypes Integer Types + * + * RenderWare supports a number of integer types: + * + * RwInt8 8-bit signed integer. + * \li RwUInt8 8-bit unsigned integer. + * \li RwChar Character type. + * \li RwInt16 16-bit signed integer. + * \li RwUInt16 16-bit unsigned integer. + * \li RwInt32 32-bit signed integer. + * \li RwUInt32 32-bit unsigned integer. + * \li RwInt64 64-bit signed integer. + * \li RwUInt64 64-bit unsigned integer. + * \li RwInt128 128-bit signed integer. + * \li RwUInt128 128-bit unsigned integer. + * \li RwBool Boolean type (in 32 bits). + * + * These types should be used in applications in preference to the underlying + * native types. + * + * The following constants indicate the maximum and minimum values possible + * for the various RenderWare integer types: + * + * \li RwInt32MAXVAL Maximum RwInt32 value. + * \li RwInt32MINVAL Minimum RwInt32 value. + * \li RwUInt32MAXVAL Maximum RwUInt32 value. + * \li RwUInt32MINVAL Minimum RwUInt32 value. + * \li RwInt16MAXVAL Maximum RwInt16 value. + * \li RwInt16MINVAL Minimum RwInt16 value. + * \li RwUInt16MAXVAL Maximum RwUInt16 value. + * \li RwUInt16MINVAL Minimum RwUInt16 value. + * + * \see RwReal + */ + +/** + * \ingroup realtypes + * \typedef RwReal + * + * RenderWare supports a single RwReal floating-point type to aid portability + * across platforms. This type should be used in applications in preference to + * the underlying native type. + * + * The constants RwRealMAXVAL and RwRealMINVAL are provided for determining + * the maximum and minimum values possible using the RwReal type. + * + * In addition, the following macros are available for operations on RwReal + * types: + * \li RwRealMin2(a, b) Find the minimum of two RwReal values. + * \li RwRealMax2(a, b) Find the maximum of two RwReal values. + * \li RwRealMin3(a, b, c) Find the minimum of three RwReal values. + * \li RwRealMax3(a, b, c) Find the maximum of three RwReal values. + * \li RwRealAbs(x) Find the absolute value of a RwReal value. + * + * \see \ref inttypes + */ + +/** + * \ingroup realtypes + * \typedef RwFixed + * + * RenderWare supports a single RwFixed fixed-point type. + * + * Although popular in the days when integer mathematics was much faster than + * floating point mathematics, fixed-point math is now rarely used. It is + * provided because it is still useful for some processes. + * + * The maximum and minimum size of an RwFixed value are defined by the constants + * RWFIX_MAX and RWFIX_MIN respectively. + * + * The following macros are provided to help you work with RwFixed datatypes: + * \li RwFixedToInt(x) Convert an RwFixed to an integer. (The fractional portion is lost.) + * \li RwFixedToFloat(x) Convert an RwFixed to a float. + * \li RwFixedToReal(x) Convert an RwFixed to an RwReal. + * \li RwRealToFixed(x) Convert an RwReal to an RwFixed. (Some precision may be lost.) + * \li RwIntToFixed(x) Convert an RwInt32 to an RwFixed. (Some precision may be lost.) + */ + +/** + * \ingroup integertypes + * \typedef RwInt8 + * + * Signed 8 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwUInt8 + * + * Unsigned 8bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwChar + * + * Character type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwInt16 + * + * Signed 16 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwUInt16 + * + * Unsigned 16 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwInt32 + * + * Signed 32 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwUInt32 + * + * Unsigned 32 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwInt64 + * + * Signed 64 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwUInt64 + * + * Unsigned 64 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwInt128 + * + * Signed 128 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwUInt128 + * + * Unsigned 128 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup integertypes + * \typedef RwBool + * + * Boolean type. + * \see \ref inttypes + */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/batype.h ---*/ +/**************************************************************************** + Defines +*/ + +/* + * Object Types - these are used in the binary object + * representations and in the debug library. They must + * be unique. They are the old system. + */ + +#define rwID_DATABASE 0x64617462 /* datb */ + +#define MAKECHUNKID(vendorID, chunkID) (((vendorID & 0xFFFFFF) << 8) | (chunkID & 0xFF)) +#define GETOBJECTID(chunkID) (chunkID & 0xFF) +#define GETVENDORID(chunkID) ((chunkID >> 8) & 0xFFFFFF) + +/*** + *** These are the vendor IDs. A customer must reserve a vendor ID in order + *** to be able to write toolkits (this prevents clashes between toolkits). + *** We reserve some for our own use as shown below. These are all 24 bit. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + *** + *** They must all be unique. + ***/ + +enum RwPluginVendor +{ + rwVENDORID_CORE = 0x000000L, + rwVENDORID_CRITERIONTK = 0x000001L, + rwVENDORID_REDLINERACER = 0x000002L, + rwVENDORID_CSLRD = 0x000003L, + rwVENDORID_CRITERIONINT = 0x000004L, + rwVENDORID_CRITERIONWORLD = 0x000005L, + rwVENDORID_BETA = 0x000006L, + rwVENDORID_CRITERIONRM = 0x000007L, + rwVENDORID_CRITERIONRWA = 0x000008L, /* RenderWare Audio */ + rwVENDORID_CRITERIONRWP = 0x000009L, /* RenderWare Physics */ + rwPLUGINVENDORFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPluginVendor RwPluginVendor; + +/*** + *** These are the core objects (8 bit IDs). They must all be unique. + *** We can get away without using the MAKECHUNKID macro because the + *** vendor ID in all cases will be zero (rwVENDORID_CORE). + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ + +/* These are the internal ones. Because the core ID is 0, we can get away without + * using the MAKECHUNKID macro for the CORE chunks. + */ + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwstream + * \ref RwCorePluginID + * + * A chunk is a block of binary stream data containing objects. These objects + * are referenced using object IDs which are listed below. Before an object + * stream is read, a chunk needs to be obtained containing the object ID. + * These IDs are used with the function \ref RwStreamFindChunk. + * + * To write a chunk into a stream \ref RwStreamWriteChunkHeader is used + * with one of the following object IDs. + * + * \note \ref rt2d and \ref rt2danim use different object IDs. These + * are listed in \ref rt2dobjectids and \ref rt2danimobjectids. + * + * \see RwStreamFindChunk + * \see RwStreamWriteChunkHeader + */ +enum RwCorePluginID +{ + rwID_NAOBJECT = MAKECHUNKID(rwVENDORID_CORE, 0x00), + rwID_STRUCT = MAKECHUNKID(rwVENDORID_CORE, 0x01), + rwID_STRING = MAKECHUNKID(rwVENDORID_CORE, 0x02), + rwID_EXTENSION = MAKECHUNKID(rwVENDORID_CORE, 0x03), + + rwID_CAMERA = MAKECHUNKID(rwVENDORID_CORE, 0x05), +/**< RwCamera chunk. See \ref RwCameraStreamRead */ + + rwID_TEXTURE = MAKECHUNKID(rwVENDORID_CORE, 0x06), +/**< RwTexture chunk. See \ref RwTextureStreamRead */ + + rwID_MATERIAL = MAKECHUNKID(rwVENDORID_CORE, 0x07), +/**< RpMaterial chunk. See \ref RpMaterialStreamRead. */ + + rwID_MATLIST = MAKECHUNKID(rwVENDORID_CORE, 0x08), + rwID_ATOMICSECT = MAKECHUNKID(rwVENDORID_CORE, 0x09), + rwID_PLANESECT = MAKECHUNKID(rwVENDORID_CORE, 0x0A), + + rwID_WORLD = MAKECHUNKID(rwVENDORID_CORE, 0x0B), +/**< RpWorld chunk. See \ref RpWorldStreamRead. */ + + rwID_SPLINE = MAKECHUNKID(rwVENDORID_CORE, 0x0C), +/**< RpSpline chunk. See \ref RpSplineStreamRead */ + + rwID_MATRIX = MAKECHUNKID(rwVENDORID_CORE, 0x0D), +/**< RwMatrix chunk. See \ref RwMatrixStreamRead */ + + rwID_FRAMELIST = MAKECHUNKID(rwVENDORID_CORE, 0x0E), + + rwID_GEOMETRY = MAKECHUNKID(rwVENDORID_CORE, 0x0F), +/**< RpGeometry chunk. See \ref RpGeometryStreamRead. */ + + rwID_CLUMP = MAKECHUNKID(rwVENDORID_CORE, 0x10), +/**< RpClump chunk. See \ref RpClumpStreamRead. */ + + rwID_LIGHT = MAKECHUNKID(rwVENDORID_CORE, 0x12), +/**< RpLight chunk. See \ref RpLightStreamRead. */ + + rwID_UNICODESTRING = MAKECHUNKID(rwVENDORID_CORE, 0x13), + + rwID_ATOMIC = MAKECHUNKID(rwVENDORID_CORE, 0x14), +/**< RpAtomic chunk. See \ref RpAtomicStreamRead */ + + rwID_TEXTURENATIVE = MAKECHUNKID(rwVENDORID_CORE, 0x15), + + rwID_TEXDICTIONARY = MAKECHUNKID(rwVENDORID_CORE, 0x16), +/**< RwTexDictionary - platform specific texture dictionary. + * See \ref RwTexDictionaryStreamRead. */ + + rwID_ANIMDATABASE = MAKECHUNKID(rwVENDORID_CORE, 0x17), + + rwID_IMAGE = MAKECHUNKID(rwVENDORID_CORE, 0x18), +/**< RwImage chunk. See \ref RwImageStreamRead */ + + rwID_SKINANIMATION = MAKECHUNKID(rwVENDORID_CORE, 0x19), + rwID_GEOMETRYLIST = MAKECHUNKID(rwVENDORID_CORE, 0x1A), + + rwID_ANIMANIMATION = MAKECHUNKID(rwVENDORID_CORE, 0x1B), +/**< RtAnimAnimation chunk. See \ref RtAnimAnimationStreamRead. */ + rwID_HANIMANIMATION = MAKECHUNKID(rwVENDORID_CORE, 0x1B), +/**< RtAnimAnimation chunk. For backwards compatibility. See \ref rwID_ANIMANIMATION. */ + + rwID_TEAM = MAKECHUNKID(rwVENDORID_CORE, 0x1C), +/**< \ref RpTeam chunk. See \ref RpTeamStreamRead */ + rwID_CROWD = MAKECHUNKID(rwVENDORID_CORE, 0x1D), + + rwID_DMORPHANIMATION = MAKECHUNKID(rwVENDORID_CORE, 0x1E), +/**< RpDMorphAnimation - delta morph animation chunk. See \ref RpDMorphAnimationStreamRead */ + + rwID_RIGHTTORENDER = MAKECHUNKID(rwVENDORID_CORE, 0x1f), + + rwID_MTEFFECTNATIVE = MAKECHUNKID(rwVENDORID_CORE, 0x20), +/**< \if xbox RpMTEffect - multi-texture effect chunk. See \ref RpMTEffectStreamRead \endif */ +/**< \if gcn RpMTEffect - multi-texture effect chunk. See \ref RpMTEffectStreamRead \endif */ + + rwID_MTEFFECTDICT = MAKECHUNKID(rwVENDORID_CORE, 0x21), +/**< \if xbox RpMTEffectDict - multi-texture effect dictionary chunk. See \ref RpMTEffectDictStreamRead \endif */ +/**< \if gcn RpMTEffectDict - multi-texture effect dictionary chunk. See \ref RpMTEffectDictStreamRead \endif */ + + rwID_TEAMDICTIONARY = MAKECHUNKID(rwVENDORID_CORE, 0x22), +/**< \ref RpTeamDictionary chunk. See \ref RpTeamDictionaryStreamRead */ + + rwID_PITEXDICTIONARY = MAKECHUNKID(rwVENDORID_CORE, 0x23), +/**< RwTexDictionary - platform independent texture dictionary. See \ref RtPITexDictionaryStreamRead. */ + + rwID_TOC = MAKECHUNKID(rwVENDORID_CORE, 0x24), +/**< RtTOC chunk. See \ref RtTOCStreamRead */ + + rwID_PRTSTDGLOBALDATA = MAKECHUNKID(rwVENDORID_CORE, 0x25), +/**< RpPrtStdEmitterClass, RpPrtStdParticleClass and RpPrtStdPropertyTable chunks. + * See \ref RpPrtStdEClassStreamRead, \ref RpPrtStdPClassStreamRead + * \ref RpPrtStdPropTabStreamRead and \ref RpPrtStdGlobalDataStreamRead */ + + rwID_ALTPIPE = MAKECHUNKID(rwVENDORID_CORE, 0x26), + rwID_PIPEDS = MAKECHUNKID(rwVENDORID_CORE, 0x27), + rwID_PATCHMESH = MAKECHUNKID(rwVENDORID_CORE, 0x28), +/**< RpPatchMesh chunk. See \ref RpPatchMeshStreamRead */ + + rwID_CHUNKGROUPSTART = MAKECHUNKID(rwVENDORID_CORE, 0x29), + rwID_CHUNKGROUPEND = MAKECHUNKID(rwVENDORID_CORE, 0x2A), + + rwID_UVANIMDICT = MAKECHUNKID(rwVENDORID_CORE, 0x2B), +/**< UV anim dictionary chunk. See \ref RpUVAnimGetDictSchema */ + + rwID_COLLTREE = MAKECHUNKID(rwVENDORID_CORE, 0x2C), + + rwID_ENVIRONMENT = MAKECHUNKID(rwVENDORID_CORE, 0x2D), +/**< RpEnvironment chunk is used internally to convey art package background + < settings to the Visualizer.*/ + +/* Insert before MAX and increment MAX */ + rwID_COREPLUGINIDMAX = MAKECHUNKID(rwVENDORID_CORE, 0x2E), + rwCOREPLUGINIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCorePluginID RwCorePluginID ; +#endif /* RWADOXYGENEXTERNAL */ + +/*** + *** These are the Criterion internal plugin extensions. Use with rwVENDORID_CRITERIONINT. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ + +enum RwCriterionPluginID +{ + rwID_COREPLUGIN = 0x01, + rwID_WORLDPLUGIN = 0x02, + rwID_TOOLPLUGIN = 0x03, + rwID_TOOL2PLUGIN = 0x04, + rwCRITERIONPLUGINIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCriterionPluginID RwCriterionPluginID; + +/** + * \ingroup rwengine + * The Core Library is consisted from a collection of plugins that constitute + * it. This is a list of the pluginIDs that belong to the Core. See + * \ref RwEngineRegisterPlugin + */ +enum RwCriterionCoreID +{ + /* Guard value that should not be used. */ + rwID_NACOREID = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x00), + + /* The valid plugin IDs */ + /** Vector module pluginID. See \ref rwv2d and \ref rwv3d */ + rwID_VECTORMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x01), + /** Matrix module pluginID. See \ref rwmatrix */ + rwID_MATRIXMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x02), + /** Frame module pluginID. See \ref rwframe */ + rwID_FRAMEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x03), + /** Stream module pluginID. See \ref rwstream */ + rwID_STREAMMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x04), + /** Camera module pluginID. See \ref rwcamera */ + rwID_CAMERAMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x05), + /** Image module pluginID. See \ref rwimage */ + rwID_IMAGEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x06), + /** Raster module pluginID. See \ref rwraster */ + rwID_RASTERMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x07), + /** Texture module pluginID. See \ref rwtexture */ + rwID_TEXTUREMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x08), + /** Pipeline module pluginID. See \ref RxPipeline */ + rwID_PIPEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x09), + /** Immediate module pluginID. See \ref rwim3d */ + rwID_IMMEDIATEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0A), + /** Resource module pluginID. See \ref rwresources */ + rwID_RESOURCESMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0B), + /** Device module pluginID */ + rwID_DEVICEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0C), + /** Color module pluginID. See \ref rwrgba */ + rwID_COLORMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0D), + /* Not used */ + rwID_POLYPIPEMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0E), + /** Error module pluginID. See \ref rwerror */ + rwID_ERRORMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x0F), + /** Metrics module pluginID. See \ref RwMetrics */ + rwID_METRICSMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x10), + /** Driver module pluginID */ + rwID_DRIVERMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x11), + /** Chunk group module pluginID. See \ref rwchunkgroup */ + rwID_CHUNKGROUPMODULE = MAKECHUNKID(rwVENDORID_CRITERIONINT, 0x12), + rwCRITERIONCOREIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCriterionCoreID RwCriterionCoreID; + +/*** + *** These are the Criterion internal platform identifies. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ +enum RwPlatformID +{ + rwID_PCD3D7 = 1, + rwID_PCOGL, + rwID_MAC, + rwID_PS2, + rwID_XBOX, + rwID_GAMECUBE, + rwID_SOFTRAS, + rwID_PCD3D8, + rwID_PCD3D9, + rwPLATFROMIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPlatformID RwPlatformID; + + +/**************************************************************************** + Global Types + */ + +typedef struct RwObject RwObject; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwobject + * \struct RwObject + * This should be considered an opaque type. Use + * the RwObject API functions to access. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwObject +{ + RwUInt8 type; /**< Internal Use */ + RwUInt8 subType; /**< Internal Use */ + RwUInt8 flags; /**< Internal Use */ + RwUInt8 privateFlags; /**< Internal Use */ + void *parent; /**< Internal Use */ + /* Often a Frame */ +}; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwobject + * \ref RwObjectCallBack + * callback function supplied for object callback functions. + * + * \param object Pointer to the current object, supplied by + * iterator. + * \param data Pointer to developer-defined data structure. + * + * \return Pointer to the current object + * + * \see RwFrameForAllObjects + * + */ +#endif /* RWADOXYGENEXTERNAL */ +typedef RwObject *(*RwObjectCallBack)(RwObject *object, void *data); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* TYPE METHODS */ + +/* Creation/cloning */ + +#define rwObjectCopy(d,s) \ +MACRO_START \ +{ \ + ((RwObject *)(d))->type = \ + ((const RwObject *)(s))->type; \ + ((RwObject *)(d))->subType = \ + ((const RwObject *)(s))->subType; \ + ((RwObject *)(d))->flags = \ + ((const RwObject *)(s))->flags; \ + ((RwObject *)(d))->privateFlags = \ + ((const RwObject *)(s))->privateFlags; \ + ((RwObject *)(d))->parent = \ + NULL; \ +} \ +MACRO_STOP + +#define rwObjectInitialize(o, t, s) \ +MACRO_START \ +{ \ + ((RwObject *)(o))->type = (RwUInt8)(t); \ + ((RwObject *)(o))->subType = (RwUInt8)(s); \ + ((RwObject *)(o))->flags = 0; \ + ((RwObject *)(o))->privateFlags = 0; \ + ((RwObject *)(o))->parent = NULL; \ +} \ +MACRO_STOP + +/* Debug */ +#define RwObjectGetType(o) (((const RwObject *)(o))->type) + +#define rwObjectSetType(o, t) (((RwObject *)(o))->type) = (RwUInt8)(t) + +/* Sub type */ +#define rwObjectGetSubType(o) (((const RwObject *)(o))->subType) +#define rwObjectSetSubType(o, t) (((RwObject *)(o))->subType) = (RwUInt8)(t) + +/* Flags */ +#define rwObjectGetFlags(o) (((const RwObject *)(o))->flags) +#define rwObjectSetFlags(o, f) (((RwObject *)(o))->flags) = (RwUInt8)(f) +#define rwObjectTestFlags(o, f) ((((const RwObject *)(o))->flags) & (RwUInt8)(f)) + +/* Private flags */ +#define rwObjectGetPrivateFlags(c) (((const RwObject *)(c))->privateFlags) +#define rwObjectSetPrivateFlags(c,f) (((RwObject *)(c))->privateFlags) = (RwUInt8)(f) +#define rwObjectTestPrivateFlags(c,flag) ((((const RwObject *)(c))->privateFlags) & (RwUInt8)(flag)) + +/* Hierarchy */ +#define rwObjectGetParent(object) (((const RwObject *)(object))->parent) +#define rwObjectSetParent(c,p) (((RwObject *)(c))->parent) = (void *)(p) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/os/win/osintf.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/rwdbgerr.h ---*/ +#define RWECODE(a,b) a, + +/* Construct an enum type with all the plugin error codes (for the app to use) */ +enum RwErrorCodePlugin_errcore +{ +#include "errcore.def" + rwLASTERROR_errcore = RWFORCEENUMSIZEINT +}; +typedef enum RwErrorCodePlugin_errcore RwErrorCodePlugin_errcore; + + +#undef RWECODE + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/resmem.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bamemory.h ---*/ +#if (defined(RWMEMDEBUG)) +#ifdef _XBOX +/* Need OutputDebugString macros */ +#include +#endif +#endif + +/**************************************************************************** + Defines + */ + +/* + * Debug fill bytes for compatibility with MSVC/C++ debug heap + * See + * \Program Files\Microsoft Visual Studio\VC98\CRT\SRC\DBGHEAP.C: + * static unsigned char _bNoMansLandFill = 0xFD; + * // fill no-man's land with this + * static unsigned char _bDeadLandFill = 0xDD; + * // fill free objects with this + * static unsigned char _bCleanLandFill = 0xCD; + * // fill new objects with this + */ + +#if (!defined(rwFREELISTNOMANSLANDFILL)) +#define rwFREELISTNOMANSLANDFILL 0xFD +#endif /* (!defined(rwFREELISTNOMANSLANDFILL)) */ + +#if (!defined(rwFREELISTDEADLANDFILL)) +#define rwFREELISTDEADLANDFILL 0xDD +#endif /* (!defined(rwFREELISTDEADLANDFILL)) */ + +#if (!defined(rwFREELISTCLEANLANDFILL)) +#define rwFREELISTCLEANLANDFILL 0xCD +#endif /* (!defined(rwFREELISTCLEANLANDFILL)) */ + +#define RWFREELISTALIGNED(_pData, _freelist) \ + (! (((RwUInt32)(_pData)) & ((_freelist)->alignment - 1)) ) + +/***************************** + * REGULAR MEMORY ALLOCATION * + *****************************/ + +/** + * \ingroup memoryfileinterface + * \def RwMalloc + * RwMalloc(_s, _h) is a macro that calls the currently registered RwMalloc function. + * You can access all registered memory functions through an + * \ref RwOsGetMemoryInterface() call which returns a pointer to an + * \ref RwMemoryFunctions structure. You can also override the default + * RenderWare Graphics functions by passing a structure populated with + * your own RwMemoryFunctions structure to \ref RwEngineInit(). + * + * For \c RWDEBUG applications, the default \ref RwMalloc records the file and line + * on which it was called. These records are shared between \ref RwCalloc and + * \ref RwRealloc, and does not store any additional history. To retrieve the last + * file and line, use \ref RwMemoryGetLastAllocFile and \ref RwMemoryGetLastAllocLine. + * + * \see RwMemoryFunctions for more specific function documentation. + */ + +/** + * \ingroup memoryfileinterface + * \def RwFree + * RwFree(_p) is a macro that calls the currently registered RwFree function. + * You can access all registered memory functions through an + * \ref RwOsGetMemoryInterface() call which returns a pointer to an + * \ref RwMemoryFunctions structure. You can also override the default + * RenderWare Graphics functions by passing a structure populated with + * your own RwMemoryFunctions structure to \ref RwEngineInit(). + * + * \see RwMemoryFunctions for more specific function documentation. + */ + +/** + * \ingroup memoryfileinterface + * \def RwCalloc + * RwCalloc(_n, _s, _h) is a macro that calls the currently registered RwCalloc + * function. You can access all registered memory functions + * through an \ref RwOsGetMemoryInterface() call which returns a pointer + * to an \ref RwMemoryFunctions structure. You can also override the + * default RenderWare Graphics functions by passing a structure populated + * with your own RwMemoryFunctions structure to \ref RwEngineInit(). + * + * For \c RWDEBUG applications, the default \ref RwCalloc records the file and line + * on which it was called. These records are shared between \ref RwMalloc and + * \ref RwRealloc, and does not store any additional history. To retrieve the last + * file and line, use \ref RwMemoryGetLastAllocFile and \ref RwMemoryGetLastAllocLine. + * + * \see RwMemoryFunctions for more specific function documentation. + */ + +/** + * \ingroup memoryfileinterface + * \def RwRealloc + * RwRealloc(_p, _s, _h) is a macro that calls the currently registered RwRealloc + * function. You can access all registered memory functions + * through an \ref RwOsGetMemoryInterface() call which returns a pointer + * to an \ref RwMemoryFunctions structure. You can also override the + * default RenderWare Graphics functions by passing a structure populated + * with your own RwMemoryFunctions structure to \ref RwEngineInit(). + * + * For \c RWDEBUG applications, the default \ref RwRealloc records the file and line + * on which it was called. These records are shared between \ref RwMalloc and + * \ref RwCalloc, and does not store any additional history. To retrieve the last + * file and line, use \ref RwMemoryGetLastAllocFile and \ref RwMemoryGetLastAllocLine. + * + * \see RwMemoryFunctions for more specific function documentation. + */ + +#if ( (defined(RWMEMDEBUG)) && defined(RWDEBUG) ) + +#if (!defined(RWNOFREELISTS)) +#define RWNOFREELISTS +#endif /* (!defined(RWNOFREELISTS)) */ + +#if (defined(rwPLUGIN_ID)) +#define _CLIENT_TAG \ + ( 0xFFFF & (rwPLUGIN_ID) ) +#endif /* (defined(rwPLUGIN_ID)) */ + +#if (!defined(_CLIENT_TAG)) +#define _CLIENT_TAG \ + ( 0xFFFF & (MAKECHUNKID(rwVENDORID_CRITERIONTK, 0x00) ) ) +#endif /* (!defined(_CLIENT_TAG)) */ + +# if (defined(_MSC_VER)) +# if ((_MSC_VER>=1000) && defined(_DEBUG)) + +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include + +#define RwMalloc(_s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + _malloc_dbg((_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__)) + +#define RwFree(_p) \ + _free_dbg((_p), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16)) + +#define RwCalloc(_n, _s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + _calloc_dbg((_n), (_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__)) + +#define RwRealloc(_p, _s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + _realloc_dbg((_p), \ + (_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__)) + +#define RWCRTORDBGFLAG(_flag) \ + do \ + { \ + int _DbgFlag; \ + \ + _DbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ + _DbgFlag |= (_flag); \ + _CrtSetDbgFlag(_DbgFlag); \ + } while(0) + +#define VALID_HEAP_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): valid heap\n" + +#define RWCRTCHECKMEMORY() \ + do \ + { \ + int valid_heap; \ + \ + valid_heap = _CrtCheckMemory(); \ + _ASSERTE(valid_heap); \ + } while(0) + +/* + * if (valid_heap) \ + * OutputDebugString(VALID_HEAP_STR); \ + */ + +#define NO_LEAKS_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): no heap leaks found\n" + +#define RWCRTDUMPMEMORYLEAKS() \ + do \ + { \ + int leaks_found; \ + \ + leaks_found = _CrtDumpMemoryLeaks(); \ + _ASSERTE(!leaks_found); \ + if (!leaks_found) \ + OutputDebugString(NO_LEAKS_FOUND_STR); \ + } while(0) + +#define HEAP_DIFFERENCES_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): heap differences found\n" + +#define NO_DIFFERENCES_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): no heap differences found\n" + +#define RWCRTHEAPDIFFERENCESINCE(_Then) \ + do \ + { \ + /* only dump differences when \ + * there are in fact differences */ \ + _CrtMemState _Now; \ + _CrtMemState _Delta; \ + const int _DbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ + int Differences; \ + \ + _CrtMemCheckpoint(&_Now); \ + _CrtMemDifference(&_Delta, _Then, &_Now); \ + \ + (Differences) = ( ( 0 != _Delta.lCounts[_CLIENT_BLOCK] ) || \ + ( 0 != _Delta.lCounts[_NORMAL_BLOCK] ) || \ + ( (_DbgFlag & _CRTDBG_CHECK_CRT_DF) && \ + ( 0 != _Delta.lCounts[_CRT_BLOCK]) ) ); \ + \ + if ( (Differences) ) \ + { \ + /* difference detected: dump objects since _Then. */ \ + OutputDebugString(HEAP_DIFFERENCES_FOUND_STR); \ + _CrtMemDumpAllObjectsSince(_Then); \ + _CrtMemDumpStatistics(&_Delta); \ + } \ + else \ + { \ + OutputDebugString(NO_DIFFERENCES_FOUND_STR); \ + } \ + } while (0) + +#define RWCRTDBGBREAK() \ + _CrtDbgBreak() + +#define RWCRTDOFORALLCLIENTOBJECTS(_f, _c) \ + _CrtDoForAllClientObjects(_f, _c) + +#define RWCRTISMEMORYBLOCK(_p, _t, _r, _f, _l) \ + _CrtIsMemoryBlock(_p, _t, _r, _f, _l) + +#define RWCRTISVALIDHEAPPOINTER(_p) \ + _CrtIsValidHeapPointer(_p) + +#define RWCRTISVALIDPOINTER(_p, _n, _r) \ + _CrtIsValidPointer(_p, _n, _r) + +#define RWCRTMEMCHECKPOINT(_s) \ + _CrtMemCheckpoint(_s) + +#define RWCRTMEMDIFFERENCE(_s1, _s2, _s3) \ + _CrtMemDifference(_s1, _s2, _s3) + +#define RWCRTMEMDUMPALLOBJECTSSINCE(_s) \ + _CrtMemDumpAllObjectsSince(_s) + +#define RWCRTMEMDUMPSTATISTICS(_s) \ + _CrtMemDumpStatistics(_s) + +#define RWCRTSETALLOCHOOK(_f) \ + _CrtSetAllocHook(_f) + +#define RWCRTSETBREAKALLOC(_a) \ + _CrtSetBreakAlloc(_a) + +#define RWCRTSETDBGFLAG(_f) \ + _CrtSetDbgFlag(_f) + +#define RWCRTSETDUMPCLIENT(_f) \ + _CrtSetDumpClient(_f) + +#define RWCRTSETREPORTFILE(_t, _f) \ + _CrtSetReportFile(_t, _f) + +#define RWCRTSETREPORTHOOK(_f) \ + _CrtSetReportHook(_f) + +#define RWCRTSETREPORTMODE(_t, _f) \ + _CrtSetReportMode(_t, _f) + +#if (!defined(_CRTDBG_FLAGS)) +#define _CRTDBG_FLAGS \ + ( (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | \ + _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF) & \ + ~(_CRTDBG_CHECK_ALWAYS_DF |_CRTDBG_RESERVED_DF) ) +#endif /* (!defined(_CRTDBG_FLAGS)) */ + +# endif /* ((_MSC_VER>=1000) && defined(_DEBUG)) */ +# endif /* (defined(_MSC_VER)) */ + + + +#if (!defined(rwDEADPTRFILL)) +#define rwDEADPTRFILL ((void *)0xDDDDDDDD) +#endif /* (!defined(rwDEADPTRFILL)) */ + +#endif /* (defined(RWDEBUG) && (defined(RWMEMDEBUG))) */ + +#if (!defined(rwDEADPTRFILL)) +#define rwDEADPTRFILL (NULL) +#endif /* (!defined(rwDEADPTRFILL)) */ + +#if (!defined(RwMalloc)) +#if (!defined(RWDEBUG) || defined(DOXYGEN)) +#define RwMalloc(_s, _h) \ + ((RWSRCGLOBAL(memoryFuncs).rwmalloc)((_s), (_h))) +#else /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#define RwMalloc(_s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + ((RWSRCGLOBAL(memoryFuncs).rwmalloc)((_s), (_h)))) +#endif /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#endif /* (!defined(RwMalloc)) */ + +#if (!defined(RwFree)) +#define RwFree(_p) \ + ((RWSRCGLOBAL(memoryFuncs).rwfree)((_p))) +#endif /* (!defined(RwFree)) */ + +#if (!defined(RwCalloc)) +#if (!defined(RWDEBUG) || defined(DOXYGEN)) +#define RwCalloc(_n, _s, _h) \ + ((RWSRCGLOBAL(memoryFuncs).rwcalloc)((_n), (_s), (_h))) +#else /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#define RwCalloc(_n, _s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + ((RWSRCGLOBAL(memoryFuncs).rwcalloc)((_n), (_s), (_h)))) +#endif /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#endif /* (!defined(RwCalloc)) */ + +#if (!defined(RwRealloc)) +#if (!defined(RWDEBUG) || defined(DOXYGEN)) +#define RwRealloc(_p, _s, _h) \ + ((RWSRCGLOBAL(memoryFuncs).rwrealloc)((_p),(_s), (_h))) +#else /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#define RwRealloc(_p, _s, _h) \ + (_rwMemoryLastAllocFile = __FILE__, \ + _rwMemoryLastAllocLine = __LINE__, \ + ((RWSRCGLOBAL(memoryFuncs).rwrealloc)((_p),(_s), (_h)))) +#endif /* (!defined(RWDEBUG) || defined(DOXYGEN)) */ +#endif /* (!defined(RwRealloc)) */ + +#if (!defined(RWCRTORDBGFLAG)) +#define RWCRTORDBGFLAG(_flag) /* No op */ +#endif /* (!defined(RWCRTORDBGFLAG)) */ + +#if (!defined(RWCRTCHECKMEMORY)) +#define RWCRTCHECKMEMORY() /* No Op */ +#endif /* (!defined(RWCRTCHECKMEMORY)) */ + +#if (!defined(RWCRTDBGBREAK)) +#define RWCRTDBGBREAK() /* No Op */ +#endif /* (!defined(RWCRTDBGBREAK)) */ + +#if (!defined(RWCRTDOFORALLCLIENTOBJECTS)) +#define RWCRTDOFORALLCLIENTOBJECTS(_f, _c) /* No Op */ +#endif /* (!defined(RWCRTDOFORALLCLIENTOBJECTS)) */ + +#if (!defined(RWCRTDUMPMEMORYLEAKS)) +#define RWCRTDUMPMEMORYLEAKS() /* No Op */ +#endif /* (!defined(RWCRTDUMPMEMORYLEAKS)) */ + +#if (!defined(RWCRTHEAPDIFFERENCESINCE)) +#define RWCRTHEAPDIFFERENCESINCE(_Then) /* No Op */ +#endif /* (!defined(RWCRTHEAPDIFFERENCESINCE)) */ + +#if (!defined(RWCRTISMEMORYBLOCK)) +#define RWCRTISMEMORYBLOCK(_p, _t, _r, _f, _l) (NULL != (_p)) +#endif /* (!defined(RWCRTISMEMORYBLOCK)) */ + +#if (!defined(RWCRTISVALIDHEAPPOINTER)) +#define RWCRTISVALIDHEAPPOINTER(_p) (NULL != (_p)) +#endif /* (!defined(RWCRTISVALIDHEAPPOINTER)) */ + +#if (!defined(RWCRTISVALIDPOINTER)) +#define RWCRTISVALIDPOINTER(_p, _n, _r) (NULL != (_p)) +#endif /* (!defined(RWCRTISVALIDPOINTER)) */ + +#if (!defined(RWCRTMEMCHECKPOINT)) +#define RWCRTMEMCHECKPOINT(_s) /* No Op */ +#endif /* (!defined(RWCRTMEMCHECKPOINT)) */ + +#if (!defined(RWCRTMEMDIFFERENCE)) +#define RWCRTMEMDIFFERENCE(_s1, _s2, _s3) /* No Op */ +#endif /* (!defined(RWCRTMEMDIFFERENCE)) */ + +#if (!defined(RWCRTMEMDUMPALLOBJECTSSINCE)) +#define RWCRTMEMDUMPALLOBJECTSSINCE(_s) /* No Op */ +#endif /* (!defined(RWCRTMEMDUMPALLOBJECTSSINCE)) */ + +#if (!defined(RWCRTMEMDUMPSTATISTICS)) +#define RWCRTMEMDUMPSTATISTICS(_s) (NULL) +#endif /* (!defined(RWCRTMEMDUMPSTATISTICS)) */ + +#if (!defined(RWCRTSETALLOCHOOK)) +#define RWCRTSETALLOCHOOK(_f) (NULL) +#endif /* (!defined(RWCRTSETALLOCHOOK)) */ + +#if (!defined(RWCRTSETBREAKALLOC)) +#define RWCRTSETBREAKALLOC(_a) (0) +#endif /* (!defined(RWCRTSETBREAKALLOC)) */ + +#if (!defined(RWCRTSETDBGFLAG)) +#define RWCRTSETDBGFLAG(_f) (0) +#endif /* (!defined(RWCRTSETDBGFLAG)) */ + +#if (!defined(RWCRTSETDUMPCLIENT)) +#define RWCRTSETDUMPCLIENT(_f) (NULL) +#endif /* (!defined(RWCRTSETDUMPCLIENT)) */ + +#if (!defined(RWCRTSETREPORTFILE)) +#define RWCRTSETREPORTFILE(_t, _f) (NULL) +#endif /* (!defined(RWCRTSETREPORTFILE)) */ + +#if (!defined(RWCRTSETREPORTHOOK)) +#define RWCRTSETREPORTHOOK(_f) (NULL) +#endif /* (!defined(RWCRTSETREPORTHOOK)) */ + +#if (!defined(RWCRTSETREPORTMODE)) +#define RWCRTSETREPORTMODE(_t, _f) (0) +#endif /* (!defined(RWCRTSETREPORTMODE)) */ + +#if (!defined(RWREGSETBREAKALLOC)) +#define RWREGSETBREAKALLOC(_name) /* No op */ +#endif /* (!defined(RWREGSETBREAKALLOC)) */ + +#if (!defined(RWREGSETASSERTPRINT)) +#define RWREGSETASSERTPRINT(_name) /* No op */ +#endif /* (!defined(RWREGSETASSERTPRINT)) */ + +#if (!defined(RWGETWINREGDWORD)) +#define RWGETWINREGDWORD(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGDWORD)) */ + +#if (!defined(RWGETWINREGBINARY)) +#define RWGETWINREGBINARY(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGBINARY)) */ + +#if (!defined(RWGETWINREGSTRING)) +#define RWGETWINREGSTRING(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGSTRING)) */ + +#if (!defined(_CRTDBG_FLAGS)) +#define _CRTDBG_FLAGS 0x33 +#endif /* (!defined(_CRTDBG_FLAGS)) */ + +/** + * \ingroup memoryfileinterface + * Macro for extracting chunkID from a hint. This is the id of either + * the object for which a memory request came, or of the module a call + * for allocation belongs to. Refer to \ref RwCorePluginID for a list of + * all object IDs and to \ref rwengine, \ref RwCriterionCoreID + * and \ref RwCriterionWorldID for a list of all module IDs. Refer to + * RwMemoryFunctions for more details about the hints. + */ +#define RwMemoryHintGetChunkID(_h) ((_h) & 0xFFFF) +/** + * \ingroup memoryfileinterface + * Macro for extracting duration from a hint. Refer to RwMemoryFunctions + * for more details about the hints. + * \see RwMemoryHintDuration + */ +#define RwMemoryHintGetDuration(_h) ((_h) & rwMEMHINTDUR_MASK) +/** + * \ingroup memoryfileinterface + * Macro for extracting flags from a hint. Refer to RwMemoryFunctions + * for more details about the hints. + * \see RwMemoryHintFlag + */ +#define RwMemoryHintGetFlags(_h) ((_h) & rwMEMHINTFLAG_MASK) + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup memoryfileinterface + * This type represents the memory hint flags. + */ +enum RwMemoryHintFlag +{ + /** Indicates that memory being allocated will potentially be + * resized with calls to \ref RwRealloc + */ + rwMEMHINTFLAG_RESIZABLE = 0x01000000, + rwMEMHINTFLAG_MASK = 0xFF000000, + rwMEMHINTFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwMemoryHintFlag RwMemoryHintFlag; + +/** + * \ingroup memoryfileinterface + * This type represents the duration of a memory. + */ +enum RwMemoryHintDuration +{ + rwMEMHINTDUR_NADURATION = 0x00000000, + /** Is used for allocating some temporary memory which + * will be freed inside the function scope. + */ + rwMEMHINTDUR_FUNCTION = 0x00010000, + /** Is used for per frame memory allocations. + */ + rwMEMHINTDUR_FRAME = 0x00020000, + /** Is used for allocations which persist for longer + * than per frame, but are not global. This can be per + * level or per event. + */ + rwMEMHINTDUR_EVENT = 0x00030000, + /** Is used for all global allocations, happening on and + * before RwEngineStart() and which are freed on and after + * RwEngineStop() + */ + rwMEMHINTDUR_GLOBAL = 0x00040000, + rwMEMHINTDUR_MASK = 0x00FF0000, + rwMEMHINTDURFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwMemoryHintDuration RwMemoryHintDuration; + +/** + * \ingroup memoryfileinterface + * \struct RwMemoryFunctions + * This type represents the memory functions used by RenderWare. The + * application may override the default functions by passing a + * RwMemoryFunctions structure populated with a user defined functions + * to \ref RwEngineInit(). + * + * All RenderWare Graphics memory-management functions that allocate + * memory take an additional RwUInt32 parameter which is a memory hint. + * The main purpose of the hints is to help improve memory management, + * such as preventing memory fragmentation. To use the memory hints, you + * should have provided your own memory-management function through the + * RwEngineInit() function. For example, you might want to have a + * separate memory heap just for the RwMatrix or RpGeometry objects, or + * a separate heap for all temporary allocations inside RenderWare + * Graphics. As always, memory-management is very specific to each + * application and has to be organized and tuned for each one. + + * A memory hint contains the following information: + * RwMemoryHintDuration, RwMemoryHintFlag and chunkID. ChunkID is the id + * of either the object for which a memory request came, or of the module + * a call for allocation belongs to. Refer to \ref RwCorePluginID for a + * list of all object IDs and to \ref rwengine, \ref RwCriterionCoreID + * and \ref RwCriterionWorldID for a list of all module IDs. You can extend + * all of these fields using specific values for duration, object IDs, + * flags and create custom hints that can be passed to all the memory + * allocation calls you make. A tipical call to RwMalloc looks like: + * \code RwMalloc(size, rwID_MATRIX | rwMEMHINTDUR_FUNCTION);\endcode + * + * \note Note that once you override these function you will be responsible + * for aligning the memory properly. Memory alignment differs between the + * various platforms and it can also affect the application performance. + * + * \see RwMemoryHintGetDuration, RwMemoryHintGetChunkID, + * RwMemoryHintGetFlags, RwEngineInit. + */ +struct RwMemoryFunctions +{ + /* c.f. + * Program Files/Microsoft Visual Studio/VC98/Include/MALLOC.H + */ + void *(*rwmalloc)(size_t size, RwUInt32 hint); + /**< Allocates memory blocks. + * \param size Number of bytes to allocate. Should be greater + * then zero. + * \param hint A RwUInt32 value representing a memory hint. + * \return A void pointer to the allocated space, or NULL if + * there is insufficient memory available. + */ + void (*rwfree)(void *mem); + /**< Deallocates or frees a memory block. + * \param mem Previously allocated memory block to be freed. + * Shouldn't be NULL pointer. + */ + void *(*rwrealloc)(void *mem, size_t newSize, RwUInt32 hint); + /**< Reallocate memory blocks. + * \param mem Pointer to previously allocated memory block. + * \param size New size in bytes. Should be greater then zero. + * \param hint A RwUInt32 value representing a memory hint. + * \return A void pointer to the allocated space, or NULL if + * there is insufficient memory available. + */ + void *(*rwcalloc)(size_t numObj, size_t sizeObj, RwUInt32 hint); + /**< Allocates an array in memory with elements initialized to 0. + * \param numObj Non-zero number of elements. + * \param sizeObj Non-zero length in bytes of each element. + * \param hint A RwUInt32 value representing a memory hint. + * \return A void pointer to the allocated space, or NULL if + * there is insufficient memory available. + */ +}; +typedef struct RwMemoryFunctions RwMemoryFunctions; + + /** + * \ingroup rwfreelist + * The free list was statically allocated + * + * \see RwFreeListSetFlags + */ +#define rwFREELISTFLAG_STATIC 0x00000001 + +/** + * \ingroup rwfreelist + * \hideinitializer + * Free blocks as soon as they are empty. + * + * \see RwFreeListSetFlags + */ +#define rwFREELISTFLAG_FREEBLOCKS 0x00000002 + + +typedef struct RwFreeList RwFreeList; + +/** + * \ingroup rwfreelist + * Holds free list info, should be considered opaque. Use API functions to access. + */ +struct RwFreeList +{ + RwUInt32 entrySize; /** + rwFREELISTFLAG_FREEBLOCKS */ + RwLLLink link; /** + +#define RwFreeListAlloc(_f, _h) \ + memalign(((_f)->alignment), (_f)->entrySize) + +#else /* ((defined(__MWERKS__) || defined(__GNUC__)) && defined(__R5900__)) */ + +#define RwFreeListAlloc(_f, _h) \ + RwMalloc(((_f)->entrySize), (_h)) + +#endif /* ((defined(__MWERKS__) || defined(__GNUC__)) && defined(__R5900__)) */ + +#define RwFreeListFree(_f, _p) \ + RwFree((_p)) + +#endif /* (defined(RWDEBUG) && defined(RWNOFREELISTS) && !defined(RWKEEPFREELISTS)) */ + +#if (!defined(RwFreeListAlloc)) +#define RwFreeListAlloc(_f, _h) \ + RWSRCGLOBAL(memoryAlloc)((_f), (_h)) +#endif /* (!defined(RwFreeListAlloc)) */ + +#if (!defined(RwFreeListFree)) +#define RwFreeListFree(_f, _p) \ + RWSRCGLOBAL(memoryFree)(_f, _p) +#endif /* (!defined(RwFreeListFree)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bastream.h ---*/ + +/**************************************************************************** + Defines + */ + +#define rwSTREAMSTACKSIZE 512 + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup rwstream + * \ref RwStreamType + * This type represents the different types of stream that + * can be used. + * See API section \ref rwstream + */ +enum RwStreamType +{ + rwNASTREAM = 0, /**=1000) && defined(_DEBUG)) + +typedef char MatrixString[1024]; + +#define RWMATRIXPRINT(_matrix) \ +MACRO_START \ +{ \ + MatrixString message; \ + MatrixString output; \ + \ + if (NULL != (_matrix)) \ + { \ + const RwV3d * const _x = &(_matrix)->right; \ + const RwV3d * const _y = &(_matrix)->up; \ + const RwV3d * const _z = &(_matrix)->at; \ + const RwV3d * const _w = &(_matrix)->pos; \ + \ + _snprintf(message, sizeof(MatrixString), \ + "[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n" \ + " %08x == flags\n", \ + _x->x, _x->y, _x->z, (RwReal) 0, \ + _y->x, _y->y, _y->z, (RwReal) 0, \ + _z->x, _z->y, _z->z, (RwReal) 0, \ + _w->x, _w->y, _w->z, (RwReal) 1, \ + (_matrix)->flags); \ + } \ + else \ + { \ + _snprintf(message, sizeof(MatrixString), \ + "NULL"); \ + } \ + \ + _snprintf(output, sizeof(MatrixString), \ + "%s(%d): %s [%p] ==\n%s\n", \ + __FILE__, __LINE__, \ + #_matrix, _matrix, message); \ + \ + OutputDebugString(RWSTRING(output)); \ +} \ +MACRO_STOP + +# endif /* ((_MSC_VER>=1000) && defined(_DEBUG)) */ +# endif /* (defined(_MSC_VER)) */ +#endif /* (defined(RWMATRIXMONITOR)) */ + +#if (!(defined(RWMATRIXPRINT))) +#define RWMATRIXPRINT(_matrix) /* No op */ +#endif /* (!(defined(RWMATRIXPRINT))) */ + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwmatrix + * enum RwOpCombineType + * This type represents a combination operator which + * can be applied to frames and matrices. + * The operator determines the order + * in which one object is combined with another + */ +#endif /* RWADOXYGENEXTERNAL */ +enum RwOpCombineType +{ + rwCOMBINEREPLACE = 0, /**right.x = (m)->up.y = (m)->at.z = (RwReal)((1.0)); \ + (m)->right.y = (m)->right.z = (m)->up.x = (RwReal)((0.0)); \ + (m)->up.z = (m)->at.x = (m)->at.y = (RwReal)((0.0)); \ + (m)->pos.x = (m)->pos.y = (m)->pos.z = (RwReal)((0.0)); \ + rwMatrixSetFlags((m), \ + rwMatrixGetFlags(m) | \ + (rwMATRIXINTERNALIDENTITY | \ + rwMATRIXTYPEORTHONORMAL)); \ +} \ +MACRO_STOP +#endif /* (!defined(RwMatrixSetIdentityMacro)) */ + +typedef void (RWASMCALL * rwMatrixMultFn) (RwMatrix * dstMat, + const RwMatrix * matA, + const RwMatrix * matB); + +typedef struct RwMatrixTolerance RwMatrixTolerance; + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwmatrix + * \struct RwMatrixTolerance + * Holds tolerances for matrix optimizations with \ref RwMatrixOptimize + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwMatrixTolerance +{ + RwReal Normal; + /**< Tolerance within which matrix is deemed to be normal */ + RwReal Orthogonal; + /**< Tolerance within which matrix is deemed to be orthogonal */ + RwReal Identity; + /**< Tolerance within which matrix is deemed to be identity */ +}; + + +/**************************************************************************** + Function prototypes + */ + +/* Matrix operations */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RwEngineGetMatrixTolerances(RwMatrixTolerance * const tolerance); + +extern RwBool +RwEngineSetMatrixTolerances(const RwMatrixTolerance * const tolerance); + +/* Update */ +#define rwMatrixSetFlags(m, flagsbit) ((m)->flags = (flagsbit)) +#define rwMatrixGetFlags(m) ((m)->flags) +#define rwMatrixTestFlags(m, flagsbit) ((m)->flags & (RwInt32)(flagsbit)) + +/* Creation/destruction */ +extern void +RwMatrixSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwBool +RwMatrixDestroy(RwMatrix * mpMat); + +extern RwMatrix * +RwMatrixCreate(void); + +#ifdef RWDEBUG + +/* Functions for debug */ +extern void +RwMatrixCopy(RwMatrix * dstMatrix, const RwMatrix * srcMatrix); + +extern void +RwMatrixSetIdentity(RwMatrix * matrix); + +#else /* RWDEBUG */ + +#define RwMatrixCopy(dst, src) RwMatrixCopyMacro(dst, src) +#define RwMatrixSetIdentity(m) RwMatrixSetIdentityMacro(m) + +#endif /* RWDEBUG */ + +/* Matrix multiply */ +extern RwMatrix * +RwMatrixMultiply(RwMatrix * matrixOut, + const RwMatrix * MatrixIn1, + const RwMatrix * matrixIn2); + +extern RwMatrix * +RwMatrixTransform(RwMatrix * matrix, + const RwMatrix * transform, + RwOpCombineType combineOp); + +/* Normalise */ +extern RwMatrix * +RwMatrixOrthoNormalize(RwMatrix * matrixOut, + const RwMatrix * matrixIn); + +/* Inversion */ +extern RwMatrix * +RwMatrixInvert(RwMatrix * matrixOut, + const RwMatrix * matrixIn); + +/* Unary matrix operations */ +extern RwMatrix * +RwMatrixScale(RwMatrix * matrix, + const RwV3d * scale, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixTranslate(RwMatrix * matrix, + const RwV3d * translation, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixRotate(RwMatrix * matrix, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixRotateOneMinusCosineSine(RwMatrix * matrix, + const RwV3d * unitAxis, + RwReal oneMinusCosine, + RwReal sine, + RwOpCombineType combineOp); + +/* Query what the matrix is */ +extern const RwMatrix *RwMatrixQueryRotate(const RwMatrix * matrix, + RwV3d * unitAxis, + RwReal * angle, + RwV3d * center); + +/* Get components */ +#ifndef RWDEBUG + +#define RwMatrixGetRight(m) (&(m)->right) +#define RwMatrixGetUp(m) (&(m)->up) +#define RwMatrixGetAt(m) (&(m)->at) +#define RwMatrixGetPos(m) (&(m)->pos) + +#else /* RWDEBUG */ + +extern RwV3d * +RwMatrixGetRight(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetUp(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetAt(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetPos(RwMatrix * matrix); + +#endif /* RWDEBUG */ + +/* Update the internal matrix state wrt its elements */ +extern RwMatrix * +RwMatrixUpdate(RwMatrix * matrix); + +/* Update the internal matrix flags wrt its elements */ +extern RwMatrix * +RwMatrixOptimize(RwMatrix * matrix, + const RwMatrixTolerance * + tolerance); + +extern RwReal +_rwMatrixDeterminant(const RwMatrix * matrix); + +extern RwReal +_rwMatrixNormalError(const RwMatrix * matrix); + +extern RwReal +_rwMatrixOrthogonalError(const RwMatrix * matrix); + +extern RwReal +_rwMatrixIdentityError(const RwMatrix * matrix); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compatibility macros */ + +#define rwMatrixSetOptimizations(optimizeFlags) \ + _rwMatrixSetOptimizations(optimizeFlags) + +#define rwMatrixSetMultFn(multMat) \ + _rwMatrixSetMultFn(multMat) + +#define rwMatrixOpen(instance, offset, size) \ + _rwMatrixOpen(instance, offset, size) + +#define rwMatrixClose(instance, offset, size) \ + _rwMatrixClose(instance, offset, size) + +/* Initialisation/deinitialisation */ +#define rwMatrixInitialize(m, t) \ +MACRO_START \ +{ \ + rwMatrixSetFlags((m), (t)); \ +} \ +MACRO_STOP + +#define rwMatrixIsNormal(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixNormalError(_matrix) ) + +#define rwMatrixIsOrthogonal(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixOrthogonalError(_matrix) ) + +#define rwMatrixIsOrthonormal(_matrix, _epsilon) \ + ( rwMatrixIsNormal(_matrix, _epsilon) && \ + rwMatrixIsOrthogonal(_matrix, _epsilon) ) + +#define rwMatrixIsOrthonormalPositive(_matrix, _epsilon) \ + ( rwMatrixIsOrthonormal(_matrix, _epsilon) && \ +( (((RwReal)1) - (_epsilon)) <= _rwMatrixDeterminant(_matrix) ) ) + +#define rwMatrixIsIdentity(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixIdentityError(_matrix) ) + +#define rwMatrixValidFlags(_matrix, _epsilon) \ + ( (_matrix) && /* valid pointer */ \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as identity */ \ + rwMATRIXINTERNALIDENTITY) ) || /* .. or actually is */ \ + rwMatrixIsIdentity(_matrix, _epsilon)) && \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as normal */ \ + rwMATRIXTYPENORMAL) ) || /* ... or actually is */ \ + rwMatrixIsNormal(_matrix, _epsilon)) && \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as orthogonal */ \ + rwMATRIXTYPEORTHOGONAL) ) || /* ... or actually is */ \ + rwMatrixIsOrthogonal(_matrix, _epsilon)) ) + +#define rwMat01Det(_mAA) \ + ( (_mAA) ) + +#define rwMat02Det(_mAA, _mAB, \ + _mBA, _mBB) \ + ( (_mAA) * rwMat01Det(_mBB) \ + - (_mAB) * rwMat01Det(_mBA) \ + ) + +#define rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) \ + ( (_mAA) * rwMat02Det(_mBB, _mBC, \ + _mCB, _mCC) \ + - (_mAB) * rwMat02Det(_mBA, _mBC, \ + _mCA, _mCC) \ + + (_mAC) * rwMat02Det(_mBA, _mBB, \ + _mCA, _mCB) \ + ) + +#define rwMat04Det(_mAA, _mAB, _mAC, _mAD, \ + _mBA, _mBB, _mBC, _mBD, \ + _mCA, _mCB, _mCC, _mCD, \ + _mDA, _mDB, _mDC, _mDD) \ + ( (_mAA) * rwMat03Det(_mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD) \ + - (_mAB) * rwMat03Det(_mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) \ + + (_mAC) * rwMat03Det(_mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) \ + - (_mAD) * rwMat03Det(_mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) \ + ) + + +#define rwMat02Inv(_rAA, _rAB, \ + _rBA, _rBB) \ + _mAA, _mAB, \ + _mBA, _mBB) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA) = rwMat01Det(_mBB); \ + (_rAB) = -rwMat01Det(_mAB); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) ); \ + \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + \ + (_rBA) = -rwMat01Det(_mBA) * normalize; \ + (_rBB) = rwMat01Det(_mAA) * normalize; \ + } \ +} \ +MACRO_STOP + +#define rwMat03Inv(_rAA, _rAB, _rAC, \ + _rBA, _rBB, _rBC, \ + _rCA, _rCB, _rCC, \ + _mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA)= rwMat02Det(_mBB, _mBC, \ + _mCB, _mCC); \ + (_rAB)= -rwMat02Det(_mAB, _mAC, \ + _mCB, _mCC); \ + (_rAC)= rwMat02Det(_mAB, _mAC, \ + _mBB, _mBC); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) + \ + (_rAC) * (_mCA) ); \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + (_rAC) *= normalize; \ + \ + (_rBA)= -rwMat02Det(_mBA, _mBC, \ + _mCA, _mCC) * normalize ; \ + (_rBB)= rwMat02Det(_mAA, _mAC, \ + _mCA, _mCC) * normalize ; \ + (_rBC)= -rwMat02Det(_mAA, _mAC, \ + _mBA, _mBC) * normalize ; \ + \ + (_rCA)= rwMat02Det(_mBA, _mBB, \ + _mCA, _mCB) * normalize ; \ + (_rCB)= -rwMat02Det(_mAA, _mAB, \ + _mCA, _mCB) * normalize ; \ + (_rCC)= rwMat02Det(_mAA, _mAB, \ + _mBA, _mBB) * normalize ; \ + } \ + \ +} \ +MACRO_STOP + +#define rwMat04Inv(_rAA, _rAB, _rAC, _rAD, \ + _rBA, _rBB, _rBC, _rBD, \ + _rCA, _rCB, _rCC, _rCD, \ + _rDA, _rDB, _rDC, _rDD, \ + _mAA, _mAB, _mAC, _mAD, \ + _mBA, _mBB, _mBC, _mBD, \ + _mCA, _mCB, _mCC, _mCD, \ + _mDA, _mDB, _mDC, _mDD) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA)= rwMat03Det(_mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD); \ + (_rAB)= -rwMat03Det(_mAB, _mAC, _mAD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD); \ + (_rAC)= rwMat03Det(_mAB, _mAC, _mAD, \ + _mBB, _mBC, _mBD, \ + _mDB, _mDC, _mDD); \ + (_rAD)= -rwMat03Det(_mAB, _mAC, _mAD, \ + _mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) + \ + (_rAC) * (_mCA) + \ + (_rAD) * (_mDA) ); \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + (_rAC) *= normalize; \ + (_rAD) *= normalize; \ + \ + (_rBA)= -rwMat03Det(_mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBB)= rwMat03Det(_mAA, _mAC, _mAD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBC)= -rwMat03Det(_mAA, _mAC, _mAD, \ + _mBA, _mBC, _mBD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBD)= rwMat03Det(_mAA, _mAC, _mAD, \ + _mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD) * normalize ; \ + \ + (_rCA)= rwMat03Det(_mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCB)= -rwMat03Det(_mAA, _mAB, _mAD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCC)= rwMat03Det(_mAA, _mAB, _mAD, \ + _mBA, _mBB, _mBD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCD)= -rwMat03Det(_mAA, _mAB, _mAD, \ + _mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD) * normalize ; \ + \ + (_rDA)= -rwMat03Det(_mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDB)= rwMat03Det(_mAA, _mAB, _mAC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDC)= -rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDD)= rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) * normalize ; \ + } \ +} \ +MACRO_STOP + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d9/drvmodel.h ---*/ +#ifndef D3D9_DRVMODEL_H +#define D3D9_DRVMODEL_H + +#if (defined(__ICL)) +/* Avoid voluminous + * 'warning #344: typedef name has already been declared (with same type)' + * warnings from MS include files + */ +#pragma warning( disable : 344 ) +#endif /* (defined(__ICL)) */ + + +#if (defined(RWDEBUG)) +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#define ERR_WRAP(A) (_rwRePrintErrorDDD3D((A), __FILE__, __LINE__)) +#endif /* (defined(RWDEBUG)) */ + +#if (!defined(ERR_WRAP)) +#define ERR_WRAP(A) (A) +#endif /* (!defined(ERR_WRAP)) */ + +/**************************************************************************** + Defines + */ + +/* Set true depth information (for fogging, eg) */ +#define RwIm2DVertexSetCameraX(vert, camx) /* Nothing */ +#define RwIm2DVertexSetCameraY(vert, camy) /* Nothing */ +#define RwIm2DVertexSetCameraZ(vert, camz) /* Nothing */ + +#define RwIm2DVertexSetRecipCameraZ(vert, recipz) ((vert)->rhw = recipz) + +#define RwIm2DVertexGetCameraX(vert) (cause an error) +#define RwIm2DVertexGetCameraY(vert) (cause an error) +#define RwIm2DVertexGetCameraZ(vert) (cause an error) +#define RwIm2DVertexGetRecipCameraZ(vert) ((vert)->rhw) + +/* Set screen space coordinates in a device vertex */ +#define RwIm2DVertexSetScreenX(vert, scrnx) ((vert)->x = (scrnx)) +#define RwIm2DVertexSetScreenY(vert, scrny) ((vert)->y = (scrny)) +#define RwIm2DVertexSetScreenZ(vert, scrnz) ((vert)->z = (scrnz)) +#define RwIm2DVertexGetScreenX(vert) ((vert)->x) +#define RwIm2DVertexGetScreenY(vert) ((vert)->y) +#define RwIm2DVertexGetScreenZ(vert) ((vert)->z) + +/* Set texture coordinates in a device vertex */ +#define RwIm2DVertexSetU(vert, texU, recipz) ((vert)->u = (texU)) +#define RwIm2DVertexSetV(vert, texV, recipz) ((vert)->v = (texV)) +#define RwIm2DVertexGetU(vert) ((vert)->u) +#define RwIm2DVertexGetV(vert) ((vert)->v) + +/* Modify the luminance stuff */ +#define RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + (((RwFastRealToUInt32(alpha)) << 24) | \ + ((RwFastRealToUInt32(red)) << 16) | \ + ((RwFastRealToUInt32(green)) << 8) | \ + ((RwFastRealToUInt32(blue))))) + +#define RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + ((((RwUInt32)(alpha)) << 24) | \ + (((RwUInt32)(red)) << 16) | \ + (((RwUInt32)(green)) << 8) | \ + (((RwUInt32)(blue))))) + +#define RwIm2DVertexGetRed(vert) \ + (((vert)->emissiveColor >> 16) & 0xFF) + +#define RwIm2DVertexGetGreen(vert) \ + (((vert)->emissiveColor >> 8) & 0xFF) + +#define RwIm2DVertexGetBlue(vert) \ + ((vert)->emissiveColor & 0xFF) + +#define RwIm2DVertexGetAlpha(vert) \ + (((vert)->emissiveColor >> 24) & 0xFF) + +#define RwIm2DVertexCopyRGBA(dst, src) \ + ((dst)->emissiveColor = (src)->emissiveColor) + +/* Clipper stuff */ + +#define RwIm2DVertexClipRGBA(o, i, n, f) \ +MACRO_START \ +{ \ + const RwInt32 _factor = \ + (RwFastRealToUInt32(i * (RwReal)(255))) & 255; \ + \ + (o)->emissiveColor = \ + (((((RwIm2DVertexGetAlpha(f) - RwIm2DVertexGetAlpha(n)) * \ + _factor) >> 8) + RwIm2DVertexGetAlpha(n)) << 24) | \ + (((((RwIm2DVertexGetRed(f) - RwIm2DVertexGetRed(n)) * \ + _factor) >> 8) + RwIm2DVertexGetRed(n)) << 16) | \ + (((((RwIm2DVertexGetGreen(f) - RwIm2DVertexGetGreen(n)) * \ + _factor) >> 8) + RwIm2DVertexGetGreen(n)) << 8) | \ + (((((RwIm2DVertexGetBlue(f) - RwIm2DVertexGetBlue(n)) * \ + _factor) >> 8) + RwIm2DVertexGetBlue(n))); \ +} \ +MACRO_STOP + +/**************************************************************************** + Global Types + */ + +/* We use RwD3D9Vertex to drive the hardware in 2D mode */ + +/* + * D3D9 vertex structure definition for 2D geometry + */ +#if !defined(RWADOXYGENEXTERNAL) +typedef struct RwD3D9Vertex RwD3D9Vertex; +/** + * \ingroup rwcoredriverd3d9 + * \struct RwD3D9Vertex + * D3D9 vertex structure definition for 2D geometry + */ +struct RwD3D9Vertex +{ + RwReal x; /**< Screen X */ + RwReal y; /**< Screen Y */ + RwReal z; /**< Screen Z */ + RwReal rhw; /**< Reciprocal of homogeneous W */ + + RwUInt32 emissiveColor; /**< Vertex color */ + + RwReal u; /**< Texture coordinate U */ + RwReal v; /**< Texture coordinate V */ +}; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +/* Define types used */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RwIm2DVertex + * Typedef for a RenderWare Graphics Immediate Mode 2D Vertex + */ +typedef RwD3D9Vertex RwIm2DVertex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RxVertexIndex + * + * Typedef for a RenderWare Graphics Powe rPipe Immediate + * Mode Vertex + */ +typedef RwUInt16 RxVertexIndex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \ref RwImVertexIndex + * Typedef for a RenderWare Graphics Immediate Mode Vertex. + */ +typedef RxVertexIndex RwImVertexIndex; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#if !defined(RWADOXYGENEXTERNAL) +/** + * \ingroup rwcoredriverd3d9 + * \struct RwD3D9Metrics + * Structure containing metrics counters + */ +typedef struct +{ + RwUInt32 numRenderStateChanges; /**< Number of Render States changed */ + RwUInt32 numTextureStageStateChanges; /**< Number of Texture Stage States changed */ + RwUInt32 numSamplerStageStateChanges; /**< Number of Sampler States changed */ + RwUInt32 numMaterialChanges; /**< Number of Material changes */ + RwUInt32 numLightsChanged; /**< Number of Lights changed */ + RwUInt32 numVBSwitches; /**< Number of Vertex Buffer switches */ +} +RwD3D9Metrics; +#endif /* !defined(RWADOXYGENEXTERNAL) */ + +#endif /* D3D9_DRVMODEL_H */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bavector.h ---*/ +/**************************************************************************** + Defines + */ + +/* If sqrt is overloaded for this platform, we will remove + * all the sqrt table stuff from the build entirely + * currently applies to SKY2 and XBOX - IDBS [2/11/2001] + * [and, if using the intel compiler version 400 or above, + * we will use the single-precision float "sqrtf" under + * D3D8, OpenGL or SoftRas] */ +#if (defined(rwSqrtMacro)) +#define RWNOSQRTTABLE +#endif /* (defined(rwSqrtMacro)) */ +#if (defined(rwInvSqrtMacro)) +#define RWNOINVSQRTTABLE +#endif /* (defined(rwSqrtMacro)) */ + +#if (!defined(rwSqrtMacro)) +#define rwSqrtMacro(_root, _input) \ + ( *(_root) = _rwSqrt(_input) ) +#endif /* (!defined(rwSqrtMacro)) */ + +#if (!defined(rwInvSqrtMacro)) +#define rwInvSqrtMacro(_recip, _input) \ + ( *(_recip) = _rwInvSqrt(_input) ) +#endif /* (!defined(rwInvSqrtMacro)) */ + +#if (!defined(rwSqrtInvSqrtMacro)) +#define rwSqrtInvSqrtMacro(_root, _recip, _input) \ +MACRO_START \ +{ \ + RwReal _tmp = _input; \ + rwSqrt((_root), _tmp); \ + rwInvSqrt((_recip), _tmp); \ +} \ +MACRO_STOP +#endif /* (!defined(rwSqrtInvSqrtMacro)) */ + +/* Vector operations Macros */ + +#if (!defined(RwV2dAssignMacro)) +#define RwV2dAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwV2dAssignMacro)) */ + +#define RwV2dAddMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ( (b)->x)); \ + (o)->y = (((a)->y) + ( (b)->y)); \ +} \ +MACRO_STOP + +#define RwV2dSubMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) - ( (b)->x)); \ + (o)->y = (((a)->y) - ( (b)->y)); \ +} \ +MACRO_STOP + +#define RwV2dScaleMacro(o, i, s) \ +MACRO_START \ +{ \ + (o)->x = (((i)->x) * ( (s))); \ + (o)->y = (((i)->y) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV2dDotProductMacro(a,b) \ + (( ((((a)->x) * ( (b)->x))) + \ + ( (((a)->y) * ( (b)->y))))) + +#define _rwV2dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV2dDotProductMacro((_in), (_in)); \ + rwInvSqrtMacro(&(_result), length2); \ + RwV2dScaleMacro((_out), (_in), (_result)); \ +} \ +MACRO_STOP + +#define RwV2dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV2dDotProductMacro((_in), (_in)); \ + RwReal recip; \ + \ + rwSqrtInvSqrtMacro(&(_result), &recip, length2); \ + RwV2dScaleMacro((_out), (_in), recip); \ +} \ +MACRO_STOP + +#define RwV2dLengthMacro(_result, _in) \ +MACRO_START \ +{ \ + (_result) = RwV2dDotProductMacro(_in, _in); \ + rwSqrtMacro(&(_result), (_result)); \ +} \ +MACRO_STOP + +#define RwV2dLineNormalMacro(_o, _a, _b) \ +MACRO_START \ +{ \ + RwReal recip; \ + \ + (_o)->y = (((_b)->x) - ( (_a)->x)); \ + (_o)->x = (((_a)->y) - ( (_b)->y)); \ + _rwV2dNormalizeMacro(recip, _o,_o); \ +} \ +MACRO_STOP + +#define RwV2dPerpMacro(o, a) \ +MACRO_START \ +{ \ + (o)->x = -(a)->y; \ + (o)->y = (a)->x; \ +} \ +MACRO_STOP + +/* RwV3d */ + +#if (!defined(RwV3dAssignMacro)) +#define RwV3dAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwV3dAssignMacro)) */ + + +#define RwV3dAddMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ( (b)->x)); \ + (o)->y = (((a)->y) + ( (b)->y)); \ + (o)->z = (((a)->z) + ( (b)->z)); \ +} \ +MACRO_STOP + +#define RwV3dSubMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) - ( (b)->x)); \ + (o)->y = (((a)->y) - ( (b)->y)); \ + (o)->z = (((a)->z) - ( (b)->z)); \ +} \ +MACRO_STOP + +#define RwV3dScaleMacro(o, a, s) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) * ( (s))); \ + (o)->y = (((a)->y) * ( (s))); \ + (o)->z = (((a)->z) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV3dIncrementScaledMacro(o, a, s) \ +MACRO_START \ +{ \ + (o)->x += (((a)->x) * ( (s))); \ + (o)->y += (((a)->y) * ( (s))); \ + (o)->z += (((a)->z) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV3dNegateMacro(o, a) \ +MACRO_START \ +{ \ + (o)->x = -(a)->x; \ + (o)->y = -(a)->y; \ + (o)->z = -(a)->z; \ +} \ +MACRO_STOP + +#define RwV3dDotProductMacro(a, b) \ + ((((( (((a)->x) * ((b)->x))) + \ + ( (((a)->y) * ((b)->y))))) + \ + ( (((a)->z) * ((b)->z))))) + +#define RwV3dCrossProductMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = \ + (( (((a)->y) * ( (b)->z))) - \ + ( (((a)->z) * ( (b)->y)))); \ + (o)->y = \ + (( (((a)->z) * ( (b)->x))) - \ + ( (((a)->x) * ( (b)->z)))); \ + (o)->z = \ + (( (((a)->x) * ( (b)->y))) - \ + ( (((a)->y) * ( (b)->x)))); \ +} \ +MACRO_STOP + +#define _rwV3dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV3dDotProductMacro(_in, _in); \ + rwInvSqrtMacro(&(_result), length2); \ + RwV3dScaleMacro(_out, _in, _result); \ +} \ +MACRO_STOP + +#define RwV3dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV3dDotProductMacro((_in), (_in)); \ + RwReal recip; \ + \ + rwSqrtInvSqrtMacro(&(_result), &recip, length2); \ + RwV3dScaleMacro((_out), (_in), recip); \ +} \ +MACRO_STOP + +#define RwV3dLengthMacro(_result, _in) \ +MACRO_START \ +{ \ + (_result) = RwV3dDotProductMacro(_in, _in); \ + rwSqrtMacro(&(_result), _result); \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RwV2dAssign(o, a) RwV2dAssignMacro(o, a) +#define RwV2dAdd(o, a, b) RwV2dAddMacro(o, a, b) +#define RwV2dSub(o, a, b) RwV2dSubMacro(o, a, b) +#define RwV2dLineNormal(_o, _a, _b) RwV2dLineNormalMacro(_o, _a, _b) +#define RwV2dScale(o, i, s) RwV2dScaleMacro(o, i, s) +#define RwV2dDotProduct(a,b) RwV2dDotProductMacro(a,b) +#define RwV2dPerp(o, a) RwV2dPerpMacro(o, a) +#define RwV3dAssign(o, a) RwV3dAssignMacro(o, a) +#define RwV3dAdd(o, a, b) RwV3dAddMacro(o, a, b) +#define RwV3dSub(o, a, b) RwV3dSubMacro(o, a, b) +#define RwV3dScale(o, a, s) RwV3dScaleMacro(o, a, s) +#define RwV3dIncrementScaled(o, a, s) RwV3dIncrementScaledMacro(o, a, s) +#define RwV3dNegate(o, a) RwV3dNegateMacro(o, a) +#define RwV3dDotProduct(a, b) RwV3dDotProductMacro(a, b) +#define RwV3dCrossProduct(o, a, b) RwV3dCrossProductMacro(o, a, b) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +#define RWRAD2DEG(_x) ((_x) * (((RwReal)180)/(rwPI))) + +#if (!defined(rw4OVERPISQ)) +#define rw4OVERPISQ ( ((RwReal)4) / ( rwPI * rwPI )) +#endif /* (!defined(rw4OVERPISQ)) */ + +#if (!defined(rwPI3)) +#define rwPI3 (rwPI * (RwReal)3) +#endif /* (!defined(rwPI3)) */ + +#if (!defined(rwPI3OVER2)) +#define rwPI3OVER2 ( rwPI3 / (RwReal)2 ) +#endif /* (!defined(rwPI3OVER2)) */ + +#if (!defined(rwPI3OVER8)) +#define rwPI3OVER8 (rwPI3 / (RwReal)8 ) +#endif /* (!defined(rwPI3OVER8)) */ + +#define RwQuadSin(_x) \ + ( rw4OVERPISQ * \ + ( ( (_x) < 0 ) ? \ + ( ( rwPI + (_x) ) * (_x) ) : \ + ( ( rwPI - (_x) ) * (_x) ) ) ) + +#define RwQuadASin(_result, _s) \ + ( rwPIOVER2 * ( ((_s)<0) ? \ + ( rwSqrtMacro((_result), 1.0f + (_s)) - 1 ) : \ + ( 1 - rwSqrtMacro((_result), 1.0f - (_s)) ) ) ) + +#define RwQuadCos(_x) \ + ( rw4OVERPISQ * \ + ( ( (_x) < -rwPIOVER2 ) ? \ + ( ( -rwPI3OVER2 - (_x) ) * ( -rwPIOVER2 - (_x) ) ) : \ + ( ( (_x) < rwPIOVER2) ? \ + ( ( rwPIOVER2 + (_x) ) * ( rwPIOVER2 - (_x) ) ) : \ + ( ( rwPIOVER2 - (_x) ) * ( rwPI3OVER2 - (_x) ) ) ) ) ) + +#define RwQuadACos(_result, _c) \ + ( rwPIOVER2 * ( ((_c)<0) ? \ + (2.0f - rwSqrtMacro((_result), 1.0f + (_c))): \ + rwSqrtMacro((_result), 1.0f - (_c))) ) + +#define RwQuadTan(_x) \ + ( rwPI3 * (_x) / ( rwPI * rwPI - (_x) * (_x) * 4.0f ) ) + +#define RwQuadATan(_result, _t) \ + ( ( rwSqrtMacro((_result), (rwPI3OVER8 * rwPI3OVER8) + \ + (_t) * (_t) * (rwPIOVER2 * rwPIOVER2) ) - rwPI3OVER8 ) \ + / ( _t) ) + +#define RwQuadATan2(_result, _s, _c) \ + ( ( rwSqrtMacro((_result), (_c) * (_c) * (rwPI3OVER8 * rwPI3OVER8) + \ + (_s) * (_s) * (rwPIOVER2 * rwPIOVER2) ) \ + - (_c) * rwPI3OVER8 ) / ( _s) ) + +/**************************************************************************** + Global Types + */ +#if !defined(RWNOVECMULTFUNCS) +/* + * Typedef for pointer to Vector multiplication by Matrix function + */ +typedef RwV3d *(*rwVectorMultFn) (RwV3d * pointOut, + const RwV3d * pointIn, + const RwMatrix * matrix); + +typedef RwV3d *(*rwVectorsMultFn) (RwV3d * pointsOut, + const RwV3d * pointsIn, + RwInt32 numPoints, + const RwMatrix * matrix); +#endif /* !defined(RWNOVECMULTFUNCS) */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Other useful stuff */ + +/**************************************************************************** + Function prototypes + */ +extern RwReal RwV3dNormalize(RwV3d * out, const RwV3d * in); +extern RwReal RwV3dLength(const RwV3d * in); + +extern RwReal RwV2dLength(const RwV2d * in); +extern RwReal RwV2dNormalize(RwV2d * out, const RwV2d * in); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void RwV2dAssign(RwV2d * out, + const RwV2d * ina); +extern void RwV2dAdd(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dLineNormal(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dSub(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dPerp(RwV2d * out, const RwV2d * in); +extern void RwV2dScale(RwV2d * out, + const RwV2d * in, RwReal scalar); +extern RwReal RwV2dDotProduct(const RwV2d * ina, const RwV2d * inb); + +extern void RwV3dAssign(RwV3d * out, + const RwV3d * ina); +extern void RwV3dAdd(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); +extern void RwV3dSub(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); +extern void RwV3dScale(RwV3d * out, + const RwV3d * in, RwReal scalar); +extern void RwV3dIncrementScaled(RwV3d * out, + const RwV3d * in, RwReal scalar); +extern void RwV3dNegate(RwV3d * out, const RwV3d * in); +extern RwReal RwV3dDotProduct(const RwV3d * ina, const RwV3d * inb); +extern void RwV3dCrossProduct(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +/* Transform points/vectors */ +extern RwV3d *RwV3dTransformPoint(RwV3d * pointOut, + const RwV3d * pointIn, + const RwMatrix * matrix); +extern RwV3d *RwV3dTransformPoints(RwV3d * pointsOut, + const RwV3d * pointsIn, + RwInt32 numPoints, + const RwMatrix * matrix); +extern RwV3d *RwV3dTransformVector(RwV3d * vectorOut, + const RwV3d * vectorIn, + const RwMatrix * matrix); +extern RwV3d *RwV3dTransformVectors(RwV3d * vectorsOut, + const RwV3d * vectorsIn, + RwInt32 numPoints, + const RwMatrix * matrix); + +/* SPI */ + +#if (!defined(RWNOSQRTTABLE)) +extern RwReal _rwSqrt(const RwReal num); +#endif /* (!defined(RWNOSQRTTABLE)) */ +#if (!defined(RWNOINVSQRTTABLE)) +extern RwReal _rwInvSqrt(const RwReal num); +#endif /* (!defined(RWNOINVSQRTTABLE)) */ + +extern RwReal _rwV3dNormalize(RwV3d * out, const RwV3d * in); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/balist.h ---*/ +/**************************************************************************** + Global Types + */ + +typedef struct RwSList RwSList; + +#if (!defined(DOXYGEN)) +struct RwSList +{ + RwUInt8 *listElements; + RwInt32 numElementsFilled; + RwInt32 numElementsAlloced; + RwInt32 entrySize; +}; +#endif /* (!defined(DOXYGEN) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* SList functions */ +extern RwSList *_rwSListCreate(RwInt32 size, RwUInt32 hint); +extern RwBool _rwSListDestroy(RwSList *sList); +extern RwBool _rwSListDestroyArray(RwUInt8 *array); +extern void _rwSListDestroyEndEntries(RwSList *sList, RwInt32 amount); +extern RwBool _rwSListDestroyEntry(RwSList *sList, RwInt32 entry); +extern void _rwSListEmpty(RwSList *sList); +extern void *_rwSListGetArray(RwSList *sList); +extern void *_rwSListGetEntry(RwSList *sList, RwInt32 entry); +extern void *_rwSListGetNewEntry(RwSList *sList, RwUInt32 hint); +extern void *_rwSListGetNewEntries(RwSList *sList, RwInt32 entry, + RwUInt32 hint); +extern RwInt32 _rwSListGetNumEntries(const RwSList *sList); +extern RwBool _rwSListReleaseArray(RwSList *sList); +extern void *_rwSListToArray(RwSList *sList); +extern void *_rwSListGetBegin(RwSList *sList); +extern void *_rwSListGetEnd(RwSList *sList); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Comparibility macros */ + +#define rwSListCreate(size, hint) \ + _rwSListCreate(size, hint) +#define rwSListDestroy(sList) \ + _rwSListDestroy(sList) +#define rwSListDestroyArray(array) \ + _rwSListDestroyArray(array) +#define rwSListDestroyEndEntries(sList, amount) \ + _rwSListDestroyEndEntries(sList, amount) +#define rwSListDestroyEntry(sList, entry) \ + _rwSListDestroyEntry(sList, entry) +#define rwSListEmpty(sList) \ + _rwSListEmpty(sList) +#define rwSListGetArray(sList) \ + _rwSListGetArray(sList) +#define rwSListGetEntry(sList, entry) \ + _rwSListGetEntry(sList, entry) +#define rwSListGetNewEntry(sList, hint) \ + _rwSListGetNewEntry(sList, hint) +#define rwSListGetNewEntries(sList, entry, hint) \ + _rwSListGetNewEntries(sList, entry, hint) +#define rwSListGetNumEntries(sList) \ + _rwSListGetNumEntries(sList) +#define rwSListReleaseArray(sList) \ + _rwSListReleaseArray(sList) +#define rwSListToArray(sList) \ + _rwSListToArray(sList) +#define rwSListGetBegin(sList) \ + _rwSListGetBegin(sList) +#define rwSListGetEnd(sList) \ + _rwSListGetEnd(sList) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/baimmedi.h ---*/ + +/**************************************************************************** + Defines + */ + + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + Immediate mode interface V2.0 + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwrenderstate + * RwRenderState represents the global state variables that control + * rendering. These may be set and queried using the + * \ref RwRenderStateSet and \ref RwRenderStateGet functions respectively. + * + * Refer to the \ref rwrenderstateoverview for an overview of this system. + * + * \note The texture render states (raster, address & filter modes) would + * normally just be used when rendering in immediate mode and should be + * specificied completely every time a texture is used. Retained mode + * pipelines will frequently set theses states internally, usually based on + * \ref RwTexture objects. + */ +#endif /* RWADOXYGENEXTERNAL */ +enum RwRenderState +{ + rwRENDERSTATENARENDERSTATE = 0, + + rwRENDERSTATETEXTURERASTER, + /** Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: FALSE. + */ + rwRENDERSTATESTENCILFAIL, + /**<\ref RwStencilOperation used when the stencil test passes. + * Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: rwSTENCILOPERATIONKEEP. + */ + rwRENDERSTATESTENCILZFAIL, + /**<\ref RwStencilOperation used when the stencil test passes and + * the depth test (z-test) fails. + * Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: rwSTENCILOPERATIONKEEP. + */ + rwRENDERSTATESTENCILPASS, + /**<\ref RwStencilOperation used when both the stencil and the depth + * (z) tests pass. + * Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: rwSTENCILOPERATIONKEEP. + */ + rwRENDERSTATESTENCILFUNCTION, + /**<\ref RwStencilFunction for the stencil test. + * Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: rwSTENCILFUNCTIONALWAYS. + */ + rwRENDERSTATESTENCILFUNCTIONREF, + /** Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: 0. + */ + rwRENDERSTATESTENCILFUNCTIONMASK, + /** Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: 0xffffffff. + */ + rwRENDERSTATESTENCILFUNCTIONWRITEMASK, + /** Supported on Xbox, D3D8, D3D9, and OpenGL only. + * Default: 0xffffffff. + */ + rwRENDERSTATEALPHATESTFUNCTION, + /**<\ref RwAlphaTestFunction for the alpha test. When a pixel fails, + * neither the frame buffer nor the Z-buffer are updated. + * Default: rwALPHATESTFUNCTIONGREATER (GameCube, Xbox, D3D8, D3D9 + * and OpenGL). The default PS2 behaviour is to always update the + * frame buffer and update the Z-buffer only if a greater than or + * equal test passes. + */ + rwRENDERSTATEALPHATESTFUNCTIONREF, + /** Range is 0 to 255, mapped to the platform's actual range + * Default: 128 (PS2) 0 (GameCube, Xbox, D3D8, D3D9 and OpenGL). + */ + + rwRENDERSTATEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwRenderState RwRenderState; + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwrenderstate + * RwShadeMode represents the available shading modes that may be + * set using the \ref RwRenderState \ref rwRENDERSTATESHADEMODE. + */ +#endif /* RWADOXYGENEXTERNAL */ +enum RwShadeMode +{ + rwSHADEMODENASHADEMODE = 0, + rwSHADEMODEFLAT, /**>8)+8: RWBYTEFINDMSB(a)) + +#define RWLONGFINDMSB(a) \ + (((a)&0xffff0000UL)?RWWORDFINDMSB((a)>>16)+16: RWWORDFINDMSB(a)) + +/**************************************************************************** + Defines + */ + +/* macros used to access plugin data in objects */ +#define RWPLUGINOFFSET(_type, _base, _offset) \ + ((_type *)((RwUInt8 *)(_base) + (_offset))) + +#define RWPLUGINOFFSETCONST(_type, _base, _offset) \ + ((const _type *)((const RwUInt8 *)(_base) + (_offset))) + +/* macro used to access global data structure (the root type is RwGlobals) */ +#define RWSRCGLOBAL(variable) \ + (((RwGlobals *)RwEngineInstance)->variable) + +#define RWASSERTISTYPE(_f, _t) \ + RWASSERT((((const RwObject *)(_f))->type)==(_t)) + +/**************************************************************************** + Global Types + */ + +enum RwEngineStatus +{ + rwENGINESTATUSIDLE = 0, /* This needs to be zero */ + rwENGINESTATUSINITED = 1, + rwENGINESTATUSOPENED = 2, + rwENGINESTATUSSTARTED = 3, + rwENGINESTATUSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwEngineStatus RwEngineStatus; + +typedef struct RwGlobals RwGlobals; + +#if (!defined(DOXYGEN)) +struct RwGlobals +{ +#ifdef RWDEBUG + RwDebugHandler debugFunction; /* debug string handler */ + RwInt32 debugStackDepth; /* current depth of function stack */ + RwBool debugTrace; /* is function tracing enabled */ +#endif + + /* Current entities */ + void *curCamera; /* Current camera */ + void *curWorld; /* Current World */ + + /* Checking counters */ + RwUInt16 renderFrame; /* Camera display count */ + RwUInt16 lightFrame; /* Used to ensure each light is applied only once. */ + RwUInt16 pad[2]; /* Longword align it again */ + + /* For the currently accessed device */ + RwDevice dOpenDevice; + + /* Standard renderers and functions */ + RwStandardFunc stdFunc[rwSTANDARDNUMOFSTANDARD]; + + /* All of the frames which have been updated */ + RwLinkList dirtyFrameList; + + /* The string functions */ + RwStringFunctions stringFuncs; + + /* The memory allocation functions */ + RwMemoryFunctions memoryFuncs; +#ifdef RWDEBUG + RwBool freeListExtraDebug; +#endif /* RWDEBUG */ + + /* virtual memory alloc/free functions */ + RwMemoryAllocFn memoryAlloc; + RwMemoryFreeFn memoryFree; + + RwMetrics *metrics; + + /* Current engine status */ + RwEngineStatus engineStatus; + + /* Resource arena init size. */ + RwUInt32 resArenaInitSize; +}; + +typedef struct RwModuleInfo RwModuleInfo; +struct RwModuleInfo +{ + RwInt32 globalsOffset; + RwInt32 numInstances; +}; +#endif /* (!defined(DOXYGEN)) */ + + + +/**************************************************************************** + Program wide globals + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef RWGLOBALSIZE +extern RwUInt32 ourGlobals[RWGLOBALSIZE / sizeof(RwUInt32)]; +#define RwEngineInstance ourGlobals +#else /* RWGLOBALSIZE */ + +#ifdef _RWDLL +__declspec(dllimport) extern void *RwEngineInstance; +#else +extern void *RwEngineInstance; +#endif + +#endif /* RWGLOBALSIZE */ + +#if defined(_RWDLL) +__declspec(dllimport) extern RwInt8 _rwMsbBit[]; +#else /* defined(_RWDLL) */ +extern RwInt8 _rwMsbBit[]; +#endif /* defined(_RWDLL) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/baresour.h ---*/ + +#define RWRESOURCESGLOBAL(var) (RWPLUGINOFFSET(rwResourcesGlobals, \ + RwEngineInstance, resourcesModule.globalsOffset)->var) +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwresources + * \struct RwResEntry + * RwResEntry object. Instanced data block in resources arena. + * This should be considered an opaque + * type. Use the RwResEntry API functions to access. + */ +#endif /* RWADOXYGENEXTERNAL */ +typedef struct RwResEntry RwResEntry; + +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwresources + * \ref RwResEntryDestroyNotify type represents the function + * called from \ref RwResourcesFreeResEntry (and indirectly from + * \ref RwResourcesEmptyArena) immediately before the memory used by the + * specified resources entry is released. + * + * \param resEntry Pointer to the instanced data. + */ +#endif /* RWADOXYGENEXTERNAL */ +typedef void (*RwResEntryDestroyNotify) (RwResEntry * resEntry); + +#if (!defined(DOXYGEN)) +struct RwResEntry +{ + RwLLLink link; /* Node in the list of resource elements */ + RwInt32 size; /* Size of this node */ + void *owner; /* Owner of this node */ + RwResEntry **ownerRef; /* Pointer to pointer to this (enables de-alloc) */ + RwResEntryDestroyNotify destroyNotify; /* This is called right before destruction */ +}; +#endif /* (!defined(DOXYGEN)) */ + +typedef struct rwResources rwResources; + +#if (!defined(DOXYGEN)) +struct rwResources +{ + RwInt32 maxSize; + RwInt32 currentSize; + RwInt32 reusageSize; + + void *memHeap; + + RwLinkList entriesA; + RwLinkList entriesB; + + RwLinkList *freeEntries; + RwLinkList *usedEntries; +}; + + +typedef struct rwResourcesGlobals rwResourcesGlobals; +struct rwResourcesGlobals +{ + rwResources res; +}; +#endif /* (!defined(DOXYGEN)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Setting the resources arena size */ +extern RwBool RwResourcesSetArenaSize(RwUInt32 size); +extern RwInt32 RwResourcesGetArenaSize(void); +extern RwInt32 RwResourcesGetArenaUsage(void); +extern RwBool RwResourcesEmptyArena(void); + +/* Allocate */ +extern RwResEntry *RwResourcesAllocateResEntry(void *owner, + RwResEntry **ownerRef, + RwInt32 size, + RwResEntryDestroyNotify + destroyNotify); +/* Deallocate */ +extern RwBool RwResourcesFreeResEntry(RwResEntry * entry); +/* Mark all as unused */ +extern void _rwResourcesPurge(void); +#if ((defined(RWDEBUG)) || (defined(RWSUPPRESSINLINE))) +/* Mark as used */ +extern RwResEntry *RwResourcesUseResEntry(RwResEntry * entry); +#endif /* ((defined(RWDEBUG)) || (defined(RWSUPPRESSINLINE))) */ + +extern RwModuleInfo resourcesModule; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) +#define RwResourcesUseResEntry(_ntry) \ + ((((_ntry)->link.next)? \ + (rwLinkListRemoveLLLink(&((_ntry)->link)), \ + rwLinkListAddLLLink(RWRESOURCESGLOBAL(res.usedEntries), \ + &((_ntry)->link))): \ + NULL), \ + (_ntry)) +#endif /* ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bacolor.h ---*/ +/**************************************************************************** + Global Types + */ + +#ifndef RWADOXYGENEXTERNAL +typedef struct RwRGBAReal RwRGBAReal; +/** + * \ingroup rwrgba + * \struct RwRGBAReal + * This structure represents an RGBA color which has + * components specified as real values. + * + * A color component of an RwRGBA with the value 255 generally corresponds + * to the associated component in an RwRGBAReal with the value 1.0f. + * However, any values can be substituted to denormalize/normalize + * RwRGBAReal and create different effects. For example, while light colors + * are expressed as normalized RGBA, interesting effects can be gained using + * larger values. + * + * It should also be noted that a color component of an RwRGBA with the + * value 0 generally corresponds to the associcated component in an + * RwRGBAReal with the value 0.0. + */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwRGBAReal +{ + RwReal red; /**< red component */ + RwReal green; /**< green component */ + RwReal blue; /**< blue component */ + RwReal alpha; /**< alpha component */ +}; + +#if (!defined(RwRGBARealAssign)) +#define RwRGBARealAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwRGBARealAssign)) */ + +typedef struct RwRGBA RwRGBA; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwrgba + * \struct RwRGBA + * This structure represents an RGBA color + * which has integer components specified in the range 0 to 255. */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwRGBA +{ + RwUInt8 red; /**< red component */ + RwUInt8 green; /**< green component */ + RwUInt8 blue; /**< blue component */ + RwUInt8 alpha; /**< alpha component */ +}; + +#if (!defined(RwRGBAAssign)) +#define RwRGBAAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwRGBAAssign)) */ + +#define RwRGBARealAddMacro(o,a,b) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) + ( (b)->red)); \ + (o)->green = (((a)->green) + ( (b)->green)); \ + (o)->blue = (((a)->blue) + ( (b)->blue)); \ + (o)->alpha = (((a)->alpha) + ( (b)->alpha)); \ +} \ +MACRO_STOP + +#define RwRGBARealSubMacro(o,a,b) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) - ( (b)->red)); \ + (o)->green = (((a)->green) - ( (b)->green)); \ + (o)->blue = (((a)->blue) - ( (b)->blue)); \ + (o)->alpha = (((a)->alpha) - ( (b)->alpha)); \ +} \ +MACRO_STOP + +#define RwRGBARealScaleMacro(o,a,scale) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) * ( scale)); \ + (o)->green = (((a)->green) * ( scale)); \ + (o)->blue = (((a)->blue) * ( scale)); \ + (o)->alpha = (((a)->alpha) * ( scale)); \ +} \ +MACRO_STOP + +/* Conversion macros */ +#define RwRGBAFromRwRGBARealMacro(o, i) \ +MACRO_START \ +{ \ + RwInt32 quantize; \ + \ + quantize = RwInt32FromRealMacro( ((i)->red * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->red = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->green * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->green = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->blue * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->blue = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->alpha * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->alpha = (RwUInt8) quantize; \ + \ +} \ +MACRO_STOP + +#define RwRGBARealFromRwRGBAMacro(o, i) \ +MACRO_START \ +{ \ + (o)->red = \ + (((RwReal)(((i)->red))) * ( (RwReal)((1.0/255.0)))); \ + (o)->green = \ + (((RwReal)(((i)->green))) * ( (RwReal)((1.0/255.0)))); \ + (o)->blue = \ + (((RwReal)(((i)->blue))) * ( (RwReal)((1.0/255.0)))); \ + (o)->alpha = \ + (((RwReal)(((i)->alpha))) * ( (RwReal)((1.0/255.0)))); \ +} \ +MACRO_STOP + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RwRGBARealAdd(o,a,b) \ + RwRGBARealAddMacro(o,a,b) + +#define RwRGBARealSub(o,a,b) \ + RwRGBARealSubMacro(o,a,b) + +#define RwRGBARealScale(o,a,scale) \ + RwRGBARealScaleMacro(o,a,scale) + +#define RwRGBAFromRwRGBAReal(o, i) \ + RwRGBAFromRwRGBARealMacro(o, i) + +#define RwRGBARealFromRwRGBA(o, i) \ + RwRGBARealFromRwRGBAMacro(o, i) + +#else /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/* Function versions for debug */ +extern void RwRGBARealAdd(RwRGBAReal *result, + const RwRGBAReal *source1, + const RwRGBAReal *source2); + +extern void RwRGBARealSub(RwRGBAReal *result, + const RwRGBAReal *source1, + const RwRGBAReal *source2); + +extern void RwRGBARealScale(RwRGBAReal *result, + const RwRGBAReal *source, + RwReal scalar); + +extern void RwRGBAFromRwRGBAReal(RwRGBA *result, + const RwRGBAReal *source); + +extern void RwRGBARealFromRwRGBA(RwRGBAReal *result, + RwRGBA *source); + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/babinmtx.h ---*/ + +/**************************************************************************** + Global types + */ + +/* Matrix stream format */ +typedef struct rwStreamMatrix RwMatrixChunkInfo; +typedef struct rwStreamMatrix rwStreamMatrix; +#if (!defined(DOXYGEN)) +struct rwStreamMatrix +{ + RwV3d right; + RwV3d up; + RwV3d at; + RwV3d pos; + RwInt32 type; +}; +#endif /* (!defined(DOXYGEN)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Matrix binary format */ +extern RwUInt32 RwMatrixStreamGetSize(const RwMatrix * matrix); +extern RwMatrix *RwMatrixStreamRead(RwStream * stream, + RwMatrix * matrix); +extern const RwMatrix *RwMatrixStreamWrite(const RwMatrix * matrix, + RwStream * stream); +extern RwMatrixChunkInfo *RwMatrixChunkInfoRead(RwStream * stream, + RwMatrixChunkInfo * + matrixChunkInfo, + RwInt32 * bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/babinary.h ---*/ +/**************************************************************************** + Defines + */ +#ifndef rwCHUNKHEADERSIZE +#define rwCHUNKHEADERSIZE (sizeof(RwUInt32)*3) +#endif /* rwCHUNKHEADERSIZE */ + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE) || defined(rwBIGENDIAN)) +/* Binary Portability Functions/Macros */ +#define RwMemLittleEndian16(_m, _s) (_m) +#define RwMemLittleEndian32(_m, _s) (_m) +#define RwMemNative16(_m, _s) (_m) +#define RwMemNative32(_m, _s) (_m) +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE) || defined(rwBIGENDIAN)) */ + +#if (!defined(RWFLOAT32FROMREAL)) +#define RwMemRealToFloat32(_m, _s) (_m) +#endif /* (!defined(RWFLOAT32FROMREAL)) */ + +#if (!defined(RWREALFROMFLOAT32)) +#define RwMemFloat32ToReal(_m, _s) (_m) +#endif /* (!defined(RWREALFROMFLOAT32)) */ + +/* Compatibility macro */ +#define RwStreamWriteInt(_stream, _ints, _numBytes) \ + RwStreamWriteInt32(_stream, _ints, _numBytes) + +#define RwStreamReadInt(_stream, _ints, _numBytes) \ + RwStreamReadInt32(_stream, _ints, _numBytes) + +#define RwMemLittleEndian(_mem, _size) \ + RwMemLittleEndian32(_mem, _size) + +#define RwMemNative(_mem, _size) \ + RwMemNative32(_mem, _size) + +/**************************************************************************** + Global Types + */ + +typedef struct RwChunkHeaderInfo RwChunkHeaderInfo; +#ifndef RWADOXYGENEXTERNAL +/** + * \ingroup rwstream + * \struct RwChunkHeaderInfo + * Holds data for a chunk header read from a + * stream with \ref RwStreamReadChunkHeaderInfo. */ +#endif /* RWADOXYGENEXTERNAL */ +struct RwChunkHeaderInfo +{ + RwUInt32 type; /**< chunk ID - see \ref RwStreamFindChunk */ + RwUInt32 length; /**< length of the chunk data in bytes */ + RwUInt32 version; /**< version of the chunk data. + * See \ref RwEngineGetVersion. */ + RwUInt32 buildNum; /**< build number of the RenderWare libraries + * previously used to stream out the data */ + RwBool isComplex; /**< Internal Use */ +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Chunk header stuff */ +extern RwBool RwStreamFindChunk(RwStream *stream, RwUInt32 type, + RwUInt32 *lengthOut, RwUInt32 *versionOut); + +#define RwStreamWriteChunkHeader(stream, type, size) \ + _rwStreamWriteVersionedChunkHeader( \ + stream, type, size, rwLIBRARYCURRENTVERSION, RWBUILDNUMBER) + +extern RwStream *_rwStreamWriteVersionedChunkHeader(RwStream *stream, + RwInt32 type, + RwInt32 size, + RwUInt32 version, + RwUInt32 buildNum); + +extern RwStream *RwStreamWriteReal(RwStream *stream, const RwReal *reals, + RwUInt32 numBytes); +extern RwStream *RwStreamWriteInt32(RwStream *stream, const RwInt32 *ints, + RwUInt32 numBytes); +extern RwStream *RwStreamWriteInt16(RwStream *stream, const RwInt16 *ints, + RwUInt32 numBytes); + +extern RwStream *RwStreamReadReal(RwStream *stream, RwReal *reals, + RwUInt32 numBytes); +extern RwStream *RwStreamReadInt32(RwStream *stream, RwInt32 *ints, + RwUInt32 numBytes); +extern RwStream *RwStreamReadInt16(RwStream *stream, RwInt16 *ints, + RwUInt32 numBytes); + +/* Binary Portability Functions */ +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE) || defined(rwBIGENDIAN)) +extern void *RwMemLittleEndian16(void *mem, RwUInt32 size); +extern void *RwMemLittleEndian32(void *mem, RwUInt32 size); +extern void *RwMemNative16(void *mem, RwUInt32 size); +extern void *RwMemNative32(void *mem, RwUInt32 size); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE) || defined(rwBIGENDIAN)) */ + +#if (defined(RWFLOAT32FROMREAL)) +extern void *RwMemRealToFloat32(void *mem, RwUInt32 size); +#endif /* (defined(RWFLOAT32FROMREAL)) */ + +#if (defined(RWREALFROMFLOAT32)) +extern void *RwMemFloat32ToReal(void *mem, RwUInt32 size); +#else +#endif /* (defined(RWREALFROMFLOAT32)) */ + +extern RwStream * +RwStreamReadChunkHeaderInfo(RwStream *stream, RwChunkHeaderInfo *chunkHeaderInfo); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWPLCORE_H */ diff --git a/includes/rwsdk/rwversion.h b/includes/rwsdk/rwversion.h new file mode 100644 index 0000000..66bb773 --- /dev/null +++ b/includes/rwsdk/rwversion.h @@ -0,0 +1,102 @@ +/*************************************************************************** + * * + * Module : rwversion.h * + * * + * Purpose : RenderWare Versioning * + * * + **************************************************************************/ + +#ifndef RWVERSION_H +#define RWVERSION_H + +/* + * Library version number + * + * 0xVJNBB: + * + * V = RenderWare version (3 - 7) + * J = Release major revision (0 - 15) + * N = Release minor revision (0 - 15) + * BB = Binary format revision (0 - 63) + * + * The limits given above are imposed by the 16-bit packed version + * format contained in stream chunk headers. + * + * rwLIBRARYBASEVERSION Earliest binary compatible version. + * + * rwLIBRARYNOWARNVERSION 'No Warning' version. Binary data older than + * this will cause warnings to be generated on + * loading. + */ + +#define rwLIBRARYCURRENTRWVERSION 3 +#define rwLIBRARYCURRENTMAJORREVISION 7 +#define rwLIBRARYCURRENTMINORREVISION 0 +#define rwLIBRARYCURRENTBINARYREVISION 2 + +#define rwLIBRARYBASEVERSION 0x35000 +#define rwLIBRARYNOWARNVERSION 0x36000 +#define rwLIBRARYCURRENTVERSION ((rwLIBRARYCURRENTRWVERSION << 16) | \ + (rwLIBRARYCURRENTMAJORREVISION << 12) | \ + (rwLIBRARYCURRENTMINORREVISION << 8) | \ + (rwLIBRARYCURRENTBINARYREVISION)) + + +#define rwLIBRARYVERSION35000 0x35000 +#if (rwLIBRARYVERSION35000 < rwLIBRARYBASEVERSION) +#error "Time to remove all rwLIBRARYVERSION35000 code" +#endif + +#define rwLIBRARYVERSION36000 0x36000 +#if (rwLIBRARYVERSION36000 < rwLIBRARYBASEVERSION) +#error "Time to remove all rwLIBRARYVERSION36000 code" +#endif + +#define rwLIBRARYVERSION36002 0x36002 +#if (rwLIBRARYVERSION36002 < rwLIBRARYBASEVERSION) +#error "Time to remove all rwLIBRARYVERSION36002 code" +#endif + +#define rwLIBRARYVERSION36003 0x36003 +#if (rwLIBRARYVERSION36003 < rwLIBRARYBASEVERSION) +#error "Time to remove all rwLIBRARYVERSION36003 code" +#endif + +/* + * RWBUILDNUMBER + * + * This 16-bit int will be externally defined in an official build, and + * is used to construct library ID stamp contained in stream chunk headers. + * All unofficial builds will be stamped with the following:- + */ + +#if !defined(RWBUILDNUMBER) +#define RWBUILDNUMBER 10 +#endif + +/* + * + * Library ID stamp + * + * Bits allocated in packed format (MSB first):- + * + * 2 SDK version (zero is RW3) + * 4 Major revision number + * 4 Minor revision number + * 6 Binary format revision number + * 16 Library build number + */ + +#define RWLIBRARYIDPACK(_version, _buildNum) \ + ( ((((_version) - 0x30000U) & 0x3ff00U) << 14) \ + | (((_version) & 0x0003fU) << 16) \ + | ((_buildNum) & 0xffffU)) + +#define RWLIBRARYIDUNPACKVERSION(_libraryID) \ + ( ((((_libraryID) >> 14) & 0x3ff00U) + 0x30000U) \ + | (((_libraryID) >> 16) & 0x0003fU)) + +#define RWLIBRARYIDUNPACKBUILDNUM(_libraryID) \ + ((_libraryID) & 0xffffU) + +#endif /* RWVERSION_H */ diff --git a/includes/stdafx.h b/includes/stdafx.h index f3a0737..c409634 100644 --- a/includes/stdafx.h +++ b/includes/stdafx.h @@ -1,16 +1,44 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - #pragma once +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include -#include "targetver.h" +#pragma warning(disable:4201) +#pragma warning(disable:4458) -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include +#include "IniReader.h" + +#include "injector\injector.hpp" +#include "injector\assembly.hpp" +#include "injector\calling.hpp" +#include "injector\hooking.hpp" +#include "injector\utility.hpp" + +#include "rwsdk\rwcore.h" +#include "rwsdk\rpworld.h" + +#include "Maths.h" +#include "General.h" +#include "Camera.h" +template +inline T random(T a, T b) +{ + return a + static_cast(rand() * (1.0f / RAND_MAX) * (b - a)); +} +template +inline T Min(const T& a, const T& b) +{ + return a > b ? b : a; +} -// TODO: reference additional headers your program requires here +template +inline T Max(const T& a, const T& b) +{ + return a > b ? a : b; +} \ No newline at end of file