I'm trying to change TextureMatrix of a created scene node
Code: Select all
node = smgr->addCubeSceneNode(500.0f);
video::SMaterial& m = node->getMaterial(0);
m.getTextureMatrix(0).setTextureScale(10,10);
Thank you
Code: Select all
node = smgr->addCubeSceneNode(500.0f);
video::SMaterial& m = node->getMaterial(0);
m.getTextureMatrix(0).setTextureScale(10,10);
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
scene::ISceneNode* node = 0;
IrrlichtDevice* device = 0;
/*
To get events like mouse and keyboard input, or GUI events like
"the OK button has been clicked", we need an object wich is derived from the
IEventReceiver object. There is only one method to override: OnEvent.
This method will be called by the engine when an event happened.
We will use this input to move the scene node with the keys W and S.
*/
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
/*
If the key 'W' or 'S' was left up, we get the position of the scene node,
and modify the Y coordinate a little bit. So if you press 'W', the node
moves up, and if you press 'S' it moves down.
*/
if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = node->getPosition();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
node->setPosition(v);
}
return true;
case KEY_KEY_Q:
{
device->closeDevice();
}
}
}
return false;
}
};
/*
The event receiver for moving a scene node is ready. So lets just create
an Irrlicht Device and the scene node we want to move. We also create some
other additional scene nodes, to show that there are also some different
possibilities to move and animate scene nodes.
*/
int main()
{
// let user select driver type
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
// create device
MyEventReceiver receiver;
device = createDevice( driverType, core::dimension2d<s32>(800, 600),
16, false, false, false, &receiver);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
node = smgr->addCubeSceneNode(500.0f);
node->setPosition(core::vector3df(0,-250.0f,0));
node->setMaterialFlag(video::EMF_LIGHTING,false);
node->setMaterialTexture(0, driver->getTexture("./media/ground.jpg"));
node->getMaterial(0).getTextureMatrix(0).setTextureScale(30,30);
scene::ICameraSceneNode * cam = smgr->addCameraSceneNodeMaya();
cam->setTarget(core::vector3df(0,0,0));
cam->setPosition(core::vector3df(50.0f,70.0f,0));
device->getCursorControl()->setVisible(true);
/*
We have done everything, so lets draw it. We also write the current
frames per second and the name of the driver to the caption of the
window.
*/
int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,113,113,133));
smgr->drawAll(); // draw the 3d scene
device->getGUIEnvironment()->drawAll(); // draw the gui environment (the logo)
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw tmp(L"Movement Example - Irrlicht Engine [");
tmp += driver->getName();
tmp += L"] fps: ";
tmp += fps;
device->setWindowCaption(tmp.c_str());
lastFPS = fps;
}
}
/*
In the end, delete the Irrlicht device.
*/
node->drop();
device->drop();
return 0;
}