attempting to merge Queatz/the-wielded-tool and kahrl/viewbobbing, something doesn...
authorKahrl <kahrl@gmx.net>
Thu, 8 Sep 2011 12:21:56 +0000 (14:21 +0200)
committerKahrl <kahrl@gmx.net>
Thu, 8 Sep 2011 12:21:56 +0000 (14:21 +0200)
1  2 
src/client.cpp
src/client.h
src/game.cpp

diff --cc src/client.cpp
index 81dedd1446336f3b3fe0263ee49addd63b2e39fd,d491f9d3646b461a40339335d80e38cf1dbb9421..71a826a1fa5dc5b6aa9f68e88d9453beeb445d72
@@@ -1999,11 -1998,24 +1999,19 @@@ NodeMetadata* Client::getNodeMetadata(v
        return m_env.getMap().getNodeMetadata(p);
  }
  
 -v3f Client::getPlayerPosition(v3f *eye_position)
 +LocalPlayer* Client::getLocalPlayer()
  {
 -      //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
 -      LocalPlayer *player = m_env.getLocalPlayer();
 -      assert(player != NULL);
 -      if (eye_position)
 -              *eye_position = player->getEyePosition();
 -      return player->getPosition();
 +      return m_env.getLocalPlayer();
  }
  
+ void Client::setPlayerWield(scene::ISceneNode *wield)
+ {
+       //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
+       LocalPlayer *player = m_env.getLocalPlayer();
+       assert(player != NULL);
+       player->wield = wield;
+ }
  void Client::setPlayerControl(PlayerControl &control)
  {
        //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
diff --cc src/client.h
index 930987c02e7f676f1289626c4ad44bdb85dc5aef,398a3b849420ea37189f8f78082ff57520435f4a..e7a81a1112487dcdbf4974f2df299d864b11f472
@@@ -208,8 -206,11 +208,9 @@@ public
        // Wrapper to Map
        NodeMetadata* getNodeMetadata(v3s16 p);
  
 -      // Get the player position, and optionally put the
 -      // eye position in *eye_position
 -      v3f getPlayerPosition(v3f *eye_position=NULL);
 +      LocalPlayer* getLocalPlayer();
  
+       void setPlayerWield(scene::ISceneNode *wield);
        void setPlayerControl(PlayerControl &control);
  
        void selectPlayerItem(u16 item);
diff --cc src/game.cpp
index 24f356e466ddda964a1c75d1c558aad3ed0c764b,86f1939c382922eebb49ce2ee572f69b128a04b7..af4886137ccf40d37ff36a5a83c67fe0d7ef1135
@@@ -827,6 -970,49 +827,44 @@@ void the_game
        f32 camera_yaw = 0; // "right/left"
        f32 camera_pitch = 0; // "up/down"
  
 -      v3f tool_wield_position(0.6, -0.6, 1.0);
+       /*
+               Tool
+       */
+       
 -              tool_wield = smgr->addMeshSceneNode(mesh, camera);
++      v3f tool_wield_position(0.06*BS, 1.619*BS, 0.1*BS);
+       v3f tool_wield_rotation(-25, 180, -25);
+       float tool_wield_animation = 0.0;
+       scene::IMeshSceneNode *tool_wield;
+       {
+               scene::SMesh *mesh = new scene::SMesh();
+               scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+               video::SColor c(255,255,255,255);
+               video::S3DVertex vertices[4] =
+               {
+                       video::S3DVertex(-0.5,0,0, 0,0,0, c, 0,1),
+                       video::S3DVertex(0.5,0,0, 0,0,0, c, 1,1),
+                       video::S3DVertex(0.5,0.5,0, 0,0,0, c, 1,0),
+                       video::S3DVertex(-0.5,0.5,0, 0,0,0, c, 0,0),
+               };
+               u16 indices[] = {0,1,2,2,3,0};
+               buf->append(vertices, 4, indices, 6);
+               // Set material
+               buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+               buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+               buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+               // Add to mesh
+               mesh->addMeshBuffer(buf);
+               buf->drop();
+       
++              tool_wield = smgr->addMeshSceneNode(mesh, camera.getPlayerNode());
+               mesh->drop();
+       }
+       tool_wield->setVisible(false);
+       tool_wield->setPosition(tool_wield_position);
+       tool_wield->setRotation(tool_wield_rotation);
+       
+       client.setPlayerWield(tool_wield);
        /*
                Clouds
        */