Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
- {
- ITextureSource *tsrc = gamedef->getTextureSource();
- IItemDefManager *idef = gamedef->getItemDefManager();
- IShaderSource *shdrsrc = gamedef->getShaderSource();
- INodeDefManager *ndef = gamedef->getNodeDefManager();
- const ItemDefinition &def = item.getDefinition(idef);
- const ContentFeatures &f = ndef->get(def.name);
- // If wield_image is defined, it overrides everything else
- if (def.wield_image != "") {
- setExtruded(def.wield_image, def.wield_scale, tsrc);
- }
- // Handle nodes
- // See also CItemDefManager::createClientCached()
- else if (def.type == ITEM_NODE) {
- if (f.mesh_ptr[0]) {
- // e.g. mesh nodes and nodeboxes
- changeToMesh(f.mesh_ptr[0]);
- // mesh_ptr[0] is pre-scaled by BS * f->visual_scale
- m_meshnode->setScale(
- def.wield_scale * WIELD_SCALE_FACTOR
- / (BS * f.visual_scale));
- } else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
- setCube(f.tiles, def.wield_scale, tsrc);
- } else if (f.drawtype == NDT_AIRLIKE) {
- changeToMesh(NULL);
- }
- }
- // Customize materials
- for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
- assert(i < 6);
- video::SMaterial &material = m_meshnode->getMaterial(i);
- material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
- material.setFlag(video::EMF_BACK_FACE_CULLING, true);
- material.setFlag(video::EMF_FOG_ENABLE, true);
- material.setFlag(video::EMF_LIGHTING, false);
- material.setFlag(video::EMF_BILINEAR_FILTER, false);
- material.setFlag(video::EMF_TRILINEAR_FILTER, false);
- // anisotropic filtering removes "thin black line" artifacts
- material.setFlag(video::EMF_ANISOTROPIC_FILTER, true);
- material.setFlag(video::EMF_TEXTURE_WRAP, false);
- material.setTexture(0, f.tiles[i].texture);
- if (m_enable_shaders) {
- material.MaterialType = shdrsrc->getShaderInfo(f.tiles[i].shader_id).material;
- f.tiles[i].applyMaterialOptionsWithShaders(material);
- if (f.tiles[i].normal_texture) {
- material.setTexture(1, f.tiles[i].normal_texture);
- material.setTexture(2, tsrc->getTexture("enable_img.png"));
- } else {
- material.setTexture(2, tsrc->getTexture("disable_img.png"));
- }
- } else {
- f.tiles[i].applyMaterialOptions(material);
- }
- }
- // no wield mesh found
- //changeToMesh(NULL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement