Commit ace653f4 authored by hybrid's avatar hybrid

Merged revisions 1885:1912 from 1.5 branch. More unit tests and bug fixes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1913 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7a1fac9d
...@@ -160,6 +160,9 @@ void loadModel(const c8* fn) ...@@ -160,6 +160,9 @@ void loadModel(const c8* fn)
menu->setItemChecked(5, false); menu->setItemChecked(5, false);
menu->setItemChecked(6, false); menu->setItemChecked(6, false);
} }
Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(901, true)->setText(L"1.0");
Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(902, true)->setText(L"1.0");
Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(903, true)->setText(L"1.0");
} }
...@@ -178,34 +181,43 @@ void createToolBox() ...@@ -178,34 +181,43 @@ void createToolBox()
e->remove(); e->remove();
// create the toolbox window // create the toolbox window
IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,480), IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,45,800,480),
false, L"Toolset", 0, 5000); false, L"Toolset", 0, 5000);
// create tab control and tabs // create tab control and tabs
IGUITabControl* tab = env->addTabControl( IGUITabControl* tab = env->addTabControl(
core::rect<s32>(2,20,800-602,480-7), wnd, true, true); core::rect<s32>(2,20,800-602,480-7), wnd, true, true);
IGUITab* t1 = tab->addTab(L"Scale"); IGUITab* t1 = tab->addTab(L"Config");
// add some edit boxes and a button to tab one // add some edit boxes and a button to tab one
env->addEditBox(L"1.0", core::rect<s32>(40,50,130,70), true, t1, 901); env->addStaticText(L"Scale:",
env->addEditBox(L"1.0", core::rect<s32>(40,80,130,100), true, t1, 902); core::rect<s32>(10,20,150,45), false, false, t1);
env->addEditBox(L"1.0", core::rect<s32>(40,110,130,130), true, t1, 903); env->addStaticText(L"X:", core::rect<s32>(22,48,40,66), false, false, t1);
env->addEditBox(L"1.0", core::rect<s32>(40,46,130,66), true, t1, 901);
env->addButton(core::rect<s32>(10,150,100,190), t1, 1101, L"set"); env->addStaticText(L"Y:", core::rect<s32>(22,82,40,100), false, false, t1);
env->addEditBox(L"1.0", core::rect<s32>(40,76,130,96), true, t1, 902);
// add senseless checkbox env->addStaticText(L"Z:", core::rect<s32>(22,108,40,126), false, false, t1);
env->addCheckBox(true, core::rect<s32>(10,220,200,240), t1, -1, env->addEditBox(L"1.0", core::rect<s32>(40,106,130,126), true, t1, 903);
L"Senseless Checkbox");
env->addButton(core::rect<s32>(10,134,85,165), t1, 1101, L"Set");
// add undocumented transparent control
env->addStaticText(L"Transparent Control:", // add transparency control
core::rect<s32>(10,240,150,260), true, false, t1); env->addStaticText(L"GUI Transparency Control:",
core::rect<s32>(10,200,150,225), true, false, t1);
IGUIScrollBar* scrollbar = env->addScrollBar(true, IGUIScrollBar* scrollbar = env->addScrollBar(true,
core::rect<s32>(10,260,150,275), t1, 104); core::rect<s32>(10,225,150,240), t1, 104);
scrollbar->setMax(255); scrollbar->setMax(255);
scrollbar->setPos(255); scrollbar->setPos(255);
// add framerate control
env->addStaticText(L"Framerate:",
core::rect<s32>(10,240,150,265), true, false, t1);
scrollbar = env->addScrollBar(true,
core::rect<s32>(10,265,150,280), t1, 105);
scrollbar->setMax(1000);
scrollbar->setPos(30);
// bring irrlicht engine logo to front, because it // bring irrlicht engine logo to front, because it
// now may be below the newly created toolbox // now may be below the newly created toolbox
root->bringToFront(root->getElementFromId(666, true)); root->bringToFront(root->getElementFromId(666, true));
...@@ -225,18 +237,29 @@ public: ...@@ -225,18 +237,29 @@ public:
{ {
// Escape swaps Camera Input // Escape swaps Camera Input
if (event.EventType == EET_KEY_INPUT_EVENT && if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == irr::KEY_ESCAPE &&
event.KeyInput.PressedDown == false) event.KeyInput.PressedDown == false)
{ {
if (Device) if (event.KeyInput.Key == irr::KEY_ESCAPE)
{
if (Device)
{
scene::ICameraSceneNode * camera =
Device->getSceneManager()->getActiveCamera();
if (camera)
{
camera->setInputReceiverEnabled( !camera->isInputReceiverEnabled() );
}
return true;
}
}
else if (event.KeyInput.Key == irr::KEY_F1)
{ {
scene::ICameraSceneNode * camera = if (Device)
Device->getSceneManager()->getActiveCamera();
if (camera)
{ {
camera->setInputReceiverEnabled( !camera->isInputReceiverEnabled() ); IGUIElement* elem = Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(2001);
if (elem)
elem->setVisible(!elem->isVisible());
} }
return true;
} }
} }
...@@ -364,7 +387,7 @@ public: ...@@ -364,7 +387,7 @@ public:
// control skin transparency // control skin transparency
if (id == 104) if (id == 104)
{ {
s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); const s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
for (s32 i=0; i<irr::gui::EGDC_COUNT ; ++i) for (s32 i=0; i<irr::gui::EGDC_COUNT ; ++i)
{ {
video::SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i); video::SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
...@@ -372,6 +395,12 @@ public: ...@@ -372,6 +395,12 @@ public:
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col); env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
} }
} }
else if (id == 105)
{
const s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
if (scene::ESNT_ANIMATED_MESH == Model->getType())
((scene::IAnimatedMeshSceneNode*)Model)->setAnimationSpeed((f32)pos);
}
break; break;
case EGET_COMBO_BOX_CHANGED: case EGET_COMBO_BOX_CHANGED:
...@@ -695,6 +724,10 @@ int main(int argc, char* argv[]) ...@@ -695,6 +724,10 @@ int main(int argc, char* argv[])
IGUIStaticText* fpstext = env->addStaticText(L"", IGUIStaticText* fpstext = env->addStaticText(L"",
core::rect<s32>(400,4,570,23), true, false, bar); core::rect<s32>(400,4,570,23), true, false, bar);
IGUIStaticText* postext = env->addStaticText(L"",
core::rect<s32>(10,50,470,80),false, false, 0, 2001);
postext->setVisible(false);
// set window caption // set window caption
Caption += " - ["; Caption += " - [";
...@@ -728,8 +761,10 @@ int main(int argc, char* argv[]) ...@@ -728,8 +761,10 @@ int main(int argc, char* argv[])
// add a camera scene node // add a camera scene node
Camera[0] = smgr->addCameraSceneNodeMaya(); Camera[0] = smgr->addCameraSceneNodeMaya();
Camera[0]->setFarValue(20000.f); Camera[0]->setFarValue(20000.f);
Camera[0]->setPosition(core::vector3df(0,0,-100));
Camera[1] = smgr->addCameraSceneNodeFPS(); Camera[1] = smgr->addCameraSceneNodeFPS();
Camera[1]->setFarValue(20000.f); Camera[1]->setFarValue(20000.f);
Camera[1]->setPosition(core::vector3df(0,0,-100));
setActiveCamera(Camera[0]); setActiveCamera(Camera[0]);
...@@ -760,6 +795,21 @@ int main(int argc, char* argv[]) ...@@ -760,6 +795,21 @@ int main(int argc, char* argv[])
str += L" Tris: "; str += L" Tris: ";
str.append(core::stringw(driver->getPrimitiveCountDrawn())); str.append(core::stringw(driver->getPrimitiveCountDrawn()));
fpstext->setText(str.c_str()); fpstext->setText(str.c_str());
scene::ICameraSceneNode* cam = Device->getSceneManager()->getActiveCamera();
str = L"Pos: ";
str.append(core::stringw(cam->getPosition().X));
str += L" ";
str.append(core::stringw(cam->getPosition().Y));
str += L" ";
str.append(core::stringw(cam->getPosition().Z));
str += L" Tgt: ";
str.append(core::stringw(cam->getTarget().X));
str += L" ";
str.append(core::stringw(cam->getTarget().Y));
str += L" ";
str.append(core::stringw(cam->getTarget().Z));
postext->setText(str.c_str());
} }
else else
Device->yield(); Device->yield();
......
...@@ -414,8 +414,6 @@ int main() ...@@ -414,8 +414,6 @@ int main()
scene::IParticleSystemSceneNode* ps = scene::IParticleSystemSceneNode* ps =
smgr->addParticleSystemSceneNode(false, light2); smgr->addParticleSystemSceneNode(false, light2);
ps->setParticleSize(core::dimension2d<f32>(30.0f, 40.0f));
// create and set emitter // create and set emitter
scene::IParticleEmitter* em = ps->createBoxEmitter( scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-3,0,-3,3,1,3), core::aabbox3d<f32>(-3,0,-3,3,1,3),
...@@ -423,6 +421,9 @@ int main() ...@@ -423,6 +421,9 @@ int main()
80,100, 80,100,
video::SColor(0,255,255,255), video::SColor(0,255,255,255), video::SColor(0,255,255,255), video::SColor(0,255,255,255),
400,1100); 400,1100);
em->setMinStartSize(core::dimension2d<f32>(30.0f, 40.0f));
em->setMaxStartSize(core::dimension2d<f32>(30.0f, 40.0f));
ps->setEmitter(em); ps->setEmitter(em);
em->drop(); em->drop();
......
...@@ -148,6 +148,9 @@ user. ...@@ -148,6 +148,9 @@ user.
camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0)); camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0));
//User-controlled //User-controlled
camera[3] = smgr->addCameraSceneNodeFPS(); camera[3] = smgr->addCameraSceneNodeFPS();
// don't start at sydney's position
if (camera[3])
camera[3]->setPosition(core::vector3df(-50,0,-50));
/* /*
Create a variable for counting the fps and hide the mouse: Create a variable for counting the fps and hide the mouse:
......
...@@ -533,13 +533,14 @@ void CDemo::loadSceneData() ...@@ -533,13 +533,14 @@ void CDemo::loadSceneData()
campFire->setPosition(core::vector3df(100,120,600)); campFire->setPosition(core::vector3df(100,120,600));
campFire->setScale(core::vector3df(2,2,2)); campFire->setScale(core::vector3df(2,2,2));
campFire->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
scene::IParticleEmitter* em = campFire->createBoxEmitter( scene::IParticleEmitter* em = campFire->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7), core::aabbox3d<f32>(-7,0,-7,7,1,7),
core::vector3df(0.0f,0.06f,0.0f), core::vector3df(0.0f,0.06f,0.0f),
80,100, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 800,2000); 80,100, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 800,2000);
em->setMinStartSize(core::dimension2d<f32>(20.0f, 10.0f));
em->setMaxStartSize(core::dimension2d<f32>(20.0f, 10.0f));
campFire->setEmitter(em); campFire->setEmitter(em);
em->drop(); em->drop();
......
...@@ -152,14 +152,30 @@ namespace scene ...@@ -152,14 +152,30 @@ namespace scene
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0; virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0;
//! Initializes the terrain data. Loads the vertices from the heightMapFile. //! Initializes the terrain data. Loads the vertices from the heightMapFile.
/** The file must contain a loadable image of the heightmap. The heightmap
must be square.
\param file The file to read the image from. File is not rewinded.
\param vertexColor Color of all vertices.
\param smoothFactor Number of smoothing passes. */
virtual bool loadHeightMap(io::IReadFile* file, virtual bool loadHeightMap(io::IReadFile* file,
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0; video::SColor vertexColor=video::SColor(255,255,255,255),
s32 smoothFactor=0) =0;
//! Initializes the terrain data. Loads the vertices from the heightMapFile. //! Initializes the terrain data. Loads the vertices from the heightMapFile.
/** The data is interpreted as signed integers of the given bit size. Allowed /** The data is interpreted as (signed) integers of the given bit size or
values are 8, 16, and 32. The heightmap must be square. */ floats (with 32bits, signed). Allowed bitsizes for integers are
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16, 8, 16, and 32. The heightmap must be square.
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0; \param file The file to read the RAW data from. File is not rewinded.
\param bitsPerPixel Size of data if integers used, for floats always use 32.
\param signedData Whether we use signed or unsigned ints, ignored for floats.
\param floatVals Whether the data is float or int.
\param width Width (and also Height, as it must be square) of the heightmap. Use 0 for autocalculating from the filesize.
\param vertexColor Color of all vertices.
\param smoothFactor Number of smoothing passes. */
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel=16,
bool signedData=false, bool floatVals=false, s32 width=0,
video::SColor vertexColor=video::SColor(255,255,255,255),
s32 smoothFactor=0) =0;
}; };
......
...@@ -667,7 +667,7 @@ namespace video ...@@ -667,7 +667,7 @@ namespace video
Specifies where fog starts. Specifies where fog starts.
\param end Only used in linear fog mode (linearFog=true). \param end Only used in linear fog mode (linearFog=true).
Specifies where fog ends. Specifies where fog ends.
\param density Only used in expotential fog mode \param density Only used in exponential fog mode
(linearFog=false). Must be a value between 0 and 1. (linearFog=false). Must be a value between 0 and 1.
\param pixelFog Set this to false for vertex fog, and true if \param pixelFog Set this to false for vertex fog, and true if
you want per-pixel fog. you want per-pixel fog.
......
...@@ -709,8 +709,8 @@ namespace core ...@@ -709,8 +709,8 @@ namespace core
} }
//! Returns a rotation that is equivalent to that set by setRotationDegrees(). //! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return /** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node. */ be equivalent, i.e. will have the same result when used to rotate a vector or node. */
template <class T> template <class T>
......
...@@ -235,8 +235,8 @@ void CCameraSceneNode::OnRegisterSceneNode() ...@@ -235,8 +235,8 @@ void CCameraSceneNode::OnRegisterSceneNode()
up.X += 0.5f; up.X += 0.5f;
} }
ViewArea.Matrices [ video::ETS_VIEW ].buildCameraLookAtMatrixLH(pos, Target, up); ViewArea.Matrices[video::ETS_VIEW].buildCameraLookAtMatrixLH(pos, Target, up);
ViewArea.setTransformState ( video::ETS_VIEW ); ViewArea.setTransformState(video::ETS_VIEW);
recalculateViewArea(); recalculateViewArea();
if ( SceneManager->getActiveCamera () == this ) if ( SceneManager->getActiveCamera () == this )
...@@ -275,7 +275,7 @@ const SViewFrustum* CCameraSceneNode::getViewFrustum() const ...@@ -275,7 +275,7 @@ const SViewFrustum* CCameraSceneNode::getViewFrustum() const
void CCameraSceneNode::recalculateViewArea() void CCameraSceneNode::recalculateViewArea()
{ {
ViewArea.cameraPosition = getAbsolutePosition(); ViewArea.cameraPosition = getAbsolutePosition();
ViewArea.setFrom ( ViewArea.Matrices [ SViewFrustum::ETS_VIEW_PROJECTION_3 ] ); ViewArea.setFrom(ViewArea.Matrices[SViewFrustum::ETS_VIEW_PROJECTION_3]);
} }
...@@ -318,6 +318,7 @@ void CCameraSceneNode::bindTargetAndRotation(bool bound) ...@@ -318,6 +318,7 @@ void CCameraSceneNode::bindTargetAndRotation(bool bound)
TargetAndRotationAreBound = bound; TargetAndRotationAreBound = bound;
} }
//! Gets the binding between the camera's rotation and target. //! Gets the binding between the camera's rotation and target.
bool CCameraSceneNode::getTargetAndRotationBinding(void) const bool CCameraSceneNode::getTargetAndRotationBinding(void) const
{ {
......
...@@ -378,7 +378,7 @@ bool CGUIContextMenu::highlight(const core::position2d<s32>& p, bool canOpenSubM ...@@ -378,7 +378,7 @@ bool CGUIContextMenu::highlight(const core::position2d<s32>& p, bool canOpenSubM
for (s32 j=0; j<(s32)Items.size(); ++j) for (s32 j=0; j<(s32)Items.size(); ++j)
if (Items[j].SubMenu) if (Items[j].SubMenu)
{ {
if ( j == i && canOpenSubMenu ) if ( j == i && canOpenSubMenu && Items[j].Enabled )
Items[j].SubMenu->setVisible(true); Items[j].SubMenu->setVisible(true);
else if ( j != i ) else if ( j != i )
Items[j].SubMenu->setVisible(false); Items[j].SubMenu->setVisible(false);
......
...@@ -83,6 +83,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) ...@@ -83,6 +83,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
// enable key to character translation // enable key to character translation
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
if ( CreationParams.Fullscreen ) if ( CreationParams.Fullscreen )
SDL_Flags |= SDL_FULLSCREEN; SDL_Flags |= SDL_FULLSCREEN;
if (CreationParams.DriverType == video::EDT_OPENGL) if (CreationParams.DriverType == video::EDT_OPENGL)
......
...@@ -619,6 +619,9 @@ void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& t ...@@ -619,6 +619,9 @@ void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& t
c8 c=0; c8 c=0;
token = ""; token = "";
if (file->getPos() >= file->getSize())
return;
file->read(&c, sizeof(c8)); file->read(&c, sizeof(c8));
// search for word beginning // search for word beginning
while ( core::isspace(c) && (file->getPos() < file->getSize())) while ( core::isspace(c) && (file->getPos() < file->getSize()))
...@@ -835,6 +838,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique ...@@ -835,6 +838,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
} }
else if (token=="texture_unit") else if (token=="texture_unit")
{ {
#ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Texture unit");
#endif
getMaterialToken(file, token); //open brace getMaterialToken(file, token); //open brace
getMaterialToken(file, token); getMaterialToken(file, token);
while(token != "}") while(token != "}")
...@@ -842,6 +848,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique ...@@ -842,6 +848,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
if (token=="texture") if (token=="texture")
{ {
getMaterialToken(file, pass.Texture.Filename); getMaterialToken(file, pass.Texture.Filename);
#ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Texture", pass.Texture.Filename.c_str());
#endif
getMaterialToken(file, pass.Texture.CoordsType, true); getMaterialToken(file, pass.Texture.CoordsType, true);
getMaterialToken(file, pass.Texture.MipMaps, true); getMaterialToken(file, pass.Texture.MipMaps, true);
getMaterialToken(file, pass.Texture.Alpha, true); getMaterialToken(file, pass.Texture.Alpha, true);
......
...@@ -648,11 +648,11 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ...@@ -648,11 +648,11 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
rotateSpeed, zoomSpeed, translationSpeed); rotateSpeed, zoomSpeed, translationSpeed);
node->addAnimator(anm); node->addAnimator(anm);
setActiveCamera(node);
anm->drop(); anm->drop();
node->drop(); node->drop();
setActiveCamera(node);
return node; return node;
} }
...@@ -674,11 +674,10 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, ...@@ -674,11 +674,10 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
node->bindTargetAndRotation(true); node->bindTargetAndRotation(true);
node->addAnimator(anm); node->addAnimator(anm);
anm->drop();
node->drop();
setActiveCamera(node); setActiveCamera(node);
anm->drop();
node->drop();
return node; return node;
} }
......
...@@ -21,8 +21,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu ...@@ -21,8 +21,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement) SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement)
: CursorControl(cursorControl), MaxVerticalAngle(88.0f), : CursorControl(cursorControl), MaxVerticalAngle(88.0f),
MoveSpeed(moveSpeed/1000.0f), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), MoveSpeed(moveSpeed/1000.0f), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement), LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
KeyMapArray(keyMapArray), KeyMapSize(keyMapSize)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CCameraSceneNodeAnimatorFPS"); setDebugName("CCameraSceneNodeAnimatorFPS");
...@@ -34,7 +33,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu ...@@ -34,7 +33,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
allKeysUp(); allKeysUp();
// create key map // create key map
if (!KeyMapArray || !KeyMapSize) if (!keyMapArray || !keyMapSize)
{ {
// create default key map // create default key map
KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP)); KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP));
...@@ -46,7 +45,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu ...@@ -46,7 +45,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
else else
{ {
// create custom key map // create custom key map
setKeyMap(KeyMapArray, KeyMapSize); setKeyMap(keyMapArray, keyMapSize);
} }
} }
...@@ -272,7 +271,6 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count) ...@@ -272,7 +271,6 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
{ {
// clear the keymap // clear the keymap
KeyMap.clear(); KeyMap.clear();
KeyMapArray=map;
// add actions // add actions
for (u32 i=0; i<count; ++i) for (u32 i=0; i<count; ++i)
...@@ -295,20 +293,30 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count) ...@@ -295,20 +293,30 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
} }
} }
//! Sets whether vertical movement should be allowed. //! Sets whether vertical movement should be allowed.
void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow) void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow)
{ {
NoVerticalMovement = !allow; NoVerticalMovement = !allow;
} }
ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager) ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager)
{ {
CSceneNodeAnimatorCameraFPS * newAnimator = CSceneNodeAnimatorCameraFPS * newAnimator =
new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, (MoveSpeed * 1000.0f), JumpSpeed, new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, (MoveSpeed * 1000.0f), JumpSpeed,
KeyMapArray, KeyMapSize, NoVerticalMovement); 0, 0, NoVerticalMovement);
newAnimator->setKeyMap(KeyMap);
return newAnimator; return newAnimator;
} }
void CSceneNodeAnimatorCameraFPS::setKeyMap(const core::array<SCamKeyMap>& keymap)
{
KeyMap=keymap;
}
} // namespace scene } // namespace scene
} // namespace irr } // namespace irr
...@@ -77,8 +77,6 @@ namespace scene ...@@ -77,8 +77,6 @@ namespace scene
this. */ this. */
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
private:
struct SCamKeyMap struct SCamKeyMap
{ {
SCamKeyMap() {}; SCamKeyMap() {};
...@@ -88,6 +86,12 @@ namespace scene ...@@ -88,6 +86,12 @@ namespace scene
EKEY_CODE keycode; EKEY_CODE keycode;
}; };
//! Sets the keyboard mapping for this animator
/** Helper function for the clone method.
\param keymap the new keymap array */
void setKeyMap(const core::array<SCamKeyMap>& keymap);
private:
void allKeysUp(); void allKeysUp();
gui::ICursorControl *CursorControl; gui::ICursorControl *CursorControl;
...@@ -108,9 +112,6 @@ namespace scene ...@@ -108,9 +112,6 @@ namespace scene
bool firstUpdate; bool firstUpdate;
bool NoVerticalMovement; bool NoVerticalMovement;
SKeyMap* KeyMapArray;
u32 KeyMapSize;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -18,7 +18,7 @@ CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* ...@@ -18,7 +18,7 @@ CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl*
ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate), ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate),
RotateStartX(0.0f), RotateStartY(0.0f), ZoomStartX(0.0f), ZoomStartY(0.0f), RotateStartX(0.0f), RotateStartY(0.0f), ZoomStartX(0.0f), ZoomStartY(0.0f),
TranslateStartX(0.0f), TranslateStartY(0.0f), CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), TranslateStartX(0.0f), TranslateStartY(0.0f), CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f),
Target(0,0,0), OldTarget(0,0,0), OldCamera(0), MousePos(0.5f, 0.5f) OldCamera(0), MousePos(0.5f, 0.5f)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CSceneNodeAnimatorCameraMaya"); setDebugName("CSceneNodeAnimatorCameraMaya");
...@@ -133,18 +133,14 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ...@@ -133,18 +133,14 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
nZoom = old; nZoom = old;
} }
} }
else else if (Zooming)
{ {
if (Zooming) f32 old = CurrentZoom;
{ CurrentZoom = CurrentZoom + (ZoomStartX - MousePos.X ) * ZoomSpeed;
f32 old = CurrentZoom; nZoom = CurrentZoom;
CurrentZoom = CurrentZoom + (ZoomStartX - MousePos.X ) * ZoomSpeed;
nZoom = CurrentZoom;
if (nZoom < 0)
nZoom = CurrentZoom = old;
}
if (nZoom < 0)
nZoom = CurrentZoom = old;
Zooming = false; Zooming = false;
} }
...@@ -175,15 +171,11 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ...@@ -175,15 +171,11 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed; tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
} }
} }
else else if (Translating)
{ {
if (Translating) translate += tvectX * (TranslateStartX - MousePos.X)*TranslateSpeed +
{ tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
translate += tvectX * (TranslateStartX - MousePos.X)*TranslateSpeed + OldTarget = translate;
tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
OldTarget = translate;
}
Translating = false; Translating = false;
} }
...@@ -205,16 +197,12 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ...@@ -205,16 +197,12 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
nRotY += (RotateStartY - MousePos.Y) * RotateSpeed; nRotY += (RotateStartY - MousePos.Y) * RotateSpeed;
} }
} }
else else if (Rotating)
{ {
if (Rotating) RotX = RotX + (RotateStartX - MousePos.X) * RotateSpeed;
{ RotY = RotY + (RotateStartY - MousePos.Y) * RotateSpeed;
RotX = RotX + (RotateStartX - MousePos.X) * RotateSpeed; nRotX = RotX;
RotY = RotY + (RotateStartY - MousePos.Y) * RotateSpeed; nRotY = RotY;
nRotX = RotX;
nRotY = RotY;
}
Rotating = false; Rotating = false;
} }
......
...@@ -231,22 +231,33 @@ namespace scene ...@@ -231,22 +231,33 @@ namespace scene
//! Initializes the terrain data. Loads the vertices from the heightMapFile //! Initializes the terrain data. Loads the vertices from the heightMapFile
bool CTerrainSceneNode::loadHeightMapRAW( io::IReadFile* file, s32 bitsPerPixel, video::SColor vertexColor, s32 smoothFactor ) bool CTerrainSceneNode::loadHeightMapRAW( io::IReadFile* file, s32 bitsPerPixel, bool signedData, bool floatVals, s32 width, video::SColor vertexColor, s32 smoothFactor )
{ {
if( !file ) if (!file)
return false;
if (floatVals && bitsPerPixel != 32)
return false; return false;
Mesh.MeshBuffers.clear();
// start reading // start reading
const u32 startTime = os::Timer::getTime(); const u32 startTime = os::Timer::getTime();
// get file size Mesh.MeshBuffers.clear();
const long fileSize = file->getSize();
// TODO: Currently no floats are supported
const s32 bytesPerPixel = bitsPerPixel / 8; const s32 bytesPerPixel = bitsPerPixel / 8;
// Get the dimension of the heightmap data // Get the dimension of the heightmap data
TerrainData.Size = core::floor32(sqrtf( (f32)( fileSize / bytesPerPixel ) )); const s32 filesize = file->getSize();
if (!width)
TerrainData.Size = core::floor32(sqrtf( (f32)( filesize / bytesPerPixel ) ));
else
{
if ((filesize-file->getPos())/bytesPerPixel>width*width)
{
os::Printer::log("Error reading heightmap RAW file", "File is too small.");
return false;
}
TerrainData.Size = width;
}
switch( TerrainData.PatchSize ) switch( TerrainData.PatchSize )
{ {
...@@ -316,45 +327,78 @@ namespace scene ...@@ -316,45 +327,78 @@ namespace scene
float fz2=0.f; float fz2=0.f;
for( s32 z = 0; z < TerrainData.Size; ++z ) for( s32 z = 0; z < TerrainData.Size; ++z )
{ {
bool failure=false;
vertex.Pos.X = fx; vertex.Pos.X = fx;
switch (bytesPerPixel) if (floatVals)
{
if( file->read( &vertex.Pos.Y, bytesPerPixel ) != bytesPerPixel )
failure=true;
}
else if (signedData)
{ {
case 1: switch (bytesPerPixel)
{ {
s8 val; case 1:
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
{ {
os::Printer::log("Error reading heightmap RAW file."); s8 val;
mb->drop(); if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
return false; failure=true;
vertex.Pos.Y=val;
} }
vertex.Pos.Y=val; break;
} case 2:
break;
case 2:
{
s16 val;
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
{ {
os::Printer::log("Error reading heightmap RAW file."); s16 val;
mb->drop(); if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
return false; failure=true;
vertex.Pos.Y=val/256.f;
} }
vertex.Pos.Y=val; break;
case 4:
{
s32 val;
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
failure=true;
vertex.Pos.Y=val/16777216.f;
}
break;
} }
break; }
case 4: else
{
switch (bytesPerPixel)
{ {
s32 val; case 1:
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
{ {
os::Printer::log("Error reading heightmap RAW file."); u8 val;
mb->drop(); if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
return false; failure=true;
vertex.Pos.Y=val;
} }
vertex.Pos.Y=(f32)val; break;
case 2:
{
u16 val;
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
failure=true;
vertex.Pos.Y=val/256.f;
}
break;
case 4:
{
u32 val;
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
failure=true;
vertex.Pos.Y=val/16777216.f;
}
break;
} }
break; }
if (failure)
{
os::Printer::log("Error reading heightmap RAW file.");
mb->drop();
return false;
} }
vertex.Pos.Z = fz; vertex.Pos.Z = fz;
......
...@@ -55,7 +55,7 @@ namespace scene ...@@ -55,7 +55,7 @@ namespace scene
//! Initializes the terrain data. Loads the vertices from the heightMapFile. //! Initializes the terrain data. Loads the vertices from the heightMapFile.
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16, virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16,
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); bool signedData=true, bool floatVals=false, s32 width=0, video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 );
//! Returns the material based on the zero based index i. This scene node only uses //! Returns the material based on the zero based index i. This scene node only uses
//! 1 material. //! 1 material.
......
...@@ -41,7 +41,7 @@ namespace irr ...@@ -41,7 +41,7 @@ namespace irr
namespace core namespace core
{ {
IRRLICHT_API const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
} }
} // end namespace irr } // end namespace irr
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -89,7 +89,7 @@ sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm ...@@ -89,7 +89,7 @@ sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm
#Windows specific options #Windows specific options
sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc
sharedlib_win32: LDFLAGS = -lgdi32 -lopengl32 -ld3dx9d sharedlib_win32: LDFLAGS = -lgdi32 -lopengl32 -ld3dx9d -lwinmm
sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
......
...@@ -6,7 +6,7 @@ NDEBUG = 1; ...@@ -6,7 +6,7 @@ NDEBUG = 1;
PROFILE = 1; PROFILE = 1;
APPLICATION_NAME = 'Irrlicht'; APPLICATION_NAME = 'Irrlicht';
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d']; LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d', 'winmm'];
if USE_GCC==1 and PROFILE==1: if USE_GCC==1 and PROFILE==1:
LIBRARIES += ['gmon']; LIBRARIES += ['gmon'];
......
// Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h> #include <assert.h>
...@@ -8,40 +12,71 @@ using namespace video; ...@@ -8,40 +12,71 @@ using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
/** This tests verifies that textures opened from different places in the filesystem
can be distinguished, even if they have the same filename. */
bool disambiguateTextures(void) bool disambiguateTextures(void)
{ {
IrrlichtDevice *device = IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16, createDevice( video::EDT_NULL, dimension2d<s32>(640, 480));
false, false, false, 0);
if (!device) if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
if(-1 == wd.find("/tests") && -1 == wd.find("\\tests"))
{
logTestString("The tests must be run from the /tests directory, regardless of where\n"\
"the test executable was built.\n");
device->drop();
return false; return false;
}
IVideoDriver * driver = device->getVideoDriver(); IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png"); ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png"); ITexture * tex2 = driver->getTexture("../media/tools.png");
assert(tex2);
if(!tex2)
logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png"); IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile); assert(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile); ITexture * tex3 = driver->getTexture(readFile);
assert(tex3);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop(); readFile->drop();
// Expects an empty tmp/tmp directory under this app's wd and // All 3 of the above textures should be identical.
// a media directory under this apps' directory with tools.png in it. assert(tex1 == tex2 && tex1 == tex3);
stringc wd = device->getFileSystem()->getWorkingDirectory();
stringc newWd = wd + "/empty/empty"; stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str()); bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed); assert(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png"); ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4); assert(tex4);
assert(tex1 == tex2 && tex1 == tex3 && tex1 != tex4); if(!tex4)
logTestString("Unable to open ../../media/tools.png\n");
assert(tex1 != tex4);
// The working directory must be restored for the other tests to work.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str()); changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->drop(); device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false; return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
} }
// Tests IVideoDriver::drawPixel(). // Copyright (C) 2008 Colin MacDonald
// Expect to see two diagonal lines overlaying a wall texture cube. // No rights reserved: this software is in the public domain.
// One line should run from red at the top left to green at the bottom right.
// The other should run from cyan 100% transparent at the bottom left to
// cyan 100% opaque at the top right.
#include "irrlicht.h" #include "irrlicht.h"
#include "testUtils.h" #include "testUtils.h"
...@@ -14,16 +11,21 @@ using namespace video; ...@@ -14,16 +11,21 @@ using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
//! Tests IVideoDriver::drawPixel().
/** Expect to see two diagonal lines overlaying a wall texture cube.
One line should run from green at the top left to red at the bottom right.
The other should run from cyan 100% transparent at the bottom left to
cyan 100% opaque at the top right. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType) static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{ {
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480)); IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(160, 120), 32);
if (!device) if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver(); IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager(); ISceneManager * smgr = device->getSceneManager();
// Draw a cube to check that the pixels' alpha is working. // Draw a cube background so that we can check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60)); ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false); cube->setMaterialFlag(video::EMF_LIGHTING, false);
...@@ -32,18 +34,18 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType) ...@@ -32,18 +34,18 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
driver->beginScene(true, true, SColor(255,100,101,140)); driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll(); smgr->drawAll();
// Test for offscreen values as well as onscreen. // Test for benign handling of offscreen pixel values as well as onscreen ones.
for(s32 x = -10; x < 650; ++x) for(s32 x = -10; x < 170; ++x)
{ {
s32 y = 480 * x / 640; s32 y = 120 * x / 160;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0)); driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 480 - y; y = 120 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255)); driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
} }
driver->endScene(); driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.jpg"); bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.png");
device->drop(); device->drop();
...@@ -55,12 +57,11 @@ bool drawPixel(void) ...@@ -55,12 +57,11 @@ bool drawPixel(void)
{ {
bool passed = true; bool passed = true;
passed |= runTestWithDriver(EDT_NULL); // Don't use the NULL or SOFTWARE drivers since they produce no image, and a 16 bit screenshot respectively.
passed |= runTestWithDriver(EDT_SOFTWARE); passed &= runTestWithDriver(EDT_BURNINGSVIDEO);
passed |= runTestWithDriver(EDT_BURNINGSVIDEO); passed &= runTestWithDriver(EDT_OPENGL);
passed |= runTestWithDriver(EDT_OPENGL); passed &= runTestWithDriver(EDT_DIRECT3D8);
passed |= runTestWithDriver(EDT_DIRECT3D8); passed &= runTestWithDriver(EDT_DIRECT3D9);
passed |= runTestWithDriver(EDT_DIRECT3D9);
return passed; return passed;
} }
......
// Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include "irrlicht.h"
//! Tests that symbols exported from Irrlicht can be used by the user app.
bool exports(void)
{
irr::core::matrix4 identity = irr::core::IdentityMatrix;
(void)identity; // Satisfy the compiler that it's used.
// If it built, we're done.
return true;
}
// Test the accuracy and speed of // Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h> #include <assert.h>
#include <float.h> #include <float.h>
...@@ -8,6 +10,7 @@ ...@@ -8,6 +10,7 @@
using namespace irr; using namespace irr;
using namespace core; using namespace core;
//! This was an older Irrlicht implementation, tested against for reference.
static inline u32 old_strtol10(const char* in, const char** out=0) static inline u32 old_strtol10(const char* in, const char** out=0)
{ {
u32 value = 0; u32 value = 0;
...@@ -22,9 +25,7 @@ static inline u32 old_strtol10(const char* in, const char** out=0) ...@@ -22,9 +25,7 @@ static inline u32 old_strtol10(const char* in, const char** out=0)
return value; return value;
} }
//! Provides a fast function for converting a string into a float, //! This was an older Irrlicht implementation, tested against for reference.
//! about 6 times faster than atof in win32.
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
static inline const char* old_fast_atof_move( const char* c, float& out) static inline const char* old_fast_atof_move( const char* c, float& out)
{ {
bool inv = false; bool inv = false;
...@@ -75,6 +76,7 @@ static inline const char* old_fast_atof_move( const char* c, float& out) ...@@ -75,6 +76,7 @@ static inline const char* old_fast_atof_move( const char* c, float& out)
return c; return c;
} }
//! This was an older Irrlicht implementation, tested against for reference.
static inline float old_fast_atof(const char* c) static inline float old_fast_atof(const char* c)
{ {
float ret; float ret;
...@@ -89,17 +91,18 @@ static bool testCalculation(const char * valueString) ...@@ -89,17 +91,18 @@ static bool testCalculation(const char * valueString)
const f32 oldFastValue = old_fast_atof(valueString); const f32 oldFastValue = old_fast_atof(valueString);
const f32 atofValue = (f32)atof(valueString); const f32 atofValue = (f32)atof(valueString);
(void)printf("\n String '%s'\n New fast %.40f\n Old fast %.40f\n atof %.40f\n", logTestString("\n String '%s'\n New fast %.40f\n Old fast %.40f\n atof %.40f\n",
valueString, newFastValue, oldFastValue, atofValue); valueString, newFastValue, oldFastValue, atofValue);
bool accurate = fabs(newFastValue - atofValue) <= fabs(oldFastValue - atofValue); bool accurate = fabs(newFastValue - atofValue) <= fabs(oldFastValue - atofValue);
if(!accurate) if(!accurate)
(void)printf("*** ERROR - less accurate than old method ***\n\n"); logTestString("*** ERROR - less accurate than old method ***\n\n");
return accurate; return accurate;
} }
//! Test both the accuracy and speed of Irrlicht's fast_atof() implementation.
bool fast_atof(void) bool fast_atof(void)
{ {
bool accurate = true; bool accurate = true;
...@@ -132,7 +135,7 @@ bool fast_atof(void) ...@@ -132,7 +135,7 @@ bool fast_atof(void)
if(!accurate) if(!accurate)
{ {
(void)printf("Calculation is not accurate, so the speed is irrelevant\n"); logTestString("Calculation is not accurate, so the speed is irrelevant\n");
return false; return false;
} }
...@@ -161,13 +164,13 @@ bool fast_atof(void) ...@@ -161,13 +164,13 @@ bool fast_atof(void)
value = old_fast_atof("-340282346638528859811704183484516925440.000000"); value = old_fast_atof("-340282346638528859811704183484516925440.000000");
const u32 oldFastAtofTime = timer->getRealTime() - then; const u32 oldFastAtofTime = timer->getRealTime() - then;
(void)printf(" atof time = %d\n fast_atof Time = %d\nold fast_atof time = %d\n", logTestString(" atof time = %d\n fast_atof Time = %d\nold fast_atof time = %d\n",
atofTime, fastAtofTime, oldFastAtofTime); atofTime, fastAtofTime, oldFastAtofTime);
device->drop(); device->drop();
if(fastAtofTime > atofTime) if(fastAtofTime > atofTime)
{ {
(void)printf("The fast method is slower than atof()\n"); logTestString("The fast method is slower than atof()\n");
return false; return false;
} }
......
// Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "irrlicht.h"
#include "testUtils.h"
#include <assert.h>
using namespace irr;
using namespace core;
using namespace gui;
// Tests that disabled GUI menu items don't cause their submenu to appear when hovered over.
/**
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=178436#178436
*/
bool guiDisabledMenu(void)
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<s32>(160, 40), 32);
assert(device);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
gui::IGUIContextMenu* menu = env->addMenu();
menu->addItem(L"Menu", -1, true, true);
gui::IGUIContextMenu* subMenu = menu->getSubMenu(0);
subMenu->addItem(L"Submenu 1", -1, false, true);
gui::IGUIContextMenu* subSubMenu = subMenu->getSubMenu(0);
subSubMenu->addItem(L"Final item");
SEvent event;
event.EventType = EET_MOUSE_INPUT_EVENT;
event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
event.MouseInput.X = menu->getAbsolutePosition().UpperLeftCorner.X + 1;
event.MouseInput.Y = menu->getAbsolutePosition().UpperLeftCorner.Y + 1;
(void)menu->OnEvent(event);
// Hovering over the disabled submenu shouldn't cause the "Final item" to appear.
event.MouseInput.Event = EMIE_MOUSE_MOVED;
event.MouseInput.X = subMenu->getAbsolutePosition().UpperLeftCorner.X + 40;
event.MouseInput.Y = subMenu->getAbsolutePosition().UpperLeftCorner.Y + 10;
(void)menu->OnEvent(event);
device->run();
driver->beginScene(true, true, video::SColor(150,50,50,50));
env->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-guiDisabledMenu.png");
device->drop();
return result;
}
// Test the functionality of line2d>T>::intersectWith(). // Copyright (C) 2008 Colin MacDonald
// Validation is done with asserts() on back-of-an-envelope // No rights reserved: this software is in the public domain.
// expected results.
#include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h> #include <assert.h>
...@@ -15,23 +15,23 @@ static bool testLines(line2df const & line1, ...@@ -15,23 +15,23 @@ static bool testLines(line2df const & line1,
{ {
bool gotExpectedResult = true; bool gotExpectedResult = true;
(void)printf("\nLine 1 = %.1f %.1f to %.1f %.1f \n", logTestString("\nLine 1 = %.1f %.1f to %.1f %.1f \n",
line1.start.X, line1.start.Y, line1.start.X, line1.start.Y,
line1.end.X, line1.end.Y); line1.end.X, line1.end.Y);
(void)printf("Line 2 = %.1f %.1f to %.1f %.1f\n", logTestString("Line 2 = %.1f %.1f to %.1f %.1f\n",
line2.start.X, line2.start.Y, line2.start.X, line2.start.Y,
line2.end.X, line2.end.Y); line2.end.X, line2.end.Y);
vector2df intersection; vector2df intersection;
(void)printf("line1 with line2 = "); logTestString("line1 with line2 = ");
if(line1.intersectWith(line2, intersection)) if(line1.intersectWith(line2, intersection))
{ {
(void)printf("hit at %.1f %.1f - ", logTestString("hit at %.1f %.1f - ",
intersection.X, intersection.Y); intersection.X, intersection.Y);
if(!line1.isPointOnLine(intersection) || !line2.isPointOnLine(intersection)) if(!line1.isPointOnLine(intersection) || !line2.isPointOnLine(intersection))
{ {
(void)printf("ERROR! point is not on both lines - "); logTestString("ERROR! point is not on both lines - ");
gotExpectedResult = false; gotExpectedResult = false;
} }
...@@ -39,43 +39,43 @@ static bool testLines(line2df const & line1, ...@@ -39,43 +39,43 @@ static bool testLines(line2df const & line1,
{ {
if(intersection == expectedIntersection) if(intersection == expectedIntersection)
{ {
(void)printf("expected\n"); logTestString("expected\n");
} }
else else
{ {
(void)printf("unexpected intersection (expected %.1f %.1f)\n", logTestString("unexpected intersection (expected %.1f %.1f)\n",
expectedIntersection.X, expectedIntersection.Y); expectedIntersection.X, expectedIntersection.Y);
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
else else
{ {
(void)printf("UNEXPECTED\n"); logTestString("UNEXPECTED\n");
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
else else
{ {
(void)printf("miss - "); logTestString("miss - ");
if(!expectedHit) if(!expectedHit)
{ {
(void)printf("expected\n"); logTestString("expected\n");
} }
else else
{ {
(void)printf("UNEXPECTED\n"); logTestString("UNEXPECTED\n");
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
(void)printf("line2 with line1 = "); logTestString("line2 with line1 = ");
if(line2.intersectWith(line1, intersection)) if(line2.intersectWith(line1, intersection))
{ {
(void)printf("hit at %.1f %.1f - ", logTestString("hit at %.1f %.1f - ",
intersection.X, intersection.Y); intersection.X, intersection.Y);
if(!line1.isPointOnLine(intersection) || !line2.isPointOnLine(intersection)) if(!line1.isPointOnLine(intersection) || !line2.isPointOnLine(intersection))
{ {
(void)printf("ERROR! point is not on both lines - "); logTestString("ERROR! point is not on both lines - ");
gotExpectedResult = false; gotExpectedResult = false;
} }
...@@ -83,31 +83,31 @@ static bool testLines(line2df const & line1, ...@@ -83,31 +83,31 @@ static bool testLines(line2df const & line1,
{ {
if(intersection == expectedIntersection) if(intersection == expectedIntersection)
{ {
(void)printf("expected\n"); logTestString("expected\n");
} }
else else
{ {
(void)printf("unexpected intersection (expected %.1f %.1f)\n", logTestString("unexpected intersection (expected %.1f %.1f)\n",
expectedIntersection.X, expectedIntersection.Y); expectedIntersection.X, expectedIntersection.Y);
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
else else
{ {
(void)printf("UNEXPECTED\n"); logTestString("UNEXPECTED\n");
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
else else
{ {
(void)printf("miss - "); logTestString("miss - ");
if(!expectedHit) if(!expectedHit)
{ {
(void)printf("expected\n"); logTestString("expected\n");
} }
else else
{ {
(void)printf("UNEXPECTED\n"); logTestString("UNEXPECTED\n");
gotExpectedResult = false; gotExpectedResult = false;
} }
} }
...@@ -115,6 +115,8 @@ static bool testLines(line2df const & line1, ...@@ -115,6 +115,8 @@ static bool testLines(line2df const & line1,
return gotExpectedResult; return gotExpectedResult;
} }
// Test the functionality of line2d>T>::intersectWith().
/** Validation is done with asserts() against expected results. */
bool line2dIntersectWith(void) bool line2dIntersectWith(void)
{ {
bool allExpected = true; bool allExpected = true;
...@@ -217,9 +219,9 @@ bool line2dIntersectWith(void) ...@@ -217,9 +219,9 @@ bool line2dIntersectWith(void)
true, vector2df(1.5f, 1.5f)); true, vector2df(1.5f, 1.5f));
if(allExpected) if(allExpected)
(void)printf("\nAll tests passed\n"); logTestString("\nAll tests passed\n");
else else
(void)printf("\nFAIL!\n"); logTestString("\nFAIL!\n");
return allExpected; return allExpected;
} }
......
// This is the entry point for the Irrlicht test suite. // This is the entry point for the Irrlicht test suite.
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#include "testUtils.h"
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <assert.h>
// This is an MSVC pragma to link against the Irrlicht library. // This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files. // Other builds must link against it in the project files.
...@@ -17,10 +19,11 @@ ...@@ -17,10 +19,11 @@
*/ */
#define RUN_TEST(testEntryPoint)\ #define RUN_TEST(testEntryPoint)\
extern bool testEntryPoint(void);\ extern bool testEntryPoint(void);\
logTestString("\nStarting test '" #testEntryPoint "'\n");\
if(!testEntryPoint()) \ if(!testEntryPoint()) \
{\ {\
(void)printf("\n\n\n******** Test failure ********\nTest '" #testEntryPoint "' failed\n"\ (void)printf("\n\n\n******** Test failure ********\nTest '" #testEntryPoint "' failed\n"\
"******** Test failure ********\n\nPress return to continue\n\a\a\a");\ "******** Test failure ********\n\nPress return to continue\n");\
(void)getc(stdin);\ (void)getc(stdin);\
fails++;\ fails++;\
} }
...@@ -29,16 +32,21 @@ ...@@ -29,16 +32,21 @@
/** \return The number of test that failed, i.e. 0 is success. */ /** \return The number of test that failed, i.e. 0 is success. */
int main() int main()
{ {
bool logFileOpened = openTestLog();
assert(logFileOpened);
int fails = 0; int fails = 0;
RUN_TEST(disambiguateTextures); // Run this first, since it validates the WD.
RUN_TEST(exports);
RUN_TEST(testVector3d); RUN_TEST(testVector3d);
RUN_TEST(testVector2d); RUN_TEST(testVector2d);
RUN_TEST(planeMatrix); RUN_TEST(planeMatrix);
RUN_TEST(fast_atof); RUN_TEST(fast_atof);
RUN_TEST(line2dIntersectWith); RUN_TEST(line2dIntersectWith);
RUN_TEST(disambiguateTextures);
RUN_TEST(drawPixel); RUN_TEST(drawPixel);
RUN_TEST(md2Animation); RUN_TEST(md2Animation);
RUN_TEST(guiDisabledMenu);
(void)printf("\nTests finished. %d test%s failed.\n", fails, 1 == fails ? "" : "s"); (void)printf("\nTests finished. %d test%s failed.\n", fails, 1 == fails ? "" : "s");
......
// This test validates the last frame of a non-looped MD2 animation // Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "irrlicht.h" #include "irrlicht.h"
#include "testUtils.h" #include "testUtils.h"
...@@ -11,9 +12,12 @@ using namespace video; ...@@ -11,9 +12,12 @@ using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
// Tests MD2 animations.
/** At the moment, this just verifies that the last frame of the animation produces the expected bitmap. */
bool md2Animation(void) bool md2Animation(void)
{ {
IrrlichtDevice *device = createDevice( EDT_OPENGL, dimension2d<s32>(640, 480)); // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<s32>(320, 240), 32);
assert(device); assert(device);
if (!device) if (!device)
return false; return false;
...@@ -39,26 +43,19 @@ bool md2Animation(void) ...@@ -39,26 +43,19 @@ bool md2Animation(void)
(void)smgr->addCameraSceneNode(); (void)smgr->addCameraSceneNode();
// We could just jump to the last frame, but where's the fun in that? // Just jump to the last frame since that's all we're interested in.
// Let's watch the animation, doing the initial run() first so that we
// don't miss any of the fun.
device->run();
node->setMD2Animation(EMAT_DEATH_FALLBACK); node->setMD2Animation(EMAT_DEATH_FALLBACK);
const s32 endFrame = node->getEndFrame(); node->setCurrentFrame((f32)(node->getEndFrame()));
device->run();
while((s32)node->getFrameNr() < endFrame) driver->beginScene(true, true, SColor(255, 255, 255, 0));
{ smgr->drawAll();
device->run(); driver->endScene();
driver->beginScene(true, true, SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
}
} }
} }
bool result = takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.jpg"); bool result = takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
device->drop(); device->drop();
return result; return result;
} }
\ No newline at end of file
// Test the ability to transform a plane with a matrix. // Copyright (C) 2008 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h> #include <assert.h>
...@@ -10,7 +12,7 @@ using namespace video; ...@@ -10,7 +12,7 @@ using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
// There's all sorts of FP accuracy errors here, so use a sloppy comparison. // There's all sorts of minor and inevitable FP accuracy errors here, so use a sloppy comparison.
static bool sloppyComparePlanes(const plane3df plane1, const plane3df plane2) static bool sloppyComparePlanes(const plane3df plane1, const plane3df plane2)
{ {
return(equals(plane1.D, plane2.D, 0.001f) && return(equals(plane1.D, plane2.D, 0.001f) &&
...@@ -24,32 +26,28 @@ static bool transformPlane(const vector3df & point, const vector3df & normal, ...@@ -24,32 +26,28 @@ static bool transformPlane(const vector3df & point, const vector3df & normal,
{ {
plane3df plane(point, vector3df(normal).normalize()); plane3df plane(point, vector3df(normal).normalize());
(void)printf("\n Pre: (%.3ff,%.3ff,%.3ff), %.3ff\n", logTestString("\n Pre: (%.3ff,%.3ff,%.3ff), %.3ff\n",
plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D); plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D);
matrix.transformPlane(plane); matrix.transformPlane(plane);
(void)printf(" Post: (%.3ff,%.3ff,%.3ff), %.3ff\n", logTestString(" Post: (%.3ff,%.3ff,%.3ff), %.3ff\n",
plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D); plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D);
(void)printf("Expected: (%.3ff,%.3ff,%.3ff), %.3ff\n", logTestString("Expected: (%.3ff,%.3ff,%.3ff), %.3ff\n",
expected.Normal.X, expected.Normal.Y, expected.Normal.Z, expected.D); expected.Normal.X, expected.Normal.Y, expected.Normal.Z, expected.D);
// (void)printf("success &= transformPlane(vector3df(%d, %d, %d), vector3df(%d, %d, %d), matrix, plane3df(vector3df(%.3ff,%.3ff,%.3ff), %.3ff));\n",
// (int)point.X, (int)point.Y, (int)point.Z,
// (int)normal.X, (int)normal.Y, (int)normal.Z,
// plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D);
assert(sloppyComparePlanes(plane, expected)); assert(sloppyComparePlanes(plane, expected));
if(!sloppyComparePlanes(plane, expected)) if(!sloppyComparePlanes(plane, expected))
{ {
(void)printf("Unexpected result\n"); logTestString("Unexpected result\n");
return false; return false;
} }
return true; return true;
} }
// Test the ability to transform a plane with a matrix.
bool planeMatrix(void) bool planeMatrix(void)
{ {
matrix4 rotationMatrix; matrix4 rotationMatrix;
...@@ -64,7 +62,7 @@ bool planeMatrix(void) ...@@ -64,7 +62,7 @@ bool planeMatrix(void)
bool success = true; bool success = true;
matrix4 matrix = rotationMatrix; matrix4 matrix = rotationMatrix;
(void)printf("\nRotation matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nRotation matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -83,7 +81,7 @@ bool planeMatrix(void) ...@@ -83,7 +81,7 @@ bool planeMatrix(void)
matrix = translationMatrix; matrix = translationMatrix;
(void)printf("\nTranslation matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nTranslation matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -102,7 +100,7 @@ bool planeMatrix(void) ...@@ -102,7 +100,7 @@ bool planeMatrix(void)
matrix = scaleMatrix; matrix = scaleMatrix;
(void)printf("\nScale matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nScale matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -120,7 +118,7 @@ bool planeMatrix(void) ...@@ -120,7 +118,7 @@ bool planeMatrix(void)
success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.894f,-0.447f,0.000f), 0.894f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.894f,-0.447f,0.000f), 0.894f));
matrix = rotationMatrix * translationMatrix; matrix = rotationMatrix * translationMatrix;
(void)printf("\nRotation * translation matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nRotation * translation matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -138,7 +136,7 @@ bool planeMatrix(void) ...@@ -138,7 +136,7 @@ bool planeMatrix(void)
success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f), 2.828f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f), 2.828f));
matrix = rotationMatrix * scaleMatrix; matrix = rotationMatrix * scaleMatrix;
(void)printf("\nRotation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nRotation * scale matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -156,7 +154,7 @@ bool planeMatrix(void) ...@@ -156,7 +154,7 @@ bool planeMatrix(void)
success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.447f,0.000f,-0.894f), 1.118f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.447f,0.000f,-0.894f), 1.118f));
matrix = translationMatrix * scaleMatrix; matrix = translationMatrix * scaleMatrix;
(void)printf("\nTranslation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nTranslation * scale matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
...@@ -174,7 +172,7 @@ bool planeMatrix(void) ...@@ -174,7 +172,7 @@ bool planeMatrix(void)
success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.894f,-0.447f,0.000f), 2.236f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.894f,-0.447f,0.000f), 2.236f));
matrix = rotationMatrix * translationMatrix * scaleMatrix; matrix = rotationMatrix * translationMatrix * scaleMatrix;
(void)printf("\nRotation * translation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" logTestString("\nRotation * translation * scale matrix\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f" "\n%02.02f %02.02f %02.02f %02.02f"
"\n%02.02f %02.02f %02.02f %02.02f\n", "\n%02.02f %02.02f %02.02f %02.02f\n",
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
// No rights reserved: this software is in the public domain. // No rights reserved: this software is in the public domain.
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#include "testUtils.h" #include "testUtils.h"
#include <memory.h> #include <memory.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <stdarg.h>
#if defined(_MSC_VER) && !defined(NDEBUG)
#include <windows.h>
#endif // #if defined(_MSC_VER) && !defined(NDEBUG)
using namespace irr;
bool binaryCompareFiles(const char * fileName1, const char * fileName2) bool binaryCompareFiles(const char * fileName1, const char * fileName2)
{ {
...@@ -16,19 +22,19 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2) ...@@ -16,19 +22,19 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
return false; return false;
FILE * file1 = fopen(fileName1, "rb"); FILE * file1 = fopen(fileName1, "rb");
assert(file1);
if(!file1) if(!file1)
{ {
(void)printf("binaryCompareFiles: File '%s' cannot be opened\n", fileName1); logTestString("binaryCompareFiles: File '%s' cannot be opened\n", fileName1);
assert(file1);
return false; return false;
} }
FILE * file2 = fopen(fileName2, "rb"); FILE * file2 = fopen(fileName2, "rb");
assert(file2);
if(!file2) if(!file2)
{ {
(void)printf("binaryCompareFiles: File '%s' cannot be opened\n", fileName2); logTestString("binaryCompareFiles: File '%s' cannot be opened\n", fileName2);
(void)fclose(file1); (void)fclose(file1);
assert(file2);
return false; return false;
} }
...@@ -37,7 +43,7 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2) ...@@ -37,7 +43,7 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
(void)fseek(file2, 0, SEEK_END); (void)fseek(file2, 0, SEEK_END);
if(ftell(file1) != ftell(file2)) if(ftell(file1) != ftell(file2))
{ {
(void)printf("binaryCompareFiles: Files are different sizes\n"); logTestString("binaryCompareFiles: Files are different sizes\n");
(void)fclose(file1); (void)fclose(file1);
(void)fclose(file2); (void)fclose(file2);
return false; return false;
...@@ -55,13 +61,13 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2) ...@@ -55,13 +61,13 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
||(fread(file1Buffer, sizeof(file1Buffer), 1, file1) != ||(fread(file1Buffer, sizeof(file1Buffer), 1, file1) !=
fread(file2Buffer, sizeof(file2Buffer), 1, file2))) fread(file2Buffer, sizeof(file2Buffer), 1, file2)))
{ {
(void)printf("binaryCompareFiles: Error during file reading\n"); logTestString("binaryCompareFiles: Error during file reading\n");
break; break;
} }
if(memcmp(file1Buffer, file2Buffer, sizeof(file1Buffer))) if(memcmp(file1Buffer, file2Buffer, sizeof(file1Buffer)))
{ {
(void)printf("binaryCompareFiles: Error during file reading\n"); logTestString("binaryCompareFiles: files are different\n");
break; break;
} }
} }
...@@ -73,38 +79,147 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2) ...@@ -73,38 +79,147 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
return filesAreIdentical; return filesAreIdentical;
} }
//! Compare two images, returning the degree to which they match.
/** \param image1 The first image to compare.
\param image2 The second image to compare.
\return The match, from 0.f to 100.f */
static float fuzzyCompareImages(irr::video::IImage * image1,
irr::video::IImage * image2)
{
assert(image1);
assert(image2);
if(!image1 || !image2)
return 0.f;
if(image1->getDimension() != image2->getDimension())
{
logTestString("fuzzyCompareImages: images are different sizes\n");
return 0.f;
}
video::ECOLOR_FORMAT format1 = image1->getColorFormat();
if(video::ECF_A8R8G8B8 != format1 && video::ECF_R8G8B8 != format1)
{
logTestString("fuzzyCompareImages: image 1 must be ECF_A8R8G8B8 or ECF_R8G8B8\n");
return 0.f;
}
video::ECOLOR_FORMAT format2 = image2->getColorFormat();
if(video::ECF_A8R8G8B8 != format2 && video::ECF_R8G8B8 != format2)
{
logTestString("fuzzyCompareImages: image 2 must be ECF_AR8G8B8 or ECF_R8G8B8\n");
return 0.f;
}
u8 * image1Data = (u8*)image1->lock();
u8 * image2Data = (u8*)image2->lock();
const u32 pixels = (image1->getPitch() * image1->getDimension().Height) / 4;
u32 mismatchedPixels = 0;
for(u32 pixel = 0; pixel < pixels; ++pixel)
{
if(video::ECF_A8R8G8B8 == format1)
image1Data++;
const u8 r1 = *(image1Data++);
const u8 g1 = *(image1Data++);
const u8 b1 = *(image1Data++);
if(video::ECF_A8R8G8B8 == format2)
image2Data++;
const u8 r2 = *(image2Data++);
const u8 g2 = *(image2Data++);
const u8 b2 = *(image2Data++);
// Empirically, some OpenGL screenshots have up to 2 shades difference per pixel.
if(abs(r1 - r2) > 2 || abs(g1 - g2) > 2 || abs(b1 - b2) > 2)
++mismatchedPixels;
}
image1->unlock();
image2->unlock();
return 100.f * (pixels - mismatchedPixels) / pixels;
}
bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, const char * fileName) bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, const char * fileName)
{ {
irr::video::IImage * screenshot = driver->createScreenShot(); irr::video::IImage * screenshot = driver->createScreenShot();
if(screenshot) if(!screenshot)
{ {
irr::core::stringc driverName = driver->getName(); logTestString("Failed to take screenshot\n");
// For OpenGL (only), chop the version number out. Other drivers have more stable version numbers. return false;
if(driverName.find("OpenGL") > -1) }
driverName = "OpenGL";
irr::core::stringc filename = "results/";
filename += driverName;
filename += fileName;
bool written = driver->writeImageToFile(screenshot, filename.c_str());
screenshot->drop();
if(!written) irr::core::stringc driverName = driver->getName();
{ // For OpenGL (only), chop the version number out. Other drivers have more stable version numbers.
(void)printf("Failed to write screenshot to file '%s'\n", filename.c_str()); if(driverName.find("OpenGL") > -1)
return false; driverName = "OpenGL";
}
irr::core::stringc referenceFilename = "media/"; irr::core::stringc referenceFilename = "media/";
referenceFilename += driverName; referenceFilename += driverName;
referenceFilename += fileName; referenceFilename += fileName;
return binaryCompareFiles(filename.c_str(), referenceFilename.c_str()); irr::video::IImage * reference = driver->createImageFromFile(referenceFilename.c_str());
} if(!reference)
else
{ {
(void)printf("Failed to take screenshot\n"); logTestString("\n*** Failed to load reference image '%s'\n*** Creating from screenshot - please check this image.\n\n",
referenceFilename.c_str());
(void)driver->writeImageToFile(screenshot, referenceFilename.c_str());
screenshot->drop();
return false;
} }
return false; float match = fuzzyCompareImages(screenshot, reference);
screenshot->drop();
reference->drop();
logTestString("Image match: %f%%\n", match);
return (match > 99.f); // Require a very confident match.
}
static FILE * logFile = 0;
bool openTestLog(const char * filename)
{
closeTestLog();
logFile = fopen(filename, "w");
assert(logFile);
if(!logFile)
logTestString("\nWARNING: unable to open the test log file %s\n", filename);
return (logFile != 0);
} }
void closeTestLog(void)
{
if(logFile)
(void)fclose(logFile);
}
void logTestString(const char * format, ...)
{
char logString[1024];
va_list arguments;
va_start(arguments, format);
vsprintf(logString, format, arguments);
va_end(arguments);
(void)printf(logString);
if(logFile)
{
(void)fprintf(logFile, logString);
(void)fflush(logFile);
}
#if defined(_MSC_VER) && !defined(NDEBUG)
OutputDebugStringA(logString);
#endif // #if defined(_MSC_VER) && !defined(NDEBUG)
}
...@@ -15,7 +15,20 @@ extern bool binaryCompareFiles(const char * fileName1, const char * fileName2); ...@@ -15,7 +15,20 @@ extern bool binaryCompareFiles(const char * fileName1, const char * fileName2);
\fileName The unique filename suffix that will be appended to the name of the video driver. \fileName The unique filename suffix that will be appended to the name of the video driver.
\return true if the screenshot was taken and is identical to the reference image of the same name \return true if the screenshot was taken and is identical to the reference image of the same name
in the tests/media directory, false on any error or difference. */ in the tests/media directory, false on any error or difference. */
bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, const char * fileName); extern bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, const char * fileName);
//! Opens a test log file, deleting any existing contents.
/** \param filename The filename to open
\return true if the test log file was opened, false on error. */
extern bool openTestLog(const char * filename = "tests.log");
//! Close the test log file opened with openTestLog()
extern void closeTestLog();
//! Log a string to the console and the test log file created by openTestLog().
/** \param format The format string
\... optional parameters */
extern void logTestString(const char * format, ...);
#endif // _TEST_UTILS_H_ #endif // _TEST_UTILS_H_
// Test the functionality of vector2d<T>, particularly methods that // Copyright (C) 2008 Colin MacDonald
// involve calculations done using different precision than <T>. // No rights reserved: this software is in the public domain.
// Note that all reference vector2d<T>s are creating using double precision
// values cast to (T), as we need to test <f64>.
#include "testUtils.h"
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h> #include <assert.h>
...@@ -15,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare, ...@@ -15,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare,
{ {
if(compare != with) if(compare != with)
{ {
(void)printf("\nERROR: vector2d %.16f, %.16f != vector2d %.16f, %.16f\n", logTestString("\nERROR: vector2d %.16f, %.16f != vector2d %.16f, %.16f\n",
(f64)compare.X, (f64)compare.Y, (f64)with.X, (f64)with.Y); (f64)compare.X, (f64)compare.Y, (f64)with.X, (f64)with.Y);
assert(compare == with); assert(compare == with);
return false; return false;
...@@ -34,7 +33,7 @@ static bool doTests() ...@@ -34,7 +33,7 @@ static bool doTests()
vector2d<T> otherVec(10, 20); vector2d<T> otherVec(10, 20);
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883)) if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{ {
(void)printf("vector2d::getDistanceFrom() failed\n"); logTestString("vector2d::getDistanceFrom() failed\n");
assert(0); assert(0);
return false; return false;
} }
...@@ -107,26 +106,30 @@ static bool doTests() ...@@ -107,26 +106,30 @@ static bool doTests()
return true; return true;
} }
/** Test the functionality of vector2d<T>, particularly methods that
involve calculations done using different precision than <T>.
Note that all reference vector2d<T>s are creating using double precision
values cast to (T), as we need to test <f64>. */
bool testVector2d(void) bool testVector2d(void)
{ {
bool f32Success = doTests<f32>(); bool f32Success = doTests<f32>();
if(f32Success) if(f32Success)
(void)printf("vector2df tests passed\n\n"); logTestString("vector2df tests passed\n\n");
else else
(void)printf("\n*** vector2df tests failed ***\n\n"); logTestString("\n*** vector2df tests failed ***\n\n");
bool f64Success = doTests<f64>(); bool f64Success = doTests<f64>();
if(f64Success) if(f64Success)
(void)printf("vector2d<f64> tests passed\n\n"); logTestString("vector2d<f64> tests passed\n\n");
else else
(void)printf("\n*** vector2d<f64> tests failed ***\n\n"); logTestString("\n*** vector2d<f64> tests failed ***\n\n");
bool s32Success = doTests<s32>(); bool s32Success = doTests<s32>();
if(s32Success) if(s32Success)
(void)printf("vector2di tests passed\n\n"); logTestString("vector2di tests passed\n\n");
else else
(void)printf("\n*** vector2di tests failed ***\n\n"); logTestString("\n*** vector2di tests failed ***\n\n");
return f32Success && f64Success && s32Success; return f32Success && f64Success && s32Success;
} }
// Test the functionality of vector3d<T>, particularly methods that // Copyright (C) 2008 Colin MacDonald
// involve calculations done using different precision than <T>. // No rights reserved: this software is in the public domain.
// Note that all reference vector3d<T>s are creating using double precision
// values cast to (T), as we need to test <f64>.
#include "testUtils.h"
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h> #include <assert.h>
...@@ -15,7 +14,7 @@ static bool compareVectors(const core::vector3d<T> & compare, ...@@ -15,7 +14,7 @@ static bool compareVectors(const core::vector3d<T> & compare,
{ {
if(compare != with) if(compare != with)
{ {
(void)printf("\nERROR: vector3d %.16f, %.16f, %.16f != vector3d %.16f, %.16f, %.16f\n", logTestString("\nERROR: vector3d %.16f, %.16f, %.16f != vector3d %.16f, %.16f, %.16f\n",
(f64)compare.X, (f64)compare.Y, (f64)compare.Z, (f64)compare.X, (f64)compare.Y, (f64)compare.Z,
(f64)with.X, (f64)with.Y, (f64)with.Z); (f64)with.X, (f64)with.Y, (f64)with.Z);
assert(compare == with); assert(compare == with);
...@@ -35,7 +34,7 @@ static bool doTests() ...@@ -35,7 +34,7 @@ static bool doTests()
vector3d<T> otherVec(10, 20, 0); vector3d<T> otherVec(10, 20, 0);
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883)) if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{ {
(void)printf("vector3d::getDistanceFrom() failed\n"); logTestString("vector3d::getDistanceFrom() failed\n");
assert(0); assert(0);
return false; return false;
} }
...@@ -119,25 +118,30 @@ static bool doTests() ...@@ -119,25 +118,30 @@ static bool doTests()
} }
/** Test the functionality of vector3d<T>, particularly methods that
involve calculations done using different precision than <T>.
Note that all reference vector3d<T>s are creating using double precision
values cast to (T), as we need to test <f64>. */
bool testVector3d(void) bool testVector3d(void)
{ {
bool f32Success = doTests<f32>(); bool f32Success = doTests<f32>();
if(f32Success) if(f32Success)
(void)printf("vector3df tests passed\n\n"); logTestString("vector3df tests passed\n\n");
else else
(void)printf("\n*** vector3df tests failed ***\n\n"); logTestString("\n*** vector3df tests failed ***\n\n");
bool f64Success = doTests<f64>(); bool f64Success = doTests<f64>();
if(f64Success) if(f64Success)
(void)printf("vector3d<f64> tests passed\n\n"); logTestString("vector3d<f64> tests passed\n\n");
else else
(void)printf("\n*** vector3d<f64> tests failed ***\n\n"); logTestString("\n*** vector3d<f64> tests failed ***\n\n");
bool s32Success = doTests<s32>(); bool s32Success = doTests<s32>();
if(s32Success) if(s32Success)
(void)printf("vector3di tests passed\n\n"); logTestString("vector3di tests passed\n\n");
else else
(void)printf("\n*** vector3di tests failed ***\n\n"); logTestString("\n*** vector3di tests failed ***\n\n");
return f32Success && f64Success && s32Success; return f32Success && f64Success && s32Success;
} }
Test suite pass at GMT Thu Nov 6 01:32:10 2008 Test suite pass at GMT Wed Dec 03 12:54:57 2008
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="tests" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="..\bin\Win32-gcc\tests" prefix_auto="1" extension_auto="1" />
<Option object_output="Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="..\bin\Win32-gcc\tests" prefix_auto="1" extension_auto="1" />
<Option object_output="Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add directory="..\include" />
</Compiler>
<Linker>
<Add library="Irrlicht" />
<Add directory="..\bin\Win32-gcc" />
</Linker>
<Unit filename="disambiguateTextures.cpp" />
<Unit filename="drawPixel.cpp" />
<Unit filename="exports.cpp" />
<Unit filename="fast_atof.cpp" />
<Unit filename="guiDisabledMenu.cpp" />
<Unit filename="line2dIntersectWith.cpp" />
<Unit filename="main.cpp" />
<Unit filename="md2Animation.cpp" />
<Unit filename="planeMatrix.cpp" />
<Unit filename="testUtils.cpp" />
<Unit filename="testVector2d.cpp" />
<Unit filename="testVector3d.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
...@@ -177,10 +177,18 @@ ...@@ -177,10 +177,18 @@
RelativePath=".\drawPixel.cpp" RelativePath=".\drawPixel.cpp"
> >
</File> </File>
<File
RelativePath=".\exports.cpp"
>
</File>
<File <File
RelativePath=".\fast_atof.cpp" RelativePath=".\fast_atof.cpp"
> >
</File> </File>
<File
RelativePath=".\guiDisabledMenu.cpp"
>
</File>
<File <File
RelativePath=".\line2dIntersectWith.cpp" RelativePath=".\line2dIntersectWith.cpp"
> >
......
...@@ -173,10 +173,18 @@ ...@@ -173,10 +173,18 @@
RelativePath=".\drawPixel.cpp" RelativePath=".\drawPixel.cpp"
> >
</File> </File>
<File
RelativePath=".\exports.cpp"
>
</File>
<File <File
RelativePath=".\fast_atof.cpp" RelativePath=".\fast_atof.cpp"
> >
</File> </File>
<File
RelativePath=".\guiDisabledMenu.cpp"
>
</File>
<File <File
RelativePath=".\line2dIntersectWith.cpp" RelativePath=".\line2dIntersectWith.cpp"
> >
......
...@@ -13,12 +13,10 @@ using namespace gui; ...@@ -13,12 +13,10 @@ using namespace gui;
//! constructor //! constructor
CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rectangle, IGUIElement *parent) CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rectangle, IGUIElement *parent)
: IGUIWindow(environment, parent, -1, rectangle), : IGUIWindow(environment, parent, -1, rectangle),
Dragging(false), Resizing(false), SelectedElement(0), Dragging(false), Resizing(false), SelectedElement(0),
AttribEditor(0), OptionEditor(0), EnvEditor(0) AttribEditor(0), OptionEditor(0), EnvEditor(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CGUIEditWindow"); setDebugName("CGUIEditWindow");
#endif #endif
...@@ -41,7 +39,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -41,7 +39,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
setRelativePosition(core::rect<s32>(50,50,250,500)); setRelativePosition(core::rect<s32>(50,50,250,500));
setMinSize( core::dimension2di(200,200)); setMinSize(core::dimension2di(200,200));
IGUITabControl *TabControl = environment->addTabControl(core::rect<s32>(1,th+5,199,449), this, false, true); IGUITabControl *TabControl = environment->addTabControl(core::rect<s32>(1,th+5,199,449), this, false, true);
TabControl->setSubElement(true); TabControl->setSubElement(true);
...@@ -58,7 +56,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -58,7 +56,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab); OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab);
OptionEditor->grab(); OptionEditor->grab();
OptionEditor->setID(EGUIEDCE_OPTION_EDITOR); OptionEditor->setID(EGUIEDCE_OPTION_EDITOR);
OptionEditor->setRelativePosition(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f)); OptionEditor->setRelativePositionProportional(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f));
OptionEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); OptionEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
if (Parent && Parent->getParent() == Environment->getRootGUIElement()) if (Parent && Parent->getParent() == Environment->getRootGUIElement())
...@@ -67,7 +65,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -67,7 +65,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab); EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab);
EnvEditor->grab(); EnvEditor->grab();
EnvEditor->setID(EGUIEDCE_ENV_EDITOR); EnvEditor->setID(EGUIEDCE_ENV_EDITOR);
EnvEditor->setRelativePosition(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f)); EnvEditor->setRelativePositionProportional(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f));
EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
} }
IGUITab* ElementTab = TabControl->addTab(L"Element"); IGUITab* ElementTab = TabControl->addTab(L"Element");
...@@ -75,9 +73,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -75,9 +73,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab); AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab);
AttribEditor->grab(); AttribEditor->grab();
AttribEditor->setID(EGUIEDCE_ATTRIB_EDITOR); AttribEditor->setID(EGUIEDCE_ATTRIB_EDITOR);
AttribEditor->setRelativePosition( core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f)); AttribEditor->setRelativePositionProportional(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f));
AttribEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); AttribEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ResizeButton = environment->addButton(core::rect<s32>(199-th,449-th,199,449), this); ResizeButton = environment->addButton(core::rect<s32>(199-th,449-th,199,449), this);
ResizeButton->setDrawBorder(false); ResizeButton->setDrawBorder(false);
ResizeButton->setEnabled(false); ResizeButton->setEnabled(false);
...@@ -87,9 +85,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec ...@@ -87,9 +85,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
ResizeButton->grab(); ResizeButton->grab();
ResizeButton->setSubElement(true); ResizeButton->setSubElement(true);
ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
} }
//! destructor //! destructor
CGUIEditWindow::~CGUIEditWindow() CGUIEditWindow::~CGUIEditWindow()
{ {
...@@ -140,7 +138,6 @@ void CGUIEditWindow::setSelectedElement(IGUIElement *sel) ...@@ -140,7 +138,6 @@ void CGUIEditWindow::setSelectedElement(IGUIElement *sel)
SelectedElement->serializeAttributes(Attribs); SelectedElement->serializeAttributes(Attribs);
AttribEditor->refreshAttribs(); AttribEditor->refreshAttribs();
} }
//! draws the element and its children. //! draws the element and its children.
...@@ -197,7 +194,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event) ...@@ -197,7 +194,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
{ {
case EMIE_LMOUSE_PRESSED_DOWN: case EMIE_LMOUSE_PRESSED_DOWN:
{ {
DragStart.X = event.MouseInput.X; DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y; DragStart.Y = event.MouseInput.Y;
...@@ -250,7 +247,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event) ...@@ -250,7 +247,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
else if (Resizing) else if (Resizing)
{ {
core::position2di dp = RelativeRect.LowerRightCorner + diff; core::position2di dp = RelativeRect.LowerRightCorner + diff;
setRelativePosition( core::rect<s32>(RelativeRect.UpperLeftCorner, dp)); setRelativePosition(core::rect<s32>(RelativeRect.UpperLeftCorner, dp));
DragStart += dp - RelativeRect.LowerRightCorner + diff; DragStart += dp - RelativeRect.LowerRightCorner + diff;
} }
...@@ -264,10 +261,6 @@ bool CGUIEditWindow::OnEvent(const SEvent &event) ...@@ -264,10 +261,6 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
} }
// we're supposed to supply these if we're creating an IGUIWindow // we're supposed to supply these if we're creating an IGUIWindow
// but we don't need them so we'll just return null // but we don't need them so we'll just return null
IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;} IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment