quasi related camera nonsense.
Welp RTT works, but I'm not getting useful output because I can't quite pinpoint how to move the camera as I want.
the mesh node is pretty simple, I built every face at a scale of 1 unit, I then scaled it up by 10 so each tile is 10.0fx10.0fx10.0f in volume.
scene::ICameraSceneNode* playerCamera = smgr->addCameraSceneNode(0, core::vector3df(70,5,80), core::vector3df(100,5,80));
this SHOULD put this camera in tile 7,8 - in the exact vertical center, pointing at tile 10,8 (or 3 tiles ahead, same height).
this works ok, but I don't want to hardcode it - it also does not seem to actually put the camera at tile center, it seems to be on the seam between tiles. (this is easily proven by testing tile 12,8 - this is the opening to a hallway) - so fine, I'll just add 0.5 tiles to everything. ez...
so let's write a function to do this for me then.
... and done.
time to assign, this should have the camera in tile x,y facing x+30,y.
vector3df pos = spawnPlayer(playerCamera, level);
playerCamera->setPosition(pos);
playerCamera->setTarget(pos+vector3df(30.0f, 0.0f, 0.0f));
expected result: I should have a face of brick... I think, arguably my original test case is ambiguous since the map is a mirror of itself.
actual result: I see the corridor behind me.. wait what? that means my idea of what direction it's facing is wrong.
(EDIT: of course... I build the level from the top left corner and build upwards, this creates a vertically mirrored version
welp that solves that mystery, still need to remember to update the target every time - I don't know a good way to do this but I just set it to +3 tiles(+30.0f) in the current direction which SEEMS to work)
so I expected this direction:
t
|
|
c
but I got the inverse (c denotes camera, t denotes target). Fine, that I can deal with.
now I just have to remember to update the target appropriately for each of the four cardinal directions (NORTH/SOUTH/EAST/WEST).
also: when using RTT like this the FPS camera can't move, very strange.
assuming, of course, that I'm doing it right, which I'll know soon because I'm just about to write a simple function that moves the camera one tile in the current direction if triggered.
or in other words: the camera isn't behaving as I expected and I felt like a <rant> was in order.
oh and </rant>
in better news: I noticed that if you draw a rect with a texture id of NULL you get a black background (which is ideal, I wanted to keep the GUI background null for now).
the only real question in this rant is really: is it normal for the FPS camera to not be able to move if you've set another camera as the active camera? I expected it should still be able to move but it sorta makes sense that it doesn't - so I'm pretty sure it's on purpose.
EDIT2: as I sorta expected, \mainGame.cpp|63|warning: the address of 'eReceiver' will always evaluate as 'true' [-Waddress]| prevents me from actually fetching input (this proven by debug printing not printing even when the requested key was pressed, or held down for that matter).
hmm, welp time to figure it out.
Code: Select all
MyEventReceiver eReceiver;
IrrlichtDevice* iDevice = createDevice(EDT_OPENGL, res, 32, fullscreen, vsync, &eReceiver);
//SNIP
while(iDevice->run())
{
if(eReceiver.isKeyDown(irr::KEY_KEY_W))
{
std::cout << "moving player" <<std::endl;
playerCamera->setPosition(movePlayer(direction, playerCamera->getPosition(), keys::KEY_W));
}
//SNIP
and of course the event receiver.
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
keyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool isKeyDown(EKEY_CODE keyCode) const
{
return keyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
keyIsDown[i] = false;
}
private:
bool keyIsDown[KEY_KEY_CODES_COUNT];
};
switching both of them to true causes the player to race into the distance, so the moving function WORKS.
that means one of the two false statements has to be true since
false + false = no movement
true + true = always moving
true + false = no movement.
false + true = always moving... wait what?
I don't get it.