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-e03cc46cb475master
|
@ -160,6 +160,9 @@ void loadModel(const c8* fn)
|
|||
menu->setItemChecked(5, 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()
|
|||
e->remove();
|
||||
|
||||
// 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);
|
||||
|
||||
// create tab control and tabs
|
||||
IGUITabControl* tab = env->addTabControl(
|
||||
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
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,50,130,70), true, t1, 901);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,80,130,100), true, t1, 902);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,110,130,130), true, t1, 903);
|
||||
env->addStaticText(L"Scale:",
|
||||
core::rect<s32>(10,20,150,45), false, false, t1);
|
||||
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->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);
|
||||
env->addStaticText(L"Z:", core::rect<s32>(22,108,40,126), false, false, t1);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,106,130,126), true, t1, 903);
|
||||
|
||||
env->addButton(core::rect<s32>(10,150,100,190), t1, 1101, L"set");
|
||||
env->addButton(core::rect<s32>(10,134,85,165), t1, 1101, L"Set");
|
||||
|
||||
// add senseless checkbox
|
||||
env->addCheckBox(true, core::rect<s32>(10,220,200,240), t1, -1,
|
||||
L"Senseless Checkbox");
|
||||
|
||||
// add undocumented transparent control
|
||||
env->addStaticText(L"Transparent Control:",
|
||||
core::rect<s32>(10,240,150,260), true, false, t1);
|
||||
// add transparency control
|
||||
env->addStaticText(L"GUI Transparency Control:",
|
||||
core::rect<s32>(10,200,150,225), true, false, t1);
|
||||
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->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
|
||||
// now may be below the newly created toolbox
|
||||
root->bringToFront(root->getElementFromId(666, true));
|
||||
|
@ -225,18 +237,29 @@ public:
|
|||
{
|
||||
// Escape swaps Camera Input
|
||||
if (event.EventType == EET_KEY_INPUT_EVENT &&
|
||||
event.KeyInput.Key == irr::KEY_ESCAPE &&
|
||||
event.KeyInput.PressedDown == false)
|
||||
{
|
||||
if (Device)
|
||||
if (event.KeyInput.Key == irr::KEY_ESCAPE)
|
||||
{
|
||||
scene::ICameraSceneNode * camera =
|
||||
Device->getSceneManager()->getActiveCamera();
|
||||
if (camera)
|
||||
if (Device)
|
||||
{
|
||||
camera->setInputReceiverEnabled( !camera->isInputReceiverEnabled() );
|
||||
scene::ICameraSceneNode * camera =
|
||||
Device->getSceneManager()->getActiveCamera();
|
||||
if (camera)
|
||||
{
|
||||
camera->setInputReceiverEnabled( !camera->isInputReceiverEnabled() );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event.KeyInput.Key == irr::KEY_F1)
|
||||
{
|
||||
if (Device)
|
||||
{
|
||||
IGUIElement* elem = Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(2001);
|
||||
if (elem)
|
||||
elem->setVisible(!elem->isVisible());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +387,7 @@ public:
|
|||
// control skin transparency
|
||||
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)
|
||||
{
|
||||
video::SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
|
||||
|
@ -372,6 +395,12 @@ public:
|
|||
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;
|
||||
|
||||
case EGET_COMBO_BOX_CHANGED:
|
||||
|
@ -695,6 +724,10 @@ int main(int argc, char* argv[])
|
|||
IGUIStaticText* fpstext = env->addStaticText(L"",
|
||||
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
|
||||
|
||||
Caption += " - [";
|
||||
|
@ -728,8 +761,10 @@ int main(int argc, char* argv[])
|
|||
// add a camera scene node
|
||||
Camera[0] = smgr->addCameraSceneNodeMaya();
|
||||
Camera[0]->setFarValue(20000.f);
|
||||
Camera[0]->setPosition(core::vector3df(0,0,-100));
|
||||
Camera[1] = smgr->addCameraSceneNodeFPS();
|
||||
Camera[1]->setFarValue(20000.f);
|
||||
Camera[1]->setPosition(core::vector3df(0,0,-100));
|
||||
|
||||
setActiveCamera(Camera[0]);
|
||||
|
||||
|
@ -760,6 +795,21 @@ int main(int argc, char* argv[])
|
|||
str += L" Tris: ";
|
||||
str.append(core::stringw(driver->getPrimitiveCountDrawn()));
|
||||
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
|
||||
Device->yield();
|
||||
|
|
|
@ -414,8 +414,6 @@ int main()
|
|||
scene::IParticleSystemSceneNode* ps =
|
||||
smgr->addParticleSystemSceneNode(false, light2);
|
||||
|
||||
ps->setParticleSize(core::dimension2d<f32>(30.0f, 40.0f));
|
||||
|
||||
// create and set emitter
|
||||
scene::IParticleEmitter* em = ps->createBoxEmitter(
|
||||
core::aabbox3d<f32>(-3,0,-3,3,1,3),
|
||||
|
@ -423,6 +421,9 @@ int main()
|
|||
80,100,
|
||||
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
|
||||
400,1100);
|
||||
em->setMinStartSize(core::dimension2d<f32>(30.0f, 40.0f));
|
||||
em->setMaxStartSize(core::dimension2d<f32>(30.0f, 40.0f));
|
||||
|
||||
ps->setEmitter(em);
|
||||
em->drop();
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ user.
|
|||
camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0));
|
||||
//User-controlled
|
||||
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:
|
||||
|
|
|
@ -533,13 +533,14 @@ void CDemo::loadSceneData()
|
|||
campFire->setPosition(core::vector3df(100,120,600));
|
||||
campFire->setScale(core::vector3df(2,2,2));
|
||||
|
||||
campFire->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
|
||||
|
||||
scene::IParticleEmitter* em = campFire->createBoxEmitter(
|
||||
core::aabbox3d<f32>(-7,0,-7,7,1,7),
|
||||
core::vector3df(0.0f,0.06f,0.0f),
|
||||
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);
|
||||
em->drop();
|
||||
|
||||
|
|
|
@ -152,14 +152,30 @@ namespace scene
|
|||
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0;
|
||||
|
||||
//! 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,
|
||||
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.
|
||||
/** The data is interpreted as signed integers of the given bit size. Allowed
|
||||
values are 8, 16, and 32. The heightmap must be square. */
|
||||
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16,
|
||||
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0;
|
||||
/** The data is interpreted as (signed) integers of the given bit size or
|
||||
floats (with 32bits, signed). Allowed bitsizes for integers are
|
||||
8, 16, and 32. The heightmap must be square.
|
||||
\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
|
|||
Specifies where fog starts.
|
||||
\param end Only used in linear fog mode (linearFog=true).
|
||||
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.
|
||||
\param pixelFog Set this to false for vertex fog, and true if
|
||||
you want per-pixel fog.
|
||||
|
|
|
@ -709,8 +709,8 @@ namespace core
|
|||
}
|
||||
|
||||
|
||||
//! 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
|
||||
//! 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
|
||||
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. */
|
||||
template <class T>
|
||||
|
|
|
@ -235,8 +235,8 @@ void CCameraSceneNode::OnRegisterSceneNode()
|
|||
up.X += 0.5f;
|
||||
}
|
||||
|
||||
ViewArea.Matrices [ video::ETS_VIEW ].buildCameraLookAtMatrixLH(pos, Target, up);
|
||||
ViewArea.setTransformState ( video::ETS_VIEW );
|
||||
ViewArea.Matrices[video::ETS_VIEW].buildCameraLookAtMatrixLH(pos, Target, up);
|
||||
ViewArea.setTransformState(video::ETS_VIEW);
|
||||
recalculateViewArea();
|
||||
|
||||
if ( SceneManager->getActiveCamera () == this )
|
||||
|
@ -275,7 +275,7 @@ const SViewFrustum* CCameraSceneNode::getViewFrustum() const
|
|||
void CCameraSceneNode::recalculateViewArea()
|
||||
{
|
||||
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)
|
|||
TargetAndRotationAreBound = bound;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the binding between the camera's rotation and target.
|
||||
bool CCameraSceneNode::getTargetAndRotationBinding(void) const
|
||||
{
|
||||
|
|
|
@ -378,7 +378,7 @@ bool CGUIContextMenu::highlight(const core::position2d<s32>& p, bool canOpenSubM
|
|||
for (s32 j=0; j<(s32)Items.size(); ++j)
|
||||
if (Items[j].SubMenu)
|
||||
{
|
||||
if ( j == i && canOpenSubMenu )
|
||||
if ( j == i && canOpenSubMenu && Items[j].Enabled )
|
||||
Items[j].SubMenu->setVisible(true);
|
||||
else if ( j != i )
|
||||
Items[j].SubMenu->setVisible(false);
|
||||
|
|
|
@ -83,6 +83,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
|||
// enable key to character translation
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
if ( CreationParams.Fullscreen )
|
||||
SDL_Flags |= SDL_FULLSCREEN;
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
|
|
|
@ -619,6 +619,9 @@ void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& t
|
|||
c8 c=0;
|
||||
token = "";
|
||||
|
||||
if (file->getPos() >= file->getSize())
|
||||
return;
|
||||
|
||||
file->read(&c, sizeof(c8));
|
||||
// search for word beginning
|
||||
while ( core::isspace(c) && (file->getPos() < file->getSize()))
|
||||
|
@ -835,6 +838,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
|
|||
}
|
||||
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);
|
||||
while(token != "}")
|
||||
|
@ -842,6 +848,9 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
|
|||
if (token=="texture")
|
||||
{
|
||||
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.MipMaps, true);
|
||||
getMaterialToken(file, pass.Texture.Alpha, true);
|
||||
|
|
|
@ -648,11 +648,11 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
|
|||
rotateSpeed, zoomSpeed, translationSpeed);
|
||||
|
||||
node->addAnimator(anm);
|
||||
setActiveCamera(node);
|
||||
|
||||
anm->drop();
|
||||
node->drop();
|
||||
|
||||
setActiveCamera(node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -674,11 +674,10 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
|
|||
node->bindTargetAndRotation(true);
|
||||
|
||||
node->addAnimator(anm);
|
||||
anm->drop();
|
||||
node->drop();
|
||||
|
||||
setActiveCamera(node);
|
||||
|
||||
anm->drop();
|
||||
node->drop();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
|
|||
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement)
|
||||
: CursorControl(cursorControl), MaxVerticalAngle(88.0f),
|
||||
MoveSpeed(moveSpeed/1000.0f), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
|
||||
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement),
|
||||
KeyMapArray(keyMapArray), KeyMapSize(keyMapSize)
|
||||
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CCameraSceneNodeAnimatorFPS");
|
||||
|
@ -34,7 +33,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
|
|||
allKeysUp();
|
||||
|
||||
// create key map
|
||||
if (!KeyMapArray || !KeyMapSize)
|
||||
if (!keyMapArray || !keyMapSize)
|
||||
{
|
||||
// create default key map
|
||||
KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP));
|
||||
|
@ -46,7 +45,7 @@ CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cu
|
|||
else
|
||||
{
|
||||
// create custom key map
|
||||
setKeyMap(KeyMapArray, KeyMapSize);
|
||||
setKeyMap(keyMapArray, keyMapSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,7 +271,6 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
|
|||
{
|
||||
// clear the keymap
|
||||
KeyMap.clear();
|
||||
KeyMapArray=map;
|
||||
|
||||
// add actions
|
||||
for (u32 i=0; i<count; ++i)
|
||||
|
@ -295,20 +293,30 @@ void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//! Sets whether vertical movement should be allowed.
|
||||
void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow)
|
||||
{
|
||||
NoVerticalMovement = !allow;
|
||||
}
|
||||
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorCameraFPS * newAnimator =
|
||||
new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, (MoveSpeed * 1000.0f), JumpSpeed,
|
||||
KeyMapArray, KeyMapSize, NoVerticalMovement);
|
||||
0, 0, NoVerticalMovement);
|
||||
newAnimator->setKeyMap(KeyMap);
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::setKeyMap(const core::array<SCamKeyMap>& keymap)
|
||||
{
|
||||
KeyMap=keymap;
|
||||
}
|
||||
|
||||
|
||||
} // namespace scene
|
||||
} // namespace irr
|
||||
|
||||
|
|
|
@ -77,8 +77,6 @@ namespace scene
|
|||
this. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
|
||||
|
||||
private:
|
||||
|
||||
struct SCamKeyMap
|
||||
{
|
||||
SCamKeyMap() {};
|
||||
|
@ -88,6 +86,12 @@ namespace scene
|
|||
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();
|
||||
|
||||
gui::ICursorControl *CursorControl;
|
||||
|
@ -108,9 +112,6 @@ namespace scene
|
|||
|
||||
bool firstUpdate;
|
||||
bool NoVerticalMovement;
|
||||
|
||||
SKeyMap* KeyMapArray;
|
||||
u32 KeyMapSize;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -18,7 +18,7 @@ CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl*
|
|||
ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate),
|
||||
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),
|
||||
Target(0,0,0), OldTarget(0,0,0), OldCamera(0), MousePos(0.5f, 0.5f)
|
||||
OldCamera(0), MousePos(0.5f, 0.5f)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CSceneNodeAnimatorCameraMaya");
|
||||
|
@ -133,18 +133,14 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
|||
nZoom = old;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (Zooming)
|
||||
{
|
||||
if (Zooming)
|
||||
{
|
||||
f32 old = CurrentZoom;
|
||||
CurrentZoom = CurrentZoom + (ZoomStartX - MousePos.X ) * ZoomSpeed;
|
||||
nZoom = CurrentZoom;
|
||||
|
||||
if (nZoom < 0)
|
||||
nZoom = CurrentZoom = old;
|
||||
}
|
||||
f32 old = CurrentZoom;
|
||||
CurrentZoom = CurrentZoom + (ZoomStartX - MousePos.X ) * ZoomSpeed;
|
||||
nZoom = CurrentZoom;
|
||||
|
||||
if (nZoom < 0)
|
||||
nZoom = CurrentZoom = old;
|
||||
Zooming = false;
|
||||
}
|
||||
|
||||
|
@ -175,15 +171,11 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
|||
tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (Translating)
|
||||
{
|
||||
if (Translating)
|
||||
{
|
||||
translate += tvectX * (TranslateStartX - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
|
||||
OldTarget = translate;
|
||||
}
|
||||
|
||||
translate += tvectX * (TranslateStartX - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStartY - MousePos.Y)*TranslateSpeed;
|
||||
OldTarget = translate;
|
||||
Translating = false;
|
||||
}
|
||||
|
||||
|
@ -205,16 +197,12 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
|||
nRotY += (RotateStartY - MousePos.Y) * RotateSpeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (Rotating)
|
||||
{
|
||||
if (Rotating)
|
||||
{
|
||||
RotX = RotX + (RotateStartX - MousePos.X) * RotateSpeed;
|
||||
RotY = RotY + (RotateStartY - MousePos.Y) * RotateSpeed;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
}
|
||||
|
||||
RotX = RotX + (RotateStartX - MousePos.X) * RotateSpeed;
|
||||
RotY = RotY + (RotateStartY - MousePos.Y) * RotateSpeed;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
Rotating = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -231,22 +231,33 @@ namespace scene
|
|||
|
||||
|
||||
//! 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;
|
||||
|
||||
Mesh.MeshBuffers.clear();
|
||||
// start reading
|
||||
const u32 startTime = os::Timer::getTime();
|
||||
|
||||
// get file size
|
||||
const long fileSize = file->getSize();
|
||||
// TODO: Currently no floats are supported
|
||||
Mesh.MeshBuffers.clear();
|
||||
|
||||
const s32 bytesPerPixel = bitsPerPixel / 8;
|
||||
|
||||
// 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 )
|
||||
{
|
||||
|
@ -316,45 +327,78 @@ namespace scene
|
|||
float fz2=0.f;
|
||||
for( s32 z = 0; z < TerrainData.Size; ++z )
|
||||
{
|
||||
bool failure=false;
|
||||
vertex.Pos.X = fx;
|
||||
switch (bytesPerPixel)
|
||||
if (floatVals)
|
||||
{
|
||||
case 1:
|
||||
if( file->read( &vertex.Pos.Y, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
}
|
||||
else if (signedData)
|
||||
{
|
||||
switch (bytesPerPixel)
|
||||
{
|
||||
s8 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
case 1:
|
||||
{
|
||||
os::Printer::log("Error reading heightmap RAW file.");
|
||||
mb->drop();
|
||||
return false;
|
||||
s8 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
vertex.Pos.Y=val;
|
||||
}
|
||||
vertex.Pos.Y=val;
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
s16 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
vertex.Pos.Y=val/256.f;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
s32 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
vertex.Pos.Y=val/16777216.f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (bytesPerPixel)
|
||||
{
|
||||
s16 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
case 1:
|
||||
{
|
||||
os::Printer::log("Error reading heightmap RAW file.");
|
||||
mb->drop();
|
||||
return false;
|
||||
u8 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
vertex.Pos.Y=val;
|
||||
}
|
||||
vertex.Pos.Y=val;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
s32 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
os::Printer::log("Error reading heightmap RAW file.");
|
||||
mb->drop();
|
||||
return false;
|
||||
u16 val;
|
||||
if( file->read( &val, bytesPerPixel ) != bytesPerPixel )
|
||||
failure=true;
|
||||
vertex.Pos.Y=val/256.f;
|
||||
}
|
||||
vertex.Pos.Y=(f32)val;
|
||||
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;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace scene
|
|||
|
||||
//! Initializes the terrain data. Loads the vertices from the heightMapFile.
|
||||
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
|
||||
//! 1 material.
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace irr
|
|||
|
||||
namespace core
|
||||
{
|
||||
IRRLICHT_API const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
|
||||
const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm
|
|||
|
||||
#Windows specific options
|
||||
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
|
||||
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ NDEBUG = 1;
|
|||
PROFILE = 1;
|
||||
|
||||
APPLICATION_NAME = 'Irrlicht';
|
||||
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d'];
|
||||
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d', 'winmm'];
|
||||
if USE_GCC==1 and PROFILE==1:
|
||||
LIBRARIES += ['gmon'];
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright (C) 2008 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "testUtils.h"
|
||||
#include <irrlicht.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -8,40 +12,71 @@ using namespace video;
|
|||
using namespace io;
|
||||
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)
|
||||
{
|
||||
IrrlichtDevice *device =
|
||||
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
|
||||
false, false, false, 0);
|
||||
createDevice( video::EDT_NULL, dimension2d<s32>(640, 480));
|
||||
|
||||
if (!device)
|
||||
{
|
||||
logTestString("Unable to create EDT_NULL device\n");
|
||||
return false;
|
||||
|
||||
IVideoDriver * driver = device->getVideoDriver();
|
||||
|
||||
ITexture * tex1 = driver->getTexture("../media/tools.png");
|
||||
ITexture * tex2 = driver->getTexture("../media/tools.png");
|
||||
|
||||
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
|
||||
assert(readFile);
|
||||
|
||||
ITexture * tex3 = driver->getTexture(readFile);
|
||||
readFile->drop();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
IVideoDriver * driver = device->getVideoDriver();
|
||||
|
||||
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");
|
||||
assert(tex2);
|
||||
if(!tex2)
|
||||
logTestString("Unable to open ../media/tools.png\n");
|
||||
|
||||
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
|
||||
assert(readFile);
|
||||
if(!readFile)
|
||||
logTestString("Unable to open ../media/tools.png\n");
|
||||
|
||||
ITexture * tex3 = driver->getTexture(readFile);
|
||||
assert(tex3);
|
||||
if(!readFile)
|
||||
logTestString("Unable to create texture from ../media/tools.png\n");
|
||||
|
||||
readFile->drop();
|
||||
|
||||
// All 3 of the above textures should be identical.
|
||||
assert(tex1 == tex2 && tex1 == tex3);
|
||||
|
||||
stringc newWd = wd + "/empty/empty";
|
||||
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
|
||||
assert(changed);
|
||||
ITexture * tex4 = driver->getTexture("../../media/tools.png");
|
||||
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());
|
||||
|
||||
device->drop();
|
||||
|
||||
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
// Tests IVideoDriver::drawPixel().
|
||||
// Expect to see two diagonal lines overlaying a wall texture cube.
|
||||
// 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.
|
||||
// Copyright (C) 2008 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "irrlicht.h"
|
||||
#include "testUtils.h"
|
||||
|
@ -14,16 +11,21 @@ using namespace video;
|
|||
using namespace io;
|
||||
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)
|
||||
{
|
||||
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480));
|
||||
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(160, 120), 32);
|
||||
if (!device)
|
||||
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
|
||||
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
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));
|
||||
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
|
||||
cube->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
@ -32,18 +34,18 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
|
|||
driver->beginScene(true, true, SColor(255,100,101,140));
|
||||
smgr->drawAll();
|
||||
|
||||
// Test for offscreen values as well as onscreen.
|
||||
for(s32 x = -10; x < 650; ++x)
|
||||
// Test for benign handling of offscreen pixel values as well as onscreen ones.
|
||||
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));
|
||||
y = 480 - y;
|
||||
y = 120 - y;
|
||||
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
|
||||
}
|
||||
|
||||
driver->endScene();
|
||||
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.jpg");
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.png");
|
||||
|
||||
device->drop();
|
||||
|
||||
|
@ -55,12 +57,11 @@ bool drawPixel(void)
|
|||
{
|
||||
bool passed = true;
|
||||
|
||||
passed |= runTestWithDriver(EDT_NULL);
|
||||
passed |= runTestWithDriver(EDT_SOFTWARE);
|
||||
passed |= runTestWithDriver(EDT_BURNINGSVIDEO);
|
||||
passed |= runTestWithDriver(EDT_OPENGL);
|
||||
passed |= runTestWithDriver(EDT_DIRECT3D8);
|
||||
passed |= runTestWithDriver(EDT_DIRECT3D9);
|
||||
// Don't use the NULL or SOFTWARE drivers since they produce no image, and a 16 bit screenshot respectively.
|
||||
passed &= runTestWithDriver(EDT_BURNINGSVIDEO);
|
||||
passed &= runTestWithDriver(EDT_OPENGL);
|
||||
passed &= runTestWithDriver(EDT_DIRECT3D8);
|
||||
passed &= runTestWithDriver(EDT_DIRECT3D9);
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// 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;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
// 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 <assert.h>
|
||||
#include <float.h>
|
||||
|
@ -8,6 +10,7 @@
|
|||
using namespace irr;
|
||||
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)
|
||||
{
|
||||
u32 value = 0;
|
||||
|
@ -22,9 +25,7 @@ static inline u32 old_strtol10(const char* in, const char** out=0)
|
|||
return value;
|
||||
}
|
||||
|
||||
//! Provides a fast function for converting a string into a float,
|
||||
//! about 6 times faster than atof in win32.
|
||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||
//! This was an older Irrlicht implementation, tested against for reference.
|
||||
static inline const char* old_fast_atof_move( const char* c, float& out)
|
||||
{
|
||||
bool inv = false;
|
||||
|
@ -75,6 +76,7 @@ static inline const char* old_fast_atof_move( const char* c, float& out)
|
|||
return c;
|
||||
}
|
||||
|
||||
//! This was an older Irrlicht implementation, tested against for reference.
|
||||
static inline float old_fast_atof(const char* c)
|
||||
{
|
||||
float ret;
|
||||
|
@ -89,17 +91,18 @@ static bool testCalculation(const char * valueString)
|
|||
const f32 oldFastValue = old_fast_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);
|
||||
|
||||
bool accurate = fabs(newFastValue - atofValue) <= fabs(oldFastValue - atofValue);
|
||||
|
||||
if(!accurate)
|
||||
(void)printf("*** ERROR - less accurate than old method ***\n\n");
|
||||
logTestString("*** ERROR - less accurate than old method ***\n\n");
|
||||
|
||||
return accurate;
|
||||
}
|
||||
|
||||
//! Test both the accuracy and speed of Irrlicht's fast_atof() implementation.
|
||||
bool fast_atof(void)
|
||||
{
|
||||
bool accurate = true;
|
||||
|
@ -132,7 +135,7 @@ bool fast_atof(void)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -161,13 +164,13 @@ bool fast_atof(void)
|
|||
value = old_fast_atof("-340282346638528859811704183484516925440.000000");
|
||||
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);
|
||||
|
||||
device->drop();
|
||||
if(fastAtofTime > atofTime)
|
||||
{
|
||||
(void)printf("The fast method is slower than atof()\n");
|
||||
logTestString("The fast method is slower than atof()\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// 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;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Test the functionality of line2d>T>::intersectWith().
|
||||
// Validation is done with asserts() on back-of-an-envelope
|
||||
// expected results.
|
||||
// Copyright (C) 2008 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "testUtils.h"
|
||||
#include <irrlicht.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -15,23 +15,23 @@ static bool testLines(line2df const & line1,
|
|||
{
|
||||
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.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.end.X, line2.end.Y);
|
||||
|
||||
vector2df intersection;
|
||||
(void)printf("line1 with line2 = ");
|
||||
logTestString("line1 with line2 = ");
|
||||
if(line1.intersectWith(line2, intersection))
|
||||
{
|
||||
(void)printf("hit at %.1f %.1f - ",
|
||||
logTestString("hit at %.1f %.1f - ",
|
||||
intersection.X, intersection.Y);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -39,43 +39,43 @@ static bool testLines(line2df const & line1,
|
|||
{
|
||||
if(intersection == expectedIntersection)
|
||||
{
|
||||
(void)printf("expected\n");
|
||||
logTestString("expected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("unexpected intersection (expected %.1f %.1f)\n",
|
||||
logTestString("unexpected intersection (expected %.1f %.1f)\n",
|
||||
expectedIntersection.X, expectedIntersection.Y);
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("UNEXPECTED\n");
|
||||
logTestString("UNEXPECTED\n");
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("miss - ");
|
||||
logTestString("miss - ");
|
||||
if(!expectedHit)
|
||||
{
|
||||
(void)printf("expected\n");
|
||||
logTestString("expected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("UNEXPECTED\n");
|
||||
logTestString("UNEXPECTED\n");
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
(void)printf("line2 with line1 = ");
|
||||
logTestString("line2 with line1 = ");
|
||||
if(line2.intersectWith(line1, intersection))
|
||||
{
|
||||
(void)printf("hit at %.1f %.1f - ",
|
||||
logTestString("hit at %.1f %.1f - ",
|
||||
intersection.X, intersection.Y);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -83,31 +83,31 @@ static bool testLines(line2df const & line1,
|
|||
{
|
||||
if(intersection == expectedIntersection)
|
||||
{
|
||||
(void)printf("expected\n");
|
||||
logTestString("expected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("unexpected intersection (expected %.1f %.1f)\n",
|
||||
logTestString("unexpected intersection (expected %.1f %.1f)\n",
|
||||
expectedIntersection.X, expectedIntersection.Y);
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("UNEXPECTED\n");
|
||||
logTestString("UNEXPECTED\n");
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("miss - ");
|
||||
logTestString("miss - ");
|
||||
if(!expectedHit)
|
||||
{
|
||||
(void)printf("expected\n");
|
||||
logTestString("expected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("UNEXPECTED\n");
|
||||
logTestString("UNEXPECTED\n");
|
||||
gotExpectedResult = false;
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ static bool testLines(line2df const & line1,
|
|||
return gotExpectedResult;
|
||||
}
|
||||
|
||||
// Test the functionality of line2d>T>::intersectWith().
|
||||
/** Validation is done with asserts() against expected results. */
|
||||
bool line2dIntersectWith(void)
|
||||
{
|
||||
bool allExpected = true;
|
||||
|
@ -217,9 +219,9 @@ bool line2dIntersectWith(void)
|
|||
true, vector2df(1.5f, 1.5f));
|
||||
|
||||
if(allExpected)
|
||||
(void)printf("\nAll tests passed\n");
|
||||
logTestString("\nAll tests passed\n");
|
||||
else
|
||||
(void)printf("\nFAIL!\n");
|
||||
logTestString("\nFAIL!\n");
|
||||
|
||||
return allExpected;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// This is the entry point for the Irrlicht test suite.
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include "testUtils.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
// This is an MSVC pragma to link against the Irrlicht library.
|
||||
// Other builds must link against it in the project files.
|
||||
|
@ -17,10 +19,11 @@
|
|||
*/
|
||||
#define RUN_TEST(testEntryPoint)\
|
||||
extern bool testEntryPoint(void);\
|
||||
logTestString("\nStarting test '" #testEntryPoint "'\n");\
|
||||
if(!testEntryPoint()) \
|
||||
{\
|
||||
(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);\
|
||||
fails++;\
|
||||
}
|
||||
|
@ -29,16 +32,21 @@
|
|||
/** \return The number of test that failed, i.e. 0 is success. */
|
||||
int main()
|
||||
{
|
||||
bool logFileOpened = openTestLog();
|
||||
assert(logFileOpened);
|
||||
|
||||
int fails = 0;
|
||||
|
||||
RUN_TEST(disambiguateTextures); // Run this first, since it validates the WD.
|
||||
RUN_TEST(exports);
|
||||
RUN_TEST(testVector3d);
|
||||
RUN_TEST(testVector2d);
|
||||
RUN_TEST(planeMatrix);
|
||||
RUN_TEST(fast_atof);
|
||||
RUN_TEST(line2dIntersectWith);
|
||||
RUN_TEST(disambiguateTextures);
|
||||
RUN_TEST(drawPixel);
|
||||
RUN_TEST(md2Animation);
|
||||
RUN_TEST(guiDisabledMenu);
|
||||
|
||||
(void)printf("\nTests finished. %d test%s failed.\n", fails, 1 == fails ? "" : "s");
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// 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 "testUtils.h"
|
||||
|
@ -11,9 +12,12 @@ using namespace video;
|
|||
using namespace io;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
if (!device)
|
||||
return false;
|
||||
|
@ -39,26 +43,19 @@ bool md2Animation(void)
|
|||
|
||||
(void)smgr->addCameraSceneNode();
|
||||
|
||||
// We could just jump to the last frame, but where's the fun in that?
|
||||
// Let's watch the animation, doing the initial run() first so that we
|
||||
// don't miss any of the fun.
|
||||
device->run();
|
||||
|
||||
// Just jump to the last frame since that's all we're interested in.
|
||||
node->setMD2Animation(EMAT_DEATH_FALLBACK);
|
||||
const s32 endFrame = node->getEndFrame();
|
||||
|
||||
while((s32)node->getFrameNr() < endFrame)
|
||||
{
|
||||
device->run();
|
||||
driver->beginScene(true, true, SColor(255, 255, 255, 0));
|
||||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
}
|
||||
node->setCurrentFrame((f32)(node->getEndFrame()));
|
||||
device->run();
|
||||
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();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 742 B |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 17 KiB |
|
@ -1,5 +1,7 @@
|
|||
// 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 <assert.h>
|
||||
|
||||
|
@ -10,7 +12,7 @@ using namespace video;
|
|||
using namespace io;
|
||||
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)
|
||||
{
|
||||
return(equals(plane1.D, plane2.D, 0.001f) &&
|
||||
|
@ -24,32 +26,28 @@ static bool transformPlane(const vector3df & point, const vector3df & normal,
|
|||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
(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);
|
||||
|
||||
// (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));
|
||||
if(!sloppyComparePlanes(plane, expected))
|
||||
{
|
||||
(void)printf("Unexpected result\n");
|
||||
logTestString("Unexpected result\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Test the ability to transform a plane with a matrix.
|
||||
bool planeMatrix(void)
|
||||
{
|
||||
matrix4 rotationMatrix;
|
||||
|
@ -64,7 +62,7 @@ bool planeMatrix(void)
|
|||
bool success = true;
|
||||
|
||||
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",
|
||||
|
@ -83,7 +81,7 @@ bool planeMatrix(void)
|
|||
|
||||
|
||||
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",
|
||||
|
@ -102,7 +100,7 @@ bool planeMatrix(void)
|
|||
|
||||
|
||||
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",
|
||||
|
@ -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));
|
||||
|
||||
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",
|
||||
|
@ -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));
|
||||
|
||||
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",
|
||||
|
@ -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));
|
||||
|
||||
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",
|
||||
|
@ -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));
|
||||
|
||||
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",
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include "testUtils.h"
|
||||
#include <memory.h>
|
||||
#include <stdio.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)
|
||||
{
|
||||
|
@ -16,19 +22,19 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
|
|||
return false;
|
||||
|
||||
FILE * file1 = fopen(fileName1, "rb");
|
||||
assert(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;
|
||||
}
|
||||
|
||||
FILE * file2 = fopen(fileName2, "rb");
|
||||
assert(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);
|
||||
assert(file2);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -37,7 +43,7 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
|
|||
(void)fseek(file2, 0, SEEK_END);
|
||||
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(file2);
|
||||
return false;
|
||||
|
@ -55,13 +61,13 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
|
|||
||(fread(file1Buffer, sizeof(file1Buffer), 1, file1) !=
|
||||
fread(file2Buffer, sizeof(file2Buffer), 1, file2)))
|
||||
{
|
||||
(void)printf("binaryCompareFiles: Error during file reading\n");
|
||||
logTestString("binaryCompareFiles: Error during file reading\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(memcmp(file1Buffer, file2Buffer, sizeof(file1Buffer)))
|
||||
{
|
||||
(void)printf("binaryCompareFiles: Error during file reading\n");
|
||||
logTestString("binaryCompareFiles: files are different\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -73,38 +79,147 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
|
|||
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)
|
||||
{
|
||||
irr::video::IImage * screenshot = driver->createScreenShot();
|
||||
if(screenshot)
|
||||
if(!screenshot)
|
||||
{
|
||||
irr::core::stringc driverName = driver->getName();
|
||||
// For OpenGL (only), chop the version number out. Other drivers have more stable version numbers.
|
||||
if(driverName.find("OpenGL") > -1)
|
||||
driverName = "OpenGL";
|
||||
logTestString("Failed to take screenshot\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
irr::core::stringc filename = "results/";
|
||||
filename += driverName;
|
||||
filename += fileName;
|
||||
bool written = driver->writeImageToFile(screenshot, filename.c_str());
|
||||
irr::core::stringc driverName = driver->getName();
|
||||
// For OpenGL (only), chop the version number out. Other drivers have more stable version numbers.
|
||||
if(driverName.find("OpenGL") > -1)
|
||||
driverName = "OpenGL";
|
||||
|
||||
irr::core::stringc referenceFilename = "media/";
|
||||
referenceFilename += driverName;
|
||||
referenceFilename += fileName;
|
||||
irr::video::IImage * reference = driver->createImageFromFile(referenceFilename.c_str());
|
||||
if(!reference)
|
||||
{
|
||||
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();
|
||||
|
||||
if(!written)
|
||||
{
|
||||
(void)printf("Failed to write screenshot to file '%s'\n", filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
irr::core::stringc referenceFilename = "media/";
|
||||
referenceFilename += driverName;
|
||||
referenceFilename += fileName;
|
||||
return binaryCompareFiles(filename.c_str(), referenceFilename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)printf("Failed to take screenshot\n");
|
||||
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);
|
|||
\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
|
||||
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_
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// 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>.
|
||||
// Copyright (C) 2008 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "testUtils.h"
|
||||
#include "irrlicht.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -15,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare,
|
|||
{
|
||||
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);
|
||||
assert(compare == with);
|
||||
return false;
|
||||
|
@ -34,7 +33,7 @@ static bool doTests()
|
|||
vector2d<T> otherVec(10, 20);
|
||||
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
|
||||
{
|
||||
(void)printf("vector2d::getDistanceFrom() failed\n");
|
||||
logTestString("vector2d::getDistanceFrom() failed\n");
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
@ -107,26 +106,30 @@ static bool doTests()
|
|||
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 f32Success = doTests<f32>();
|
||||
if(f32Success)
|
||||
(void)printf("vector2df tests passed\n\n");
|
||||
logTestString("vector2df tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector2df tests failed ***\n\n");
|
||||
logTestString("\n*** vector2df tests failed ***\n\n");
|
||||
|
||||
bool f64Success = doTests<f64>();
|
||||
if(f64Success)
|
||||
(void)printf("vector2d<f64> tests passed\n\n");
|
||||
logTestString("vector2d<f64> tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector2d<f64> tests failed ***\n\n");
|
||||
logTestString("\n*** vector2d<f64> tests failed ***\n\n");
|
||||
|
||||
bool s32Success = doTests<s32>();
|
||||
if(s32Success)
|
||||
(void)printf("vector2di tests passed\n\n");
|
||||
logTestString("vector2di tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector2di tests failed ***\n\n");
|
||||
logTestString("\n*** vector2di tests failed ***\n\n");
|
||||
|
||||
return f32Success && f64Success && s32Success;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// 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>.
|
||||
// Copyright (C) 2008 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "testUtils.h"
|
||||
#include "irrlicht.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -15,7 +14,7 @@ static bool compareVectors(const core::vector3d<T> & compare,
|
|||
{
|
||||
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)with.X, (f64)with.Y, (f64)with.Z);
|
||||
assert(compare == with);
|
||||
|
@ -35,7 +34,7 @@ static bool doTests()
|
|||
vector3d<T> otherVec(10, 20, 0);
|
||||
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
|
||||
{
|
||||
(void)printf("vector3d::getDistanceFrom() failed\n");
|
||||
logTestString("vector3d::getDistanceFrom() failed\n");
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
@ -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 f32Success = doTests<f32>();
|
||||
if(f32Success)
|
||||
(void)printf("vector3df tests passed\n\n");
|
||||
logTestString("vector3df tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector3df tests failed ***\n\n");
|
||||
logTestString("\n*** vector3df tests failed ***\n\n");
|
||||
|
||||
bool f64Success = doTests<f64>();
|
||||
if(f64Success)
|
||||
(void)printf("vector3d<f64> tests passed\n\n");
|
||||
logTestString("vector3d<f64> tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector3d<f64> tests failed ***\n\n");
|
||||
logTestString("\n*** vector3d<f64> tests failed ***\n\n");
|
||||
|
||||
bool s32Success = doTests<s32>();
|
||||
if(s32Success)
|
||||
(void)printf("vector3di tests passed\n\n");
|
||||
logTestString("vector3di tests passed\n\n");
|
||||
else
|
||||
(void)printf("\n*** vector3di tests failed ***\n\n");
|
||||
logTestString("\n*** vector3di tests failed ***\n\n");
|
||||
|
||||
return f32Success && f64Success && s32Success;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Test suite pass at GMT Thu Nov 6 01:32:10 2008
|
||||
|
||||
Test suite pass at GMT Wed Dec 03 12:54:57 2008
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?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 @@
|
|||
RelativePath=".\drawPixel.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\exports.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fast_atof.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\guiDisabledMenu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\line2dIntersectWith.cpp"
|
||||
>
|
||||
|
|
|
@ -173,10 +173,18 @@
|
|||
RelativePath=".\drawPixel.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\exports.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fast_atof.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\guiDisabledMenu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\line2dIntersectWith.cpp"
|
||||
>
|
||||
|
|
|
@ -13,12 +13,10 @@ using namespace gui;
|
|||
|
||||
//! constructor
|
||||
CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rectangle, IGUIElement *parent)
|
||||
: IGUIWindow(environment, parent, -1, rectangle),
|
||||
Dragging(false), Resizing(false), SelectedElement(0),
|
||||
AttribEditor(0), OptionEditor(0), EnvEditor(0)
|
||||
|
||||
: IGUIWindow(environment, parent, -1, rectangle),
|
||||
Dragging(false), Resizing(false), SelectedElement(0),
|
||||
AttribEditor(0), OptionEditor(0), EnvEditor(0)
|
||||
{
|
||||
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUIEditWindow");
|
||||
#endif
|
||||
|
@ -41,7 +39,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
|
|||
s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
|
||||
|
||||
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);
|
||||
TabControl->setSubElement(true);
|
||||
|
@ -58,7 +56,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
|
|||
OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab);
|
||||
OptionEditor->grab();
|
||||
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);
|
||||
|
||||
if (Parent && Parent->getParent() == Environment->getRootGUIElement())
|
||||
|
@ -67,7 +65,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
|
|||
EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab);
|
||||
EnvEditor->grab();
|
||||
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);
|
||||
}
|
||||
IGUITab* ElementTab = TabControl->addTab(L"Element");
|
||||
|
@ -75,9 +73,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
|
|||
AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab);
|
||||
AttribEditor->grab();
|
||||
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);
|
||||
|
||||
|
||||
ResizeButton = environment->addButton(core::rect<s32>(199-th,449-th,199,449), this);
|
||||
ResizeButton->setDrawBorder(false);
|
||||
ResizeButton->setEnabled(false);
|
||||
|
@ -87,9 +85,9 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
|
|||
ResizeButton->grab();
|
||||
ResizeButton->setSubElement(true);
|
||||
ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CGUIEditWindow::~CGUIEditWindow()
|
||||
{
|
||||
|
@ -140,7 +138,6 @@ void CGUIEditWindow::setSelectedElement(IGUIElement *sel)
|
|||
SelectedElement->serializeAttributes(Attribs);
|
||||
|
||||
AttribEditor->refreshAttribs();
|
||||
|
||||
}
|
||||
|
||||
//! draws the element and its children.
|
||||
|
@ -197,7 +194,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
|
|||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
{
|
||||
|
||||
|
||||
DragStart.X = event.MouseInput.X;
|
||||
DragStart.Y = event.MouseInput.Y;
|
||||
|
||||
|
@ -250,7 +247,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
|
|||
else if (Resizing)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -264,10 +261,6 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// we're supposed to supply these if we're creating an IGUIWindow
|
||||
// but we don't need them so we'll just return null
|
||||
IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;}
|
||||
|
|