ЗАПИСЬ КАРТИНКИ В ФАЙЛ Code IImage* image = Device.driver->createScreenShot(); if (image) { Device.driver->writeImageToFile(image, "c:\\images\\dump.jpeg"); Device.driver->writeImageToFile(image, "c:\\images\\dump.png"); Device.driver->writeImageToFile(image, "c:\\images\\dump.bmp"); Device.driver->writeImageToFile(image, "c:\\images\\dump.tga"); Device.driver->writeImageToFile(image, "c:\\images\\dump.jpg"); image->drop(); } ЗАГРУЗИТЬ КАРТИНКУ ИЗ ФАЙЛА (256X256) ИЗМЕНИТЬ И СОХРАНИТЬ Code video::ITexture * image1 = driver->getTexture("d:\\x\\map.bmp"); //driver->makeColorKeyTexture(image1, core::position2d<s32>(0,0)); u8 * ff=(u8 *)image1->lock(); IImage* im = driver->createImageFromData(image1->getColorFormat(), dimension2d<s32>(256,256), ff); im->setPixel(100,100,SColor(255,255,0,0)); driver->writeImageToFile(im,"D:\\x\\map.bmp"); im->drop(); ОПРЕДЕЛЕНИЕ СТОЛКНОВЕНИЙ ЧЕРЕЗ BOUNDING BOX Code bool collision(ISceneNode* one, ISceneNode* two) { aabbox3d<f32> b1, b2;
b1 = one->getBoundingBox (); b2 = two->getBoundingBox ();
one->getRelativeTransformation().transformBoxEx( b1 ); two->getRelativeTransformation().transformBoxEx( b2 ); return b1.intersectsWithBox( b2 ); } //OTHER WAY //bool collision(ISceneNode* one, ISceneNode* two) { //if(one->getTransformedBoundingBox().intersectsWithBox(two->getTransformedBoundingBox())) { //return (one->getTransformedBoundingBox().intersectsWithBox(two->getTransformedBoundingBox())); //} //return false; //} ПОКАЗАТЬ BOUNDING BOX Code node->setDebugDataVisible(scene::EDS_BBOX); ПЕРЕМЕСТИТЬ ОБЬЕКТ Code core::vector3df v=node->getPosition(); v.X+=1.0f; node->setPosition(vector3df(v)); УСТАНОВКА ТЕКСТУРЫ НА ОБЬЕКТ Code irr::video::ITexture * texture[1]; texture[0]=driver->getTexture("c:/x/0.bmp"); texture[1]=driver->getTexture("c:/x/1.bmp"); node->setMaterialTexture(0,texture[0]); node->setMaterialTexture(1,texture[1]); node->setMaterialFlag(EMF_LIGHTING, false); node->setMaterialType(video::EMT_REFLECTION_2_LAYER); НЕ ПОКАЗЫВАТЬ КОНСОЛЬ Code #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") int main() { return 0; } ДОБАВЛЕНИЕ АНИМАЦИИ ОБЪЕКТУ Code irr::scene::ISceneNodeAnimator * anim = smgr->createFlyCircleAnimator (core::vector3df(0,55,110),5.0f, 0.01,core::vector3df(1,0,1)); bill->addAnimator(anim); anim->drop(); ДОБАВЛЕНИЕ ОБЬЕКТА СВЕТА Code scene::ILightSceneNode* nodeLight = smgr->addLightSceneNode(0, core::vector3df(100, 100, 100), video::SColorf(1.0f,1.0f,1.0f,1.0f), 20000.0f); video::SLight light; light.Direction = core::vector3df(100, 100, 0); light.Type = video::ELT_DIRECTIONAL; light.AmbientColor = video::SColorf(0.3f,0.3f,0.3f,1); light.SpecularColor= video::SColorf(0.4f,0.4f,0.4f,1); light.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f,1); light.CastShadows = false; nodeLight->setLightData(light); ПОЛУЧИТЬ РАСТОЯНИЕ МЕЖДУ ОБЪЕКТАМИ Code ISceneNode* one; ISceneNode* two; one->getAbsolutePosition().getDistanceFrom(two->getAbsolutePosition()); ТУМАН Code driver->setFog(SColor(0,0, 0, 0),true, 150,220,0.01,false, false); node->setMaterialFlag(video::EMF_FOG_ENABLE, true); Получить позицию от ротации 3D Code inline vector3df AIGetPositionFromRotation3D(ISceneNode * Node, irr::f32 ValueUpDown) { if(!Node) return vector3df(0,0,0); vector3df Target = Node->getAbsolutePosition() + Node->getRotation().rotationToDirection(); //MAX_CHANGE insert in irr 1.5.1 rotationToDirection core::vector3df start = Node->getPosition(); core::vector3df end = (Target - start); end.normalize(); start += end*ValueUpDown; end = start + (end * ValueUpDown); return end; } Получить позицию от ротации 2D Code inline void AIGetPositionFromRotation(vector3df * Rezult, vector3df Position,vector3df Rotation, irr::f32 ZanacPlus) { if(!Rezult) return;
Rezult->X = Position.X + ZanacPlus * sin((Rotation.Y / 180) * (irr::f32)3.141592653589793); Rezult->Z = Position.Z + ZanacPlus * cos((Rotation.Y / 180) * (irr::f32)3.141592653589793); } Незвисимая ротация Code inline void rotate(irr::scene::ISceneNode *node, irr::core::vector3df rot) { irr::core::matrix4 m; m.setRotationDegrees(node->getRotation()); irr::core::matrix4 n; n.setRotationDegrees(rot); m *= n; node->setRotation( m.getRotationDegrees() ); node->updateAbsolutePosition(); }
|