Advertisement
Guest User

Untitled

a guest
Nov 10th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
  2. {
  3. ITextureSource *tsrc = gamedef->getTextureSource();
  4. IItemDefManager *idef = gamedef->getItemDefManager();
  5. IShaderSource *shdrsrc = gamedef->getShaderSource();
  6. INodeDefManager *ndef = gamedef->getNodeDefManager();
  7. const ItemDefinition &def = item.getDefinition(idef);
  8. const ContentFeatures &f = ndef->get(def.name);
  9.  
  10. // If wield_image is defined, it overrides everything else
  11. if (def.wield_image != "") {
  12. setExtruded(def.wield_image, def.wield_scale, tsrc);
  13. }
  14. // Handle nodes
  15. // See also CItemDefManager::createClientCached()
  16. else if (def.type == ITEM_NODE) {
  17. if (f.mesh_ptr[0]) {
  18. // e.g. mesh nodes and nodeboxes
  19. changeToMesh(f.mesh_ptr[0]);
  20. // mesh_ptr[0] is pre-scaled by BS * f->visual_scale
  21. m_meshnode->setScale(
  22. def.wield_scale * WIELD_SCALE_FACTOR
  23. / (BS * f.visual_scale));
  24. } else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
  25. setCube(f.tiles, def.wield_scale, tsrc);
  26. } else if (f.drawtype == NDT_AIRLIKE) {
  27. changeToMesh(NULL);
  28. }
  29. }
  30.  
  31. // Customize materials
  32. for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
  33. assert(i < 6);
  34. video::SMaterial &material = m_meshnode->getMaterial(i);
  35. material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
  36. material.setFlag(video::EMF_BACK_FACE_CULLING, true);
  37. material.setFlag(video::EMF_FOG_ENABLE, true);
  38. material.setFlag(video::EMF_LIGHTING, false);
  39. material.setFlag(video::EMF_BILINEAR_FILTER, false);
  40. material.setFlag(video::EMF_TRILINEAR_FILTER, false);
  41. // anisotropic filtering removes "thin black line" artifacts
  42. material.setFlag(video::EMF_ANISOTROPIC_FILTER, true);
  43. material.setFlag(video::EMF_TEXTURE_WRAP, false);
  44. material.setTexture(0, f.tiles[i].texture);
  45. if (m_enable_shaders) {
  46. material.MaterialType = shdrsrc->getShaderInfo(f.tiles[i].shader_id).material;
  47. f.tiles[i].applyMaterialOptionsWithShaders(material);
  48. if (f.tiles[i].normal_texture) {
  49. material.setTexture(1, f.tiles[i].normal_texture);
  50. material.setTexture(2, tsrc->getTexture("enable_img.png"));
  51. } else {
  52. material.setTexture(2, tsrc->getTexture("disable_img.png"));
  53. }
  54. } else {
  55. f.tiles[i].applyMaterialOptions(material);
  56. }
  57. }
  58.  
  59. // no wield mesh found
  60. //changeToMesh(NULL);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement