Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 06-06-2011, 01:39 PM   #1
gestures468
 
Banned
Join Date: May 2010
Reputation: 852
Posts: 4,540
Making it so you can see your legs in source games

It's been done in Left 4 Dead and in Garry's Mod as a Client side addon

In gmod the legs change based on your player model ( even completely new custom models not just stock ones) but like all gmod addons it's in lua

Is there a way to convert this into c++ for use in source mods?

I'll get the code later so you can look at it.
gestures468 is offline  
Reply With Quote
Old 06-06-2011, 02:38 PM   #2
CrAzYpotpie
 
Join Date: Sep 2010
Reputation: 49
Posts: 482
I have always wanted this feature, but still haven't tried to code it yet.

The EP2 mod "1187 Episode 1" does a great job at showing legs in first person.

http://www.moddb.com/mods/1187

Try sending them a message and maybe they will share some code or push you in the right direction... Pretty sure you would have to model and animate the legs yourself too.
CrAzYpotpie is offline   Reply With Quote
Old 06-06-2011, 02:44 PM   #3
gestures468
 
Banned
Join Date: May 2010
Reputation: 852
Posts: 4,540
Quote:
Originally Posted by CrAzYpotpie View Post
Try sending them a message and maybe they will share some code or push you in the right direction... Pretty sure you would have to model and animate the legs yourself too.
just look up gmod legs...

Its not a perfect system but it dosent require any models or animating just coding and it works in multiplayer

I believe it puts a screen at the bottom of your view and a camera under the screen or something bt I'm not sure sense I never looked at the code yet

I want this feature fOr my multiplayer mod
gestures468 is offline   Reply With Quote
Old 06-10-2011, 11:07 AM   #4
Zombie Killa
 
Join Date: Jul 2007
Reputation: 0
Posts: 127
http://pastebin.com/EpD258aS this code works great i got the hole body to show up just need to figure out how to move the body back.
Zombie Killa is offline   Reply With Quote
Old 06-11-2011, 03:45 AM   #5
ferdyfist
 
Join Date: Apr 2011
Reputation: 0
Posts: 167
Quote:
Originally Posted by Zombie Killa View Post
http://pastebin.com/EpD258aS this code works great i got the hole body to show up just need to figure out how to move the body back.
Where should I put it? And what should it be called? (sorry for breaking in to topic
ferdyfist is offline   Reply With Quote
Old 06-11-2011, 04:00 AM   #6
tingtom
 
 
 
Join Date: Mar 2011
Reputation: 38
Posts: 388
it says C_BasePlayer so put it in c_baseplayer.cpp, it wont work for single player i think.

Last edited by tingtom: 06-11-2011 at 04:06 AM.
tingtom is offline   Reply With Quote
Old 06-11-2011, 07:44 AM   #7
Zombie Killa
 
Join Date: Jul 2007
Reputation: 0
Posts: 127
Show your leg's in SP Mod
I was board figured i'd clean this up.
add animations from this tut first https://developer.valvesoftware.com/..._6:_Animations
Then open c_baseplayer.cpp and search for bool IsInFreezeCam( void )
after return false add this
Quote:
bool IsInEye( void )
{
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_IN_EYE )
return true;

}
then in C_BasePlayer.h search for bool IsInFreezeCam( void ); add this under it.
bool IsInEye( void );
then go back to c_baseplayer.cpp and search for bool C_BasePlayer::ShouldDraw()
and make it look like this
Quote:
bool C_BasePlayer::ShouldDraw()
{
return BaseClass::ShouldDraw();
}

static ConVar cl_legs("cl_legs", "1", FCVAR_CHEAT, "Enable or disable player leg rendering", true, 0, true, 1);
static ConVar cl_legs_origin_shift("cl_legs_origin_shift", "-16.5", FCVAR_CHEAT, "Amount in game units to shift the player model relative to the direction the player is facing");
static ConVar cl_legs_clip_height("cl_legs_clip_height", "0", FCVAR_CHEAT, "Amount in game units of the player model to render up to [0 = disable]", true, 0, false, 0);

const Vector& C_BasePlayer::GetRenderOrigin( void )
{
// If we're not observing this player, or if we're not drawing it at the
// moment then use the normal absolute origin.
// NOTE: the GetCurrentlyDrawingEntity check is here to make sure the
// shadow is rendered from the correct origin
if(!IsInEye() || view->GetCurrentlyDrawingEntity() != this)
return BaseClass::GetRenderOrigin();

// Get the forward vector
static Vector forward; // static because this method returns a reference
AngleVectors(GetRenderAngles(), &forward);

// Shift the render origin by a fixed amount
forward *= cl_legs_origin_shift.GetFloat();
forward += GetAbsOrigin();

return forward;
}

int C_BasePlayer:rawModel( int flags )
{
// No need for clipping or render origin shifting if we aren't a local
// player
if(!IsInEye())
return BaseClass:rawModel(flags);

// If we aren't drawing legs, return
if(!cl_legs.GetBool())
return 0;

CMatRenderContextPtr context(materials);

// Don't render above a certain height of the body
if(cl_legs_clip_height.GetInt() > 0)
{
context->SetHeightClipMode(MATERIAL_HEIGHTCLIPMODE_RENDER_ BELOW_HEIGHT);
context->SetHeightClipZ(GetAbsOrigin().z+cl_legs_clip_heig ht.GetFloat());
}

// Draw the model
int nDrawRes = BaseClass:rawModel(flags);

// Remove height clipping
context->SetHeightClipMode(MATERIAL_HEIGHTCLIPMODE_DISABLE );

return nDrawRes;
}
Then go back to C_BasePlayer.h and search for
virtual int DrawModel( int flags ); and add this underneath it
const Vector& C_BasePlayer::GetRenderOrigin();
that's it hope that helps.

Last edited by Zombie Killa: 04-10-2012 at 12:04 PM. Reason: Clean up
Zombie Killa is offline   Reply With Quote
Old 06-11-2011, 08:54 AM   #8
Santo1991
 
Join Date: Dec 2009
Reputation: 1
Posts: 288
Quote:
Originally Posted by Zombie Killa View Post
...
Please use CODE bbcode
Santo1991 is offline   Reply With Quote
Old 06-12-2011, 05:59 AM   #9
ferdyfist
 
Join Date: Apr 2011
Reputation: 0
Posts: 167
Do you think it works for MP too?
ferdyfist is offline   Reply With Quote
Old 06-12-2011, 06:59 AM   #10
Zombie Killa
 
Join Date: Jul 2007
Reputation: 0
Posts: 127
i think that's what it was originally made for.
Zombie Killa is offline   Reply With Quote
Old 06-12-2011, 12:05 PM   #11
ferdyfist
 
Join Date: Apr 2011
Reputation: 0
Posts: 167
Quote:
Originally Posted by Zombie Killa View Post
i think that's what it was originally made for.
Thanks. I will test it and reply back if it works in MP
ferdyfist is offline   Reply With Quote
Old 06-13-2011, 01:01 PM   #12
ferdyfist
 
Join Date: Apr 2011
Reputation: 0
Posts: 167
Nope.. Here is what i get:
Code:
1>------ Build started: Project: Client HL2MP, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>c_baseplayer.cpp
1>.\c_baseplayer.cpp(1221) : error C2509: 'GetRenderOrigin' : member function not declared in 'C_BasePlayer'
1>        c:\lwgmferdyfist\Mod\src\game\client\c_baseplayer.h(61) : see declaration of 'C_BasePlayer'
1>.\c_baseplayer.cpp(1244) : error C3861: 'IsInEye': identifier not found
1>.\c_baseplayer.cpp(1256) : error C2065: 'MATERIAL_HEIGHTCLIPMODE_RENDER_' : undeclared identifier
1>.\c_baseplayer.cpp(1256) : error C2146: syntax error : missing ')' before identifier 'BELOW_HEIGHT'
1>.\c_baseplayer.cpp(1256) : error C2059: syntax error : ')'
1>.\c_baseplayer.cpp(1257) : error C2065: 'cl_legs_clip_heig' : undeclared identifier
1>.\c_baseplayer.cpp(1257) : error C2146: syntax error : missing ')' before identifier 'ht'
1>.\c_baseplayer.cpp(1257) : error C2059: syntax error : ')'
1>Build log was saved at "file://c:\LWGMFERDYFIST\Mod\src\game\client\Release_hl2mp\BuildLog.htm"
1>Client HL2MP - 8 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
ferdyfist is offline   Reply With Quote
Old 06-14-2011, 05:48 AM   #13
Wunderboy
 
Wunderboy's Avatar
 
Volunteer Moderator
Join Date: Oct 2007
Reputation: 275
Posts: 721
What code base are you using? I was curious about adding this to our mod but then I realised that the example given is for the OrangeBox SDK and no the EP1 SDK.

A lot of the classes/functions this code needs are in the OB (2007) SDK version only.
Wunderboy is offline   Reply With Quote
Old 06-14-2011, 07:43 AM   #14
daman123
 
Guest
Posts: n/a
Hmm it seems the code in the fourth post isn't working
  Reply With Quote
Old 06-14-2011, 07:52 AM   #15
R_Yell
 
Join Date: Jun 2007
Reputation: 36
Posts: 188
I decided to give it a try as well, this is an interesting approach however it had a few significant flaws for me. If someone is interested, this is how I went around them (2007 HL2MP SDK BTW):

- the clip distance to hide upper body part is a nice trick, doesn't work well while crouching though. I decided to move head/arms to a different bodygroup which is displayed only when rendering other player. Therefore, I only had to render the player model back its original position
- trains and other moving objects: since such entities aren't predicted, once player gets over them the model will lag like crazy. A hack for this is just disabling render if the train moves, don't think there's a real solution other than adding prediction to such entities
- player model trails if rotation speed is excessive, I just force m_bForceAimYaw = true in ComputePoseParam_AimYaw. Hoping this is only a performance optimization and doesn't damage something else.

Let me know if you need any extra info.
R_Yell is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 01:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.