* fixed: fixed bug that prevented item querying
* fixed irrlicht<->world orientation calculation * added estimated formula to convert irrlicht camera to world coords. thx for all goes to bLuma!
This commit is contained in:
parent
ef35b7bd09
commit
38cbcb026c
@ -72,7 +72,8 @@ private:
|
|||||||
ZThread::FastMutex mutex;
|
ZThread::FastMutex mutex;
|
||||||
PseuGUI *gui;
|
PseuGUI *gui;
|
||||||
uint32 map_gridX, map_gridY;
|
uint32 map_gridX, map_gridY;
|
||||||
s32 mapsize, tilesize, meshsize;
|
s32 mapsize, meshsize;
|
||||||
|
f32 tilesize;
|
||||||
WorldSession *wsession;
|
WorldSession *wsession;
|
||||||
MapMgr *mapmgr;
|
MapMgr *mapmgr;
|
||||||
IGUIStaticText *debugText;
|
IGUIStaticText *debugText;
|
||||||
|
|||||||
@ -16,6 +16,11 @@
|
|||||||
#define ANGLE_STEP (M_PI/180)
|
#define ANGLE_STEP (M_PI/180)
|
||||||
#define DEG_TO_RAD(x) ((x)*ANGLE_STEP)
|
#define DEG_TO_RAD(x) ((x)*ANGLE_STEP)
|
||||||
#define RAD_TO_DEG(x) ((x)/ANGLE_STEP)
|
#define RAD_TO_DEG(x) ((x)/ANGLE_STEP)
|
||||||
|
#define RAD_FIX(x) ( (x)>(2*M_PI) ? ((x)-(2*M_PI)) : (x) )
|
||||||
|
#define DEG_FIX(x) ( (x)>360 ? ((x)-360) : (x) )
|
||||||
|
|
||||||
|
#define COORD_SCALE_VALUE_X 0.336f
|
||||||
|
#define COORD_SCALE_VALUE_Y 0.2f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -163,16 +168,16 @@ void SceneWorld::OnUpdate(s32 timediff)
|
|||||||
WorldPosition wp = GetWorldPosition();
|
WorldPosition wp = GetWorldPosition();
|
||||||
core::stringw str = L"Camera: pitch:";
|
core::stringw str = L"Camera: pitch:";
|
||||||
str += camera->getPitch();
|
str += camera->getPitch();
|
||||||
str += L" dir:";
|
str += L" c pos:";
|
||||||
str += camera->getDirection().X;
|
str += camera->getPosition().X;
|
||||||
str += L",";
|
str += L",";
|
||||||
str += camera->getDirection().Y;
|
str += camera->getPosition().Y;
|
||||||
str += L",";
|
str += L",";
|
||||||
str += camera->getDirection().Z;
|
str += camera->getPosition().Z;
|
||||||
str += " ## o: ";
|
str += " ## HEAD: ";
|
||||||
str += DEG_TO_RAD(camera->getHeading());
|
str += DEG_TO_RAD(camera->getHeading());
|
||||||
str += L" Pos: ";
|
str += L" Pos: ";
|
||||||
str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | ") + wp.o;
|
str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | OR:") + wp.o;
|
||||||
str += L" -- Terrain: Sectors: ";
|
str += L" -- Terrain: Sectors: ";
|
||||||
str += (int)terrain->getSectorsRendered();
|
str += (int)terrain->getSectorsRendered();
|
||||||
str += L" / ";
|
str += L" / ";
|
||||||
@ -201,7 +206,7 @@ void SceneWorld::InitTerrain(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapsize = 9 * 16 * 3; // 9 height floats in 16 chunks per tile per axis in 3 MapTiles
|
mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles
|
||||||
tilesize = UNITSIZE;
|
tilesize = UNITSIZE;
|
||||||
meshsize = CHUNKSIZE*3;
|
meshsize = CHUNKSIZE*3;
|
||||||
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
||||||
@ -264,13 +269,13 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
for(uint32 chx = 0; chx < 16; chx++)
|
for(uint32 chx = 0; chx < 16; chx++)
|
||||||
{
|
{
|
||||||
MapChunk *chunk = maptile->GetChunk(chx, chy);
|
MapChunk *chunk = maptile->GetChunk(chx, chy);
|
||||||
for(uint32 hy = 0; hy < 9; hy++)
|
for(uint32 hy = 0; hy < 8; hy++)
|
||||||
{
|
{
|
||||||
for(uint32 hx = 0; hx < 9; hx++)
|
for(uint32 hx = 0; hx < 8; hx++)
|
||||||
{
|
{
|
||||||
f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
||||||
u32 terrainx = (144 * tilex) + (9 * chx) + hx;
|
u32 terrainx = (128 * tilex) + (8 * chx) + hx;
|
||||||
u32 terrainy = (144 * tiley) + (9 * chy) + hy;
|
u32 terrainy = (128 * tiley) + (8 * chy) + hy;
|
||||||
terrain->setHeight(terrainy, terrainx, h);
|
terrain->setHeight(terrainy, terrainx, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +329,13 @@ WorldPosition SceneWorld::GetWorldPosition(void)
|
|||||||
MapTile *tile = mapmgr->GetCurrentTile();
|
MapTile *tile = mapmgr->GetCurrentTile();
|
||||||
float mapx = tile->GetBaseX();
|
float mapx = tile->GetBaseX();
|
||||||
float mapy = tile->GetBaseY();
|
float mapy = tile->GetBaseY();
|
||||||
return WorldPosition(cam.X + mapx, cam.Z + mapy, cam.Y, DEG_TO_RAD(camera->getHeading()));
|
|
||||||
|
// the following formulas are NOT correct, just estimated. in most places they will differ from real expected values a lot!
|
||||||
|
float relx = cam.X * COORD_SCALE_VALUE_X + CHUNKSIZE;
|
||||||
|
float rely = cam.Z * COORD_SCALE_VALUE_Y + CHUNKSIZE;
|
||||||
|
|
||||||
|
float o = DEG_TO_RAD(camera->getHeading()) + ((M_PI*3.0f)/2.0f);
|
||||||
|
return WorldPosition(mapx - relx, mapy - rely, cam.Y, RAD_FIX(o) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneWorld::SetWorldPosition(WorldPosition wp)
|
void SceneWorld::SetWorldPosition(WorldPosition wp)
|
||||||
@ -340,10 +351,11 @@ void SceneWorld::SetWorldPosition(WorldPosition wp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE);
|
cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE);
|
||||||
cam.Y = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE);
|
cam.Z = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE);
|
||||||
float heading = RAD_TO_DEG(wp.o);
|
float heading = RAD_TO_DEG(((M_PI*3.0f)/2.0f) - wp.o);
|
||||||
float heading_diff = camera->getHeading() - heading;
|
float heading_diff = camera->getHeading() - heading;
|
||||||
logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading);
|
logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading);
|
||||||
|
camera->turnLeft(heading_diff);
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - correct the above formulas
|
// - correct the above formulas
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
MapMgr::MapMgr()
|
MapMgr::MapMgr()
|
||||||
{
|
{
|
||||||
|
DEBUG(logdebug("Creating MapMgr with TILESIZE=%.3f CHUNKSIZE=%.3f UNITSIZE=%.3f",TILESIZE,CHUNKSIZE,UNITSIZE));
|
||||||
_tiles = new MapTileStorage();
|
_tiles = new MapTileStorage();
|
||||||
_gridx = _gridy = _mapid = (-1);
|
_gridx = _gridy = _mapid = (-1);
|
||||||
_mapsLoaded = false;
|
_mapsLoaded = false;
|
||||||
|
|||||||
@ -89,7 +89,7 @@ void ObjMgr::AddNonexistentItem(uint32 id)
|
|||||||
|
|
||||||
bool ObjMgr::ItemNonExistent(uint32 id)
|
bool ObjMgr::ItemNonExistent(uint32 id)
|
||||||
{
|
{
|
||||||
return _noitem.find(id) == _noitem.end();
|
return _noitem.find(id) != _noitem.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjMgr::AddRequestedPlayerGUID(uint32 loguid)
|
void ObjMgr::AddRequestedPlayerGUID(uint32 loguid)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user