Advertisement
Guest User

3d Player patch

a guest
Jan 29th, 2012
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 39.71 KB | None | 0 0
  1. --- a\content_cao.cpp   2012-01-28 21:52:18.000000000 -0000
  2. +++ b\content_cao.cpp   2012-01-26 15:46:20.000000000 -0000
  3. @@ -2055,29 +2055,41 @@
  4.  */
  5.  
  6.  class PlayerCAO : public ClientActiveObject
  7.  {
  8.  private:
  9.     core::aabbox3d<f32> m_selection_box;
  10. -   scene::IMeshSceneNode *m_node;
  11. +   scene::IMeshSceneNode *m_body, *m_head, *m_leg_l, *m_leg_r, *m_arm_l, *m_arm_r;
  12.     scene::ITextSceneNode* m_text;
  13.     std::string m_name;
  14.     v3f m_position;
  15. +   v3f m_old_position;
  16. +   float m_leg_rot;
  17. +   float m_leg_rot_i;
  18. +   float m_speed;
  19. +   float m_pitch;
  20.     float m_yaw;
  21.     SmoothTranslator pos_translator;
  22. +   SmoothTranslator old_pos_translator;
  23. +   SmoothTranslator head_translator;
  24.     bool m_is_local_player;
  25.     LocalPlayer *m_local_player;
  26.     float m_damage_visual_timer;
  27.  
  28.  public:
  29.     PlayerCAO(IGameDef *gamedef, ClientEnvironment *env):
  30.         ClientActiveObject(0, gamedef, env),
  31.         m_selection_box(-BS/3.,0.0,-BS/3., BS/3.,BS*2.0,BS/3.),
  32. -       m_node(NULL),
  33. +       m_body(NULL), m_head(NULL), m_leg_l(NULL), m_leg_r(NULL), m_arm_l(NULL), m_arm_r(NULL),
  34.         m_text(NULL),
  35. -       m_position(v3f(0,10*BS,0)),
  36. +       m_position(v3f(0,0,0)),
  37. +       m_old_position(v3f(0,0,0)),
  38. +       m_leg_rot(0),
  39. +       m_leg_rot_i(0),
  40. +       m_speed(0),
  41. +       m_pitch(0),
  42.         m_yaw(0),
  43.         m_is_local_player(false),
  44.         m_local_player(NULL),
  45.         m_damage_visual_timer(0)
  46.     {
  47.         if(gamedef == NULL)
  48. @@ -2094,29 +2106,45 @@
  49.         // check version
  50.         if(version != 0)
  51.             return;
  52.         // name
  53.         m_name = deSerializeString(is);
  54.         // pos
  55. +       m_old_position = m_position; // old position
  56.         m_position = readV3F1000(is);
  57. +       // pitch
  58. +       m_pitch = readF1000(is);
  59. +       m_pitch = updateHeadPitch(m_pitch);
  60.         // yaw
  61.         m_yaw = readF1000(is);
  62.  
  63.         pos_translator.init(m_position);
  64. +       old_pos_translator.init(m_old_position);
  65. +       head_translator.init(v3f(m_pitch, 0, 0));
  66.  
  67.         Player *player = m_env->getPlayer(m_name.c_str());
  68.         if(player && player->isLocal()){
  69.             m_is_local_player = true;
  70.             m_local_player = (LocalPlayer*)player;
  71.         }
  72.     }
  73.  
  74.     ~PlayerCAO()
  75.     {
  76. -       if(m_node)
  77. -           m_node->remove();
  78. +       if(m_body)
  79. +           m_body->remove();
  80. +       if(m_head)
  81. +           m_head->remove();
  82. +       if(m_leg_l)
  83. +           m_leg_l->remove();
  84. +       if(m_leg_r)
  85. +           m_leg_r->remove();
  86. +       if(m_arm_l)
  87. +           m_arm_l->remove();
  88. +       if(m_arm_r)
  89. +           m_arm_r->remove();
  90.     }
  91.  
  92.     static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env)
  93.     {
  94.         return new PlayerCAO(gamedef, env);
  95.     }
  96. @@ -2136,121 +2164,641 @@
  97.         return pos_translator.vect_show;
  98.     }
  99.        
  100.     void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
  101.             IrrlichtDevice *irr)
  102.     {
  103. -       if(m_node != NULL)
  104. +       if(m_body != NULL || m_head != NULL || m_leg_l != NULL || m_leg_r != NULL || m_arm_l != NULL || m_arm_r != NULL)
  105.             return;
  106.         if(m_is_local_player)
  107.             return;
  108.        
  109.         //video::IVideoDriver* driver = smgr->getVideoDriver();
  110.         gui::IGUIEnvironment* gui = irr->getGUIEnvironment();
  111.        
  112. +       { // Body
  113.         scene::SMesh *mesh = new scene::SMesh();
  114. -       { // Front
  115. +       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  116. +       video::SColor c(255,255,255,255);
  117. +       video::S3DVertex vertices[46] =
  118. +       {
  119. +           video::S3DVertex(1.125000, 0.750000, 2.125066, 1.000000, 0.000000, -0.000000,c, 0.815385, 0.714286),
  120. +           video::S3DVertex(1.125001, 0.750000, 4.375066, 1.000000, 0.000000, -0.000000,c, 0.815385, 0.642857),
  121. +           video::S3DVertex(1.125000, -0.750000, 2.125066, 1.000000, 0.000000, -0.000000,c, 0.769231, 0.714286),
  122. +           video::S3DVertex(1.125001, 0.750000, 4.375066, 1.000000, -0.000001, 0.000000,c, 0.815385, 0.642857),
  123. +           video::S3DVertex(1.124999, -0.750001, 4.375066, 1.000000, -0.000001, 0.000000,c, 0.769231, 0.642857),
  124. +           video::S3DVertex(1.125000, -0.750000, 2.125066, 1.000000, -0.000001, 0.000000,c, 0.769231, 0.714286),
  125. +           video::S3DVertex(1.125000, -0.750000, 2.125066, 0.000000, -1.000000, -0.000000,c, 0.753846, 0.714286),
  126. +           video::S3DVertex(1.124999, -0.750001, 4.375066, 0.000000, -1.000000, -0.000000,c, 0.753846, 0.642857),
  127. +           video::S3DVertex(-1.125000, -0.750000, 2.125066, 0.000000, -1.000000, -0.000000,c, 0.692308, 0.714286),
  128. +           video::S3DVertex(1.124999, -0.750001, 4.375066, -0.000001, -1.000000, 0.000000,c, 0.753846, 0.642857),
  129. +           video::S3DVertex(-1.125001, -0.749999, 4.375066, -0.000001, -1.000000, 0.000000,c, 0.692308, 0.642857),
  130. +           video::S3DVertex(-1.125000, -0.750000, 2.125066, -0.000001, -1.000000, 0.000000,c, 0.692308, 0.714286),
  131. +           video::S3DVertex(-1.125000, -0.750000, 2.125066, -1.000000, 0.000000, -0.000000,c, 0.876923, 0.714286),
  132. +           video::S3DVertex(-1.125001, -0.749999, 4.375066, -1.000000, 0.000000, -0.000000,c, 0.876923, 0.642857),
  133. +           video::S3DVertex(-1.125000, 0.750000, 4.375066, -1.000000, 0.000000, -0.000000,c, 0.830769, 0.642857),
  134. +           video::S3DVertex(-1.125000, 0.750000, 2.125066, -1.000000, 0.000000, -0.000000,c, 0.830769, 0.714286),
  135. +           video::S3DVertex(1.125001, 0.750000, 4.375066, 0.000000, 1.000000, 0.000000,c, 0.953846, 0.714286),
  136. +           video::S3DVertex(1.125000, 0.750000, 2.125066, 0.000000, 1.000000, 0.000000,c, 0.953846, 0.642857),
  137. +           video::S3DVertex(-1.125000, 0.750000, 2.125066, 0.000000, 1.000000, 0.000000,c, 0.892308, 0.642857),
  138. +           video::S3DVertex(-1.125000, 0.750000, 4.375066, 0.000000, 1.000000, 0.000000,c, 0.892308, 0.714286),
  139. +           video::S3DVertex(3.000002, 1.124999, 2.499885, 0.000000, 1.000000, 0.000000,c, 0.353846, 0.446429),
  140. +           video::S3DVertex(3.000000, 1.125000, -5.000116, 0.000000, 1.000000, 0.000000,c, 0.353846, 0.714286),
  141. +           video::S3DVertex(-2.999999, 1.125000, -5.000116, 0.000000, 1.000000, 0.000000,c, 0.507692, 0.714286),
  142. +           video::S3DVertex(-3.000000, 1.124999, 2.499885, 0.000000, 1.000000, 0.000000,c, 0.507692, 0.446429),
  143. +           video::S3DVertex(-3.000000, -1.125000, -5.000116, -1.000000, 0.000001, -0.000000,c, 0.338462, 0.714286),
  144. +           video::S3DVertex(-3.000001, -1.124999, 2.499885, -1.000000, 0.000001, -0.000000,c, 0.338462, 0.446429),
  145. +           video::S3DVertex(-3.000000, 1.124999, 2.499885, -1.000000, 0.000001, -0.000000,c, 0.261538, 0.446429),
  146. +           video::S3DVertex(-2.999999, 1.125000, -5.000116, -1.000000, 0.000001, -0.000000,c, 0.261538, 0.714286),
  147. +           video::S3DVertex(3.000000, -1.124999, -5.000116, 0.000000, -1.000000, -0.000000,c, 0.153846, 0.714286),
  148. +           video::S3DVertex(2.999998, -1.125001, 2.499885, 0.000000, -1.000000, -0.000000,c, 0.153846, 0.446429),
  149. +           video::S3DVertex(-3.000000, -1.125000, -5.000116, 0.000000, -1.000000, -0.000000,c, 0.000000, 0.714286),
  150. +           video::S3DVertex(-3.000001, -1.124999, 2.499885, -0.000000, -1.000000, 0.000000,c, 0.000000, 0.446429),
  151. +           video::S3DVertex(3.000000, 1.125000, -5.000116, 1.000000, -0.000000, -0.000000,c, 0.246154, 0.714286),
  152. +           video::S3DVertex(3.000002, 1.124999, 2.499885, 1.000000, -0.000000, -0.000000,c, 0.246154, 0.446429),
  153. +           video::S3DVertex(3.000000, -1.124999, -5.000116, 1.000000, -0.000000, -0.000000,c, 0.169231, 0.714286),
  154. +           video::S3DVertex(3.000002, 1.124999, 2.499885, 1.000000, -0.000002, 0.000000,c, 0.246154, 0.446429),
  155. +           video::S3DVertex(2.999998, -1.125001, 2.499885, 1.000000, -0.000002, 0.000000,c, 0.169231, 0.446429),
  156. +           video::S3DVertex(3.000000, -1.124999, -5.000116, 1.000000, -0.000002, 0.000000,c, 0.169231, 0.714286),
  157. +           video::S3DVertex(3.000002, 1.124999, 2.499885, -0.000000, -0.000000, 1.000000,c, 0.676923, 0.517857),
  158. +           video::S3DVertex(-3.000000, 1.124999, 2.499885, -0.000000, -0.000000, 1.000000,c, 0.523077, 0.517857),
  159. +           video::S3DVertex(2.999998, -1.125001, 2.499885, -0.000000, -0.000000, 1.000000,c, 0.676923, 0.607143),
  160. +           video::S3DVertex(-3.000001, -1.124999, 2.499885, 0.000000, -0.000000, 1.000000,c, 0.523077, 0.607143),
  161. +           video::S3DVertex(3.000000, 1.125000, -5.000116, 0.000000, 0.000000, -1.000000,c, 0.676923, 0.714286),
  162. +           video::S3DVertex(3.000000, -1.124999, -5.000116, 0.000000, 0.000000, -1.000000,c, 0.676923, 0.625000),
  163. +           video::S3DVertex(-2.999999, 1.125000, -5.000116, 0.000000, 0.000000, -1.000000,c, 0.523077, 0.714286),
  164. +           video::S3DVertex(-3.000000, -1.125000, -5.000116, 0.000000, -0.000000, -1.000000,c, 0.523077, 0.625000),
  165. +       };
  166. +       u16 indices[] = {0, 1, 2,
  167. +                       3, 4, 5,
  168. +                       6, 7, 8,
  169. +                       9, 10, 11,
  170. +                       12, 13, 14,
  171. +                       12, 14, 15,
  172. +                       16, 17, 18,
  173. +                       16, 18, 19,
  174. +                       20, 21, 22,
  175. +                       20, 22, 23,
  176. +                       24, 25, 26,
  177. +                       24, 26, 27,
  178. +                       28, 29, 30,
  179. +                       29, 31, 30,
  180. +                       32, 33, 34,
  181. +                       35, 36, 37,
  182. +                       38, 39, 40,
  183. +                       39, 41, 40,
  184. +                       42, 43, 44,
  185. +                       43, 45, 44};
  186. +       buf->append(vertices, 46, indices, 60);
  187. +       // Set material
  188. +       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  189. +       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  190. +       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  191. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  192. +       // Add to mesh
  193. +       mesh->addMeshBuffer(buf);
  194. +       buf->drop();
  195. +      
  196. +       m_body = smgr->addMeshSceneNode(mesh, NULL);
  197. +       m_body->setPosition(v3f(0,0,0));
  198. +       m_body->setRotation(v3f(-90,0,0));
  199. +      
  200. +       // Set it to use the materials of the meshbuffers directly.
  201. +       // This is needed for changing the texture in the future
  202. +       m_body->setReadOnlyMaterials(true);
  203. +       updateNodePos();
  204. +       }
  205. +      
  206. +       { // Head
  207. +       scene::SMesh *mesh = new scene::SMesh();
  208.         scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  209.         video::SColor c(255,255,255,255);
  210. -       video::S3DVertex vertices[4] =
  211. +       video::S3DVertex vertices[30] =
  212.         {
  213. -           video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
  214. -           video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
  215. -           video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
  216. -           video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
  217. +           video::S3DVertex(2.250001, 1.499998, 3.774997, 0.000000, 1.000000, 0.000001,c, 0.353846, 0.000000),
  218. +           video::S3DVertex(2.249999, 1.500000, 0.024998, 0.000000, 1.000000, 0.000001,c, 0.353846, 0.142857),
  219. +           video::S3DVertex(-2.250000, 1.499999, 3.774997, 0.000000, 1.000000, 0.000001,c, 0.507638, -0.000000),
  220. +           video::S3DVertex(2.249999, 1.500000, 0.024998, 0.000000, 1.000000, 0.000000,c, 0.353846, 0.142857),
  221. +           video::S3DVertex(-2.250000, 1.500001, 0.024998, 0.000000, 1.000000, 0.000000,c, 0.507638, 0.142857),
  222. +           video::S3DVertex(-2.250000, 1.499999, 3.774997, 0.000000, 1.000000, 0.000000,c, 0.507638, -0.000000),
  223. +           video::S3DVertex(-2.250000, -1.500000, 0.024998, -1.000000, -0.000000, -0.000000,c, 0.338462, 0.142857),
  224. +           video::S3DVertex(-2.250000, -1.499999, 3.774997, -1.000000, -0.000000, -0.000000,c, 0.338285, 0.000163),
  225. +           video::S3DVertex(-2.250000, 1.499999, 3.774997, -1.000000, -0.000000, -0.000000,c, 0.261538, 0.000000),
  226. +           video::S3DVertex(-2.250000, 1.500001, 0.024998, -1.000000, 0.000000, -0.000000,c, 0.261538, 0.142857),
  227. +           video::S3DVertex(2.250001, -1.499999, 0.024998, 0.000000, -1.000000, -0.000001,c, 0.153846, 0.142857),
  228. +           video::S3DVertex(2.249998, -1.500001, 3.774997, 0.000000, -1.000000, -0.000001,c, 0.153846, -0.000000),
  229. +           video::S3DVertex(-2.250000, -1.500000, 0.024998, 0.000000, -1.000000, -0.000001,c, 0.000000, 0.142857),
  230. +           video::S3DVertex(2.249998, -1.500001, 3.774997, -0.000001, -1.000000, 0.000000,c, 0.153846, -0.000000),
  231. +           video::S3DVertex(-2.250000, -1.499999, 3.774997, -0.000001, -1.000000, 0.000000,c, 0.000000, 0.000000),
  232. +           video::S3DVertex(-2.250000, -1.500000, 0.024998, -0.000001, -1.000000, 0.000000,c, 0.000000, 0.142857),
  233. +           video::S3DVertex(2.249999, 1.500000, 0.024998, 1.000000, 0.000001, -0.000000,c, 0.246154, 0.142857),
  234. +           video::S3DVertex(2.250001, 1.499998, 3.774997, 1.000000, 0.000001, -0.000000,c, 0.246154, 0.000000),
  235. +           video::S3DVertex(2.250001, -1.499999, 0.024998, 1.000000, 0.000001, -0.000000,c, 0.169231, 0.142857),
  236. +           video::S3DVertex(2.250001, 1.499998, 3.774997, 1.000000, -0.000001, 0.000001,c, 0.246154, 0.000000),
  237. +           video::S3DVertex(2.249998, -1.500001, 3.774997, 1.000000, -0.000001, 0.000001,c, 0.169231, 0.000000),
  238. +           video::S3DVertex(2.250001, -1.499999, 0.024998, 1.000000, -0.000001, 0.000001,c, 0.169231, 0.142857),
  239. +           video::S3DVertex(2.250001, 1.499998, 3.774997, -0.000000, -0.000000, 1.000000,c, 0.523077, 0.142857),
  240. +           video::S3DVertex(-2.250000, 1.499999, 3.774997, -0.000000, -0.000000, 1.000000,c, 0.676923, 0.142857),
  241. +           video::S3DVertex(-2.250000, -1.499999, 3.774997, -0.000000, -0.000000, 1.000000,c, 0.676923, 0.053571),
  242. +           video::S3DVertex(2.249998, -1.500001, 3.774997, 0.000000, -0.000000, 1.000000,c, 0.523077, 0.053571),
  243. +           video::S3DVertex(2.249999, 1.500000, 0.024998, 0.000000, 0.000000, -1.000000,c, 0.692308, 0.053571),
  244. +           video::S3DVertex(2.250001, -1.499999, 0.024998, 0.000000, 0.000000, -1.000000,c, 0.692308, 0.142857),
  245. +           video::S3DVertex(-2.250000, -1.500000, 0.024998, 0.000000, 0.000000, -1.000000,c, 0.846154, 0.142857),
  246. +           video::S3DVertex(-2.250000, 1.500001, 0.024998, 0.000000, 0.000000, -1.000000,c, 0.846154, 0.053571),
  247.         };
  248. -       u16 indices[] = {0,1,2,2,3,0};
  249. -       buf->append(vertices, 4, indices, 6);
  250. +       u16 indices[] = {0, 1, 2,
  251. +                       3, 4, 5,
  252. +                       6, 7, 8,
  253. +                       6, 8, 9,
  254. +                       10, 11, 12,
  255. +                       13, 14, 15,
  256. +                       16, 17, 18,
  257. +                       19, 20, 21,
  258. +                       22, 23, 24,
  259. +                       22, 24, 25,
  260. +                       26, 27, 28,
  261. +                       26, 28, 29};
  262. +       buf->append(vertices, 30, indices, 36);
  263.         // Set material
  264.         buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  265.         buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  266.         buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  267. -       buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  268. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  269.         // Add to mesh
  270.         mesh->addMeshBuffer(buf);
  271.         buf->drop();
  272. +      
  273. +       m_head = smgr->addMeshSceneNode(mesh, NULL);
  274. +       m_head->setPosition(v3f(0,0,0));
  275. +       m_head->setRotation(v3f(-90,0,0));
  276. +      
  277. +       // Set it to use the materials of the meshbuffers directly.
  278. +       // This is needed for changing the texture in the future
  279. +       m_head->setReadOnlyMaterials(true);
  280. +       updateNodePos();
  281.         }
  282. -       { // Back
  283. +      
  284. +       { // Leg-Left
  285. +       scene::SMesh *mesh = new scene::SMesh();
  286.         scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  287.         video::SColor c(255,255,255,255);
  288. -       video::S3DVertex vertices[4] =
  289. +       video::S3DVertex vertices[28] =
  290.         {
  291. -           video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
  292. -           video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
  293. -           video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
  294. -           video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
  295. +           video::S3DVertex(-0.144449, 1.124999, 0.224998, 0.000000, 1.000000, 0.000000,c, 0.292308, 0.732143),
  296. +           video::S3DVertex(-0.144450, 1.125000, -8.025005, 0.000000, 1.000000, 0.000000,c, 0.292308, 1.000000),
  297. +           video::S3DVertex(-2.995950, 1.125000, -8.025005, 0.000000, 1.000000, 0.000000,c, 0.384615, 1.000000),
  298. +           video::S3DVertex(-2.995950, 1.125000, 0.224998, 0.000000, 1.000000, 0.000000,c, 0.384615, 0.732143),
  299. +           video::S3DVertex(-2.995950, -1.125000, -8.025005, -1.000000, 0.000000, -0.000000,c, 0.276923, 1.000000),
  300. +           video::S3DVertex(-2.995950, -1.124999, 0.224998, -1.000000, 0.000000, -0.000000,c, 0.276923, 0.732143),
  301. +           video::S3DVertex(-2.995950, 1.125000, -8.025005, -1.000000, 0.000000, -0.000000,c, 0.200000, 1.000000),
  302. +           video::S3DVertex(-2.995950, 1.125000, 0.224998, -1.000000, 0.000000, -0.000000,c, 0.200000, 0.732143),
  303. +           video::S3DVertex(-0.144450, -1.125000, -8.025005, -0.000001, -1.000000, -0.000000,c, 0.092308, 1.000000),
  304. +           video::S3DVertex(-0.144451, -1.125001, 0.224998, -0.000001, -1.000000, -0.000000,c, 0.092308, 0.732143),
  305. +           video::S3DVertex(-2.995950, -1.124999, 0.224998, -0.000001, -1.000000, -0.000000,c, 0.000000, 0.732143),
  306. +           video::S3DVertex(-0.144450, -1.125000, -8.025005, -0.000000, -1.000000, 0.000000,c, 0.092308, 1.000000),
  307. +           video::S3DVertex(-2.995950, -1.124999, 0.224998, -0.000000, -1.000000, 0.000000,c, 0.000000, 0.732143),
  308. +           video::S3DVertex(-2.995950, -1.125000, -8.025005, -0.000000, -1.000000, 0.000000,c, 0.000000, 1.000000),
  309. +           video::S3DVertex(-0.144450, 1.125000, -8.025005, 1.000000, -0.000000, -0.000000,c, 0.184615, 1.000000),
  310. +           video::S3DVertex(-0.144449, 1.124999, 0.224998, 1.000000, -0.000000, -0.000000,c, 0.184615, 0.732143),
  311. +           video::S3DVertex(-0.144450, -1.125000, -8.025005, 1.000000, -0.000000, -0.000000,c, 0.107692, 1.000000),
  312. +           video::S3DVertex(-0.144449, 1.124999, 0.224998, 1.000000, -0.000001, 0.000000,c, 0.184615, 0.732143),
  313. +           video::S3DVertex(-0.144451, -1.125001, 0.224998, 1.000000, -0.000001, 0.000000,c, 0.107692, 0.732143),
  314. +           video::S3DVertex(-0.144450, -1.125000, -8.025005, 1.000000, -0.000001, 0.000000,c, 0.107692, 1.000000),
  315. +           video::S3DVertex(-0.144449, 1.124999, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.400000, 0.892857),
  316. +           video::S3DVertex(-2.995950, 1.125000, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.492308, 0.892857),
  317. +           video::S3DVertex(-2.995950, -1.124999, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.492308, 0.803656),
  318. +           video::S3DVertex(-0.144451, -1.125001, 0.224998, 0.000000, -0.000000, 1.000000,c, 0.400000, 0.803656),
  319. +           video::S3DVertex(-0.144450, 1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.400000, 1.000000),
  320. +           video::S3DVertex(-0.144450, -1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.492308, 1.000000),
  321. +           video::S3DVertex(-2.995950, -1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.492308, 0.910714),
  322. +           video::S3DVertex(-2.995950, 1.125000, -8.025005, 0.000000, -0.000000, -1.000000,c, 0.400000, 0.910714),
  323.         };
  324. -       u16 indices[] = {0,1,2,2,3,0};
  325. -       buf->append(vertices, 4, indices, 6);
  326. +       u16 indices[] = {0, 1, 2,
  327. +                       0, 2, 3,
  328. +                       4, 5, 6,
  329. +                       5, 7, 6,
  330. +                       8, 9, 10,
  331. +                       11, 12, 13,
  332. +                       14, 15, 16,
  333. +                       17, 18, 19,
  334. +                       20, 21, 22,
  335. +                       20, 22, 23,
  336. +                       24, 25, 26,
  337. +                       24, 26, 27};
  338. +       buf->append(vertices, 28, indices, 36);
  339.         // Set material
  340.         buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  341.         buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  342.         buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  343. -       buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
  344. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  345.         // Add to mesh
  346.         mesh->addMeshBuffer(buf);
  347.         buf->drop();
  348. +      
  349. +       m_leg_l = smgr->addMeshSceneNode(mesh, NULL);
  350. +       m_leg_l->setPosition(v3f(0,0,0));
  351. +       m_leg_l->setRotation(v3f(-90,0,0));
  352. +      
  353. +       // Set it to use the materials of the meshbuffers directly.
  354. +       // This is needed for changing the texture in the future
  355. +       m_leg_l->setReadOnlyMaterials(true);
  356. +       updateNodePos();
  357.         }
  358. -       m_node = smgr->addMeshSceneNode(mesh, NULL);
  359. -       mesh->drop();
  360. +      
  361. +       { // Leg-Right
  362. +       scene::SMesh *mesh = new scene::SMesh();
  363. +       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  364. +       video::SColor c(255,255,255,255);
  365. +       video::S3DVertex vertices[28] =
  366. +       {
  367. +           video::S3DVertex(2.995751, 1.124999, 0.224998, 0.000000, 1.000000, 0.000000,c, 0.615385, 0.732143),
  368. +           video::S3DVertex(2.995750, 1.125000, -8.025005, 0.000000, 1.000000, 0.000000,c, 0.615385, 1.000000),
  369. +           video::S3DVertex(0.144250, 1.125000, -8.025005, 0.000000, 1.000000, 0.000000,c, 0.707692, 1.000000),
  370. +           video::S3DVertex(0.144250, 1.125000, 0.224998, 0.000000, 1.000000, 0.000000,c, 0.707692, 0.732143),
  371. +           video::S3DVertex(0.144249, -1.125000, -8.025005, -1.000000, 0.000000, -0.000000,c, 0.892308, 1.000000),
  372. +           video::S3DVertex(0.144249, -1.124999, 0.224998, -1.000000, 0.000000, -0.000000,c, 0.892308, 0.732143),
  373. +           video::S3DVertex(0.144250, 1.125000, -8.025005, -1.000000, 0.000000, -0.000000,c, 0.815385, 1.000000),
  374. +           video::S3DVertex(0.144250, 1.125000, 0.224998, -1.000000, 0.000000, -0.000000,c, 0.815385, 0.732143),
  375. +           video::S3DVertex(2.995750, -1.125000, -8.025005, -0.000001, -1.000000, -0.000000,c, 1.000000, 1.000000),
  376. +           video::S3DVertex(2.995749, -1.125001, 0.224998, -0.000001, -1.000000, -0.000000,c, 1.000000, 0.732143),
  377. +           video::S3DVertex(0.144249, -1.124999, 0.224998, -0.000001, -1.000000, -0.000000,c, 0.907692, 0.732143),
  378. +           video::S3DVertex(2.995750, -1.125000, -8.025005, -0.000000, -1.000000, 0.000000,c, 1.000000, 1.000000),
  379. +           video::S3DVertex(0.144249, -1.124999, 0.224998, -0.000000, -1.000000, 0.000000,c, 0.907692, 0.732143),
  380. +           video::S3DVertex(0.144249, -1.125000, -8.025005, -0.000000, -1.000000, 0.000000,c, 0.907692, 1.000000),
  381. +           video::S3DVertex(2.995750, 1.125000, -8.025005, 1.000000, 0.000000, -0.000000,c, 0.800022, 1.000000),
  382. +           video::S3DVertex(2.995751, 1.124999, 0.224998, 1.000000, 0.000000, -0.000000,c, 0.800000, 0.732143),
  383. +           video::S3DVertex(2.995750, -1.125000, -8.025005, 1.000000, 0.000000, -0.000000,c, 0.723055, 1.000000),
  384. +           video::S3DVertex(2.995751, 1.124999, 0.224998, 1.000000, -0.000001, 0.000000,c, 0.800000, 0.732143),
  385. +           video::S3DVertex(2.995749, -1.125001, 0.224998, 1.000000, -0.000001, 0.000000,c, 0.723055, 0.732143),
  386. +           video::S3DVertex(2.995750, -1.125000, -8.025005, 1.000000, -0.000001, 0.000000,c, 0.723055, 1.000000),
  387. +           video::S3DVertex(2.995751, 1.124999, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.600000, 0.803571),
  388. +           video::S3DVertex(0.144250, 1.125000, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.507692, 0.803571),
  389. +           video::S3DVertex(0.144249, -1.124999, 0.224998, -0.000000, 0.000000, 1.000000,c, 0.507692, 0.892857),
  390. +           video::S3DVertex(2.995749, -1.125001, 0.224998, 0.000000, -0.000000, 1.000000,c, 0.600000, 0.892857),
  391. +           video::S3DVertex(2.995750, 1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.600000, 0.910714),
  392. +           video::S3DVertex(2.995750, -1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.507659, 0.910714),
  393. +           video::S3DVertex(0.144249, -1.125000, -8.025005, 0.000000, 0.000000, -1.000000,c, 0.507659, 1.000000),
  394. +           video::S3DVertex(0.144250, 1.125000, -8.025005, 0.000000, -0.000000, -1.000000,c, 0.600000, 1.000000),
  395. +       };
  396. +       u16 indices[] = {0, 1, 2,
  397. +                       0, 2, 3,
  398. +                       4, 5, 6,
  399. +                       5, 7, 6,
  400. +                       8, 9, 10,
  401. +                       11, 12, 13,
  402. +                       14, 15, 16,
  403. +                       17, 18, 19,
  404. +                       20, 21, 22,
  405. +                       20, 22, 23,
  406. +                       24, 25, 26,
  407. +                       24, 26, 27};
  408. +       buf->append(vertices, 28, indices, 36);
  409. +       // Set material
  410. +       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  411. +       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  412. +       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  413. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  414. +       // Add to mesh
  415. +       mesh->addMeshBuffer(buf);
  416. +       buf->drop();
  417. +      
  418. +       m_leg_r = smgr->addMeshSceneNode(mesh, NULL);
  419. +       m_leg_r->setPosition(v3f(0,0,0));
  420. +       m_leg_r->setRotation(v3f(-90,0,0));
  421. +      
  422. +       // Set it to use the materials of the meshbuffers directly.
  423. +       // This is needed for changing the texture in the future
  424. +       m_leg_r->setReadOnlyMaterials(true);
  425. +       updateNodePos();
  426. +       }
  427. +      
  428. +       { // Arm-Left
  429. +       scene::SMesh *mesh = new scene::SMesh();
  430. +       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  431. +       video::SColor c(255,255,255,255);
  432. +       video::S3DVertex vertices[28] =
  433. +       {
  434. +           video::S3DVertex(-3.049999, 1.124999, 0.300000, 0.000000, 1.000000, 0.000000,c, 0.261538, 0.160714),
  435. +           video::S3DVertex(-3.049999, 1.125000, -7.200000, 0.000000, 1.000000, 0.000000,c, 0.261538, 0.428571),
  436. +           video::S3DVertex(-4.849999, 1.125001, -7.200000, 0.000000, 1.000000, 0.000000,c, 0.323077, 0.428644),
  437. +           video::S3DVertex(-3.049999, 1.124999, 0.300000, 0.000001, 1.000000, 0.000000,c, 0.261538, 0.160714),
  438. +           video::S3DVertex(-4.849999, 1.125001, -7.200000, 0.000001, 1.000000, 0.000000,c, 0.323077, 0.428644),
  439. +           video::S3DVertex(-4.849999, 1.125000, 0.300000, 0.000001, 1.000000, 0.000000,c, 0.323077, 0.160714),
  440. +           video::S3DVertex(-4.849999, -1.125000, -7.200000, -1.000000, 0.000000, -0.000000,c, 0.246154, 0.428571),
  441. +           video::S3DVertex(-4.850000, -1.124999, 0.300000, -1.000000, 0.000000, -0.000000,c, 0.246154, 0.160714),
  442. +           video::S3DVertex(-4.849999, 1.125001, -7.200000, -1.000000, 0.000000, -0.000000,c, 0.169231, 0.428571),
  443. +           video::S3DVertex(-4.849999, 1.125000, 0.300000, -1.000000, 0.000000, 0.000000,c, 0.169231, 0.160714),
  444. +           video::S3DVertex(-3.049999, -1.125000, -7.200000, -0.000001, -1.000000, -0.000000,c, 0.061538, 0.428571),
  445. +           video::S3DVertex(-3.050000, -1.125001, 0.300000, -0.000001, -1.000000, -0.000000,c, 0.061538, 0.160714),
  446. +           video::S3DVertex(-4.850000, -1.124999, 0.300000, -0.000001, -1.000000, -0.000000,c, 0.000000, 0.160714),
  447. +           video::S3DVertex(-3.049999, -1.125000, -7.200000, -0.000000, -1.000000, 0.000000,c, 0.061538, 0.428571),
  448. +           video::S3DVertex(-4.850000, -1.124999, 0.300000, -0.000000, -1.000000, 0.000000,c, 0.000000, 0.160714),
  449. +           video::S3DVertex(-4.849999, -1.125000, -7.200000, -0.000000, -1.000000, 0.000000,c, 0.000000, 0.428571),
  450. +           video::S3DVertex(-3.049999, 1.125000, -7.200000, 1.000000, -0.000000, 0.000000,c, 0.153846, 0.428571),
  451. +           video::S3DVertex(-3.049999, 1.124999, 0.300000, 1.000000, -0.000000, 0.000000,c, 0.153846, 0.160714),
  452. +           video::S3DVertex(-3.049999, -1.125000, -7.200000, 1.000000, -0.000000, 0.000000,c, 0.076923, 0.428571),
  453. +           video::S3DVertex(-3.050000, -1.125001, 0.300000, 1.000000, -0.000000, 0.000000,c, 0.076923, 0.160714),
  454. +           video::S3DVertex(-3.049999, 1.124999, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.400000, 0.232143),
  455. +           video::S3DVertex(-4.849999, 1.125000, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.338462, 0.232143),
  456. +           video::S3DVertex(-4.850000, -1.124999, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.338462, 0.321429),
  457. +           video::S3DVertex(-3.050000, -1.125001, 0.300000, 0.000000, -0.000000, 1.000000,c, 0.400000, 0.321429),
  458. +           video::S3DVertex(-3.049999, 1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.400000, 0.428571),
  459. +           video::S3DVertex(-3.049999, -1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.400000, 0.339286),
  460. +           video::S3DVertex(-4.849999, -1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.338462, 0.339286),
  461. +           video::S3DVertex(-4.849999, 1.125001, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.338462, 0.428571),
  462. +       };
  463. +       u16 indices[] = {0, 1, 2,
  464. +                       3, 4, 5,
  465. +                       6, 7, 8,
  466. +                       7, 9, 8,
  467. +                       10, 11, 12,
  468. +                       13, 14, 15,
  469. +                       16, 17, 18,
  470. +                       17, 19, 18,
  471. +                       20, 21, 22,
  472. +                       20, 22, 23,
  473. +                       24, 25, 26,
  474. +                       24, 26, 27};
  475. +       buf->append(vertices, 28, indices, 36);
  476. +       // Set material
  477. +       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  478. +       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  479. +       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  480. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  481. +       // Add to mesh
  482. +       mesh->addMeshBuffer(buf);
  483. +       buf->drop();
  484. +      
  485. +       m_arm_l = smgr->addMeshSceneNode(mesh, NULL);
  486. +       m_arm_l->setPosition(v3f(0,0,0));
  487. +       m_arm_l->setRotation(v3f(-90,0,0));
  488. +      
  489.         // Set it to use the materials of the meshbuffers directly.
  490.         // This is needed for changing the texture in the future
  491. -       m_node->setReadOnlyMaterials(true);
  492. +       m_arm_l->setReadOnlyMaterials(true);
  493.         updateNodePos();
  494. +       }
  495. +      
  496. +       { // Arm-Right
  497. +       scene::SMesh *mesh = new scene::SMesh();
  498. +       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
  499. +       video::SColor c(255,255,255,255);
  500. +       video::S3DVertex vertices[28] =
  501. +       {
  502. +           video::S3DVertex(4.850001, 1.124999, 0.300000, 0.000000, 1.000000, 0.000000,c, 0.753846, 0.160714),
  503. +           video::S3DVertex(4.850000, 1.125000, -7.200000, 0.000000, 1.000000, 0.000000,c, 0.753846, 0.428571),
  504. +           video::S3DVertex(3.050001, 1.125000, -7.200000, 0.000000, 1.000000, 0.000000,c, 0.815385, 0.428571),
  505. +           video::S3DVertex(4.850001, 1.124999, 0.300000, 0.000001, 1.000000, 0.000000,c, 0.753846, 0.160714),
  506. +           video::S3DVertex(3.050001, 1.125000, -7.200000, 0.000001, 1.000000, 0.000000,c, 0.815385, 0.428571),
  507. +           video::S3DVertex(3.050001, 1.125000, 0.300000, 0.000001, 1.000000, 0.000000,c, 0.815385, 0.160714),
  508. +           video::S3DVertex(3.050000, -1.125000, -7.200000, -1.000000, 0.000000, -0.000000,c, 0.738462, 0.428571),
  509. +           video::S3DVertex(3.050000, -1.124999, 0.300000, -1.000000, 0.000000, -0.000000,c, 0.738462, 0.160714),
  510. +           video::S3DVertex(3.050001, 1.125000, -7.200000, -1.000000, 0.000000, -0.000000,c, 0.661538, 0.428571),
  511. +           video::S3DVertex(3.050001, 1.125000, 0.300000, -1.000000, 0.000000, 0.000000,c, 0.661538, 0.160714),
  512. +           video::S3DVertex(4.850000, -1.125000, -7.200000, -0.000001, -1.000000, -0.000000,c, 0.553846, 0.428571),
  513. +           video::S3DVertex(4.850000, -1.125001, 0.300000, -0.000001, -1.000000, -0.000000,c, 0.553846, 0.160714),
  514. +           video::S3DVertex(3.050000, -1.124999, 0.300000, -0.000001, -1.000000, -0.000000,c, 0.492308, 0.160714),
  515. +           video::S3DVertex(4.850000, -1.125000, -7.200000, -0.000000, -1.000000, 0.000000,c, 0.553846, 0.428571),
  516. +           video::S3DVertex(3.050000, -1.124999, 0.300000, -0.000000, -1.000000, 0.000000,c, 0.492308, 0.160714),
  517. +           video::S3DVertex(3.050000, -1.125000, -7.200000, -0.000000, -1.000000, 0.000000,c, 0.492308, 0.428571),
  518. +           video::S3DVertex(4.850000, 1.125000, -7.200000, 1.000000, 0.000000, -0.000000,c, 0.646154, 0.428571),
  519. +           video::S3DVertex(4.850001, 1.124999, 0.300000, 1.000000, 0.000000, -0.000000,c, 0.646154, 0.160714),
  520. +           video::S3DVertex(4.850000, -1.125000, -7.200000, 1.000000, 0.000000, -0.000000,c, 0.569231, 0.428571),
  521. +           video::S3DVertex(4.850000, -1.125001, 0.300000, 1.000000, -0.000000, 0.000000,c, 0.569279, 0.160714),
  522. +           video::S3DVertex(4.850001, 1.124999, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.415385, 0.321429),
  523. +           video::S3DVertex(3.050001, 1.125000, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.476923, 0.321429),
  524. +           video::S3DVertex(3.050000, -1.124999, 0.300000, -0.000000, 0.000000, 1.000000,c, 0.476923, 0.232143),
  525. +           video::S3DVertex(4.850000, -1.125001, 0.300000, 0.000000, -0.000000, 1.000000,c, 0.415385, 0.232143),
  526. +           video::S3DVertex(4.850000, 1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.415385, 0.339286),
  527. +           video::S3DVertex(4.850000, -1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.415385, 0.428571),
  528. +           video::S3DVertex(3.050000, -1.125000, -7.200000, 0.000000, 0.000000, -1.000000,c, 0.476923, 0.428571),
  529. +           video::S3DVertex(3.050001, 1.125000, -7.200000, 0.000000, -0.000000, -1.000000,c, 0.476923, 0.339286),
  530. +       };
  531. +       u16 indices[] = {0, 1, 2,
  532. +                       3, 4, 5,
  533. +                       6, 7, 8,
  534. +                       7, 9, 8,
  535. +                       10, 11, 12,
  536. +                       13, 14, 15,
  537. +                       16, 17, 18,
  538. +                       17, 19, 18,
  539. +                       20, 21, 22,
  540. +                       20, 22, 23,
  541. +                       24, 25, 26,
  542. +                       24, 26, 27};
  543. +       buf->append(vertices, 28, indices, 36);
  544. +       // Set material
  545. +       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
  546. +       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
  547. +       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
  548. +       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  549. +       // Add to mesh
  550. +       mesh->addMeshBuffer(buf);
  551. +       buf->drop();
  552. +      
  553. +       m_arm_r = smgr->addMeshSceneNode(mesh, NULL);
  554. +       m_arm_r->setPosition(v3f(0,0,0));
  555. +       m_arm_r->setRotation(v3f(-90,0,0));
  556. +      
  557. +       // Set it to use the materials of the meshbuffers directly.
  558. +       // This is needed for changing the texture in the future
  559. +       m_arm_r->setReadOnlyMaterials(true);
  560. +       updateNodePos();
  561. +       }
  562.  
  563.         // Add a text node for showing the name
  564.         std::wstring wname = narrow_to_wide(m_name);
  565.         m_text = smgr->addTextSceneNode(gui->getBuiltInFont(),
  566. -               wname.c_str(), video::SColor(255,255,255,255), m_node);
  567. -       m_text->setPosition(v3f(0, (f32)BS*2.1, 0));
  568. +               wname.c_str(), video::SColor(255,255,255,255), m_head);
  569. +       m_text->setPosition(v3f(0, 0, 5));
  570.        
  571.         updateTextures("");
  572. +       //updateLegRot(dtime);
  573.         updateNodePos();
  574.     }
  575.  
  576.     void removeFromScene()
  577.     {
  578. -       if(m_node == NULL)
  579. -           return;
  580. -
  581. -       m_node->remove();
  582. -       m_node = NULL;
  583. +       if (m_body != NULL) {
  584. +           m_body->remove();
  585. +           m_body = NULL;
  586. +       }
  587. +       if (m_head != NULL) {
  588. +           m_head->remove();
  589. +           m_head = NULL;
  590. +       }
  591. +       if (m_leg_l != NULL) {
  592. +           m_leg_l->remove();
  593. +           m_leg_l = NULL;
  594. +       }
  595. +       if (m_leg_r != NULL) {
  596. +           m_leg_r->remove();
  597. +           m_leg_r = NULL;
  598. +       }
  599. +       if (m_arm_l != NULL) {
  600. +           m_arm_l->remove();
  601. +           m_arm_l = NULL;
  602. +       }
  603. +       if (m_arm_r != NULL) {
  604. +           m_arm_r->remove();
  605. +           m_arm_r = NULL;
  606. +       }
  607.     }
  608.  
  609.     void updateLight(u8 light_at_pos)
  610.     {
  611. -       if(m_node == NULL)
  612. -           return;
  613. -      
  614. -       m_node->setVisible(true);
  615. -
  616.         u8 li = decode_light(light_at_pos);
  617.         video::SColor color(255,li,li,li);
  618. -       setMeshColor(m_node->getMesh(), color);
  619. +      
  620. +       if (m_body != NULL) {
  621. +           m_body->setVisible(true);
  622. +           setMeshColor(m_body->getMesh(), color);
  623. +       }
  624. +      
  625. +       if (m_head != NULL) {
  626. +           m_head->setVisible(true);
  627. +           setMeshColor(m_head->getMesh(), color);
  628. +       }
  629. +      
  630. +       if (m_leg_l != NULL) {
  631. +           m_leg_l->setVisible(true);
  632. +           setMeshColor(m_leg_l->getMesh(), color);
  633. +       }
  634. +      
  635. +       if (m_leg_r != NULL) {
  636. +           m_leg_r->setVisible(true);
  637. +           setMeshColor(m_leg_r->getMesh(), color);
  638. +       }
  639. +      
  640. +       if (m_arm_l != NULL) {
  641. +           m_arm_l->setVisible(true);
  642. +           setMeshColor(m_arm_l->getMesh(), color);
  643. +       }
  644. +      
  645. +       if (m_arm_r != NULL) {
  646. +           m_arm_r->setVisible(true);
  647. +           setMeshColor(m_arm_r->getMesh(), color);
  648. +       }
  649.     }
  650.  
  651.     v3s16 getLightPosition()
  652.     {
  653.         return floatToInt(m_position+v3f(0,BS*1.5,0), BS);
  654.     }
  655. +  
  656. +   float updateHeadPitch(float pitch) {
  657. +       if (pitch > 75) {
  658. +           return 75-90;
  659. +       }
  660. +       else if (pitch < -75) {
  661. +           return -75-90;
  662. +       }
  663. +       else {
  664. +           return pitch-90;
  665. +       }
  666. +       return false;
  667. +   }
  668. +  
  669. +   void updateLegRot(float dtime) {
  670. +       v3f real_pos = pos_translator.vect_show;
  671. +       v3f real_old_pos = old_pos_translator.vect_show;
  672. +      
  673. +       m_speed = (real_pos.X-real_old_pos.X+real_pos.Z-real_old_pos.Z)/2;
  674. +       if (m_speed < 0) {
  675. +           m_speed = -m_speed;
  676. +       }
  677. +      
  678. +       if (m_speed > 0.5) {
  679. +           m_leg_rot = sin(m_leg_rot_i)*25;
  680. +           m_leg_rot_i += (m_speed*2.5)*dtime;
  681. +       }
  682. +       else {
  683. +           if (m_leg_rot > 0) {
  684. +               if (m_leg_rot-(50.0*dtime) < 0) {
  685. +                   m_leg_rot = 0;
  686. +               }
  687. +               else {
  688. +                   m_leg_rot -= 50.0*dtime;
  689. +                   m_leg_rot_i = 0;
  690. +               }
  691. +           }
  692. +           else if (m_leg_rot < 0) {
  693. +               if (m_leg_rot+(50.0*dtime) > 0) {
  694. +                   m_leg_rot = 0;
  695. +               }
  696. +               else {
  697. +                   m_leg_rot += 50.0*dtime;
  698. +                   m_leg_rot_i = 0;
  699. +               }
  700. +           }
  701. +       }
  702. +   }
  703.  
  704.     void updateNodePos()
  705.     {
  706. -       if(m_node == NULL)
  707. -           return;
  708. +       v3f real_pos = pos_translator.vect_show;
  709. +       v3f real_old_pos = old_pos_translator.vect_show;
  710. +       v3f head_pitch = head_translator.vect_show;
  711. +      
  712. +       if (m_body != NULL) {
  713. +           v3f rot = m_body->getRotation();
  714. +           rot.Y = -m_yaw;
  715. +           m_body->setPosition(v3f(real_pos.X+0, real_pos.Y+13.3, real_pos.Z+0));
  716. +           m_body->setRotation(rot);
  717. +       }
  718. +      
  719. +       if (m_head != NULL) {
  720. +           v3f rot = m_head->getRotation();
  721. +           rot.Y = -m_yaw;
  722. +           rot.X = head_pitch.X;
  723.  
  724. -       m_node->setPosition(pos_translator.vect_show);
  725. -
  726. -       v3f rot = m_node->getRotation();
  727. -       rot.Y = -m_yaw;
  728. -       m_node->setRotation(rot);
  729. +           m_head->setPosition(v3f(real_pos.X+0, real_pos.Y+16.2, real_pos.Z+0));
  730. +           m_head->setRotation(rot);
  731. +       }
  732. +      
  733. +       if (m_leg_l != NULL) {
  734. +           v3f rot = m_leg_l->getRotation();
  735. +           rot.Y = -m_yaw;
  736. +           rot.X = m_leg_rot-90;
  737. +          
  738. +           m_leg_l->setPosition(v3f(real_pos.X+0, real_pos.Y+8.03, real_pos.Z+0));
  739. +           m_leg_l->setRotation(rot);
  740. +       }
  741. +       if (m_leg_r != NULL) {
  742. +           v3f rot = m_leg_r->getRotation();
  743. +           rot.Y = -m_yaw;
  744. +           rot.X = -m_leg_rot-90;
  745. +          
  746. +           m_leg_r->setPosition(v3f(real_pos.X+0, real_pos.Y+8.03, real_pos.Z+0));
  747. +           m_leg_r->setRotation(rot);
  748. +       }
  749. +      
  750. +       if (m_arm_l != NULL) {
  751. +           v3f rot = m_arm_l->getRotation();
  752. +           rot.Y = -m_yaw;
  753. +           rot.X = -m_leg_rot-90;
  754. +          
  755. +           m_arm_l->setPosition(v3f(real_pos.X+0, real_pos.Y+15.5, real_pos.Z+0));
  756. +           m_arm_l->setRotation(rot);
  757. +       }
  758. +       if (m_arm_r != NULL) {
  759. +           v3f rot = m_arm_r->getRotation();
  760. +           rot.Y = -m_yaw;
  761. +           rot.X = m_leg_rot-90;
  762. +          
  763. +           m_arm_r->setPosition(v3f(real_pos.X+0, real_pos.Y+15.5, real_pos.Z+0));
  764. +           m_arm_r->setRotation(rot);
  765. +       }
  766.     }
  767.  
  768.     void step(float dtime, ClientEnvironment *env)
  769.     {
  770.         pos_translator.translate(dtime);
  771. +       old_pos_translator.translate(dtime);
  772. +       head_translator.translate(dtime);
  773. +       updateLegRot(dtime);
  774.         updateNodePos();
  775.  
  776.         if(m_damage_visual_timer > 0){
  777.             m_damage_visual_timer -= dtime;
  778.             if(m_damage_visual_timer <= 0){
  779.                 updateTextures("");
  780. @@ -2264,18 +2812,25 @@
  781.         std::istringstream is(data, std::ios::binary);
  782.         // command
  783.         u8 cmd = readU8(is);
  784.         if(cmd == 0) // update position
  785.         {
  786.             // pos
  787. +           m_old_position = m_position; //old position
  788.             m_position = readV3F1000(is);
  789. +           // pitch
  790. +           m_pitch = readF1000(is);
  791. +           m_pitch = updateHeadPitch(m_pitch);
  792.             // yaw
  793.             m_yaw = readF1000(is);
  794.  
  795.             pos_translator.update(m_position, false);
  796. -
  797. +           old_pos_translator.update(m_old_position);
  798. +           head_translator.update(v3f(m_pitch, 0, 0));
  799. +          
  800. +           //updateLegRot(dtime);
  801.             updateNodePos();
  802.         }
  803.         else if(cmd == 1) // punched
  804.         {
  805.             // damage
  806.             s16 damage = readS16(is);
  807. @@ -2287,33 +2842,89 @@
  808.             updateTextures("^[brighten");
  809.         }
  810.     }
  811.  
  812.     void updateTextures(const std::string &mod)
  813.     {
  814. -       if(!m_node)
  815. -           return;
  816.         ITextureSource *tsrc = m_gamedef->tsrc();
  817. -       scene::IMesh *mesh = m_node->getMesh();
  818. -       if(mesh){
  819. -           {
  820. -               std::string tname = "player.png";
  821. -               tname += mod;
  822. -               scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  823. -               buf->getMaterial().setTexture(0,
  824. -                       tsrc->getTextureRaw(tname));
  825. +       if(m_body) {
  826. +           scene::IMesh *mesh = m_body->getMesh();
  827. +           if(mesh){
  828. +               {
  829. +                   std::string tname = "mt_player.png";
  830. +                   tname += mod;
  831. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  832. +                   buf->getMaterial().setTexture(0,
  833. +                           tsrc->getTextureRaw(tname));
  834. +               }
  835.             }
  836. -           {
  837. -               std::string tname = "player_back.png";
  838. -               tname += mod;
  839. -               scene::IMeshBuffer *buf = mesh->getMeshBuffer(1);
  840. -               buf->getMaterial().setTexture(0,
  841. -                       tsrc->getTextureRaw(tname));
  842. +       }
  843. +      
  844. +       if(m_head) {
  845. +           scene::IMesh *mesh = m_head->getMesh();
  846. +           if(mesh){
  847. +               {
  848. +                   std::string tname = "mt_player.png";
  849. +                   tname += mod;
  850. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  851. +                   buf->getMaterial().setTexture(0,
  852. +                           tsrc->getTextureRaw(tname));
  853. +               }
  854.             }
  855.         }
  856. +      
  857. +       if(m_leg_l) {
  858. +           scene::IMesh *mesh = m_leg_l->getMesh();
  859. +           if(mesh){
  860. +               {
  861. +                   std::string tname = "mt_player.png";
  862. +                   tname += mod;
  863. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  864. +                   buf->getMaterial().setTexture(0,
  865. +                           tsrc->getTextureRaw(tname));
  866. +               }
  867. +           }
  868. +       }
  869. +      
  870. +       if(m_leg_r) {
  871. +           scene::IMesh *mesh = m_leg_r->getMesh();
  872. +           if(mesh){
  873. +               {
  874. +                   std::string tname = "mt_player.png";
  875. +                   tname += mod;
  876. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  877. +                   buf->getMaterial().setTexture(0,
  878. +                           tsrc->getTextureRaw(tname));
  879. +               }
  880. +           }
  881. +       }
  882. +      
  883. +       if(m_arm_l) {
  884. +           scene::IMesh *mesh = m_arm_l->getMesh();
  885. +           if(mesh){
  886. +               {
  887. +                   std::string tname = "mt_player.png";
  888. +                   tname += mod;
  889. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  890. +                   buf->getMaterial().setTexture(0,
  891. +                           tsrc->getTextureRaw(tname));
  892. +               }
  893. +           }
  894. +       }
  895. +      
  896. +       if(m_arm_r) {
  897. +           scene::IMesh *mesh = m_arm_r->getMesh();
  898. +           if(mesh){
  899. +               {
  900. +                   std::string tname = "mt_player.png";
  901. +                   tname += mod;
  902. +                   scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
  903. +                   buf->getMaterial().setTexture(0,
  904. +                           tsrc->getTextureRaw(tname));
  905. +               }
  906. +           }
  907. +       }
  908.     }
  909.  };
  910.  
  911.  // Prototype
  912.  PlayerCAO proto_PlayerCAO(NULL, NULL);
  913. -
  914. -
  915.  
  916. --- a\serverremoteplayer.cpp    2012-01-28 21:52:18.000000000 -0000
  917. +++ b\serverremoteplayer.cpp    2012-01-26 15:43:52.000000000 -0000
  918. @@ -137,12 +137,14 @@
  919.  
  920.         std::ostringstream os(std::ios::binary);
  921.         // command (0 = update position)
  922.         writeU8(os, 0);
  923.         // pos
  924.         writeV3F1000(os, getPosition());
  925. +       // pitch
  926. +       writeF1000(os, getPitch());
  927.         // yaw
  928.         writeF1000(os, getYaw());
  929.         // create message and add to list
  930.         ActiveObjectMessage aom(getId(), false, os.str());
  931.         m_messages_out.push_back(aom);
  932.     }
  933. @@ -154,12 +156,14 @@
  934.     // version
  935.     writeU8(os, 0);
  936.     // name
  937.     os<<serializeString(getName());
  938.     // pos
  939.     writeV3F1000(os, getPosition());
  940. +   // pitch
  941. +   writeF1000(os, getPitch());
  942.     // yaw
  943.     writeF1000(os, getYaw());
  944.     return os.str();
  945.  }
  946.  
  947.  std::string ServerRemotePlayer::getStaticData()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement