mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
terrain-zodiacs -- Changes made for rendering zodiacs on regular terrain.
This commit is contained in:
parent
3219735087
commit
00e3eb6ba8
6 changed files with 194 additions and 0 deletions
|
|
@ -20,6 +20,11 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "terrain/terrCell.h"
|
#include "terrain/terrCell.h"
|
||||||
|
|
||||||
|
|
@ -56,6 +61,7 @@ TerrCell::TerrCell()
|
||||||
mIsInteriorOnly( false )
|
mIsInteriorOnly( false )
|
||||||
{
|
{
|
||||||
dMemset( mChildren, 0, sizeof( mChildren ) );
|
dMemset( mChildren, 0, sizeof( mChildren ) );
|
||||||
|
zode_vertexBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrCell::~TerrCell()
|
TerrCell::~TerrCell()
|
||||||
|
|
@ -64,6 +70,7 @@ TerrCell::~TerrCell()
|
||||||
|
|
||||||
for ( U32 i=0; i < 4; i++ )
|
for ( U32 i=0; i < 4; i++ )
|
||||||
SAFE_DELETE( mChildren[i] );
|
SAFE_DELETE( mChildren[i] );
|
||||||
|
deleteZodiacVertexBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrCell::createPrimBuffer( GFXPrimitiveBufferHandle *primBuffer )
|
void TerrCell::createPrimBuffer( GFXPrimitiveBufferHandle *primBuffer )
|
||||||
|
|
@ -582,6 +589,7 @@ void TerrCell::_updateVertexBuffer()
|
||||||
|
|
||||||
AssertFatal( vbcounter == smVBSize, "bad" );
|
AssertFatal( vbcounter == smVBSize, "bad" );
|
||||||
mVertexBuffer.unlock();
|
mVertexBuffer.unlock();
|
||||||
|
deleteZodiacVertexBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrCell::_updatePrimitiveBuffer()
|
void TerrCell::_updatePrimitiveBuffer()
|
||||||
|
|
@ -1089,3 +1097,114 @@ void TerrCell::deleteMaterials()
|
||||||
if ( mChildren[i] )
|
if ( mChildren[i] )
|
||||||
mChildren[i]->deleteMaterials();
|
mChildren[i]->deleteMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Point3F* TerrCell::getZodiacVertexBuffer()
|
||||||
|
{
|
||||||
|
if (!zode_vertexBuffer)
|
||||||
|
createZodiacVertexBuffer();
|
||||||
|
return zode_vertexBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerrCell::createZodiacPrimBuffer(U16** zode_primBuffer)
|
||||||
|
{
|
||||||
|
if (*zode_primBuffer != 0)
|
||||||
|
delete [] *zode_primBuffer;
|
||||||
|
|
||||||
|
*zode_primBuffer = new U16[TerrCell::smMinCellSize*TerrCell::smMinCellSize*6];
|
||||||
|
|
||||||
|
// Lock and fill it up!
|
||||||
|
U16* idxBuff = *zode_primBuffer;
|
||||||
|
U32 counter = 0;
|
||||||
|
U32 maxIndex = 0;
|
||||||
|
|
||||||
|
for ( U32 y = 0; y < smMinCellSize; y++ )
|
||||||
|
{
|
||||||
|
const U32 yTess = y % 2;
|
||||||
|
|
||||||
|
for ( U32 x = 0; x < smMinCellSize; x++ )
|
||||||
|
{
|
||||||
|
U32 index = ( y * smVBStride ) + x;
|
||||||
|
|
||||||
|
const U32 xTess = x % 2;
|
||||||
|
|
||||||
|
if ( ( xTess == 0 && yTess == 0 ) ||
|
||||||
|
( xTess != 0 && yTess != 0 ) )
|
||||||
|
{
|
||||||
|
idxBuff[0] = index + 0;
|
||||||
|
idxBuff[1] = index + smVBStride;
|
||||||
|
idxBuff[2] = index + smVBStride + 1;
|
||||||
|
|
||||||
|
idxBuff[3] = index + 0;
|
||||||
|
idxBuff[4] = index + smVBStride + 1;
|
||||||
|
idxBuff[5] = index + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idxBuff[0] = index + 1;
|
||||||
|
idxBuff[1] = index;
|
||||||
|
idxBuff[2] = index + smVBStride;
|
||||||
|
|
||||||
|
idxBuff[3] = index + 1;
|
||||||
|
idxBuff[4] = index + smVBStride;
|
||||||
|
idxBuff[5] = index + smVBStride + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
idxBuff += 6;
|
||||||
|
maxIndex = index + 1 + smVBStride;
|
||||||
|
counter += 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerrCell::createZodiacVertexBuffer()
|
||||||
|
{
|
||||||
|
const F32 squareSize = mTerrain->getSquareSize();
|
||||||
|
const U32 blockSize = mTerrain->getBlockSize();
|
||||||
|
const U32 stepSize = mSize / smMinCellSize;
|
||||||
|
|
||||||
|
if (zode_vertexBuffer)
|
||||||
|
delete [] zode_vertexBuffer;
|
||||||
|
|
||||||
|
zode_vertexBuffer = new Point3F[smVBStride*smVBStride];
|
||||||
|
|
||||||
|
Point3F* vert = zode_vertexBuffer;
|
||||||
|
|
||||||
|
Point2I gridPt;
|
||||||
|
Point2F point;
|
||||||
|
F32 height;
|
||||||
|
|
||||||
|
const TerrainFile *file = mTerrain->getFile();
|
||||||
|
|
||||||
|
for ( U32 y = 0; y < smVBStride; y++ )
|
||||||
|
{
|
||||||
|
for ( U32 x = 0; x < smVBStride; x++ )
|
||||||
|
{
|
||||||
|
// We clamp here to keep the geometry from reading across
|
||||||
|
// one side of the height map to the other causing walls
|
||||||
|
// around the edges of the terrain.
|
||||||
|
gridPt.x = mClamp( mPoint.x + x * stepSize, 0, blockSize - 1 );
|
||||||
|
gridPt.y = mClamp( mPoint.y + y * stepSize, 0, blockSize - 1 );
|
||||||
|
|
||||||
|
// Setup this point.
|
||||||
|
point.x = (F32)gridPt.x * squareSize;
|
||||||
|
point.y = (F32)gridPt.y * squareSize;
|
||||||
|
height = fixedToFloat( file->getHeight( gridPt.x, gridPt.y ) );
|
||||||
|
|
||||||
|
vert->x = point.x;
|
||||||
|
vert->y = point.y;
|
||||||
|
vert->z = height;
|
||||||
|
|
||||||
|
++vert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerrCell::deleteZodiacVertexBuffer()
|
||||||
|
{
|
||||||
|
if (zode_vertexBuffer)
|
||||||
|
{
|
||||||
|
delete [] zode_vertexBuffer;
|
||||||
|
zode_vertexBuffer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#ifndef _TERRCELL_H_
|
#ifndef _TERRCELL_H_
|
||||||
#define _TERRCELL_H_
|
#define _TERRCELL_H_
|
||||||
|
|
||||||
|
|
@ -226,6 +231,13 @@ public:
|
||||||
void renderBounds() const;
|
void renderBounds() const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
protected:
|
||||||
|
Point3F* zode_vertexBuffer;
|
||||||
|
void createZodiacVertexBuffer();
|
||||||
|
public:
|
||||||
|
const Point3F* getZodiacVertexBuffer();
|
||||||
|
void deleteZodiacVertexBuffer();
|
||||||
|
static void createZodiacPrimBuffer(U16** primBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline F32 TerrCell::getDistanceTo( const Point3F &pt ) const
|
inline F32 TerrCell::getDistanceTo( const Point3F &pt ) const
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "terrain/terrData.h"
|
#include "terrain/terrData.h"
|
||||||
|
|
||||||
|
|
@ -200,6 +205,8 @@ TerrainBlock::TerrainBlock()
|
||||||
{
|
{
|
||||||
mTypeMask = TerrainObjectType | StaticObjectType | StaticShapeObjectType;
|
mTypeMask = TerrainObjectType | StaticObjectType | StaticShapeObjectType;
|
||||||
mNetFlags.set(Ghostable | ScopeAlways);
|
mNetFlags.set(Ghostable | ScopeAlways);
|
||||||
|
mIgnoreZodiacs = false;
|
||||||
|
zode_primBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -218,6 +225,7 @@ TerrainBlock::~TerrainBlock()
|
||||||
if (editor)
|
if (editor)
|
||||||
editor->detachTerrain(this);
|
editor->detachTerrain(this);
|
||||||
#endif
|
#endif
|
||||||
|
deleteZodiacPrimitiveBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBlock::_onTextureEvent( GFXTexCallbackCode code )
|
void TerrainBlock::_onTextureEvent( GFXTexCallbackCode code )
|
||||||
|
|
@ -1006,6 +1014,7 @@ void TerrainBlock::_rebuildQuadtree()
|
||||||
|
|
||||||
// Build the shared PrimitiveBuffer.
|
// Build the shared PrimitiveBuffer.
|
||||||
mCell->createPrimBuffer( &mPrimBuffer );
|
mCell->createPrimBuffer( &mPrimBuffer );
|
||||||
|
deleteZodiacPrimitiveBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBlock::_updatePhysics()
|
void TerrainBlock::_updatePhysics()
|
||||||
|
|
@ -1148,6 +1157,9 @@ void TerrainBlock::initPersistFields()
|
||||||
|
|
||||||
endGroup( "Misc" );
|
endGroup( "Misc" );
|
||||||
|
|
||||||
|
addGroup("AFX");
|
||||||
|
addField("ignoreZodiacs", TypeBool, Offset(mIgnoreZodiacs, TerrainBlock));
|
||||||
|
endGroup("AFX");
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
|
|
||||||
removeField( "scale" );
|
removeField( "scale" );
|
||||||
|
|
@ -1198,6 +1210,7 @@ U32 TerrainBlock::packUpdate(NetConnection* con, U32 mask, BitStream *stream)
|
||||||
stream->write( mScreenError );
|
stream->write( mScreenError );
|
||||||
|
|
||||||
stream->writeInt(mBaseTexFormat, 32);
|
stream->writeInt(mBaseTexFormat, 32);
|
||||||
|
stream->writeFlag(mIgnoreZodiacs);
|
||||||
|
|
||||||
return retMask;
|
return retMask;
|
||||||
}
|
}
|
||||||
|
|
@ -1267,6 +1280,7 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
|
||||||
stream->read( &mScreenError );
|
stream->read( &mScreenError );
|
||||||
|
|
||||||
mBaseTexFormat = (BaseTexFormat)stream->readInt(32);
|
mBaseTexFormat = (BaseTexFormat)stream->readInt(32);
|
||||||
|
mIgnoreZodiacs = stream->readFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBlock::getMinMaxHeight( F32 *minHeight, F32 *maxHeight ) const
|
void TerrainBlock::getMinMaxHeight( F32 *minHeight, F32 *maxHeight ) const
|
||||||
|
|
@ -1405,3 +1419,19 @@ DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, c
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
const U16* TerrainBlock::getZodiacPrimitiveBuffer()
|
||||||
|
{
|
||||||
|
if (!zode_primBuffer && !mIgnoreZodiacs)
|
||||||
|
TerrCell::createZodiacPrimBuffer(&zode_primBuffer);
|
||||||
|
return zode_primBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerrainBlock::deleteZodiacPrimitiveBuffer()
|
||||||
|
{
|
||||||
|
if (zode_primBuffer != 0)
|
||||||
|
{
|
||||||
|
delete [] zode_primBuffer;
|
||||||
|
zode_primBuffer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#ifndef _TERRDATA_H_
|
#ifndef _TERRDATA_H_
|
||||||
#define _TERRDATA_H_
|
#define _TERRDATA_H_
|
||||||
|
|
||||||
|
|
@ -457,6 +462,13 @@ public:
|
||||||
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
|
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
|
||||||
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
||||||
void inspectPostApply();
|
void inspectPostApply();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool mIgnoreZodiacs;
|
||||||
|
U16* zode_primBuffer;
|
||||||
|
void deleteZodiacPrimitiveBuffer();
|
||||||
|
public:
|
||||||
|
const U16* getZodiacPrimitiveBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _TERRDATA_H_
|
#endif // _TERRDATA_H_
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "terrain/terrRender.h"
|
#include "terrain/terrRender.h"
|
||||||
|
|
||||||
|
|
@ -45,6 +50,8 @@
|
||||||
|
|
||||||
#include "gfx/gfxDrawUtil.h"
|
#include "gfx/gfxDrawUtil.h"
|
||||||
|
|
||||||
|
#include "afx/arcaneFX.h"
|
||||||
|
#include "afx/ce/afxZodiacMgr.h"
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
#include "gfx/bitmap/ddsFile.h"
|
#include "gfx/bitmap/ddsFile.h"
|
||||||
|
|
@ -421,6 +428,7 @@ void TerrainBlock::_renderBlock( SceneRenderState *state )
|
||||||
if ( isColorDrawPass )
|
if ( isColorDrawPass )
|
||||||
lm = LIGHTMGR;
|
lm = LIGHTMGR;
|
||||||
|
|
||||||
|
bool has_zodiacs = afxZodiacMgr::doesBlockContainZodiacs(state, this);
|
||||||
for ( U32 i=0; i < renderCells.size(); i++ )
|
for ( U32 i=0; i < renderCells.size(); i++ )
|
||||||
{
|
{
|
||||||
TerrCell *cell = renderCells[i];
|
TerrCell *cell = renderCells[i];
|
||||||
|
|
@ -483,6 +491,8 @@ void TerrainBlock::_renderBlock( SceneRenderState *state )
|
||||||
|
|
||||||
inst->defaultKey = (U32)cell->getMaterials();
|
inst->defaultKey = (U32)cell->getMaterials();
|
||||||
|
|
||||||
|
if (has_zodiacs)
|
||||||
|
afxZodiacMgr::renderTerrainZodiacs(state, this, cell);
|
||||||
// Submit it for rendering.
|
// Submit it for rendering.
|
||||||
renderPass->addInst( inst );
|
renderPass->addInst( inst );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,16 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
|
||||||
|
// Copyright (C) 2015 Faust Logic, Inc.
|
||||||
|
//
|
||||||
|
// The terrain implementation of zodiacs is largely contained in
|
||||||
|
// afxZodiac.[h,cpp], however, some changes are required to the terrain
|
||||||
|
// code. Structures EmitChunk and SquareStackNode now contain an
|
||||||
|
// afxZodiacBitmask for keeping track of zodiac intersections.
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
#ifndef _TERRRENDER_H_
|
#ifndef _TERRRENDER_H_
|
||||||
#define _TERRRENDER_H_
|
#define _TERRRENDER_H_
|
||||||
|
|
||||||
|
|
@ -27,6 +37,7 @@
|
||||||
#include "terrain/terrData.h"
|
#include "terrain/terrData.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "afx/ce/afxZodiacDefs.h"
|
||||||
enum TerrConstants : U32
|
enum TerrConstants : U32
|
||||||
{
|
{
|
||||||
MaxClipPlanes = 8, ///< left, right, top, bottom - don't need far tho...
|
MaxClipPlanes = 8, ///< left, right, top, bottom - don't need far tho...
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue