#include <cmath>
#include <SAnimatedMesh.h>
#include "settings.h"
+#include "nodedef.h" // For wield visualization
+
+// In Irrlicht 1.8 the signature of ITexture::lock was changed from
+// (bool, u32) to (E_TEXTURE_LOCK_MODE, u32).
+#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 7
+#define MY_ETLM_READ_ONLY true
+#else
+#define MY_ETLM_READ_ONLY video::ETLM_READ_ONLY
+#endif
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
m_smgr(smgr),
// Position the wielded item
v3f wield_position = v3f(45, -35, 65);
- v3f wield_rotation = v3f(-100, 110, -100);
+ v3f wield_rotation = v3f(-100, 120, -100);
if (m_digging_button != -1)
{
f32 digfrac = m_digging_anim;
m_wanted_frametime = 1.0 / wanted_fps;
}
-void Camera::wield(const InventoryItem* item)
+void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
{
+ //ITextureSource *tsrc = gamedef->tsrc();
+ INodeDefManager *ndef = gamedef->ndef();
+
if (item != NULL)
{
bool isCube = false;
// A block-type material
MaterialItem* mat_item = (MaterialItem*) item;
content_t content = mat_item->getMaterial();
- if (content_features(content).solidness || content_features(content).visual_solidness)
- {
- m_wieldnode->setCube(content_features(content).tiles);
+ switch(ndef->get(content).drawtype){
+ case NDT_NORMAL:
+ case NDT_LIQUID:
+ case NDT_FLOWINGLIQUID:
+ case NDT_GLASSLIKE:
+ case NDT_ALLFACES:
+ case NDT_ALLFACES_OPTIONAL:
+ m_wieldnode->setCube(ndef->get(content).tiles);
m_wieldnode->setScale(v3f(30));
isCube = true;
+ break;
+ default:
+ break;
}
}
else
{
// Bare hands
- m_wieldnode->setVisible(false);
+ m_wieldnode->setSprite(gamedef->tsrc()->getTextureRaw("wieldhand.png"));
+ m_wieldnode->setScale(v3f(40));
+ m_wieldnode->setVisible(true);
}
}
{
// Texture is in the correct color format, we can pass it
// to extrudeARGB right away.
- void* data = texture->lock(true);
+ void* data = texture->lock(MY_ETLM_READ_ONLY);
if (data == NULL)
return NULL;
mesh = extrudeARGB(size.Width, size.Height, (u8*) data);
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
- video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(true));
+ video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(MY_ETLM_READ_ONLY));
if (img1 == NULL)
return NULL;