- // Draw the inventory texture
- if(texture != NULL)
- {
- const video::SColor color(255,255,255,255);
- const video::SColor colors[] = {color,color,color,color};
- driver->draw2DImage(texture, rect,
- core::rect<s32>(core::position2d<s32>(0,0),
- core::dimension2di(texture->getOriginalSize())),
- clip, colors, true);
+ const ItemDefinition &def = item.getDefinition(client->idef());
+ ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client);
+
+ if (imesh && imesh->mesh) {
+ scene::IMesh *mesh = imesh->mesh;
+ driver->clearZBuffer();
+ s32 delta = 0;
+ if (rotation_kind < IT_ROT_NONE) {
+ MeshTimeInfo &ti = rotation_time_infos[rotation_kind];
+ if (mesh != ti.mesh) {
+ ti.mesh = mesh;
+ ti.time = porting::getTimeMs();
+ } else {
+ delta = porting::getDeltaMs(ti.time, porting::getTimeMs()) % 100000;
+ }
+ }
+ core::rect<s32> oldViewPort = driver->getViewPort();
+ core::matrix4 oldProjMat = driver->getTransform(video::ETS_PROJECTION);
+ core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW);
+ core::matrix4 ProjMatrix;
+ ProjMatrix.buildProjectionMatrixOrthoLH(2, 2, -1, 100);
+ driver->setTransform(video::ETS_PROJECTION, ProjMatrix);
+ driver->setTransform(video::ETS_VIEW, ProjMatrix);
+ core::matrix4 matrix;
+ matrix.makeIdentity();
+
+ if (enable_animations) {
+ float timer_f = (float) delta / 5000.0;
+ matrix.setRotationDegrees(core::vector3df(0, 360 * timer_f, 0));
+ }
+
+ driver->setTransform(video::ETS_WORLD, matrix);
+ driver->setViewPort(rect);
+
+ video::SColor basecolor =
+ client->idef()->getItemstackColor(item, client);
+
+ u32 mc = mesh->getMeshBufferCount();
+ for (u32 j = 0; j < mc; ++j) {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+ // we can modify vertices relatively fast,
+ // because these meshes are not buffered.
+ assert(buf->getHardwareMappingHint_Vertex() == scene::EHM_NEVER);
+ video::SColor c = basecolor;
+ if (imesh->buffer_colors.size() > j) {
+ ItemPartColor *p = &imesh->buffer_colors[j];
+ if (p->override_base)
+ c = p->color;
+ }
+ if (imesh->needs_shading)
+ colorizeMeshBuffer(buf, &c);
+ else
+ setMeshBufferColor(buf, c);
+ video::SMaterial &material = buf->getMaterial();
+ material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ material.Lighting = false;
+ driver->setMaterial(material);
+ driver->drawMeshBuffer(buf);
+ }
+
+ driver->setTransform(video::ETS_VIEW, oldViewMat);
+ driver->setTransform(video::ETS_PROJECTION, oldProjMat);
+ driver->setViewPort(oldViewPort);