Page 1 of 3

See your own player

Posted: Tue Apr 02, 2013 15:21
by PilzAdam
Hello everyone!
I have played a bit arround with the player model and here is the result:
Image
You can see your own model when looking down. It has all the animations that other players have.
Here is the engine patch:

Code: Select all

diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index ee1009b..be66e9f 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -850,7 +850,7 @@ class GenericCAO : public ClientActiveObject
         
         m_visuals_expired = false;
 
-        if(!m_prop.is_visible || m_is_local_player)
+        if(!m_prop.is_visible)
             return;
     
         //video::IVideoDriver* driver = smgr->getVideoDriver();
@@ -1068,6 +1068,40 @@ class GenericCAO : public ClientActiveObject
 
     void step(float dtime, ClientEnvironment *env)
     {
+        //HACK!!
+        if(m_is_local_player)
+        {
+            LocalPlayer *player = m_env->getLocalPlayer();
+            m_position = player->getPosition() + v3f(0,10,0);
+            m_velocity = v3f(0,0,0);
+            m_acceleration = v3f(0,0,0);
+            pos_translator.vect_show = m_position;
+            m_yaw = player->getYaw();
+            v3f offset(sin(m_yaw/180.*core::PI)*BS*0.5, 0, -cos(m_yaw/180.*core::PI)*BS*0.5);
+            m_position += offset;
+
+            PlayerControl controls = player->getPlayerControl();
+            bool walking = false;
+            if(controls.up || controls.down or controls.left || controls.right)
+                walking = true;
+
+            m_animation_speed = 30;
+
+            if(controls.sneak && walking)
+                m_animation_speed = 15;
+
+            //if(player->hp == 0)
+            //    m_animation_range = v2f(162, 166);
+            if(walking && (controls.LMB || controls.RMB))
+                m_animation_range = v2f(200, 219);
+            else if(walking)
+                m_animation_range = v2f(168, 187);
+            else if(controls.LMB || controls.RMB)
+                m_animation_range = v2f(189, 198);
+            else
+                m_animation_range = v2f(0, 79);
+        }
+
         if(m_visuals_expired && m_smgr && m_irr){
             m_visuals_expired = false;
 
@@ -1680,9 +1714,11 @@ class GenericCAO : public ClientActiveObject
         }
         else if(cmd == GENERIC_CMD_SET_ANIMATION)
         {
-            m_animation_range = readV2F1000(is);
-            m_animation_speed = readF1000(is);
-            m_animation_blend = readF1000(is);
+            if(!m_is_local_player){
+                m_animation_range = readV2F1000(is);
+                m_animation_speed = readF1000(is);
+                m_animation_blend = readF1000(is);
+            }
 
             updateAnimation();
         }
win build: https://www.dropbox.com/sh/am3ddzfm8qxz9w0/VlbFIebGBK (in other/minetest-0.4.5-0770b3e-player_model-win32.zip)

Posted: Tue Apr 02, 2013 15:41
by Calinou
Since we can do this, we could also do third person. :)

Nice!

Posted: Tue Apr 02, 2013 15:48
by Traxie21
Neet!
Will this be committed into the main game?

Posted: Tue Apr 02, 2013 16:27
by PilzAdam
Traxie21 wrote:Neet!
Will this be committed into the main game?
No, its hacky. It has to be done differently. I just played a bit arround with the code.

Posted: Tue Apr 02, 2013 16:31
by jordan4ibanez
This is amazing!

Posted: Tue Apr 02, 2013 16:37
by PilzAdam
Windows build added.

Posted: Tue Apr 02, 2013 18:45
by Jordach
Pilzadam, how does one apply a patch?

Posted: Tue Apr 02, 2013 22:13
by stu
Wow, this even works rather well with my 3d_armor and wieldview mods.
Image

Posted: Tue Apr 02, 2013 22:26
by jojoa1997
i like it

Posted: Wed Apr 03, 2013 09:02
by Calinou
Jordach wrote:Pilzadam, how does one apply a patch?
Save the content of the patch in a file named "content_cao.patch", put it in your Minetest's "src" directory, then open a terminal in that directory and type:

Code: Select all

patch content_cao.cpp content_cao.patch

Posted: Wed Apr 03, 2013 12:43
by keneticquartz
Or just use :)

Code: Select all

git apply p.patch

Posted: Wed Apr 03, 2013 13:51
by sfan5
Awesome!

EDIT: For some reason (seems to be a problem with spaces) my git doesn't want to apply the patch.

Posted: Wed Apr 03, 2013 14:15
by PilzAdam
I also have a branch for this on my forked repo," player_model" or something like that.

Posted: Wed Apr 03, 2013 17:38
by Likwid H-Craft
Wow, you should make this work for, 0.4.6 and have it bind to F7 :)

Posted: Fri Apr 05, 2013 12:03
by sfan5
Why bind it to a key?

Posted: Fri Apr 05, 2013 17:54
by Likwid H-Craft
Idk it just how systems now days, is bind bind BIND!

Posted: Wed Apr 17, 2013 21:40
by windmere33
The download link is broken.

Posted: Mon Apr 22, 2013 16:16
by Inocudom
I like this very much. I wish for this to be added to the base game.

Posted: Mon Apr 22, 2013 17:13
by 4aiman
This and Kaeza's experiments with moving head ;)

Posted: Thu Apr 25, 2013 03:28
by Inocudom
This look like a possible and reachable goal. I hope this turns out to be a successful effort. Just make sure that the player model doesn't obscure the tile that the player is standing on too much.

Posted: Thu Apr 25, 2013 11:11
by jojoa1997
with this you could move the camera back and see your own player. maybe pressing a special button can go ointo switch mode and another will go into pan mode

Posted: Thu May 02, 2013 12:19
by Ragnar
does that mean that others can see the current hand-held stuff?

Posted: Thu May 02, 2013 12:32
by Calinou
Ragnar wrote:does that mean that others can see the current hand-held stuff?
No, showing what you have in hand to other players is done with another (server-side) mod:
http://forum.minetest.net/viewtopic.php?id=4654

Posted: Mon May 06, 2013 00:12
by Inocudom
This feature looked like it had a future, but then development stopped. Is there a coder in this community that can continue the development of this feature (maybe make it as a mod first?)

Posted: Mon May 06, 2013 00:32
by PilzAdam
Inocudom wrote:This feature looked like it had a future, but then development stopped. Is there a coder in this community that can continue the development of this feature (maybe make it as a mod first?)
I had the plan to add API functions to set the playermodel with all the animations etc. This can be send to the client and it can be used there.