WRITE IMAGE TO FILE:
Code: Select all
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();
}
Code: Select all
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();
Code: Select all
void showCaptionVar(std::string txt)
{
std::string gio1=txt;
char gio2[512];
strcpy_s(gio2, gio1.c_str());
core::stringw gio3 = gio2;
device->setWindowCaption(gio3.c_str());
}
Code: Select all
class mvm:public IEventReceiver
{
public:
bool OnEvent(const SEvent &e)
{
static bool pwheel=false;
if (e.EventType==EEVENT_TYPE::EET_MOUSE_INPUT_EVENT)
{
if (e.MouseInput.Wheel==-1)
{
}else if (e.MouseInput.Wheel==1)
{
}
if (e.MouseInput.Event==irr::EMIE_RMOUSE_PRESSED_DOWN)
{
mox=e.MouseInput.X;
moy=e.MouseInput.Y;
}
if (e.MouseInput.Event==irr::EMIE_RMOUSE_LEFT_UP)
{
}
if (e.MouseInput.Event==irr::EMIE_MOUSE_MOVED)
{
}
}
if(e.MouseInput.Wheel)
{
if (pwheel==false)
{
//middle button down event
pwheel=true;
}else{
//middle button up event
pwheel=false;
}
}
if (e.EventType==irr::EEVENT_TYPE::EET_GUI_EVENT)
{
s32 id = e.GUIEvent.Caller->getID();
switch (e.GUIEvent.EventType)
{
case gui::EGUI_EVENT_TYPE::EGET_BUTTON_CLICKED:
{
if (id==2)
{
}
break;
}
case gui::EGUI_EVENT_TYPE::EGET_ELEMENT_FOCUSED
{
if (id==2)
{
//gui::
z=z+10;
}
break;
}
}
}
if (e.EventType==EET_KEY_INPUT_EVENT)
{
switch (e.KeyInput.Key)
{
case KEY_KEY_W:
{
wasd[0]=e.KeyInput.PressedDown;
break;
}
case KEY_ESCAPE:
{
device->closeDevice();
break;
}
return true;
}
return false;
}
return false;
}
};
Code: Select all
#include "irrlicht.h"
#include <SIrrCreationParameters.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
IrrlichtDevice * device;
video::IVideoDriver * driver;
scene::ISceneManager * smgr;
scene::ICameraSceneNode * cam;
irr::SIrrlichtCreationParameters pars;
pars.EventReceiver=&receiver;
pars.AntiAlias=true;
pars.Fullscreen=true;
pars.DriverType=video::EDT_DIRECT3D9;
pars.WindowSize=core::dimension2d<s32>(1024,768);
pars.Bits=32;
device = createDeviceEx(pars);
driver = device->getVideoDriver();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
smgr = device->getSceneManager();
cam= smgr->addCameraSceneNode();
cam->setFarValue(50000.0f);
Code: Select all
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;
//}
Code: Select all
node->setDebugDataVisible(scene::EDS_BBOX);
Code: Select all
core::vector3df v=node->getPosition();
v.X+=1.0f;
node->setPosition(vector3df(v));
Code: Select all
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: Select all
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
int main()
{
return 0;
}
Code: Select all
ISceneNode * bone=node->getJointNode("Bone1");
bone->addChild(node2);
Code: Select all
IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("c:/x/b1.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setSize(dimension2d<f32>(10.0f, 10.0f));
bill->setPosition(vector3df(1.0f, 0.0f, 110.0f));
Code: Select all
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: Select all
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: Select all
// create a particle system
scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false);
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
core::vector3df(0.0f,-0.06f,0.0f), // initial direction
10,100, // emit rate
video::SColor(0,0,0,255), // darkest color
video::SColor(0,255,255,255), // brightest color
80,20000,0, // min and max age, angle
core::dimension2df(5.f,5.f), // min size
core::dimension2df(20.f,20.f)); // max size
ps->setEmitter(em); // this grabs the emitter
em->drop(); // so we can drop it here without deleting it
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf); // same goes for the affector
paf->drop();
ps->setPosition(core::vector3df(10,450,0));
ps->setScale(core::vector3df(100,100,100));
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, driver->getTexture("c:/x/b1.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
Code: Select all
IAnimatedMesh* plane = smgr->addHillPlaneMesh("floor", // Name of mesh
core::dimension2d<f32>(1,1), // Size of a tile of the mesh.
core::dimension2d<u32>(100,100), //tileCount - Specifies how much tiles there will be. If you specifiy for example that a tile has the size (10.0f, 10.0f) and the tileCount is (10,10), than you get a field of 100 tiles which has the dimension 100.0fx100.0f.
0, //material
0, //hillheight
core::dimension2d<f32>(10,10), //countHills
core::dimension2d<f32>(100,100)); // texturerepeat
ISceneNode* sea = smgr->addWaterSurfaceSceneNode(plane->getMesh(0), 2.0f, 350.0f, 8.0f,0,-1,vector3df(0,0,0),vector3df(10,0,0),vector3df(1,1,1));
sea->setMaterialTexture(0, driver->getTexture("c:/x/sand.png"));
sea->setMaterialTexture(1, driver->getTexture("c:/x/water.png"));
sea->setMaterialFlag(EMF_LIGHTING, true);
sea->setMaterialType(video::EMT_REFLECTION_2_LAYER);
Code: Select all
ISceneNode* one;
ISceneNode* two;
one->getAbsolutePosition().getDistanceFrom(two->getAbsolutePosition());
Code: Select all
myNode->setFrameLoop(1,15);
myNode->setAnimationSpeed(25);
Code: Select all
driver->setFog(SColor(0,0, 0, 0),true, 150,220,0.01,false, false);
node->setMaterialFlag(video::EMF_FOG_ENABLE, true);
Code: Select all
irr::gui::IGUIEnvironment *ige=smgr->getGUIEnvironment();
irr::gui::IGUIMeshViewer * gm=ige->addMeshViewer(rect<s32>(0,0,100,100),0,-1,0);
scene::IAnimatedMesh * mesh=smgr->getMesh("c:/x/cube.x");
gm->setMesh(mesh);
irr::gui::IGUIEditBox * txt=ige->addEditBox(L"giorgi",core::rect<s32>(150,150,300,200),true,0,-1);
Code: Select all
scene::ISceneNode *node = smgr->getSceneCollisionManager()-> getSceneNodeFromScreenCoordinatesBB(position2d<s32>(mox,moy),0x1,false);
Code: Select all
core::line3d<f32> line;
line=smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(position2d<s32>(mox,moy),cam);
scene::ISceneNode *nodeline = smgr->getSceneCollisionManager()->getSceneNodeFromRayBB(line,0x1,false);
Code: Select all
int idd=0;
int curid=0;
scene::ITriangleSelector * sel[100];
void gio::add()
{
idd++;
scene::IAnimatedMesh * mesha=smgr->getMesh("c:/x/apple/apple.x");
scene::IAnimatedMeshSceneNode *nd=smgr->addAnimatedMeshSceneNode(mesha,0,idd,core::vector3df(xx, yy, zz));
sel[idd] = smgr->createOctTreeTriangleSelector(mesha, nd, 128);
//If you wish to select animated node you can use:
//sel[idd] = smgr->createTriangleSelectorFromBoundingBox(nd);
nd->setTriangleSelector(sel[idd]);
}
core::line3d<f32> line;
core::vector3df intersection;
core::triangle3df tri;
line=smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(position2d<s32>(mox,moy),cam);
int k=0;
for(k=0; k<=idd; k++)
{
if (smgr->getSceneCollisionManager()->getCollisionPoint(line, sel[k], intersection, tri))
{
curid=k;
break;
}
}
scene::IAnimatedMeshSceneNode *curnode=smgr->getSceneNodeFromId(curid);
Code: Select all
scene::IAnimatedMesh * ter = smgr->getMesh("c:/x/ter.3ds");
scene::ISceneNode * ternode=smgr->addOctTreeSceneNode(ter,0);
ternode->setMaterialFlag(video::EMF_LIGHTING,false);
scene::ITriangleSelector * selector = smgr->createOctTreeTriangleSelector(ter, ternode, 128);
ternode->setTriangleSelector(selector);
IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("c:/x/b1.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setSize(dimension2d<f32>(10.0f, 10.0f));
bill->setPosition(vector3df(1.0f, 0.0f, 110.0f));
core::line3d<f32> line;
//1) Intersection with camera:
line.start = cam->getPosition();
line.end = line.start + (cam->getTarget() - line.start).normalize() * 1000.0f;
//2) intersection with mousecoordinates:
//line=smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(position2d<s32>(mox,moy),cam);
core::vector3df intersection;
core::triangle3df tri;
if (smgr->getSceneCollisionManager()->getCollisionPoint(line, selector, intersection, tri))
{
bill->setPosition(intersection);
}