| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***************************************************************************
- * *
- * Project Name : G *
- * *
- * $Archive:: /VSS_Sync/ww3d2/pointgr.cpp $*
- * *
- * $Author:: Vss_sync $*
- * *
- * $Modtime:: 8/29/01 7:29p $*
- * *
- * $Revision:: 37 $*
- * *
- *-------------------------------------------------------------------------*
- * Functions: *
- * PointGroupClass::PointGroupClass -- PointGroupClass CTor. *
- * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. *
- * PointGroupClass::operator = -- PointGroupClass assignment operator. *
- * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays.*
- * PointGroupClass::Set_Point_Size -- Set default point size. *
- * PointGroupClass::Get_Point_Size -- Get default point size. *
- * PointGroupClass::Set_Point_Color -- Set default point color. *
- * PointGroupClass::Get_Point_Color -- Get default point color. *
- * PointGroupClass::Set_Point_Alpha -- Set default point alpha. *
- * PointGroupClass::Get_Point_Alpha -- Get default point alpha. *
- * PointGroupClass::Set_Point_Orientation -- Set default point orientatio*
- * PointGroupClass::Get_Point_Orientation -- Get default point orientatio*
- * PointGroupClass::Set_Point_Frame -- Set default point frame. *
- * PointGroupClass::Get_Point_Frame -- Get default point frame. *
- * PointGroupClass::Set_Point_Mode -- Set point rendering method. *
- * PointGroupClass::Get_Point_Mode -- Get point rendering method. *
- * PointGroupClass::Set_Flag -- Set given flag to on or off. *
- * PointGroupClass::Get_Flag -- Get current value (on/off) of given flag.*
- * PointGroupClass::Set_Texture -- Set texture used. *
- * PointGroupClass::Get_Texture -- Get texture used. *
- * PointGroupClass::Set_Shader -- Set shader used. *
- * PointGroupClass::Get_Shader -- Get shader used. *
- * PointGroupClass::Set_Billboard -- Set whether to billboard. *
- * PointGroupClass::Get_Billboard -- Get whether to billboard. *
- * PointGroupClass::Get_Discrete_Orientation_Count_Log2 -- what it says *
- * PointGroupClass::Set_Discrete_Orientation_Count_Log2 -- what it says. *
- * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says *
- * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. *
- * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. *
- * PointGroupClass::Render -- draw point group. *
- * PointGroupClass::vInstance -- Create instance of class. *
- * PointGroupClass::sGetClassName -- Get name of class. *
- * PointGroupClass::Update_Arrays -- Update all arrays used in rendering *
- * PointGroupClass::Peek_Texture -- Peeks texture *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "pointgr.h"
- #include "vertmaterial.h"
- #include "ww3d.h"
- #include "aabox.h"
- #include "statistics.h"
- #include "simplevec.h"
- #include "texture.h"
- #include "vector.h"
- #include "vp.h"
- #include "matrix4.h"
- #include "dx8wrapper.h"
- #include "dx8vertexbuffer.h"
- #include "dx8indexbuffer.h"
- #include "rinfo.h"
- #include "camera.h"
- #include "dx8fvf.h"
- #include "D3DXMath.h"
- #include "sortingrenderer.h"
- // Upgraded to DX8 2/2/01 HY
- // static data members
- Vector3 PointGroupClass::_TriVertexLocationOrientationTable[256][3];
- Vector3 PointGroupClass::_QuadVertexLocationOrientationTable[256][4];
- Vector2 *PointGroupClass::_TriVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL};
- Vector2 *PointGroupClass::_QuadVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL};
- VertexMaterialClass *PointGroupClass::PointMaterial=NULL;
- // Static arrays for intermediate calcs (never resized down, just up):
- VectorClass<Vector3> PointGroupClass::compressed_loc; // point locations 'compressed' by APT
- VectorClass<Vector4> PointGroupClass::compressed_diffuse; // point colors 'compressed' by APT
- VectorClass<float> PointGroupClass::compressed_size; // point sizes 'compressed' by APT
- VectorClass<unsigned char> PointGroupClass::compressed_orient; // point orientations 'compressed' by APT
- VectorClass<unsigned char> PointGroupClass::compressed_frame; // point frames 'compressed' by APT
- VectorClass<Vector3> PointGroupClass::transformed_loc; // transformed point locations
- // This array has vertex locations for screenspace mode - calculated to cover exactly 1x1 and 2x2 pixels.
- Vector3 PointGroupClass::_ScreenspaceVertexLocationSizeTable[2][3] =
- {
- Vector3(0.5f, 0.0f, -1.0f),
- Vector3(1.0f, 1.0f, -1.0f),
- Vector3(0.0f, 1.0f, -1.0f),
- Vector3(1.0f, -0.5f, -1.0f),
- Vector3(2.7f, 2.0f, -1.0f),
- Vector3(-0.7f, 2.0f, -1.0f)
- };
- // useful for particles that aren't aligned with the screen.
- static Vector3 GroundMultiplierX(1.0f, 0.0f, 0.0f);
- static Vector3 GroundMultiplierY(0.0f, 1.0f, 0.0f);
- // Some internal variables
- VectorClass<Vector3> VertexLoc; // camera-space vertex locations
- VectorClass<Vector4> VertexDiffuse; // vertex diffuse/alpha colors
- VectorClass<Vector2> VertexUV; // vertex texture coords
- // Some DX 8 variables
- #define MAX_VB_SIZE 2048
- #define MAX_TRI_POINTS MAX_VB_SIZE/3
- #define MAX_TRI_IB_SIZE 3*MAX_TRI_POINTS
- #define MAX_QUAD_POINTS MAX_VB_SIZE/4
- #define MAX_QUAD_IB_SIZE 6*MAX_QUAD_POINTS
- DX8IndexBufferClass *Tris, *Quads; // Index buffers.
- SortingIndexBufferClass *SortingTris, *SortingQuads; // Sorting index buffers.
- /**************************************************************************
- * PointGroupClass::PointGroupClass -- PointGroupClass CTor. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- PointGroupClass::PointGroupClass(void) :
- PointLoc(NULL),
- PointDiffuse(NULL),
- APT(NULL),
- PointSize(NULL),
- PointOrientation(NULL),
- PointFrame(NULL),
- PointCount(0),
- FrameRowColumnCountLog2(0),
- Texture(NULL),
- Flags(0),
- Shader(ShaderClass::_PresetAdditiveSpriteShader),
- PointMode(TRIS),
- DefaultPointSize(0.0f),
- DefaultPointColor(1.0f, 1.0f, 1.0f),
- DefaultPointAlpha(1.0f),
- DefaultPointOrientation(0),
- DefaultPointFrame(0),
- VPXMin(0.0f),
- VPYMin(0.0f),
- VPXMax(0.0f),
- VPYMax(0.0f)
- {
- }
- /**************************************************************************
- * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- PointGroupClass::~PointGroupClass(void)
- {
- if (PointLoc) {
- PointLoc->Release_Ref();
- PointLoc = NULL;
- }
- if (PointDiffuse) {
- PointDiffuse->Release_Ref();
- PointDiffuse=NULL;
- }
- if (APT) {
- APT->Release_Ref();
- APT = NULL;
- }
- if (PointSize) {
- PointSize->Release_Ref();
- PointSize = NULL;
- }
- if (PointOrientation) {
- PointOrientation->Release_Ref();
- PointOrientation = NULL;
- }
- if (PointFrame) {
- PointFrame->Release_Ref();
- PointFrame = NULL;
- }
- if (Texture) {
- REF_PTR_RELEASE(Texture);
- Texture = NULL;
- }
- }
- /**************************************************************************
- * PointGroupClass::operator = -- PointGroupClass assignment operator. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- PointGroupClass & PointGroupClass::operator = (const PointGroupClass & that)
- {
- if (this != &that) {
- WWASSERT(0); // If you hit this assert implement the function!
- }
- return *this;
- }
- /**************************************************************************
- * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * NOTES: colors, alphas, APT, sizes, orientations and frames are *
- * optional. active_point_count can also be used with a NULL apt.*
- * In this case active_point_count is ignored if it is -1 *
- * (default value) and otherwise it indicates the first N active *
- * points in the arrays. *
- * The view plane rectangle may optionally be passed as well - *
- * this is only used in SCREENSPACE mode. *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- * 08/25/1999 NH : Alphas added. *
- * 06/28/2000 NH : Orientations and frames added. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- void PointGroupClass::Set_Arrays(
- ShareBufferClass<Vector3> *locs,
- ShareBufferClass<Vector4> *diffuse,
- ShareBufferClass<unsigned int> *apt,
- ShareBufferClass<float> *sizes,
- ShareBufferClass<unsigned char> *orientations,
- ShareBufferClass<unsigned char> *frames,
- unsigned int active_point_count,
- float vpxmin,
- float vpymin,
- float vpxmax,
- float vpymax)
- {
- // The point locations array is NOT optional!
- WWASSERT(locs);
- // Ensure lengths of all arrays are the same:
- WWASSERT(!diffuse || locs->Get_Count() == diffuse->Get_Count());
- WWASSERT(!apt || locs->Get_Count() == apt->Get_Count());
- WWASSERT(!sizes || locs->Get_Count() == sizes->Get_Count());
- WWASSERT(!orientations || locs->Get_Count() == orientations->Get_Count());
- WWASSERT(!frames || locs->Get_Count() == frames->Get_Count());
- REF_PTR_SET(PointLoc,locs);
- REF_PTR_SET(PointDiffuse,diffuse);
- REF_PTR_SET(APT,apt);
- REF_PTR_SET(PointSize,sizes);
- REF_PTR_SET(PointOrientation,orientations);
- REF_PTR_SET(PointFrame,frames);
- if (APT) {
- PointCount = active_point_count;
- } else {
- PointCount = (active_point_count >= 0) ? active_point_count : PointLoc->Get_Count();
- }
- // Store view plane rectangle (only used in SCREENSPACE mode)
- VPXMin = vpxmin;
- VPYMin = vpymin;
- VPXMax = vpxmax;
- VPYMax = vpymax;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Size -- Set default point size. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This size is ignored if a size array is present. *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Size(float size)
- {
- DefaultPointSize = size;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Size -- Get default point size. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This size is ignored if a size array is present. *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- float PointGroupClass::Get_Point_Size(void)
- {
- return DefaultPointSize;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Color -- Set default point color. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This color is ignored if a color array is present. *
- * *
- * HISTORY: *
- * 04/20/1999 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Color(Vector3 color)
- {
- DefaultPointColor = color;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Color -- Get default point color. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This color is ignored if a color array is present. *
- * *
- * HISTORY: *
- * 04/20/1999 NH : Created. *
- *========================================================================*/
- Vector3 PointGroupClass::Get_Point_Color(void)
- {
- return DefaultPointColor;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Alpha -- Set default point alpha. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This alpha is ignored if an alpha array is present. *
- * *
- * HISTORY: *
- * 08/25/1999 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Alpha(float alpha)
- {
- DefaultPointAlpha = alpha;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Alpha -- Get default point alpha. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This alpha is ignored if an alpha array is present. *
- * *
- * HISTORY: *
- * 08/25/1999 NH : Created. *
- *========================================================================*/
- float PointGroupClass::Get_Point_Alpha(void)
- {
- return DefaultPointAlpha;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Orientation -- Set default point orientation*
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This is ignored if an orientation array is present. *
- * *
- * NOTE: No need to ensure value in valid range - it will be masked later.*
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Orientation(unsigned char orientation)
- {
- DefaultPointOrientation = orientation;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Orientation -- Get default point orientation*
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This is ignored if an orientation array is present. *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- unsigned char PointGroupClass::Get_Point_Orientation(void)
- {
- return DefaultPointOrientation;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Frame -- Set default point frame. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This frame is ignored if an frame array is present. *
- * *
- * NOTE: No need to ensure value in valid range - it will be masked later.*
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Frame(unsigned char frame)
- {
- DefaultPointFrame = frame;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Frame -- Get default point frame. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: This frame is ignored if an frame array is present. *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- unsigned char PointGroupClass::Get_Point_Frame(void)
- {
- return DefaultPointFrame;
- }
- /**************************************************************************
- * PointGroupClass::Set_Point_Mode -- Set point rendering method. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Point_Mode(PointModeEnum mode)
- {
- PointMode = mode;
- }
- /**************************************************************************
- * PointGroupClass::Get_Point_Mode -- Get point rendering method. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- PointGroupClass::PointModeEnum PointGroupClass::Get_Point_Mode(void)
- {
- return PointMode;
- }
- /**************************************************************************
- * Set_Flag -- PointGroupClass::Set given flag to on or off. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Flag(FlagsType flag, bool onoff)
- {
- if (onoff) Flags|=1<<flag;
- else
- Flags&=~(1<<flag);
- }
- /**************************************************************************
- * PointGroupClass::Get_Flag -- Get current value (on/off) of given flag. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- int PointGroupClass::Get_Flag(FlagsType flag)
- {
- return (Flags>>flag) & 0x1;
- }
- /**************************************************************************
- * PointGroupClass::Set_Texture -- Set texture used. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- void PointGroupClass::Set_Texture(TextureClass* texture)
- {
- REF_PTR_SET(Texture,texture);
- }
- /**************************************************************************
- * PointGroupClass::Get_Texture -- Get texture used. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- TextureClass * PointGroupClass::Get_Texture(void)
- {
- if (Texture) Texture->Add_Ref();
- return Texture;
- }
- /***********************************************************************************************
- * PointGroupClass::Peek_Texture -- Peeks texture *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/12/2001 hy : Created. *
- *=============================================================================================*/
- TextureClass * PointGroupClass::Peek_Texture(void)
- {
- return Texture;
- }
- /**************************************************************************
- * PointGroupClass::Set_Shader -- Set shader used. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: the primary gradient will be set to MODULATE/DISABLE in *
- * the shader depending on whether a color or alpha array was *
- * passed in Set_Point_Arrays. also, texturing will be *
- * enabled or disabled dependent on whether a non-NULL *
- * texture was set. *
- * these will override the primary gradient/texturing *
- * settings in the given shader. *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- void PointGroupClass::Set_Shader(ShaderClass shader)
- {
- Shader = shader;
- }
- /**************************************************************************
- * PointGroupClass::Get_Shader -- Get shader used. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- ShaderClass PointGroupClass::Get_Shader(void)
- {
- return Shader;
- }
- /**************************************************************************
- * PointGroupClass::Set_Billboard -- Set whether to Billboard. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/25/2002 JM : Created. *
- *========================================================================*/
- void PointGroupClass::Set_Billboard(bool shouldBillboard)
- {
- Billboard = shouldBillboard;
- }
- /**************************************************************************
- * PointGroupClass::Get_Billboard -- Get whether to Billboard. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/25/2002 JM : Created. *
- *========================================================================*/
- bool PointGroupClass::Get_Billboard(void)
- {
- return Billboard;
- }
- /**************************************************************************
- * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- unsigned char PointGroupClass::Get_Frame_Row_Column_Count_Log2(void)
- {
- return FrameRowColumnCountLog2;
- }
- /**************************************************************************
- * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- void PointGroupClass::Set_Frame_Row_Column_Count_Log2(unsigned char frccl2)
- {
- FrameRowColumnCountLog2 = MIN(frccl2, 4);
- }
- /**************************************************************************
- * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/18/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- int PointGroupClass::Get_Polygon_Count(void)
- {
- switch (PointMode) {
- case TRIS:
- case SCREENSPACE:
- return PointCount;
- break;
- case QUADS:
- return PointCount * 2;
- break;
- }
- WWASSERT(0);
- return 0;
- }
- /**************************************************************************
- * PointGroupClass::Render -- draw point group. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 12/10/1998 NH : Created. *
- * 02/08/2001 HY : Upgraded to DX8 *
- *========================================================================*/
- static SimpleVecClass<unsigned long> remap;
- void PointGroupClass::Render(RenderInfoClass &rinfo)
- {
- /// @todo lorenzen asks: is particle culling in the shader perhaps faster than in DoParticles? Fix winding and find out...
- // NB: the winding for pointgroups is wrong, but we
- // are disabling culling for particles anyway
- Shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE);
- // If no points, do nothing:
- if (PointCount == 0) return;
- WWASSERT(PointLoc && PointLoc->Get_Array());
- // Process texture reductions:
- // if (Texture) Texture->Process_Reduction();
- // Pointers which point into existing buffers (member or static):
- Vector3 *current_loc = NULL;
- Vector4 *current_diffuse = NULL;
- float *current_size = NULL;
- unsigned char *current_orient = NULL;
- unsigned char *current_frame = NULL;
- // If there is a color or alpha array enable gradient in shader - otherwise disable.
- float value_255 = 0.9961f; //254 / 255
- bool default_white_opaque = ( DefaultPointColor.X > value_255 &&
- DefaultPointColor.Y > value_255 &&
- DefaultPointColor.Z > value_255 &&
- DefaultPointAlpha > value_255);
- // The reason we check for lack of texture here is that SR seems to render black triangles
- // rather than white triangles as would be expected) when there is no texture AND no gradient.
- if (PointDiffuse || !default_white_opaque || !Texture) {
- Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE);
- } else {
- Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE);
- }
- // If Texture is non-NULL enable texturing in shader - otherwise disable.
- if (Texture) {
- Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE);
- } else {
- Shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE);
- }
- // If there is an active point table, use it to compress the point
- // locations/colors/alphas/sizes/orientations/frames.
- if (APT) {
- // Resize compressed result arrays if needed (2x guardband to prevent
- // frequent reallocations):
- /// @todo lorenzen sez: precompute pointers to indexed array elements, below
- if (compressed_loc.Length() < PointCount) {
- compressed_loc.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_loc[0],
- PointLoc->Get_Array(), APT->Get_Array(), PointCount);
- current_loc = &compressed_loc[0];
- if (PointDiffuse) {
- if (compressed_diffuse.Length() < PointCount) {
- compressed_diffuse.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_diffuse[0],
- PointDiffuse->Get_Array(), APT->Get_Array(), PointCount);
- current_diffuse = &compressed_diffuse[0];
- }
- if (PointSize) {
- if (compressed_size.Length() < PointCount) {
- compressed_size.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_size[0],
- PointSize->Get_Array(), APT->Get_Array(), PointCount);
- current_size = &compressed_size[0];
- }
- if (PointOrientation) {
- if (compressed_orient.Length() < PointCount) {
- compressed_orient.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_orient[0],
- PointOrientation->Get_Array(), APT->Get_Array(), PointCount);
- current_orient = &compressed_orient[0];
- }
- if (PointFrame) {
- if (compressed_frame.Length() < PointCount) {
- compressed_frame.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_frame[0],
- PointFrame->Get_Array(), APT->Get_Array(), PointCount);
- current_frame = &compressed_frame[0];
- }
- } else {
- current_loc = PointLoc->Get_Array();
- if (PointDiffuse) {
- current_diffuse = PointDiffuse->Get_Array();
- }
- if (PointSize) {
- current_size = PointSize->Get_Array();
- }
- if (PointOrientation) {
- current_orient = PointOrientation->Get_Array();
- }
- if (PointFrame) {
- current_frame = PointFrame->Get_Array();
- }
- }
- // Get the world and view matrices
- Matrix4 view;
- DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
- // Transform the point locations from worldspace to camera space if needed
- // (i.e. if they are not already in camera space):
- // need to interrupt this processing. If we are not billboarding, then we need the actual position
- // of the vertice to lay it down flat.
- if (Get_Flag(TRANSFORM) && Billboard) {
- // Resize transformed location array if needed (2x guardband to prevent
- // frequent reallocations):
- if (transformed_loc.Length() < PointCount) {
- transformed_loc.Resize(PointCount * 2);
- }
- // Not using vector processor class because we are discarding w
- // Not using T&L in DX8 because we don't want DX8 to transform
- // 3 times per particle when we can do it once
- for (int i=0; i<PointCount; i++)
- {
- /// @todo lorenzen sez: use pointer arithmetic here and a fast while loop
- Vector4 result=view*current_loc[i];
- transformed_loc[i].X=result.X;
- transformed_loc[i].Y=result.Y;
- transformed_loc[i].Z=result.Z;
- }
- current_loc = &transformed_loc[0];
- } // if transform
- // Update the arrays with the offsets.
- int vnum, pnum;
- Update_Arrays(current_loc, current_diffuse, current_size, current_orient, current_frame,
- PointCount, PointLoc->Get_Count(), vnum, pnum);
- // the locations are now in view space
- // so set world and view matrices to identity and render
-
- Matrix4 identity(true);
- DX8Wrapper::Set_Transform(D3DTS_WORLD,identity);
- DX8Wrapper::Set_Transform(D3DTS_VIEW,identity);
- DX8Wrapper::Set_Material(PointMaterial);
- DX8Wrapper::Set_Shader(Shader);
- DX8Wrapper::Set_Texture(0,Texture);
- // Enable sorting if the primitives are translucent and alpha testing is not enabled.
- const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled());
- IndexBufferClass *indexbuffer;
- int verticesperprimitive;/// lorenzen fixed
- int current;
- int delta;
- /// @todo lorenzen sez: if tri-based particles are not supported, elim this test
- if (PointMode == QUADS) {
- verticesperprimitive = 2;
- indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingQuads) : static_cast <IndexBufferClass*> (Quads);
- } else {
- verticesperprimitive = 3;
- indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingTris) : static_cast <IndexBufferClass*> (Tris);
- }
- current = 0;
- while (current<vnum)
- {
- delta=MIN(vnum-current,MAX_VB_SIZE);
- DynamicVBAccessClass PointVerts (sort ? BUFFER_TYPE_DYNAMIC_SORTING : BUFFER_TYPE_DYNAMIC_DX8, dynamic_fvf_type, delta);
- // Copy in the data to the VB
- {
- DynamicVBAccessClass::WriteLockClass Lock(&PointVerts);
- int i;
- unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array();
- const FVFInfoClass& fvfinfo=PointVerts.FVF_Info();
- for (i = current; i < current + delta; i++)
- {
- /// @todo lorenzen sez: use pointer arithmetic throughout this block
- /// @todo lorenzen sez: delare thes locals outside this loop
- /// @todo lorenzen sez: use a fast while loop
- // Copy Locations
- *(Vector3*)(vb+fvfinfo.Get_Location_Offset())=VertexLoc[i];
- if (current_diffuse) {
- unsigned color=DX8Wrapper::Convert_Color_Clamp(VertexDiffuse[i]);
- *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=color;
- }
- else
- *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=
- DX8Wrapper::Convert_Color_Clamp(Vector4(DefaultPointColor[0],DefaultPointColor[1],DefaultPointColor[2],DefaultPointAlpha));
- *(Vector2*)(vb+fvfinfo.Get_Tex_Offset(0))=VertexUV[i];
- vb+=fvfinfo.Get_FVF_Size();
- }
- } // copy
- DX8Wrapper::Set_Index_Buffer (indexbuffer, 0);
- DX8Wrapper::Set_Vertex_Buffer (PointVerts);
-
- if ( sort )
- {
- SortingRendererClass::Insert_Triangles (0, delta / verticesperprimitive, 0, delta);
- }
- else
- {
- DX8Wrapper::Draw_Triangles (0, delta / verticesperprimitive, 0, delta);
- }
-
- current+=delta;
- } // loop while (current<vnum)
- // restore the matrices
- DX8Wrapper::Set_Transform(D3DTS_VIEW,view);
- }
- /**************************************************************************
- * PointGroupClass::Update_Arrays -- Update all arrays used in rendering *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/17/1998 NH : Created. *
- *========================================================================*/
- void PointGroupClass::Update_Arrays(
- Vector3 *point_loc,
- Vector4 *point_diffuse,
- float *point_size,
- unsigned char *point_orientation,
- unsigned char *point_frame,
- int active_points,
- int total_points,
- int &vnum,
- int &pnum)
- {
- int verts_per_point = (PointMode == QUADS) ? 4 : 3;
- int polys_per_point = (PointMode == QUADS) ? 2 : 1;
- // total_vnum/pnum reflect the size of the point arrays passed to the
- // point group. These (instead of vnum/pnum, which reflect the number of
- // active points) are used for the resize logic - the idea is that these
- // numbers will vary less often than the active numbers.
- int total_vnum = verts_per_point * total_points;
- vnum = verts_per_point * active_points;
- pnum = polys_per_point * active_points;
-
- // Resize the arrays if they are too small. We only need to check the length of one array
- // since they always all have the same length.
- /// @todo lorenzen sez: precompute params below
- if (VertexLoc.Length() < total_vnum) {
- // Resize arrays (2x guardband to prevent frequent reallocations).
- VertexLoc.Resize(total_vnum * 2, false);
- VertexUV.Resize(total_vnum * 2, false);
- VertexDiffuse.Resize(total_vnum * 2, false);
- }
- int vert, i, j;
- /*
- ** Generate the vertex locations from the point locations (note that both are in camera space).
- ** Vertex locations depend on the point mode and the points' orientation and size
- */
- // This defines the loop we run: the LSB indicates whether there is a size override array, the
- // next bit indicates whether there is an orientation override array, and the higher bits
- // indicate the point mode.
- enum LoopSelectionEnum {
- TRIS_NOSIZE_NOORIENT = ((int)TRIS << 2) + 0,
- TRIS_SIZE_NOORIENT = ((int)TRIS << 2) + 1,
- TRIS_NOSIZE_ORIENT = ((int)TRIS << 2) + 2,
- TRIS_SIZE_ORIENT = ((int)TRIS << 2) + 3,
- QUADS_NOSIZE_NOORIENT = ((int)QUADS << 2) + 0,
- QUADS_SIZE_NOORIENT = ((int)QUADS << 2) + 1,
- QUADS_NOSIZE_ORIENT = ((int)QUADS << 2) + 2,
- QUADS_SIZE_ORIENT = ((int)QUADS << 2) + 3,
- SCREEN_NOSIZE_NOORIENT = ((int)SCREENSPACE << 2) + 0,
- SCREEN_SIZE_NOORIENT = ((int)SCREENSPACE << 2) + 1,
- SCREEN_NOSIZE_ORIENT = ((int)SCREENSPACE << 2) + 2,
- SCREEN_SIZE_ORIENT = ((int)SCREENSPACE << 2) + 3,
- };
- LoopSelectionEnum loop_sel = (LoopSelectionEnum)(((int)PointMode << 2) +
- (point_orientation ? 2 : 0) + (point_size ? 1 : 0));
- vert = 0;
- Vector3 *vertex_loc = &VertexLoc[0];
- /// @todo lorenzen sez: this switch statement may be done more compactly another way... look into it
- switch (loop_sel) {
- case TRIS_NOSIZE_NOORIENT:
- {
- // Setup constant vertex offsets (since size and orientation are invariants)
- Vector3 scaled_offset[3];
- scaled_offset[0] = _TriVertexLocationOrientationTable[DefaultPointOrientation][0] * DefaultPointSize;
- scaled_offset[1] = _TriVertexLocationOrientationTable[DefaultPointOrientation][1] * DefaultPointSize;
- scaled_offset[2] = _TriVertexLocationOrientationTable[DefaultPointOrientation][2] * DefaultPointSize;
- // Add vertex offsets to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] + scaled_offset[0];
- vertex_loc[vert + 1] = point_loc[i] + scaled_offset[1];
- vertex_loc[vert + 2] = point_loc[i] + scaled_offset[2];
- vert += 3;
- }
- }
- break;
- case TRIS_SIZE_NOORIENT:
- {
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] +
- _TriVertexLocationOrientationTable[DefaultPointOrientation][0] * point_size[i];
- vertex_loc[vert + 1] = point_loc[i] +
- _TriVertexLocationOrientationTable[DefaultPointOrientation][1] * point_size[i];
- vertex_loc[vert + 2] = point_loc[i] +
- _TriVertexLocationOrientationTable[DefaultPointOrientation][2] * point_size[i];
- vert += 3;
- }
- }
- break;
- case TRIS_NOSIZE_ORIENT:
- {
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][0] * DefaultPointSize;
- vertex_loc[vert + 1] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][1] * DefaultPointSize;
- vertex_loc[vert + 2] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][2] * DefaultPointSize;
- vert += 3;
- }
- }
- break;
- case TRIS_SIZE_ORIENT:
- {
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][0] * point_size[i];
- vertex_loc[vert + 1] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][1] * point_size[i];
- vertex_loc[vert + 2] = point_loc[i] +
- _TriVertexLocationOrientationTable[point_orientation[i]][2] * point_size[i];
- vert += 3;
- }
- }
- break;
- case QUADS_NOSIZE_NOORIENT:
- {
- // Setup constant vertex offsets (since size and orientation are invariants)
- Vector3 scaled_offset[4];
- scaled_offset[0] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][0] * DefaultPointSize;
- scaled_offset[1] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][1] * DefaultPointSize;
- scaled_offset[2] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][2] * DefaultPointSize;
- scaled_offset[3] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][3] * DefaultPointSize;
- // Add vertex offsets to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] + scaled_offset[0];
- vertex_loc[vert + 1] = point_loc[i] + scaled_offset[1];
- vertex_loc[vert + 2] = point_loc[i] + scaled_offset[2];
- vertex_loc[vert + 3] = point_loc[i] + scaled_offset[3];
- vert += 4;
- }
- }
- break;
- case QUADS_SIZE_NOORIENT:
- {
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] +
- _QuadVertexLocationOrientationTable[DefaultPointOrientation][0] * point_size[i];
- vertex_loc[vert + 1] = point_loc[i] +
- _QuadVertexLocationOrientationTable[DefaultPointOrientation][1] * point_size[i];
- vertex_loc[vert + 2] = point_loc[i] +
- _QuadVertexLocationOrientationTable[DefaultPointOrientation][2] * point_size[i];
- vertex_loc[vert + 3] = point_loc[i] +
- _QuadVertexLocationOrientationTable[DefaultPointOrientation][3] * point_size[i];
- vert += 4;
- }
- }
- break;
- case QUADS_NOSIZE_ORIENT:
- {
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][0] * DefaultPointSize;
- vertex_loc[vert + 1] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][1] * DefaultPointSize;
- vertex_loc[vert + 2] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][2] * DefaultPointSize;
- vertex_loc[vert + 3] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][3] * DefaultPointSize;
- vert += 4;
- }
- }
- break;
- case QUADS_SIZE_ORIENT:
- {
- Matrix4 view;
- Vector4 result;
- if (!Billboard) {
- DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
- }
- // Scale vertex offsets and add them to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- if (!Billboard) {
- // If we're not billboarding, then the coordinate we have is in screen space.
- Matrix4 rotMat;
- D3DXMatrixRotationZ(&(D3DXMATRIX&) rotMat, ((float)point_orientation[i] / 255.0f * 2 * D3DX_PI));
-
- Vector4 orientedVecX = rotMat * GroundMultiplierX;
- Vector4 orientedVecY = rotMat * GroundMultiplierY;
- vertex_loc[vert + 0].X = point_loc[i].X + (orientedVecX.X + orientedVecY.X) * point_size[i];
- vertex_loc[vert + 0].Y = point_loc[i].Y + (orientedVecX.Y + orientedVecY.Y) * point_size[i];
- vertex_loc[vert + 0].Z = point_loc[i].Z;
- vertex_loc[vert + 1].X = point_loc[i].X + (orientedVecX.X - orientedVecY.X) * point_size[i];
- vertex_loc[vert + 1].Y = point_loc[i].Y + (orientedVecX.Y - orientedVecY.Y) * point_size[i];
- vertex_loc[vert + 1].Z = point_loc[i].Z;
- vertex_loc[vert + 2].X = point_loc[i].X + -(orientedVecX.X + orientedVecY.X) * point_size[i];
- vertex_loc[vert + 2].Y = point_loc[i].Y + -(orientedVecX.Y + orientedVecY.Y) * point_size[i];
- vertex_loc[vert + 2].Z = point_loc[i].Z;
- vertex_loc[vert + 3].X = point_loc[i].X + (-orientedVecX.X + orientedVecY.X) * point_size[i];
- vertex_loc[vert + 3].Y = point_loc[i].Y + (-orientedVecX.Y + orientedVecY.Y) * point_size[i];
- vertex_loc[vert + 3].Z = point_loc[i].Z;
- // now apply the view transform so that this data is in the format expected
- // upon the functions return.
- result = view*vertex_loc[vert + 0];
- vertex_loc[vert + 0].X = result.X;
- vertex_loc[vert + 0].Y = result.Y;
- vertex_loc[vert + 0].Z = result.Z;
- result = view*vertex_loc[vert + 1];
- vertex_loc[vert + 1].X = result.X;
- vertex_loc[vert + 1].Y = result.Y;
- vertex_loc[vert + 1].Z = result.Z;
- result = view*vertex_loc[vert + 2];
- vertex_loc[vert + 2].X = result.X;
- vertex_loc[vert + 2].Y = result.Y;
- vertex_loc[vert + 2].Z = result.Z;
- result = view*vertex_loc[vert + 3];
- vertex_loc[vert + 3].X = result.X;
- vertex_loc[vert + 3].Y = result.Y;
- vertex_loc[vert + 3].Z = result.Z;
- } else {
- vertex_loc[vert + 0] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][0] * point_size[i];
- vertex_loc[vert + 1] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][1] * point_size[i];
- vertex_loc[vert + 2] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][2] * point_size[i];
- vertex_loc[vert + 3] = point_loc[i] +
- _QuadVertexLocationOrientationTable[point_orientation[i]][3] * point_size[i];
- }
- vert += 4;
- }
- }
- break;
- // Orientations are ignored for screensize pointgroups
- case SCREEN_NOSIZE_NOORIENT:
- case SCREEN_NOSIZE_ORIENT:
- {
- // Offsets need to be scaled to the current screen resolution
- // First find x and y scale factors (sizes in pixels need to be
- // normalized to 2D cam viewplane of -1,-1 to 1,1)
- int xres, yres, bitdepth;
- bool windowed;
- WW3D::Get_Render_Target_Resolution(xres, yres, bitdepth, windowed);
-
- float x_scale = (VPXMax - VPXMin) / xres;
- float y_scale = (VPYMax - VPYMin) / yres;
-
- Vector3 scaled_locs[2][3];
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 3; j++) {
- scaled_locs[i][j].X = _ScreenspaceVertexLocationSizeTable[i][j].X * x_scale;
- scaled_locs[i][j].Y = _ScreenspaceVertexLocationSizeTable[i][j].Y * y_scale;
- scaled_locs[i][j].Z = _ScreenspaceVertexLocationSizeTable[i][j].Z;
- }
- }
- // Add vertex offsets to point locations to get vertex locations
- int size_idx = (DefaultPointSize <= 1.0f) ? 0 : 1;
- for (i = 0; i < active_points; i++) {
- vertex_loc[vert + 0] = point_loc[i] + scaled_locs[size_idx][0];
- vertex_loc[vert + 1] = point_loc[i] + scaled_locs[size_idx][1];
- vertex_loc[vert + 2] = point_loc[i] + scaled_locs[size_idx][2];
- vert += 3;
- }
- }
- break;
-
- case SCREEN_SIZE_NOORIENT:
- case SCREEN_SIZE_ORIENT:
- {
- // Offsets need to be scaled to the current screen resolution
- // First find x and y scale factors (sizes in pixels need to be
- // normalized to 2D cam viewplane of -1,-1 to 1,1)
- int xres, yres, bitdepth;
- bool windowed;
- WW3D::Get_Render_Target_Resolution(xres, yres, bitdepth, windowed);
-
- float x_scale = (VPXMax - VPXMin) / xres;
- float y_scale = (VPYMax - VPYMin) / yres;
-
- Vector3 scaled_locs[2][3];
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 3; j++) {
- scaled_locs[i][j].X = _ScreenspaceVertexLocationSizeTable[i][j].X * x_scale;
- scaled_locs[i][j].Y = _ScreenspaceVertexLocationSizeTable[i][j].Y * y_scale;
- scaled_locs[i][j].Z = _ScreenspaceVertexLocationSizeTable[i][j].Z;
- }
- }
- // Add vertex offsets to point locations to get vertex locations
- for (i = 0; i < active_points; i++) {
- int size_idx = (point_size[i] <= 1.0f) ? 0 : 1;
- vertex_loc[vert + 0] = point_loc[i] + scaled_locs[size_idx][0];
- vertex_loc[vert + 1] = point_loc[i] + scaled_locs[size_idx][1];
- vertex_loc[vert + 2] = point_loc[i] + scaled_locs[size_idx][2];
- vert += 3;
- }
- }
- break;
- default:
- WWASSERT(0);
- break;
- }
- /*
- ** Fill the UV vertex array
- */
- unsigned int frame_mask = ~(0xFFFFFFFF << (FrameRowColumnCountLog2 + FrameRowColumnCountLog2));// To ensure frames in range
- if (point_frame) {
- /// @todo lorenzen sez: use pointer arithmetic below
- // Fill UV array according to frame override array:
- Vector2 *vertex_uv = &VertexUV[0];
- if (PointMode != QUADS) {
- // Modes with three vertices per point:
- Vector2 *uv_ptr = _TriVertexUVFrameTable[FrameRowColumnCountLog2];
- int vert = 0;
- for (int i = 0; i < active_points; i++) {
- int uv_idx = (point_frame[i] & frame_mask) * 3;
- vertex_uv[vert++] = uv_ptr[uv_idx + 0];
- vertex_uv[vert++] = uv_ptr[uv_idx + 1];
- vertex_uv[vert++] = uv_ptr[uv_idx + 2];
- }
- } else {
- // Modes with four vertices per point:
- Vector2 *uv_ptr = _QuadVertexUVFrameTable[FrameRowColumnCountLog2];
- int vert = 0;
- for (int i = 0; i < active_points; i++) {
- int uv_idx = (point_frame[i] & frame_mask) * 4;
- vertex_uv[vert++] = uv_ptr[uv_idx + 0];
- vertex_uv[vert++] = uv_ptr[uv_idx + 1];
- vertex_uv[vert++] = uv_ptr[uv_idx + 2];
- vertex_uv[vert++] = uv_ptr[uv_idx + 3];
- }
- }
- } else {
- /// @todo lorenzen sez: use pointer arithmetic below
- // Fill UV array according to frame state:
- Vector2 *vertex_uv = &VertexUV[0];
- if (PointMode != QUADS) {
- // Modes with three vertices per point:
- Vector2 *uv_ptr = _TriVertexUVFrameTable[FrameRowColumnCountLog2] + ((DefaultPointFrame & frame_mask) * 3);
- int vert = 0;
- for (int i = 0; i < active_points; i++) {
- vertex_uv[vert++] = uv_ptr[0];
- vertex_uv[vert++] = uv_ptr[1];
- vertex_uv[vert++] = uv_ptr[2];
- }
- } else {
- // Modes with four vertices per point:
- Vector2 *uv_ptr = _QuadVertexUVFrameTable[FrameRowColumnCountLog2] + ((DefaultPointFrame & frame_mask) * 4);
- int vert = 0;
- for (int i = 0; i < active_points; i++) {
- vertex_uv[vert++] = uv_ptr[0];
- vertex_uv[vert++] = uv_ptr[1];
- vertex_uv[vert++] = uv_ptr[2];
- vertex_uv[vert++] = uv_ptr[3];
- }
- }
- }
- /*
- ** If we have a point color array, fill the vertex diffuse array from it.
- */
- /// @todo lorenzen sez: use a quicker, unwrapped loop, and pointer arithmetic
- /// @todo lorenzen sez: this is a leaf function, dang it
- vert = 0;
- if (point_diffuse) {
- Vector4* vertex_color = &VertexDiffuse[0];
- for (i = 0; i < active_points; i++) {
- for (j = 0; j < verts_per_point; j++) {
- vertex_color[vert + j] = point_diffuse[i];
- }
- vert += verts_per_point;
- }
- }
- }
- /**************************************************************************
- * PointGroupClass::_Init -- Create static data. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- void PointGroupClass::_Init(void)
- {
- int i, j;
- /*
- ** Fill vertex location orientation tables
- */
- // Unrotated locations
- Vector3 tri_locs[3] = {
- Vector3(0.0f, -2.0f, 0.0f),
- Vector3(-1.732f, 1.0f, 0.0f),
- Vector3(1.732f, 1.0f, 0.0f)
- };
- Vector3 quad_locs[4] = {
- Vector3(-0.5f, 0.5f, 0.0f),
- Vector3(-0.5f, -0.5f, 0.0f),
- Vector3(0.5f, -0.5f, 0.0f),
- Vector3(0.5f, 0.5f, 0.0f)
- };
- /// @todo lorenzen sez: unwrap loop and use pointer arithmetic (if this gets called a lot)
- float angle = 0.0f; // In radians
- float angle_step = (WWMATH_PI * 2.0f) / 256.0f; // In radians
- for (i = 0; i < 256; i++) {
- float c = WWMath::Fast_Cos(angle);
- float s = WWMath::Fast_Sin(angle);
- for (j = 0; j < 3; j++) {
- _TriVertexLocationOrientationTable[i][j].X = tri_locs[j].X * c - tri_locs[j].Y * s;
- _TriVertexLocationOrientationTable[i][j].Y = tri_locs[j].X * s + tri_locs[j].Y * c;
- _TriVertexLocationOrientationTable[i][j].Z = tri_locs[j].Z;
- }
- for (j = 0; j < 4; j++) {
- _QuadVertexLocationOrientationTable[i][j].X = quad_locs[j].X * c - quad_locs[j].Y * s;
- _QuadVertexLocationOrientationTable[i][j].Y = quad_locs[j].X * s + quad_locs[j].Y * c;
- _QuadVertexLocationOrientationTable[i][j].Z = quad_locs[j].Z;
- }
- angle += angle_step;
- }
- /*
- ** Fill frame UV tables
- */
- // Unscaled / untranslated UVs
- Vector2 tri_uvs[3] = {
- Vector2(0.5f, 0.0f),
- Vector2(0.0f, 0.866f),
- Vector2(1.0f, 0.866f)
- };
- Vector2 quad_uvs[4] = {
- Vector2(0.0f, 0.0f),
- Vector2(0.0f, 1.0f),
- Vector2(1.0f, 1.0f),
- Vector2(1.0f, 0.0f)
- };
- /// @todo lorenzen sez: umwrap and use pointers
- for (i = 0; i < 5; i++) {
- unsigned int rows = 1 << i;
- unsigned int count = rows * rows;
- Vector2 *tri_table = _TriVertexUVFrameTable[i] = W3DNEWARRAY Vector2[count * 3];
- Vector2 *quad_table = _QuadVertexUVFrameTable[i] = W3DNEWARRAY Vector2[count * 4];
- Vector2 corner(0.0f, 0.0f);
- float scale = 1.0f / (float)rows;
- int tri_idx = 0;
- int quad_idx = 0;
- for (unsigned int v = 0; v < rows; v++) {
- for (unsigned int u = 0; u < rows; u++) {
- tri_table[tri_idx++] = corner + (tri_uvs[0] * scale);
- tri_table[tri_idx++] = corner + (tri_uvs[1] * scale);
- tri_table[tri_idx++] = corner + (tri_uvs[2] * scale);
- quad_table[quad_idx++] = corner + (quad_uvs[0] * scale);
- quad_table[quad_idx++] = corner + (quad_uvs[1] * scale);
- quad_table[quad_idx++] = corner + (quad_uvs[2] * scale);
- quad_table[quad_idx++] = corner + (quad_uvs[3] * scale);
- corner.X += scale;
- }
- corner.Y += scale;
- corner.X = 0.0f;
- }
- }
- // Create the IBs
- Tris=NEW_REF(DX8IndexBufferClass,(MAX_TRI_IB_SIZE));
- Quads=NEW_REF(DX8IndexBufferClass,(MAX_QUAD_IB_SIZE));
- SortingTris=NEW_REF(SortingIndexBufferClass,(MAX_TRI_IB_SIZE));
- SortingQuads=NEW_REF(SortingIndexBufferClass,(MAX_QUAD_IB_SIZE));
- // Fill up the IBs
- {
- DX8IndexBufferClass::WriteLockClass locktris(Tris);
- unsigned short *ib=locktris.Get_Index_Array();
- for (i=0; i<MAX_TRI_IB_SIZE; i++) ib[i]=(unsigned short) i;
- }
- {
- unsigned short vert=0;
- DX8IndexBufferClass::WriteLockClass lockquads(Quads);
- unsigned short *ib=lockquads.Get_Index_Array();
- vert=0;
- for (i=0; i<MAX_QUAD_IB_SIZE; i+=6)
- {
- /// @todo lorenzen sez: pointer arithmetic like "++ib=vert+1"
- ib[i]=vert;
- ib[i+1]=vert+1;
- ib[i+2]=vert+2;
-
- ib[i+3]=vert+2;
- ib[i+4]=vert+3;
- ib[i+5]=vert;
- vert+=4;
- }
- }
- {
- SortingIndexBufferClass::WriteLockClass locktris(SortingTris);
- unsigned short *ib=locktris.Get_Index_Array();
- for (i=0; i<MAX_TRI_IB_SIZE; i++) ib[i]=(unsigned short) i;
- }
- {
- unsigned short vert=0;
- SortingIndexBufferClass::WriteLockClass lockquads(SortingQuads);
- unsigned short *ib=lockquads.Get_Index_Array();
- vert=0;
- for (i=0; i<MAX_QUAD_IB_SIZE; i+=6)
- {
- /// @todo lorenzen sez: pointers!
- ib[i]=vert;
- ib[i+1]=vert+1;
- ib[i+2]=vert+2;
-
- ib[i+3]=vert+2;
- ib[i+4]=vert+3;
- ib[i+5]=vert;
- vert+=4;
- }
- }
- PointMaterial=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE);
- }
- /**************************************************************************
- * PointGroupClass::_Shutdown -- Destroy static data. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 06/28/2000 NH : Created. *
- *========================================================================*/
- void PointGroupClass::_Shutdown(void)
- {
- for (int i = 0; i < 5; i++) {
- delete [] _TriVertexUVFrameTable[i];
- delete [] _QuadVertexUVFrameTable[i];
- }
- REF_PTR_RELEASE(PointMaterial);
- REF_PTR_RELEASE(SortingQuads);
- REF_PTR_RELEASE(SortingTris);
- REF_PTR_RELEASE(Quads);
- REF_PTR_RELEASE(Tris);
- transformed_loc.Clear();
- VertexLoc.Clear();
- VertexDiffuse.Clear();
- VertexUV.Clear();
- }
- /**************************************************************************
- * PointGroupClass::RenderVolumeParticles -- draw a point group.sandwich *
- * *
- * This is a specialized renderer. It will draw the particle repeatedly *
- * while attenuating opacity appropriately, and bumping the z-position. *
- * This is actually done by cloning the particle over and over at *
- * successively closer positions to the camera. Very Slow! *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: USE SPARINGLY, IT IS EXPENSIVE!!!!! *
- * *
- * HISTORY: *
- * 12/03/2002 Mark Lorenzen Created. *
- * *
- *========================================================================*/
- #define MAX_VOLUME_PARTICLE_DEPTH ( 16 )
- void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int depth )
- {
- if ( depth <= 1 ) //oops,wrong number
- {
- Render( rinfo );
- return;
- }
- if ( depth > MAX_VOLUME_PARTICLE_DEPTH )
- depth = MAX_VOLUME_PARTICLE_DEPTH; // sanity
- Shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE);
- if (PointCount == 0)
- return;
- WWASSERT(PointLoc && PointLoc->Get_Array());
- // Pointers which point into existing buffers (member or static):
- Vector3 *current_loc = NULL;
- Vector4 *current_diffuse = NULL;
- float *current_size = NULL;
- unsigned char *current_orient = NULL;
- unsigned char *current_frame = NULL;
- // If there is a color or alpha array enable gradient in shader - otherwise disable.
- float value_255 = 0.9961f; //254 / 255
- bool default_white_opaque = ( DefaultPointColor.X > value_255 &&
- DefaultPointColor.Y > value_255 &&
- DefaultPointColor.Z > value_255 &&
- DefaultPointAlpha > value_255);
- // The reason we check for lack of texture here is that SR seems to render black triangles
- // rather than white triangles as would be expected) when there is no texture AND no gradient.
- if (PointDiffuse || !default_white_opaque || !Texture) {
- Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE);
- } else {
- Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE);
- }
- // If Texture is non-NULL enable texturing in shader - otherwise disable.
- if (Texture) {
- Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE);
- } else {
- Shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE);
- }
- // Get the world and view matrices
- Matrix4 view;
- DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
- //// VOLUME_PARTICLE LOOP ///////////////
- for ( int t = 0; t < depth; ++t )
- {
- // If there is an active point table, use it to compress the point
- // locations/colors/alphas/sizes/orientations/frames.
- if (APT) {
- // Resize compressed result arrays if needed (2x guardband to prevent
- // frequent reallocations):
- /// @todo lorenzen sez: precompute pointers to indexed array elements, below
- if (compressed_loc.Length() < PointCount) {
- compressed_loc.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_loc[0],
- PointLoc->Get_Array(), APT->Get_Array(), PointCount);
- current_loc = &compressed_loc[0];
- if (PointDiffuse) {
- if (compressed_diffuse.Length() < PointCount) {
- compressed_diffuse.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_diffuse[0],
- PointDiffuse->Get_Array(), APT->Get_Array(), PointCount);
- current_diffuse = &compressed_diffuse[0];
- }
- if (PointSize) {
- if (compressed_size.Length() < PointCount) {
- compressed_size.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_size[0],
- PointSize->Get_Array(), APT->Get_Array(), PointCount);
- current_size = &compressed_size[0];
- }
- if (PointOrientation) {
- if (compressed_orient.Length() < PointCount) {
- compressed_orient.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_orient[0],
- PointOrientation->Get_Array(), APT->Get_Array(), PointCount);
- current_orient = &compressed_orient[0];
- }
- if (PointFrame) {
- if (compressed_frame.Length() < PointCount) {
- compressed_frame.Resize(PointCount * 2);
- }
- VectorProcessorClass::CopyIndexed(&compressed_frame[0],
- PointFrame->Get_Array(), APT->Get_Array(), PointCount);
- current_frame = &compressed_frame[0];
- }
- } else {
- current_loc = PointLoc->Get_Array();
- if (PointDiffuse) {
- current_diffuse = PointDiffuse->Get_Array();
- }
- if (PointSize) {
- current_size = PointSize->Get_Array();
- }
- if (PointOrientation) {
- current_orient = PointOrientation->Get_Array();
- }
- if (PointFrame) {
- current_frame = PointFrame->Get_Array();
- }
- }
- // Transform the point locations from worldspace to camera space if needed
- // (i.e. if they are not already in camera space):
- // need to interrupt this processing. If we are not billboarding, then we need the actual position
- // of the vertice to lay it down flat.
- if (Get_Flag(TRANSFORM) && Billboard) {
- // Resize transformed location array if needed (2x guardband to prevent
- // frequent reallocations):
- if (transformed_loc.Length() < PointCount) {
- transformed_loc.Resize(PointCount * 2);
- }
- // Not using vector processor class because we are discarding w
- // Not using T&L in DX8 because we don't want DX8 to transform
- // 3 times per particle when we can do it once
- float recipDepth = 0.1f / (float)depth;
- float shiftInc = ( t * *current_size * recipDepth );
- Vector3 volumeLayerShift;
- Vector3 cameraPosition = rinfo.Camera.Get_Position();
- for (int i=0; i<PointCount; i++)
- {
- /// @todo lorenzen sez: use pointer arithmetic here and a fast while loop
- Vector3 cameraToPointDelta;
- Vector3::Subtract( cameraPosition, current_loc[i], &cameraToPointDelta );
- cameraToPointDelta.Normalize();
- cameraToPointDelta.X *= shiftInc;
- cameraToPointDelta.Y *= shiftInc;
- cameraToPointDelta.Z *= shiftInc;
- Vector3 temp;
- temp.X = current_loc[i].X + cameraToPointDelta.X;
- temp.Y = current_loc[i].Y + cameraToPointDelta.Y;
- temp.Z = current_loc[i].Z + cameraToPointDelta.Z;
- Vector4 result= view * temp;
- transformed_loc[i].X=result.X;
- transformed_loc[i].Y=result.Y;
- transformed_loc[i].Z=result.Z;
- }
- current_loc = &transformed_loc[0];
- } // if transform
- // Update the arrays with the offsets.
- int vnum, pnum;
- //float attenuator = 1.0f - (1.0f/(float)depth);
- //current_diffuse->X *= attenuator;
- //current_diffuse->Y *= attenuator;
- //current_diffuse->Z *= attenuator;
- //current_diffuse->W *= attenuator;
- Update_Arrays(current_loc, current_diffuse, current_size, current_orient, current_frame,
- PointCount, PointLoc->Get_Count(), vnum, pnum);
- // the locations are now in view space
- // so set world and view matrices to identity and render
-
- Matrix4 identity(true);
- DX8Wrapper::Set_Transform(D3DTS_WORLD,identity);
- DX8Wrapper::Set_Transform(D3DTS_VIEW,identity);
- DX8Wrapper::Set_Material(PointMaterial);
- DX8Wrapper::Set_Shader(Shader);
- DX8Wrapper::Set_Texture(0,Texture);
- // Enable sorting if the primitives are translucent and alpha testing is not enabled.
- const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled());
- IndexBufferClass *indexbuffer;
- int verticesperprimitive;/// lorenzen fixed
- int current;
- int delta;
- /// @todo lorenzen sez: if tri-based particles are not supported, elim this test
- if (PointMode == QUADS) {
- verticesperprimitive = 2;
- indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingQuads) : static_cast <IndexBufferClass*> (Quads);
- } else {
- verticesperprimitive = 3;
- indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingTris) : static_cast <IndexBufferClass*> (Tris);
- }
- float nudge = 0;
- current = 0;
- while (current<vnum)
- {
- delta=MIN(vnum-current,MAX_VB_SIZE);
- DynamicVBAccessClass PointVerts (sort ? BUFFER_TYPE_DYNAMIC_SORTING : BUFFER_TYPE_DYNAMIC_DX8, dynamic_fvf_type, delta);
- // Copy in the data to the VB
- {
- DynamicVBAccessClass::WriteLockClass Lock(&PointVerts);
- int i;
- unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array();
- const FVFInfoClass& fvfinfo = PointVerts.FVF_Info();
- for (i = current; i < current + delta; i++)
- {
- /// @todo lorenzen sez: use pointer arithmetic throughout this block
- /// @todo lorenzen sez: delare thes locals outside this loop
- /// @todo lorenzen sez: use a fast while loop
- // Copy Locations
- *(Vector3*)(vb+fvfinfo.Get_Location_Offset()) = VertexLoc[i];
- if (current_diffuse) {
- unsigned color=DX8Wrapper::Convert_Color_Clamp(VertexDiffuse[i]);
- *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=color;
- }
- else
- *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=
- DX8Wrapper::Convert_Color_Clamp(Vector4(DefaultPointColor[0],DefaultPointColor[1],DefaultPointColor[2],DefaultPointAlpha));
- *(Vector2*)(vb+fvfinfo.Get_Tex_Offset(0))=VertexUV[i];
- vb+=fvfinfo.Get_FVF_Size();
- }
- } // copy
- DX8Wrapper::Set_Index_Buffer (indexbuffer, 0);
- DX8Wrapper::Set_Vertex_Buffer (PointVerts);
-
- /// @todo lorenzen sez: precompute these params, above
- if ( sort )
- SortingRendererClass::Insert_Triangles (0, delta / verticesperprimitive, 0, delta);
- else
- DX8Wrapper::Draw_Triangles (0, delta / verticesperprimitive, 0, delta);
-
- current+=delta;
- } // loop while (current<vnum)
- }// next volume layer
- // restore the matrices
- DX8Wrapper::Set_Transform(D3DTS_VIEW,view);
- }
|