mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Fixed a null deferencing in cUIControl.
Removed cIsoMap, since it's not part of the library. Fixed some minor bugs.
This commit is contained in:
Binary file not shown.
@@ -2,7 +2,6 @@
|
||||
#define EEPP_GAMING_HPP
|
||||
|
||||
#include <eepp/gaming/clight.hpp>
|
||||
#include <eepp/gaming/cisomap.hpp>
|
||||
#include <eepp/gaming/cgameobject.hpp>
|
||||
#include <eepp/gaming/cgameobjectsubtexture.hpp>
|
||||
#include <eepp/gaming/cgameobjectsubtextureex.hpp>
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
#ifndef EE_GAMINGCISOMAP_H
|
||||
#define EE_GAMINGCISOMAP_H
|
||||
|
||||
#include <eepp/gaming/base.hpp>
|
||||
|
||||
#include <eepp/window/cinput.hpp>
|
||||
#include <eepp/window/cwindow.hpp>
|
||||
#include <eepp/window/cengine.hpp>
|
||||
using namespace EE::Window;
|
||||
|
||||
#include <eepp/graphics/ctexture.hpp>
|
||||
#include <eepp/graphics/ctexturefactory.hpp>
|
||||
#include <eepp/graphics/csubtexture.hpp>
|
||||
#include <eepp/graphics/cfont.hpp>
|
||||
#include <eepp/graphics/cprimitives.hpp>
|
||||
using namespace EE::Graphics;
|
||||
|
||||
#include <eepp/gaming/clight.hpp>
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
class EE_API cIsoTile {
|
||||
public:
|
||||
eeColor Color[4]; //! Color of every vertex stored
|
||||
eeQuad2f Q; //! Vertex Buffer Data
|
||||
std::vector<cSubTexture*> Layers;
|
||||
std::string TilePosStr;
|
||||
eeAABB Box;
|
||||
};
|
||||
|
||||
class EE_API cIsoMap {
|
||||
public:
|
||||
cIsoMap( Window::cWindow * window = NULL );
|
||||
|
||||
~cIsoMap();
|
||||
|
||||
void Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers = 1, const eeUint TilesWidth = 64, const eeUint TilesHeight = 32, const eeColor& AmbientCol = eeColor(255,255,255) );
|
||||
|
||||
cIsoTile& Tile( const eeUint& MapTileX, const eeUint& MapTileY );
|
||||
|
||||
void Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cSubTexture * LayerData );
|
||||
|
||||
void Draw();
|
||||
|
||||
void Move( const eeFloat& offsetx, const eeFloat& offsety );
|
||||
|
||||
void SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level = 1, const bool& JointUp = true );
|
||||
|
||||
void SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level = 1, const bool& JointUp = true );
|
||||
|
||||
eeVector2f TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum);
|
||||
|
||||
eeQuad2f TileQBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY );
|
||||
|
||||
Uint32 Width() const;
|
||||
|
||||
Uint32 Height() const;
|
||||
|
||||
void AmbientColor( const eeColor& AC );
|
||||
|
||||
eeColor AmbientColor() const;
|
||||
|
||||
eeVector2i GetMouseTilePos() const;
|
||||
|
||||
eeVector2f GetMouseMapCoords() const;
|
||||
|
||||
eeAABB GetScreenMapCoords() const;
|
||||
|
||||
void Reset();
|
||||
|
||||
void Font( cFont * font );
|
||||
|
||||
cFont * Font() const;
|
||||
|
||||
cLight& BaseLight();
|
||||
|
||||
void DrawFont( bool draw );
|
||||
|
||||
bool DrawFont() const;
|
||||
protected:
|
||||
std::vector<cIsoTile> Map;
|
||||
|
||||
Window::cWindow * mWindow;
|
||||
eeColor mMapAmbientColor;
|
||||
eeUint mMapWidth;
|
||||
eeUint mMapHeight;
|
||||
eeUint mMapLayers;
|
||||
eeUint mTileWidth;
|
||||
eeUint mTileHeight;
|
||||
eeUint mTilesRange;
|
||||
eeFloat mTileHWidth;
|
||||
eeFloat mTileHHeight;
|
||||
eeFloat mTileAltitude;
|
||||
eeVector2i mMouseTilePos;
|
||||
eeVector2f mMouseMapPos;
|
||||
eeAABB mScreenAABB;
|
||||
eeInt Tx;
|
||||
eeInt Ty;
|
||||
eeInt Tx2;
|
||||
eeInt Ty2;
|
||||
eeFloat mOffsetX;
|
||||
eeFloat mOffsetY;
|
||||
|
||||
// Fast access to classes
|
||||
cPrimitives mPR;
|
||||
|
||||
cFont * mFont;
|
||||
|
||||
cLight mLight;
|
||||
|
||||
bool mDrawFont;
|
||||
|
||||
void CreateBaseVertexBuffer();
|
||||
|
||||
void VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,8 @@ using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
namespace MapEditor { class cUIMapNew; }
|
||||
|
||||
#define EE_MAP_LAYER_UNKNOWN eeINDEX_NOT_FOUND
|
||||
#define EE_MAP_MAGIC ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'M' << 16 ) | ( 'P' << 24 ) )
|
||||
|
||||
@@ -223,6 +225,8 @@ class EE_API cMap {
|
||||
|
||||
const eeColorA& GridLinesColor() const;
|
||||
protected:
|
||||
friend class EE::Gaming::MapEditor::cUIMapNew;
|
||||
|
||||
class cForcedHeaders
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.0.0, 2014-06-01T17:00:18. -->
|
||||
<!-- Written by QtCreator 3.0.0, 2014-06-01T21:32:45. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -56,7 +56,7 @@
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{388e5431-b31b-42b3-b9ad-9002d279d75d}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">11</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">../../make/linux</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
|
||||
@@ -81,7 +81,6 @@
|
||||
../../include/eepp/gaming/clightmanager.hpp
|
||||
../../include/eepp/gaming/clight.hpp
|
||||
../../include/eepp/gaming/clayer.hpp
|
||||
../../include/eepp/gaming/cisomap.hpp
|
||||
../../include/eepp/gaming/cgameobjectvirtual.hpp
|
||||
../../include/eepp/gaming/cgameobjectsprite.hpp
|
||||
../../include/eepp/gaming/cgameobjectsubtextureex.hpp
|
||||
@@ -101,7 +100,6 @@
|
||||
../../src/eepp/gaming/clightmanager.cpp
|
||||
../../src/eepp/gaming/clight.cpp
|
||||
../../src/eepp/gaming/clayer.cpp
|
||||
../../src/eepp/gaming/cisomap.cpp
|
||||
../../src/eepp/gaming/cgameobjectvirtual.cpp
|
||||
../../src/eepp/gaming/cgameobjectsprite.cpp
|
||||
../../src/eepp/gaming/cgameobjectsubtextureex.cpp
|
||||
|
||||
@@ -1,361 +0,0 @@
|
||||
#include <eepp/gaming/cisomap.hpp>
|
||||
#include <eepp/graphics/renderer/cgl.hpp>
|
||||
#include <eepp/graphics/cglobalbatchrenderer.hpp>
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
cIsoMap::cIsoMap( Window::cWindow * window ) :
|
||||
mWindow( window ),
|
||||
mOffsetX(0),
|
||||
mOffsetY(0),
|
||||
mFont(NULL)
|
||||
{
|
||||
if ( NULL == mWindow ) {
|
||||
mWindow = cEngine::instance()->GetCurrentWindow();
|
||||
}
|
||||
}
|
||||
|
||||
cIsoMap::~cIsoMap() {
|
||||
}
|
||||
|
||||
void cIsoMap::Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers, const eeUint TilesWidth, const eeUint TilesHeight, const eeColor& AmbientCol ) {
|
||||
if ( NULL == mWindow ) {
|
||||
mWindow = cEngine::instance()->GetCurrentWindow();
|
||||
}
|
||||
|
||||
mMapWidth = MapTilesX;
|
||||
mMapHeight = MapTilesY;
|
||||
mMapLayers = NumLayers;
|
||||
|
||||
mTileWidth = TilesWidth;
|
||||
mTileHeight = TilesHeight;
|
||||
|
||||
mTileHWidth = mTileWidth * 0.5f;
|
||||
mTileHHeight = mTileHeight * 0.5f;
|
||||
mTileAltitude = mTileHeight * 0.25f;
|
||||
|
||||
mMapAmbientColor = AmbientCol;
|
||||
|
||||
Map.resize( mMapWidth * mMapHeight );
|
||||
|
||||
CreateBaseVertexBuffer();
|
||||
|
||||
mTilesRange = 10;
|
||||
|
||||
mLight.Create( 250.0f, 0, 0, eeColor(255,255,255), LIGHT_ISOMETRIC );
|
||||
|
||||
mDrawFont = false;
|
||||
}
|
||||
|
||||
void cIsoMap::CreateBaseVertexBuffer() {
|
||||
eeUint i;
|
||||
|
||||
for ( eeUint x = 0; x < mMapWidth; x++ ) {
|
||||
for ( eeUint y = 0; y < mMapHeight; y++ ) {
|
||||
cIsoTile * T = &Tile(x, y);
|
||||
|
||||
if ( T->Layers.size() < 1 )
|
||||
T->Layers.resize( mMapLayers );
|
||||
|
||||
T->Q = TileQBaseCoords( x, y );
|
||||
T->Box = T->Q.ToAABB();
|
||||
T->TilePosStr = String::ToStr( x) + " - " + String::ToStr( y );
|
||||
|
||||
for ( i = 0; i < 4; i++ )
|
||||
T->Color[i] = mMapAmbientColor;
|
||||
|
||||
for ( i = 1; i < mMapLayers; i++ )
|
||||
Layer( x, y, i, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cIsoTile& cIsoMap::Tile( const eeUint& MapTileX, const eeUint& MapTileY ) {
|
||||
eeASSERT ( MapTileX < mMapWidth && MapTileY < mMapHeight );
|
||||
return Map[ MapTileX + MapTileY * mMapWidth ];
|
||||
}
|
||||
|
||||
void cIsoMap::Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cSubTexture * LayerData ) {
|
||||
if( LayerNum < mMapLayers )
|
||||
Tile(MapTileX, MapTileY).Layers[LayerNum] = LayerData;
|
||||
}
|
||||
|
||||
void cIsoMap::Draw() {
|
||||
eeAABB TileAABB;
|
||||
cIsoTile * T;
|
||||
|
||||
mScreenAABB = eeAABB( -mOffsetX, -mOffsetY, mWindow->GetWidth() - mOffsetX, mWindow->GetHeight() - mOffsetY ); // Screen AABB to MAP AABB
|
||||
|
||||
mMouseMapPos = eeVector2f( mWindow->GetInput()->MouseX() - mOffsetX, mWindow->GetInput()->MouseY() - mOffsetY );
|
||||
|
||||
mLight.UpdatePos( mMouseMapPos );
|
||||
|
||||
if (mOffsetX > 0)
|
||||
mOffsetX = 0;
|
||||
|
||||
if (mOffsetY > 0)
|
||||
mOffsetY = 0;
|
||||
|
||||
if ( -mOffsetX > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mWindow->GetWidth() )
|
||||
mOffsetX = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mWindow->GetWidth());
|
||||
|
||||
if ( -mOffsetY > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mWindow->GetHeight() )
|
||||
mOffsetY = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mWindow->GetHeight());
|
||||
|
||||
Tx = (Int32)( -mOffsetX / (eeFloat)mTileHeight ) - mTilesRange;
|
||||
Ty = (Int32)( -mOffsetY / (eeFloat)mTileHeight ) - mTilesRange;
|
||||
|
||||
if (Tx < 0) Tx = 0;
|
||||
if (Tx >= (eeInt)mMapWidth) Tx = mMapWidth-1;
|
||||
|
||||
if (Ty < 0) Ty = 0;
|
||||
if (Ty >= (eeInt)mMapHeight) Ty = mMapHeight-1;
|
||||
|
||||
Tx2 = ( Tx + mTilesRange + (eeInt)( mWindow->GetWidth() / (eeFloat)mTileHeight ) + mTilesRange );
|
||||
Ty2 = ( Ty + mTilesRange + (eeInt)( mWindow->GetHeight() / (eeFloat)mTileHeight) + mTilesRange );
|
||||
|
||||
eeColorA SC(50,50,50,100);
|
||||
|
||||
cGlobalBatchRenderer::instance()->Draw();
|
||||
|
||||
GLi->LoadIdentity();
|
||||
GLi->PushMatrix();
|
||||
GLi->Translatef( mOffsetX, mOffsetY, 0.0f );
|
||||
|
||||
for ( eeUint L = 0; L < mMapLayers; L++ ) {
|
||||
for ( eeInt y = Ty; y < Ty2; y++ ) {
|
||||
for ( eeInt x = Tx; x < Tx2; x++ ) {
|
||||
T = &Tile( (eeUint)x, (eeUint)y );
|
||||
|
||||
if ( L == 0 ) {
|
||||
TileAABB = T->Box;
|
||||
|
||||
if ( mScreenAABB.Intersect( TileAABB ) ) {
|
||||
T->Color[0] = T->Color[1] = T->Color[2] = T->Color[3] = mMapAmbientColor;
|
||||
|
||||
if ( mLight.GetAABB().Intersect( TileAABB ) ) {
|
||||
T->Color[0] = mLight.ProcessVertex( T->Q.V[0].x, T->Q.V[0].y, T->Color[0], T->Color[0] ); // Left - Top Vertex
|
||||
T->Color[1] = mLight.ProcessVertex( T->Q.V[1].x, T->Q.V[1].y, T->Color[1], T->Color[1] ); // Left - Bottom Vertex
|
||||
T->Color[2] = mLight.ProcessVertex( T->Q.V[2].x, T->Q.V[2].y, T->Color[2], T->Color[2] ); // Right - Bottom Vertex
|
||||
T->Color[3] = mLight.ProcessVertex( T->Q.V[3].x, T->Q.V[3].y, T->Color[3], T->Color[3] ); // Right - Top Vertex
|
||||
}
|
||||
|
||||
T->Layers[L]->Draw( T->Q, eeVector2f(), 0.f, eeVector2f::One, T->Color[0], T->Color[1], T->Color[2], T->Color[3] );
|
||||
|
||||
if ( TileAABB.Contains( mMouseMapPos ) ) {
|
||||
if ( eePolygon2f::IntersectQuad2( T->Q, eeQuad2f( mMouseMapPos, mMouseMapPos, mMouseMapPos, mMouseMapPos ) ) ) {
|
||||
mMouseTilePos.x = x;
|
||||
mMouseTilePos.y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( T->Layers[L] != NULL ) {
|
||||
cSubTexture * SubTexture = T->Layers[L];
|
||||
|
||||
if ( T != NULL ) {
|
||||
eeVector2f TileCenter( T->Q.V[1].x + (T->Q.V[3].x - T->Q.V[1].x) * 0.5f, T->Q.V[0].y + (T->Q.V[2].y - T->Q.V[0].y) * 0.5f );
|
||||
eeVector2f ObjPos( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y * 0.80f );
|
||||
|
||||
eeAABB LayerAABB( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x * 0.5f, TileCenter.y );
|
||||
eeAABB ShadowAABB( ObjPos.x, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x, TileCenter.y );
|
||||
|
||||
if ( mScreenAABB.Intersect( ShadowAABB ) ) {
|
||||
SubTexture->Draw( mOffsetX + ObjPos.x, mOffsetY + ObjPos.y, 0, eeVector2f::One, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC );
|
||||
}
|
||||
|
||||
if ( mScreenAABB.Intersect( LayerAABB ) ) {
|
||||
SubTexture->Draw( mOffsetX + TileCenter.x - (eeFloat)SubTexture->DestSize().x * 0.5f, mOffsetY + TileCenter.y - (eeFloat)SubTexture->DestSize().y, 0, eeVector2f::One, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cGlobalBatchRenderer::instance()->Draw();
|
||||
|
||||
if ( L == 0 ) {
|
||||
GLi->PopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
if ( mDrawFont ) {
|
||||
for ( eeInt y = Ty; y < Ty2; y++ ) {
|
||||
for ( eeInt x = Tx; x < Tx2; x++ ) {
|
||||
T = &Tile( (eeUint)x, (eeUint)y );
|
||||
mFont->Draw( T->TilePosStr, mOffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * mFont->GetFontHeight() * 0.5f, mOffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - mFont->GetFontHeight() * 0.5f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mPR.FillMode( DRAW_LINE );
|
||||
mPR.DrawQuad( Tile( mMouseTilePos.x, mMouseTilePos.y ).Q, mOffsetX, mOffsetY );
|
||||
}
|
||||
|
||||
void cIsoMap::Move( const eeFloat& offsetx, const eeFloat& offsety ) {
|
||||
mOffsetX += offsetx;
|
||||
mOffsetY += offsety;
|
||||
}
|
||||
|
||||
void cIsoMap::SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level, const bool& JointUp ) {
|
||||
SetJointHeight( MapTileX, MapTileY, 0, Level, JointUp );
|
||||
SetJointHeight( MapTileX, MapTileY, 1, Level, JointUp );
|
||||
SetJointHeight( MapTileX, MapTileY, 2, Level, JointUp );
|
||||
SetJointHeight( MapTileX, MapTileY, 3, Level, JointUp );
|
||||
}
|
||||
|
||||
void cIsoMap::SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level, const bool& JointUp ) {
|
||||
eeFloat AltitudeModif = ( JointUp ) ? -1.f : 1.f;
|
||||
eeFloat VertexHeight = (mTileAltitude * AltitudeModif) * (eeFloat)Level;
|
||||
eeFloat NJHeight;
|
||||
|
||||
if ( MapTileX >= mMapWidth || MapTileY >= mMapHeight )
|
||||
return;
|
||||
|
||||
cIsoTile * T = &Tile( MapTileX, MapTileY );
|
||||
|
||||
T->Q.V[JointNum].y += VertexHeight;
|
||||
|
||||
NJHeight = T->Q.V[JointNum].y;
|
||||
|
||||
switch (JointNum) {
|
||||
case 0:
|
||||
if ( (MapTileX % 2) == 0) {
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY - 1, 3, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX , MapTileY - 1, 2, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY - 1, 1, VertexHeight, NJHeight, JointUp );
|
||||
} else {
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY , 1, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX , MapTileY - 1, 2, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY , 3, VertexHeight, NJHeight, JointUp );
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ( (MapTileX % 2) == 0) {
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY - 1, 2, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 2, MapTileY , 3, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY , 0, VertexHeight, NJHeight, JointUp );
|
||||
} else {
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY + 1, 0, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY , 2, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 2, MapTileY , 3, VertexHeight, NJHeight, JointUp );
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ( (MapTileX % 2) == 0) {
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY , 1, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY , 3, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX , MapTileY + 1, 0, VertexHeight, NJHeight, JointUp );
|
||||
} else {
|
||||
VertexChangeHeight( MapTileX , MapTileY + 1, 0, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY + 1, 1, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX - 1, MapTileY + 1, 3, VertexHeight, NJHeight, JointUp );
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ( (MapTileX % 2) == 0) {
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY - 1, 2, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY , 0, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 2, MapTileY , 1, VertexHeight, NJHeight, JointUp );
|
||||
} else {
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY + 1, 0, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 2, MapTileY , 1, VertexHeight, NJHeight, JointUp );
|
||||
VertexChangeHeight( MapTileX + 1, MapTileY , 2, VertexHeight, NJHeight, JointUp );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cIsoMap::VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp ) {
|
||||
if ( ( MapTileX >= 0 && MapTileX < (eeInt)mMapWidth ) && ( MapTileY >= 0 && MapTileY < (eeInt)mMapHeight ) ) {
|
||||
cIsoTile * T = &Tile( MapTileX, MapTileY );
|
||||
|
||||
if ( ( JointUp && T->Q.V[JointNum].y >= NewJointHeight ) || ( !JointUp && T->Q.V[JointNum].y <= NewJointHeight ) ) {
|
||||
T->Q.V[JointNum].y += Height;
|
||||
T->Box = T->Q.ToAABB();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eeVector2f cIsoMap::TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum) {
|
||||
eeFloat dX, dY, pX, pY;
|
||||
|
||||
if ( (MapTileX % 2) == 0) {
|
||||
dX = -mTileHWidth;
|
||||
dY = -mTileHHeight;
|
||||
} else {
|
||||
dX = -mTileHWidth;
|
||||
dY = 0;
|
||||
}
|
||||
|
||||
pX = MapTileX * mTileHWidth + dX;
|
||||
pY = MapTileY * mTileHWidth + dY;
|
||||
|
||||
switch( JointNum ) {
|
||||
case 0: return eeVector2f( pX + mTileHWidth, pY ); // Left Top Vertex
|
||||
case 1: return eeVector2f( pX, pY + mTileHHeight ); // Left Bottom Vertex
|
||||
case 2: return eeVector2f( pX + mTileHWidth, pY + mTileHeight ); // Top Left Vertex
|
||||
case 3: return eeVector2f( pX + mTileWidth, pY + mTileHHeight ); // Top Bottom Vertex
|
||||
}
|
||||
|
||||
return eeVector2f(0,0);
|
||||
}
|
||||
|
||||
eeQuad2f cIsoMap::TileQBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY ) {
|
||||
return eeQuad2f( TileBaseCoords( MapTileX, MapTileY, 0 ), TileBaseCoords( MapTileX, MapTileY, 1 ), TileBaseCoords( MapTileX, MapTileY, 2 ), TileBaseCoords( MapTileX, MapTileY, 3 ) );
|
||||
}
|
||||
|
||||
void cIsoMap::Reset() {
|
||||
CreateBaseVertexBuffer();
|
||||
}
|
||||
|
||||
void cIsoMap::Font( cFont * font ) {
|
||||
mFont = font;
|
||||
}
|
||||
|
||||
cFont * cIsoMap::Font() const {
|
||||
return mFont;
|
||||
}
|
||||
|
||||
cLight& cIsoMap::BaseLight() {
|
||||
return mLight;
|
||||
}
|
||||
|
||||
void cIsoMap::DrawFont( bool draw ) {
|
||||
mDrawFont = draw;
|
||||
}
|
||||
|
||||
bool cIsoMap::DrawFont() const {
|
||||
return mDrawFont;
|
||||
}
|
||||
|
||||
Uint32 cIsoMap::Width() const {
|
||||
return mMapWidth;
|
||||
}
|
||||
|
||||
Uint32 cIsoMap::Height() const {
|
||||
return mMapHeight;
|
||||
}
|
||||
|
||||
void cIsoMap::AmbientColor( const eeColor& AC ) {
|
||||
mMapAmbientColor = AC;
|
||||
}
|
||||
|
||||
eeColor cIsoMap::AmbientColor() const {
|
||||
return mMapAmbientColor;
|
||||
}
|
||||
|
||||
eeVector2i cIsoMap::GetMouseTilePos() const {
|
||||
return mMouseTilePos;
|
||||
}
|
||||
|
||||
eeVector2f cIsoMap::GetMouseMapCoords() const {
|
||||
return mMouseMapPos;
|
||||
}
|
||||
|
||||
eeAABB cIsoMap::GetScreenMapCoords() const {
|
||||
return mScreenAABB;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -118,7 +118,8 @@ void cMap::CreateLightManager() {
|
||||
void cMap::CreateEmptyTile() {
|
||||
//! I create a texture representing an empty tile to render instead of rendering with primitives because is a lot faster, at least with NVIDIA GPUs.
|
||||
cTextureFactory * TF = cTextureFactory::instance();
|
||||
std::string tileName( "maptile-" + String::ToStr( mTileSize.Width() ) + "x" + String::ToStr( mTileSize.Height() ) );
|
||||
|
||||
std::string tileName( String::StrFormated( "maptile-%dx%d-%ul", mTileSize.Width(), mTileSize.Height(), mGridLinesColor.GetValue() ) );
|
||||
|
||||
cTexture * Tex = TF->GetByName( tileName );
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ void cMapEditor::CreateLightContainer() {
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Light Radius:", mLightCont, eeSize(), eeVector2i( TAB_CONT_X_DIST, mUIBlueTxt->Pos().y + mUIBlueTxt->Size().Height() + 16 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE );
|
||||
|
||||
mLightRadius = mTheme->CreateSpinBox( mLightCont, eeSize( 100, 22 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE, 100, false );
|
||||
mLightRadius = mTheme->CreateSpinBox( mLightCont, eeSize( 100, 22 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED, 100, false );
|
||||
mLightRadius->MaxValue( 2000 );
|
||||
mLightRadius->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnLightRadiusChangeVal ) );
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0<void> NewMapCb, bool ResizeMap
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Width:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW );
|
||||
|
||||
mUIMapWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 100, false );
|
||||
mUIMapWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 100, false );
|
||||
mUIMapWidth->MinValue(1);
|
||||
|
||||
if ( ResizeMap ) {
|
||||
@@ -42,7 +42,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0<void> NewMapCb, bool ResizeMap
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Height:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW );
|
||||
|
||||
mUIMapHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 100, false );
|
||||
mUIMapHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 100, false );
|
||||
mUIMapHeight->MinValue(1);
|
||||
|
||||
if ( ResizeMap ) {
|
||||
@@ -53,7 +53,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0<void> NewMapCb, bool ResizeMap
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Width:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW );
|
||||
|
||||
mUIMapTWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 32, false );
|
||||
mUIMapTWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 32, false );
|
||||
mUIMapTWidth->MinValue(1);
|
||||
|
||||
if ( ResizeMap ) {
|
||||
@@ -62,7 +62,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0<void> NewMapCb, bool ResizeMap
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Height:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW );
|
||||
|
||||
mUIMapTHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 32, false );
|
||||
mUIMapTHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 32, false );
|
||||
mUIMapTHeight->MinValue(1);
|
||||
|
||||
if ( ResizeMap ) {
|
||||
@@ -71,7 +71,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0<void> NewMapCb, bool ResizeMap
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Max Layers", mUIWindow->Container(), eeSize(), eeVector2i( 16, mUIMapTHeight->Pos().y + mUIMapTHeight->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE );
|
||||
|
||||
mUIMapMaxLayers = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS, 8, false );
|
||||
mUIMapMaxLayers = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 8, false );
|
||||
mUIMapMaxLayers->MaxValue( 32 );
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Map Flags:", mUIWindow->Container(), eeSize(), eeVector2i( Txt->Pos().x, mUIMapMaxLayers->Pos().y + mUIMapMaxLayers->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE );
|
||||
@@ -229,6 +229,7 @@ void cUIMapNew::OKClick( const cUIEvent * Event ) {
|
||||
mUIMap->Map()->Create( eeSize( w, h ), ml, eeSize( tw, th ), Flags, mUIMap->Map()->ViewSize() );
|
||||
mUIMap->Map()->BaseColor( mUIBaseColor->Background()->Color() );
|
||||
} else {
|
||||
std::string oldPath( mUIMap->Map()->Path() );
|
||||
std::string mapPath( Sys::GetTempPath() + "temp.eepp.map.eem" );
|
||||
mUIMap->Map()->Save( mapPath );
|
||||
|
||||
@@ -238,6 +239,7 @@ void cUIMapNew::OKClick( const cUIEvent * Event ) {
|
||||
Map->ForceHeadersOnLoad( eeSize( w, h ), eeSize( tw, th ), ml, Flags );
|
||||
Map->Load( mapPath );
|
||||
Map->DisableForcedHeaders();
|
||||
Map->mPath = oldPath;
|
||||
|
||||
mUIMap->ReplaceMap( Map );
|
||||
|
||||
|
||||
@@ -658,7 +658,10 @@ void cUIControl::ChildAddAt( cUIControl * ChildCtrl, Uint32 Pos ) {
|
||||
ChildCtrl->mPrev = NULL;
|
||||
} else {
|
||||
if( Pos == 0 ) {
|
||||
mChild->mPrev = ChildCtrl;
|
||||
if ( NULL != mChild ) {
|
||||
mChild->mPrev = ChildCtrl;
|
||||
}
|
||||
|
||||
ChildCtrl->mNext = mChild;
|
||||
ChildCtrl->mPrev = NULL;
|
||||
mChild = ChildCtrl;
|
||||
|
||||
@@ -36,7 +36,7 @@ cTextureAtlasEditor::cTextureAtlasEditor( cUIWindow * AttatchTo, const TGEditorC
|
||||
}
|
||||
|
||||
cUITextBox * TxtBox;
|
||||
Uint32 Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_CLIP_ENABLE | UI_AUTO_SIZE;
|
||||
Uint32 Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED;
|
||||
Uint32 InitY = 230;
|
||||
|
||||
CreateTxtBox( eeVector2i( mUIContainer->Size().Width() - 205, 30 ), "SubTexture List:" );
|
||||
|
||||
@@ -54,7 +54,7 @@ cTextureAtlasNew::cTextureAtlasNew( TGCreateCb NewTGCb ) :
|
||||
mComboHeight->ListBox()->SetSelected( "512" );
|
||||
|
||||
CreateTxtBox( eeVector2i( 10, 110 ), "Space between sub textures (pixels):" );
|
||||
mPixelSpace = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 100, 22 ), eeVector2i( PosX, 110 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE, 0, false );
|
||||
mPixelSpace = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 100, 22 ), eeVector2i( PosX, 110 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED, 0, false );
|
||||
|
||||
CreateTxtBox( eeVector2i( 10, 140 ), "Texture Atlas Folder Path:" );
|
||||
mTGPath = mTheme->CreateTextInput( mUIWindow->Container(), eeSize( mUIWindow->Container()->Size().Width() - 60, 22 ), eeVector2i( 10, 160 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE , false, 512 );
|
||||
|
||||
@@ -22,8 +22,6 @@ void cEETest::Init() {
|
||||
scale = 1.0f;
|
||||
Ang = ang = alpha = 0;
|
||||
lasttick = 0;
|
||||
Wireframe = false;
|
||||
TreeTilingCreated = false;
|
||||
AnimVal = 0.5f;
|
||||
mLastFPSLimit = 0;
|
||||
mWasMinimized = false;
|
||||
@@ -63,6 +61,7 @@ void cEETest::Init() {
|
||||
SetScreen( StartScreen );
|
||||
|
||||
mWindow->Caption( "eepp - Test Application" );
|
||||
mWindow->PushResizeCallback( cb::Make1( this, &cEETest::OnWindowResize ) );
|
||||
|
||||
TF = cTextureFactory::instance();
|
||||
TF->Allocate(40);
|
||||
@@ -190,8 +189,6 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) {
|
||||
eeASSERT( TTF != NULL );
|
||||
eeASSERT( TTFB != NULL );
|
||||
|
||||
Map.Font( FF );
|
||||
|
||||
Con.Create( FF, true );
|
||||
Con.IgnoreCharOnPrompt( 186 ); // 'º'
|
||||
|
||||
@@ -236,18 +233,6 @@ void cEETest::OnWinMouseUp( const cUIEvent * Event ) {
|
||||
}
|
||||
}
|
||||
|
||||
void cEETest::OnTerrainMouse( const cUIEvent * Event ) {
|
||||
cUIPushButton * PB = static_cast<cUIPushButton*>( Event->Ctrl() );
|
||||
|
||||
if ( PB->Text() == "Terrain Up" ) {
|
||||
PB->Text( "Terrain Down" );
|
||||
mTerrainUp = false;
|
||||
} else {
|
||||
PB->Text( "Terrain Up" );
|
||||
mTerrainUp = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cEETest::OnShowMenu( const cUIEvent * Event ) {
|
||||
cUIPushButton * PB = static_cast<cUIPushButton*>( Event->Ctrl() );
|
||||
|
||||
@@ -258,6 +243,9 @@ void cEETest::OnShowMenu( const cUIEvent * Event ) {
|
||||
}
|
||||
}
|
||||
|
||||
void cEETest::OnWindowResize(cWindow * win) {
|
||||
Map.ViewSize( win->Size() );
|
||||
}
|
||||
|
||||
void cEETest::CreateUI() {
|
||||
cClock TE;
|
||||
@@ -567,28 +555,6 @@ void cEETest::CreateUI() {
|
||||
mGenGrid->CollumnWidth( 1, 24 );
|
||||
mGenGrid->CollumnWidth( 2, 100 );
|
||||
|
||||
#ifdef EE_PLATFORM_TOUCH
|
||||
cTextureAtlas * SG = cGlobalTextureAtlas::instance();
|
||||
|
||||
cTexture * butTex = TF->GetTexture( TF->Load( MyPath + "sprites/button-te_normal.png" ) );
|
||||
|
||||
SG->Add( butTex->Id(), "button-te_normal" );
|
||||
SG->Add( TF->Load( MyPath + "sprites/button-te_mdown.png" ), "button-te_mdown" );
|
||||
|
||||
cUISkinSimple nSkin( "button-te" );
|
||||
|
||||
mShowMenu = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mWindow->GetWidth() - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
mShowMenu->SetSkin( nSkin );
|
||||
mShowMenu->Text( "Show Menu" );
|
||||
mShowMenu->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnShowMenu ) );
|
||||
|
||||
mTerrainBut = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mShowMenu->Pos().x - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
mTerrainBut->SetSkin( nSkin );
|
||||
mTerrainBut->Text( "Terrain Up" );
|
||||
mTerrainBut->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnTerrainMouse ) );
|
||||
mTerrainBut->Visible( 1 == Screen );
|
||||
#endif
|
||||
|
||||
C = reinterpret_cast<cUIControlAnim*> ( C->Parent() );
|
||||
|
||||
eePRINTL( "CreateUI time: %4.3f ms.", TE.Elapsed().AsMilliseconds() );
|
||||
@@ -948,59 +914,12 @@ void cEETest::LoadTextures() {
|
||||
|
||||
eePRINTL( "Textures loading time: %4.3f ms.", TE.Elapsed().AsMilliseconds() );
|
||||
|
||||
Map.Create( 100, 100, 2, 128, 64, eeColor(175,175,175) );
|
||||
RandomizeHeights();
|
||||
|
||||
TreeTilingCreated = false;
|
||||
CreateTiling(Wireframe);
|
||||
Map.Load( MyPath + "maps/test.eem" );
|
||||
Map.ViewSize( mWindow->Size() );
|
||||
|
||||
eePRINTL( "Map creation time: %4.3f ms.", TE.Elapsed().AsMilliseconds() );
|
||||
}
|
||||
|
||||
void cEETest::RandomizeHeights() {
|
||||
Map.Reset();
|
||||
PerlinNoise.Octaves(7);
|
||||
PerlinNoise.Persistence(0.25f);
|
||||
PerlinNoise.Frequency(0.015f);
|
||||
PerlinNoise.Amplitude(1);
|
||||
|
||||
for ( x = 0; x < static_cast<Int32>( Map.Width() ); x++ ) {
|
||||
for ( y = 0; y < static_cast<Int32>( Map.Height() ); y++ ) {
|
||||
H = PerlinNoise.PerlinNoise2D((eeFloat)x,(eeFloat)y);
|
||||
if (H < 0 ) H *= -1;
|
||||
|
||||
eeFloat nh = (eeFloat)( (Int32)( H * 100 ) % 255 );
|
||||
eeFloat nf = (4 * nh / 25) / 2;
|
||||
NH = Int32(nf);
|
||||
|
||||
Map.SetTileHeight( x, y, NH );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cEETest::CreateTiling( const bool& Wire ) {
|
||||
cMTRand Rand( 0xFF00FF00 );
|
||||
|
||||
for ( x = 0; x < static_cast<Int32>( Map.Width() ); x++ ) {
|
||||
for ( y = 0; y < static_cast<Int32>( Map.Height() ); y++ ) {
|
||||
if ( Wire )
|
||||
Map.Layer(x, y, 0, Tiles[6] );
|
||||
else
|
||||
Map.Layer(x, y, 0, Tiles[ Rand.RandRange( 0, 5 ) ] );
|
||||
|
||||
if ( !TreeTilingCreated )
|
||||
Map.Layer(x, y, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !TreeTilingCreated ) {
|
||||
for ( x = 0; x < 100; x++ )
|
||||
Map.Layer( Rand.RandRange( 0, Map.Width() - 1 ), Rand.RandRange( 0, Map.Height() -1 ), 1, Tiles[7] );
|
||||
|
||||
TreeTilingCreated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cEETest::Run() {
|
||||
ParticlesThread();
|
||||
}
|
||||
@@ -1022,6 +941,7 @@ void cEETest::UpdateParticles() {
|
||||
}
|
||||
|
||||
void cEETest::Screen1() {
|
||||
Map.Update();
|
||||
Map.Draw();
|
||||
}
|
||||
|
||||
@@ -1529,51 +1449,9 @@ void cEETest::Input() {
|
||||
Map.Move( 0, -mWindow->Elapsed().AsMilliseconds() * 0.2f );
|
||||
}
|
||||
|
||||
if ( KM->IsKeyDown(KEY_KP_MINUS) )
|
||||
Map.BaseLight().Radius( Map.BaseLight().Radius() - mWindow->Elapsed().AsMilliseconds() * 0.2f );
|
||||
|
||||
if ( KM->IsKeyDown(KEY_KP_PLUS) )
|
||||
Map.BaseLight().Radius( Map.BaseLight().Radius() + mWindow->Elapsed().AsMilliseconds() * 0.2f );
|
||||
|
||||
if ( KM->IsKeyUp(KEY_F6) ) {
|
||||
Wireframe = !Wireframe;
|
||||
Sys::Sleep(1);
|
||||
CreateTiling(Wireframe);
|
||||
}
|
||||
|
||||
if ( KM->IsKeyUp(KEY_F7) )
|
||||
Map.DrawFont( !Map.DrawFont() );
|
||||
|
||||
if ( KM->IsKeyUp(KEY_F8) )
|
||||
Map.Reset();
|
||||
|
||||
if ( KM->IsKeyUp(KEY_F9) )
|
||||
RandomizeHeights();
|
||||
|
||||
if ( KM->MouseLeftClick() ) {
|
||||
eeVector2i P = Map.GetMouseTilePos();
|
||||
|
||||
if ( NULL != mTerrainBut ) {
|
||||
if ( !mTerrainBut->GetPolygon().PointInside( KM->GetMousePosf() ) ) {
|
||||
if ( mTerrainUp ) {
|
||||
Map.SetTileHeight( P.x, P.y );
|
||||
} else {
|
||||
Map.SetTileHeight( P.x, P.y, 1, false );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( mTerrainUp ) {
|
||||
Map.SetTileHeight( P.x, P.y );
|
||||
} else {
|
||||
Map.SetTileHeight( P.x, P.y, 1, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( KM->MouseRightClick() ) {
|
||||
eeVector2i P = Map.GetMouseTilePos();
|
||||
Map.SetTileHeight( P.x, P.y, 1, false );
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ( KM->IsKeyUp(KEY_S) )
|
||||
|
||||
@@ -134,14 +134,7 @@ class cEETest : private cThread {
|
||||
std::string MyPath;
|
||||
bool ShowParticles;
|
||||
|
||||
cIsoMap Map;
|
||||
|
||||
bool Wireframe;
|
||||
|
||||
void CreateTiling( const bool& Wire );
|
||||
void RandomizeHeights();
|
||||
cPerlinNoise PerlinNoise;
|
||||
bool TreeTilingCreated;
|
||||
cMap Map;
|
||||
|
||||
eeFloat H;
|
||||
Int32 NH;
|
||||
@@ -304,8 +297,9 @@ class cEETest : private cThread {
|
||||
|
||||
void DestroyBody();
|
||||
|
||||
void OnTerrainMouse( const cUIEvent * Event );
|
||||
void OnShowMenu( const cUIEvent * Event );
|
||||
|
||||
void OnWindowResize( cWindow * win );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user