The 'Player' Demo - V2 (Update!)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

The 'Player' Demo - V2 (Update!)

Post by ajs15822 »

Hey there Ogre3D!

This is an update to the 'Player' Demo (original can be found here).

The changes for this release (v2.0) include but are not limited to:
  • Compatibility with Ogre 1.60+
  • Compatibility with MSVC9
  • Updated to RakNet 3.611
  • Replaced Hikari-based GUI with custom Canvas-based GUI
  • Lots more comments/documentation
  • Custom welcome-message
  • Cosmetic touch-ups (pretty skybox, texture enhancements)
Feel free to port to other platforms-- should be relatively straightforward to port now that the last Windows-only dependency (Hikari) has been replaced.

You can download the pre-compiled demo and source here: http://princeofcode.com/player.php#download

Directions:
  1. Run 'Server.exe'.
  2. Run 'Client.exe'** (or 'Player.exe' if you built from source)
  3. Login with any nickname.
  4. Move around the world by clicking on the terrain.
  5. Talk by interacting with the textbox and 'Say' button.
**You can run as many instances of the Client as you like, just edit the 'player.cfg' to make sure 'server_address' specifies the IP address of the machine you're running the server on.

Controls:
  • ESC: Exit
  • F1: Take a screenshot
  • F2: Toggle wireframe
Enjoy!


Screenshots from the new demo:

Image
Image
Image
Image
Image
Image
Image
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by AshMcConnell »

Some great changes there, looks good. I'll definitely be taking a look at some of the useful Canvas controls for light-weight in-game stuff.

Thanks!
All the best,
Ash
James Proctor
Orc
Posts: 406
Joined: Fri May 16, 2008 7:33 pm
x 5

Re: The 'Player' Demo - V2 (Update!)

Post by James Proctor »

Ok does any one know why alpha splatting is not working? I had it working in other applications but in the old player demo and this new one it isn't working yet I am using the exact same files as I did for the other Applications where it is working. Here is the error I am getting in the logs:

07:51:40: WARNING: material terrain/SplattingShaderParallax_1_4 has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program SplattingShaderParallax_1_4/VP cannot be used - not supported.
Follow me on Twitter - https://twitter.com/EmpireGames
Follow my Blog on Blogger - http://empiredevelopment.blogspot.com/
James Proctor
Orc
Posts: 406
Joined: Fri May 16, 2008 7:33 pm
x 5

Re: The 'Player' Demo - V2 (Update!)

Post by James Proctor »

Well I have been redesigning the logon screen and we changed the way that the game states are handled so now I can add new game states. Thanks so much for not using Flash for the GUI of this version! I suck at flash! lol
Attachments
screen08052009_131729868.png
screen08052009_131729868.png (28.13 KiB) Viewed 14862 times
Follow me on Twitter - https://twitter.com/EmpireGames
Follow my Blog on Blogger - http://empiredevelopment.blogspot.com/
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by ajs15822 »

AshMcConnell wrote:Some great changes there, looks good. I'll definitely be taking a look at some of the useful Canvas controls for light-weight in-game stuff.

Thanks!
All the best,
Ash
Yeah, I spent a few days implementing a super-simple Canvas-based GUI system for this demo with support for buttons, textboxes, labels, text-lists, and generic box elements. All elements derived from the 'Box' element support custom backgrounds (solid color, gradient color, or texture) and borders with arbitrary widths/colors for each side.

Should be pretty easy to use, just create a GUICanvas, create your element, customize it, and add it to the GUICanvas via GUICanvas::addElement. The GUICanvas then takes ownership of the element and will delete it once it is destroyed or the GUICanvas is cleared. You'll also need to inject mouse/keyboard events and call GUICanvas::update from your update loop. You can create your own custom elements by implementing the 'GUIElement' abstract interface and handling the necessary 'draw' calls.
James Proctor wrote:Ok does any one know why alpha splatting is not working? I had it working in other applications but in the old player demo and this new one it isn't working yet I am using the exact same files as I did for the other Applications where it is working. Here is the error I am getting in the logs:

07:51:40: WARNING: material terrain/SplattingShaderParallax_1_4 has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program SplattingShaderParallax_1_4/VP cannot be used - not supported.
How are you applying the material to the terrain, have you specified a 'CustomMaterialName' in terrain.cfg? Any extra code you can provide would also be helpful.
James Proctor wrote:Well I have been redesigning the logon screen and we changed the way that the game states are handled so now I can add new game states. Thanks so much for not using Flash for the GUI of this version! I suck at flash! lol
Nice work, thanks for sharing! :D

I'm glad you found the new GUI system easier to work with, feel free to hack away at the demo some more-- it's intended to be modified!
James Proctor
Orc
Posts: 406
Joined: Fri May 16, 2008 7:33 pm
x 5

Re: The 'Player' Demo - V2 (Update!)

Post by James Proctor »

Here is the terrain cfg I am using (or trying to use)

Code: Select all

# WorldTexture=libnoise_color.png

# Heightmap source
PageSource=Heightmap

# Heightmap-source specific settings
Heightmap.image=terrain3.png

# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=513

# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=65

# The maximum error allowed when determining which LOD to use
MaxPixelError=1

# The size of a terrain page, in world units
PageWorldX=1500
PageWorldZ=1500

# Maximum height of the terrain 
MaxHeight=150

# Upper LOD limit
MaxMipMapLevel=5

# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2

# Use vertex program to morph LODs, if available
VertexProgramMorph=no

# Custom material. Does use vertex normals.
CustomMaterialName=terrain/SplattingShaderParallax_1_4
VertexNormals=yes
the material

Code: Select all

//
//   SplattingShaderParallax_1_4.material for PLSM2
//   Xavier Verguín González
//   October 2007
//
//   - 2 Coverage maps
//   - 1 Parallax splatting texture / 4 diffuse splatting textures
//   - 1 pass
//

vertex_program SplattingShaderParallax_1_4/VP cg
{
   source SplattingShaderParallax_1_4.cg
   entry_point main_vp
   //target vs_2_0
   profiles vs_1_1 arbvp1
}

fragment_program SplattingShaderParallax_1_4/FP cg
{
   source SplattingShaderParallax_1_4.cg
   entry_point main_fp
   //target vs_2_0
   profiles ps_2_0 arbfp1 fp20
}

material terrain/SplattingShaderParallax_1_4
{   
   technique
   {
      pass
      {
		 vertex_program_ref SplattingShaderParallax_1_4/VP
         {
            param_named_auto uLightPosition light_position_object_space 0
            param_named_auto uEyePosition camera_position_object_space
            param_named_auto uWorldViewProj worldviewproj_matrix
         }

         fragment_program_ref SplattingShaderParallax_1_4/FP
         {
            param_named_auto uAmbient ambient_light_colour
			//param_named_auto uLightDiffuse light_diffuse_colour 0
			//param_named_auto uLightSpecular light_specular_colour 0
            param_named uLightDiffuse float3 0.95 1 1
            param_named uLightSpecular float3 0.6 0.6 0.6 
            // Parallax Height scale and bias
            param_named uScaleBias float4 0.05 -0.02 1 0
         }

         texture_unit
         {
            texture alpha_1test.png
         }

         texture_unit
         {
            texture alpha_2.png
         }

         texture_unit
         {
             texture 512_sand.png
         }

         texture_unit
         {
             texture 512_sandGrass.png
		 }

         texture_unit
         {
             texture 512_shortGrass.png
         }

         texture_unit
         {
             texture 512_sand.png
         }

         // Normal + height(alpha) map
         texture_unit
         {
            texture 512_crackedDirtSandNormal.png
         }

         // Base diffuse texture map
         texture_unit
         {
            texture 512_crackedDirtSand.png
         }
		 
		 // Base colour map
         texture_unit
         {
            texture mymap_c.png
         }
      }
   }
}
and the shader

Code: Select all

void main_vp(// IN
             float4 iPosition         : POSITION,
             float3 iNormal           : NORMAL,
             float2 iUv               : TEXCOORD0,
             // OUT
             out float4 oPosition     : POSITION,
             out float2 oUv           : TEXCOORD0,
             out float3 oLightDir     : TEXCOORD1,
             out float3 oEyeDir       : TEXCOORD2,
             out float3 oHalfAngle    : TEXCOORD3,
             // UNIFORM
             uniform float4           uLightPosition,
             uniform float3           uEyePosition,
             uniform float4x4         uWorldViewProj)
{
   oPosition = mul(uWorldViewProj, iPosition);

   oUv = iUv;

   float3 lightDir = normalize(uLightPosition.xyz -  (iPosition * uLightPosition.w));
   float3 eyeDir   = uEyePosition - iPosition.xyz;

   float3 binormal = cross(float3(1,0,0), iNormal);
   float3 tangent  = cross(iNormal, binormal);

   float3x3 rotation = float3x3(tangent, binormal, iNormal);

   lightDir   = normalize(mul(rotation, lightDir));
   eyeDir     = normalize(mul(rotation, eyeDir));

   oLightDir  = lightDir;
   oEyeDir    = eyeDir;
   oHalfAngle = normalize(eyeDir + lightDir);
}

// Expand a range-compressed vector
float3 expand(float3 v)
{
   return (v - 0.5) * 2;
}

void main_fp(// IN
             float2 iUv           : TEXCOORD0,
            float3 iLightDir     : TEXCOORD1,
            float3 iEyeDir       : TEXCOORD2,
            float3 iHalfAngle    : TEXCOORD3,
            // OUT
            out float4 oColor    : COLOR,
            // UNIFORM
            uniform float3       uLightDiffuse,
            uniform float3       uLightSpecular,
            uniform float4       uScaleBias,
             uniform float3       uAmbient,
             uniform sampler2D    uCoverage1         : register(s0),
             uniform sampler2D    uCoverage2         : register(s1),
             uniform sampler2D    uSplatting0        : register(s2),
             uniform sampler2D    uSplatting1        : register(s3),
             uniform sampler2D    uSplatting2        : register(s4),
             uniform sampler2D    uSplatting3        : register(s5),
            uniform sampler2D    uNormalHeightMap   : register(s6),
            uniform sampler2D    uDiffuseMap        : register(s7),
			 uniform sampler2D    uColourMap        : register(s8))
{
    // Get coverage values
    float4 Coverage1 = tex2D(uCoverage1, iUv);
    float  Coverage2 = tex2D(uCoverage2, iUv).y;
	float2 coverColourMap = iUv;
	
    // Scale UV coord
   float2 texscale = float2(300,300);
   iUv *= texscale;

   float4 col = float4(0,0,0,0);

    if(Coverage1.x>0)
    {
       // Get the height from the alpha channel of normal-height tex.
       float height = tex2D(uNormalHeightMap, iUv).a;

       // Scale and bias factors
       float scale = uScaleBias.x;
       float bias = uScaleBias.y;

       // Calculate displacement
       float displacement = (height * scale) + bias;

       float3 uv2 = float3(iUv, 1);

       // Calculate the new tex coord to use for normal and diffuse
       float2 newTexCoord = ((iEyeDir * displacement) + uv2).xy;

       // Get the new normal and diffuse values
       float3 normal = expand(tex2D(uNormalHeightMap, newTexCoord).xyz);
       float3 diffuse = tex2D(uDiffuseMap, newTexCoord).xyz;

        // Calculate specular and final pixel colour
       float3 specular = pow(saturate(dot(normal, iHalfAngle)), 32) * uLightSpecular;
       col = float4(diffuse * saturate(dot(normal, iLightDir)) * uLightDiffuse + specular, 1);

        // Adjust the ambient value
        float3 diffuse2 = diffuse*uAmbient;
        if(col.x < diffuse2.x)
            col.x += (diffuse2.x-col.x);
        if(col.y < diffuse2.y)
            col.y += (diffuse2.y-col.y);
        if(col.z < diffuse2.z)
            col.z += (diffuse2.z-col.z);
    }

    // Final pixel colour
   oColor = col*Coverage1.x
          + ((tex2D(uSplatting0, iUv) * Coverage1.y
          +  tex2D(uSplatting1, iUv) * Coverage1.z
          +  tex2D(uSplatting2, iUv) * Coverage1.w
          +  tex2D(uSplatting3, iUv) * Coverage2)
		  +  tex2D(uColourMap, coverColourMap.xy)-0.5) * float4(uAmbient, 1);
		  
}
Well after a days work we now have a patcher, Registeration state (still a work in progress), User accounts (passwords are set from with in the player.cfg), When a client connects the server connects to a mysql database. Wish there was some way I could test how many people could be connected with the server being hosted on my computer. Maybe I will upload the client and post the link here so any one can download it. If any one is interested in helping to test it let me know!
Follow me on Twitter - https://twitter.com/EmpireGames
Follow my Blog on Blogger - http://empiredevelopment.blogspot.com/
User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
x 1
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by Danoli3 »

Really awesome! Thanks so much <3
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009
sagron
Gnoblar
Posts: 7
Joined: Wed Jul 29, 2009 3:30 am

Re: The 'Player' Demo - V2 (Update!)

Post by sagron »

Awesome, I'll be checking this out when I get home (at work). Any chance of your next awesomium release using one of the newer chromium builds? Keep up the great work, always love to see your new stuff! I'd like to see ZeroC Ice as the network library too (I'm trying to change it over myself), but you may not want to use that because of license restrictions for your projects (GPL'd for non-comm or expensive for commercial).
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by AshMcConnell »

Raknet is free for indy developers (earning < $250k), Its a fantastic lib, seems perfect for the player demo.

From here: -
http://www.jenkinssoftware.com/purchase.html

All the best,
Ash
sagron
Gnoblar
Posts: 7
Joined: Wed Jul 29, 2009 3:30 am

Re: The 'Player' Demo - V2 (Update!)

Post by sagron »

ZeroC Ice:

Code: Select all

Ice is released as open source under the GNU General Public License (GPL). By linking with Ice (directly or indirectly, statically or dynamically, at compile time or run time), your application is subject to the terms of the GPL, which require that you release the source code of your application if and when you "distribute" it. Distributing an application includes giving it to customers, contractors, parent companies, subsidiaries, or any legal entity other than your own. Also note that the GPL does not permit you to distribute your application if it depends on non-free software (other than common operating system components), meaning that you can only distribute your application if all of its dependencies also have a license that is compatible with the GPL.

If you do not wish to be bound by the terms of the GPL, you can acquire a commercial license from ZeroC. We are flexible with respect to licensing, and will always try to find a licensing model that both works for our customers and gives us a fair share for our Ice software.

One of our licensing models is a license fee that is based on your organization's overall gross annual revenue of all products that use Ice. Of course, this model is only appropriate for Ice software products that are not bundled with other software or with hardware. We therefore also offer other models, including per-CPU licensing fees, fixed annual fees, and one-time buy-outs. Please contact us to discuss your licensing requirements.
http://www.zeroc.com/

Guess it just comes down to preference, Ice is actually higher level though as it doesn't require any packet building, etc. and relies mostly on RPC's. Nice thing about it is it can handle a lot of stuff for you scalability-wise (and patch for you too).

But you may be right, raknet may be better for the demo purposes.
User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
x 1
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by Danoli3 »

Anyone have working code for an implementation of WASD walking?

I'm trying if I get it to work I shall post. Please beat me to it though ;)
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009
James Proctor
Orc
Posts: 406
Joined: Fri May 16, 2008 7:33 pm
x 5

Re: The 'Player' Demo - V2 (Update!)

Post by James Proctor »

So does any one know why alpha splatting isn't working yet? I also can not seem to get caelum to work ether.
Follow me on Twitter - https://twitter.com/EmpireGames
Follow my Blog on Blogger - http://empiredevelopment.blogspot.com/
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: The 'Player' Demo - V2 (Update!)

Post by lonewolff »

Looks great! Keep it up :)
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: The 'Player' Demo - V2 (Update!)

Post by lonewolff »

Just downloaded. Excellent job!
sagron
Gnoblar
Posts: 7
Joined: Wed Jul 29, 2009 3:30 am

Re: The 'Player' Demo - V2 (Update!)

Post by sagron »

Danoli3 wrote:Anyone have working code for an implementation of WASD walking?

I'm trying if I get it to work I shall post. Please beat me to it though ;)
I sort of have an implementation working, but it's not real efficient yet - I'll post it once I finish up some of the movement prediction I'm working on (sometime later this weekend hopefully).
soulpower
Kobold
Posts: 32
Joined: Wed May 07, 2008 8:23 am
Location: hangzhou,China
Contact:

Re: The 'Player' Demo - V2 (Update!)

Post by soulpower »

When I saw the title of the thread almost with happy tears cuz always waiting for update of 'Player'. I remember ajs said there is going to be a version of more player contorl and perhaps a little NPC AI. In my imagination, even with a mini magic button list on the bottom like WOW. Maybe a little NPC task system. I am sorry, at least for me or new beginners like me. I am so eager to learn some useful skills in script like Lua. Is there anybody know how to learn these system design at the beginning? Any source code for good.
Still excellent job!! Is this V2 version the final one ? Is there any chance a version with more system especially some code in Lua?
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: The 'Player' Demo - V2 (Update!)

Post by Florin »

Very well. Thank you so much for this demo.

But my GOD, I honestly don't know how to apply the stereo plugin to this demo. Need help. Please :(
sagron
Gnoblar
Posts: 7
Joined: Wed Jul 29, 2009 3:30 am

Re: The 'Player' Demo - V2 (Update!)

Post by sagron »

Well, it's still buggy but I'm too busy to fix them at the moment so here's the WASD version I have so far. My code isn't quite as nice as adam's, but I tried to keep it pretty clean.

http://rapidshare.com/files/265542603/Player.zip (source code and binaries)

Known Bugs:
Edge of map problems, namely you can go past the edge.
Mesh orientation I think this only really screws up when you're at the edge of the map, but not sure... sometimes it flips upside down so you're walking under the map

Todo:
Fix Bugs
Make camera rotate with character
Interpolation
saiago
Gnoblar
Posts: 13
Joined: Thu Aug 06, 2009 10:35 am
Location: Israel

Re: The 'Player' Demo - V2 (Update!)

Post by saiago »

Thanks for making this demo! I've learnt a lot from reading the code. You're awesome!

I have two questions regarding the Input Manager:
1)Why do you have support for several key/mouse/joystick listeners if you can only have one game state at a time?
2)Why did you make your own singleton implementation with the input manager and didn't use the Ogre one?
I'm asking these questions because I want to know if I missed something or didn't understand your code.
xekon
Halfling
Posts: 68
Joined: Mon Jul 06, 2009 8:06 pm

Re: The 'Player' Demo - V2 (Update!)

Post by xekon »

Very Cool! I also have learned quite a bit from reading over the code.
Here is some information I found on the following line: http://www.ogre3d.org/wiki/index.php/Singleton
template<> Application* Singleton<Application>::ms_Singleton = 0;
Last edited by xekon on Fri Jan 08, 2010 6:44 pm, edited 1 time in total.
User avatar
calsmurf2904
Orc
Posts: 401
Joined: Tue Sep 16, 2008 9:39 pm
Location: Netherlands

Re: The 'Player' Demo - V2 (Update!)

Post by calsmurf2904 »

That line puts the Singleton (an object of the class thats accessable from everywhere in code) to NULL so that when the class is created the class itself can create and instance of it itself.

Hope that helps in the understanding process!
Visit my blog at http://calsmurf2904.wordpress.com !
Got a Google Wave account? Add me as contact! (projectxgame <at> gmail <dot> com)
Image
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: The 'Player' Demo - V2 (Update!)

Post by Florin »

Hello ajs15822,

Could you adapt the stereo plugin to PlayreDemo framework ? I need this for my project. Currently I am reading some documentation to understand better Ogre, and to be able to add the stereo plugin to your framework, but I don't know how much will that take me, or whether I will succeed.

I would very much appreciate it.
User avatar
Rembrandt_Q_Einstein
Gnoblar
Posts: 3
Joined: Fri Aug 07, 2009 9:28 pm

Re: The 'Player' Demo - V2 (Update!)

Post by Rembrandt_Q_Einstein »

I don't think ajs15822 is here to do your work for you. In addition, you are not going to be able to get very far with OGRE unless you are willing to learn how to do things on your own. If you are going to post questions or ask for help, please try and narrow your requests down. Making very generalised requests for assistance normally doesn't work.

Good luck!
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: The 'Player' Demo - V2 (Update!)

Post by Florin »

Sometimes it works, sometimes it doesnt. I hope at least for some helphul hints. Sometimes somebody more experienced can do the job while someone unexperienced just cant.
User avatar
Superfeesh
Halfling
Posts: 62
Joined: Tue Jun 23, 2009 4:53 pm
x 1

Re: The 'Player' Demo - V2 (Update!)

Post by Superfeesh »

This is fantastic! Thank you so much! This has helped me enormously. :D

However, I was wondering how to implement smoother movement- right now when you move the character to a new point, its rotation isn't graceful at all, it just snaps to face the new direction. If someone could point me in the right direction of how to fix this, I would be soooo grateful. :D
Locked