# ✔ ☕ General Conversation Thread

Sheesh, I know the feeling… total kick in the nuts…

Matrices?.. Camera?.. Orthogonal display?

Ya it’s so stupid simple i don’t even know what i did wrong.
The like 1000 line of spegetti code test works, i reduce it to this and its auto busted lol.

public class WorldSpaceObject
{
public Matrix world = Matrix.Identity;
public Vector3 Position
{
get { return world.Translation; }
set { world.Translation = value; }
}
public Vector3 Forward
{
get { return world.Forward; }
set { world = Matrix.CreateWorld(world.Translation, value, world.Up); }
}
/// <summary>
/// Move on a dimensional vector axis of the object itself.
/// Note, we dont use the system vectors for this.
/// </summary>
public void Move(Vector3 moveSpeedInEachAxis)
{
var motion =
moveSpeedInEachAxis.X * world.Right +
moveSpeedInEachAxis.Y * world.Up +
moveSpeedInEachAxis.Z * world.Forward
;
Position += motion;
}
/// <summary>
/// We designate the dimensional speed of rotation in dimension x y or z
/// Upon a perpendicular axis.
/// We may change the cc or ccw of rotation by using the reverse inverted axis vector.
/// </summary>
public void Rotate(Vector3 turnSpeedInDimension)
{
Vector3 temp = world.Translation;
world *=
Matrix.CreateFromAxisAngle(world.Forward, turnSpeedInDimension.Z) *
Matrix.CreateFromAxisAngle(world.Up, turnSpeedInDimension.X) *
Matrix.CreateFromAxisAngle(world.Right, turnSpeedInDimension.Y)
;
Forward = world.Forward;
world.Translation = temp;
}
}
/// <summary>
/// This class takes a world space object to create a camera. Via CreateCameraViewSpace.
/// You then get a combined world view projection matrix from GetWorldViewProjection.
/// </summary>
public class ViewSpaceCameraTransformer
{
public Vector3 OffsetPosition { get; set; }
public Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, GraphicsDeviceManager.DefaultBackBufferWidth / GraphicsDeviceManager.DefaultBackBufferHeight, 2f, 1000);
private Matrix viewSpace = Matrix.Identity;
/// <summary>
/// creates a camera view space matrixs and stores it
/// camera's are world objects too you just don't draw them ussually.
/// </summary>
public void CreateCameraViewSpace(WorldSpaceObject worldObjectToUseAsCamera)
{
viewSpace = Matrix.CreateLookAt
(
worldObjectToUseAsCamera.Position + OffsetPosition,
worldObjectToUseAsCamera.Forward + (worldObjectToUseAsCamera.Position + OffsetPosition),
worldObjectToUseAsCamera.world.Up
);
}
/// <summary>
/// Takes a world space object matrix and transforms it by view and projection space matrixs into screen space
/// </summary>
public Matrix GetWorldViewProjection(WorldSpaceObject worldObject)
{
return worldObject.world * viewSpace * projection;
}
}

couldn’t put it down lol fixed well just about its still got a couple little quirks and it could still become unstable over time. Because i never cross to get the up right once in a while, like i should of added, but its fairly stable i don’t really want to constantly cross either though…

1 Like

Ouch, is that like a fixed rotation camera view? or a camera that moves with say an analogue thumb stick? a bit too hairy for my brain right now, waiting for Grand Tour episode tonight brain needs a rest…

na its both like you could set it by position or just call rotate with x y z vectors were each element defines a amount of clockwise or counterclockwise rotation in radians. The up is free floating.

so like turn right would be like someObject.Rotate( new Vector3(.15,0,0) );
or just like directly set the objects forward

but ya i messed something up the center of rotation is off probably need to recreate the world with cross products but i don’t actually think that’s whats wrong lol ill figure it out later on. Ah i fixed it. well its still not done.

here’s a mouse keyboard input class i made to use with it.

public class OrientWorldObjectByUserInput
{
Vector3 turnOnAxis = Vector3.Zero;
Vector3 moveInAxis = Vector3.Zero;
float SpeedMovement = .01f;
float SpeedRotational = .01f;
bool didAnyChangeOccur = false;
public bool HasChangeOccured { get { return didAnyChangeOccur; } }
Vector2 windowcenter = new Vector2(GraphicsDeviceManager.DefaultBackBufferWidth * .5f, GraphicsDeviceManager.DefaultBackBufferHeight * .5f);

public Keys KeyMoveRight = Keys.D;
public Keys KeyMoveLeft = Keys.A;
public Keys KeyMoveUp = Keys.W;
public Keys KeyMoveDown = Keys.S;
public Keys KeyMoveForward = Keys.E;
public Keys KeyMoveBack = Keys.Q;

public Keys KeyLookRight = Keys.Right;
public Keys KeyLookLeft = Keys.Left;
public Keys KeyLookUp = Keys.Up;
public Keys KeyLookDown = Keys.Down;
public Keys KeySpinCW = Keys.Z;
public Keys KeySpinCCW = Keys.C;

private bool useMouseLook = false;
// if this is never called will just use the default key assignments
public bool UseMouseLook
{
get { return useMouseLook; }
set
{
if (value)
{
KeyMoveForward = Keys.W;
KeyMoveBack = Keys.S;
// just move them out of the way
KeyMoveUp = Keys.Home;
KeyMoveDown = Keys.PageUp;
}
else
{
KeyMoveRight = Keys.D;
KeyMoveLeft = Keys.A;
KeyMoveUp = Keys.W;
KeyMoveDown = Keys.S;
KeyMoveForward = Keys.E;
KeyMoveBack = Keys.Q;
}
useMouseLook = value;
}
}

public void SetWindowSizeRequiredForMouseLook(GraphicsDevice g)
{
windowcenter = new Vector2(g.Viewport.Width * .5f, g.Viewport.Height * .5f);
}
public void SetWindowSizeRequiredForMouseLook(int width, int height)
{
windowcenter = new Vector2(width * .5f, height * .5f);
}

public WorldSpaceObject UpdateOrientation(WorldSpaceObject worldObj)
{
didAnyChangeOccur = false;
if (useMouseLook)
{
MouseLook();
Move();
}
else
{
Rotate();
Move();
}
if (didAnyChangeOccur)
{
worldObj.Move(moveInAxis);
worldObj.Rotate(turnOnAxis);
}
return worldObj;
}

private void Rotate()
{
turnOnAxis = Vector3.Zero;
if (Keyboard.GetState().IsKeyDown(KeySpinCCW)) // roll ccw
{
turnOnAxis.Z = -SpeedRotational;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeySpinCW)) // roll cw
{
turnOnAxis.Z = SpeedRotational;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyLookLeft)) // r ccw
{
turnOnAxis.X = SpeedRotational;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyLookRight)) // r cw
{
turnOnAxis.X = -SpeedRotational;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyLookUp)) // u cw
{
turnOnAxis.Y = SpeedRotational;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyLookDown)) // d ccw
{
turnOnAxis.Y = -SpeedRotational;
didAnyChangeOccur = true;
}
}

private void Move()
{
moveInAxis = Vector3.Zero;
if (Keyboard.GetState().IsKeyDown(KeyMoveForward)) // Forward
{
moveInAxis.Z = SpeedMovement;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyMoveBack)) // back
{
moveInAxis.Z = -SpeedMovement;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyMoveLeft)) // left
{
moveInAxis.X = -SpeedMovement;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyMoveRight)) // right
{
moveInAxis.X = SpeedMovement;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyMoveDown)) // down
{
moveInAxis.Y = -SpeedMovement;
didAnyChangeOccur = true;
}
if (Keyboard.GetState().IsKeyDown(KeyMoveUp)) // up
{
moveInAxis.Y = SpeedMovement;
didAnyChangeOccur = true;
}
}

private void MouseLook()
{
turnOnAxis = Vector3.Zero;
Vector2 mousePos = new Vector2(Mouse.GetState().Position.X, Mouse.GetState().Position.Y) - windowcenter;
Vector2 mouseAngle = Vector2.Normalize(mousePos);
if (Mouse.GetState().LeftButton == ButtonState.Pressed)
{
Matrix r = Matrix.Identity;
mousePos.Normalize();

if (mousePos.Y > 5f)
{
turnOnAxis.Y = SpeedRotational * mouseAngle.Y;
didAnyChangeOccur = true;
}
if (mousePos.Y < 5f)
{
turnOnAxis.Y = SpeedRotational * mouseAngle.Y;
didAnyChangeOccur = true;
}
if (mousePos.X > 5f)
{
turnOnAxis.X = SpeedRotational * mouseAngle.X;
didAnyChangeOccur = true;
}
if (mousePos.X < 5f)
{
turnOnAxis.X = SpeedRotational * mouseAngle.X;
didAnyChangeOccur = true;
}
}
}
}

so like you would make some objects that represent your 3d game objects orientations.

WorldSpaceObject obj_A = new WorldSpaceObject();
WorldSpaceObject cam = new WorldSpaceObject();
ViewSpaceCameraTransformer transformer = new ViewSpaceCameraTransformer();
OrientWorldObjectByUserInput uiInput = new OrientWorldObjectByUserInput();

Then you would set them up in like load or something initially with positions and directions. …ect…

Then update them and use one of the objects as a camera.

cam = uiInput.UpdateOrientation(cam);
if (uiInput.HasChangeOccured)
{
transformer.CreateCameraViewSpace(cam);
}

worldviewprojection = transformer.GetWorldViewProjection(obj_A);

Then you have a matrix to send to your shader with the object’s your drawing.

Though mind you the whole thing is barely even tested yet.

1 Like

Sending you a PM

I was wondering, has anybody created a networking system for use with MonoGame that is open source?

I was thinking to tackle this sometime this year and make it available to all MonoGame developers… the reason being I could do with some optimisation tips and giving the engine for free might help more developers get the networking aspect out of the way in order to make a great game using MonoGame and get it out the door faster…

Personally I am not a fan of Open Source code bases, just too much work to deal with but something like this, a component that benefits all, I think will be worth the effort… Plus I can get some experience with GitHub and that will be a bonus I suppose as it is something I will have to do at some point…

However my focus - and it must be said - will be on the UWP platform implementation, meaning all UI code will be specifically for UWP Windows 10 and beyond, however the backend will all be in C#.NET code so perhaps a sub team of contributors can recode a sub project for cross platform?

I would prefer to have this separation as PCLs [Portable Class Libraries] require the project to be supportive of all platforms however my projects will strictly be Windows 10 only… so a dedicated code base is all I need… [In future I may port to iOS and MacOS platforms but LINUX is too messy for me, so a simple duplication and UI code change will be simple] but again, I believe the project will get the support it deserves as it will benefit all current and future MonoGame developers and anybody using C#.NET in general…

Understandably the variations in requirements will be vast but if designed appropriately it can support various use case scenarios… and the idea is for it to be usable for even beginners to use without the complication of vast components to trawl over… so modularity will likely be a core component of the project…

OK before I waffle on, here is an early list of requirements I can think of that will be key:

Simple to implement with full instructions, possibly become a NuGet package in future,
Flexible for various use cases such as Strategy Games, FPS Games, Racing Games, Fighting Games etc.
Implementation should be as easy as placing a single directory into a project and interfacing with commands in the main loop type thing… while being able to set up the interface style in a single method…

Well, I need food, not had lunch yet and it is freezing here in Manchester at the moment…

I know this can be done because a project such as MikeNET exists and I find it overly cumbersome to get started… so I want to build a system that is easier and much more simplified and better documented… but again, my coding skill is not top notch and I am more an architect than a coffee coder…

Let me know what you think…

I just posted a detailed linkage over in the UMGRL thread on MikeNET

Hmmm.
IMHO the problem with networking libraries for games is that the common denominator of mp-implementations of games often IS a framework like Lidgren.

I’ll give an example to get my point across:
Take something like a slow-paced RTS game like Throbax TD. I implemented the networking code using the deterministic lockstep method with a single client-game-engine being used as the server.

Now take a fast-paced shooter. You cannot use that method here since the latency and the frequency of command are too high. You don’t get a fluid gameflow, so you have to compensate, use prediction, correct those predictions when necessary. That’s a completely different league.

The only thing those implementations would have in common are basically covered in Lidgren (NAT-traversal to open the connections to the server; fast, but reliable UDP communication; etc…)

The only things I ended up NOT coding myself (I use Steamworks.net, since the game is published on steam using their servers for opening multiplayer-games as well) are the Steam-Server ‘tools’ like messaging for lobbies and finding friends.
All the rest is packing as much information into as small packages as you can manage without generating garbage along the way (many structs basically).
And I cannot think of a way you could write a framework further simplifying that process.

And I think you’re even free to use the Steamworks.net libraries when you host the server yourself (I think I read that somewhere).
So the way I would go when publishing an MP-game on a different platform than steam is that I would host my own server using the Steam-libraries anyways (or use Lidgren; It’s great).

Of course I could be wrong; Anyways, share your thoughts.

EDIT: I thing I was wrong. There seems to be no way to use Steamworks.NET ‘outside’ of a steam-publication. Thought I read that somewhere.

1 Like

I only recent heard of Lidgren but never seen it personally, linky? and I believe it was removed from the MonoGame package circa. 3.2?

You see, you are using a umm… what’s the saying… cannot think right now but a bit of a mix of puddles, and complicating things… the idea of good code is using as few libraries as possible as you introduce precisely what you said…

… generating garbage along the way

Don’t get me started on my opinion of Steam

Though your solution works, it relies heavily on two external factors…

1 - LidGren? Lidgren? continuing to function as future code changes occur across C#.NET/Core etc… and your project remains actively updated or you become reliant on LidGren for future projects and it suddenly stops functioning…

A solution to this is you create an interface in your code that can communicate with any networking system regardless of what language it uses, though this introduces a potential lag among other things, it allows you to plug and play any networking system at any time… I am considering this approach for the code…

2 - Steam, they could pull the project at any time and believe me it will happen, or it morphs and legacy code no longer functions, this leaves your project dead in the [Pun intended] water… [Get it? Steam = vaporised Water ]

Quoting your very words:

And I think you’re even free to use the Steamworks.net libraries when you host the server yourself (I think I read that somewhere).

Another factor I like to avoid is cumbersome paperwork, [Albeit digitally] can delay the packaging phase of your project as you work through the legal factors of your game before publishing, and you SHOULD be doing this to cover your legal standing… I mean, ARE YOU using that SteamWorks.NET library legally? would you want to risk them shutting you down for a simple reason that you did not spend the 30-120 minutes to read through the paperwork?

I have studied Game Production… hence the stern point

Like I said, there will be several variations, and like any code, especially modular ones, there are design schemes that will work and enable the code to be modular and functional… if you broke the system down into core components and the following is not a complete overview… you would have components that did this:

SERVER:
-/ Establish network communication with outside world and create incoming listening connections
-/ Listen for new connections
-/ Receive connection and add it to a lobby
-/ cross communicate data to connected members
-/ Authenticate members [optional login scenario]
-/ etc.

CLIENT:
-/ Create a connection to a predefined server
-/ Send packets containing data
-/ Receive packets from server
-/ Process received packets
-/ etc.

OK right that was not what I wanted to write… hang on…

Components:

Messaging
UDP
TCP

Umm I better go eat…

What I am trying to say is, there are components that can be added or removed without affecting the core functionality of the networking API code… like you will always need to establish a connection with a server, but not always require sending a message for chat functionality for example, or not always require sending a voice stream for voice chat… and the communications section can have parts that accept data from various components that can safely be ignored if they are not included…

The process will ideally be organic, such that, we can begin with a core engine that establishes a connection between a server which I plan to host in an ASP.NET application, or optionally someone can convert it into a console application… but the ASP.NET implementation can give an admin panel for use anywhere and as such I can create a server administrator app to go with it… thus even beginners can get some shared hosting somewhere to get a basic server system going while testing or even run their own on a local network using IIS…

And moving past the core functionality we can add things like the messaging routing system, lobby, auto matching, etc. as the requirements appear… and as the code will both be available to all, be usable by all, be maintainable by all and not rely on any central service as you can host it anywhere, it can essentially never die… thus giving any project you create [Say if it was P2P based] a project that has 10+ years to itself… this gripe comes from me because of what EA did with the Battlefield line of things, private servers that you have to rent, what ever happened to P2P gaming

So yeah, I like to think this will work, I know full well how much will be involved in this… If there is interest in such a project I will be willing to put in the effort of creating it, moderating it and contributing to it, otherwise I just end up making the whole thing in-house and beginners are left with no simple Networking API…

Put it this way, I am one of those beginners… but seeing as there is no Physics system readily available to use with MonoGame and no Networking either… the only solution is to make it… [I am not as versed in coding as some and moving to another system when I am happy with MonoGame is not an option for me]

Heck it could become a component of the MonoGame package, which would be doubly cool!

And yes I did just hint at doing the same for Physics… the idea of simply using a command like AddRigidPhysics(Object) or something should be a reality not a dream!

I really wish Microsoft would give more focus on C#…

Dang it, I waffled…

EDIT

Is LidGren Open Source? found it I think, https://github.com/lidgren/lidgren-network-gen3 but it appears on google code as well… confusing… what does the name stand for anyway?

Sorry. Here you go: https://github.com/lidgren/lidgren-network-gen3
Lidgren is MIT licensed and heavily used in many networking projects.
It basically is a network-layer wrapper providing reliable communication over UDP. It’s very basic; No nifty stuff.
EDIT: Dang. You beat me to it
EDIT2: It’s the name (nick) of the programmer.

1 Like

I think we need a purpose built library, don’t you? One where MonoGame is the intended platform…

I see, saw him, lol at his profile pic

Hmmm. I see your point.
The ideas for the server are good IMHO.
I would like a cross-networking platform that allows me to use a framework in my game and that connects to Steamworks, any other big hosting platform or the server-implementation of that library on demand when I’m done coding.
That would be an awesome and BIG project

So, what you’d actually have to do is:

SERVER:

• Listen for new connections
• Authentication (add, delete, modify)
• Lobby (enter, exit, create room, message, whisper, kick, search)
• Friends (add, remove)
• NAT punch-through (for Peer2Peer communication)
• Most of the client-capabilities

CLIENT:

• Connect to a server
• Send packets containing data
• TCP (you would actually never use that)
• UDP
• UDP with flow control (reliable)
• Receive packets and allow the programmer to tap into that process (delegates or something else)

I don’t see that you’ll need a server-gui in the first place. You can use cmdline for the basic stuff and do the rest with your game-client.

1 Like

If they have an interface, then it should be possible

More details such as this would be helpful

Actually, having a list of users to manipulate using a common listbox is easier than UserID(1) + UserID(14) [Or names] when you can simply ban someone by clicking a name in a list or whatnot ^^, again, entirely optional feature!

BRB having a late lunch…

Maybe I find some time to look into a list of features for client and server (personally I would draft it following the Steamworks-API closely since those guys know what they are doing).
We could use that as a starting point and evolve it from there.

1 Like

am working on some water

Looks nice! Just experimenting?

That’s so cool. What are you making your gifs with by the way? Wanted to ask you for some time now.

1 Like

Can you link to it here?

Meal got cold because I forgot to warm up the dish in the oven [Oven was already in use so usually I put it in there for a short while to heat it up]

I have some resources to start somewhere but the more resources the more robust the design can be… unlike most of the Git repositories I have seen, I will create plenty of documentation for these projects in PDF format so anybody can view them easily… and I will also upload the master files so others can contribute to them as well, I would usually use a third party software package to make them but if I am to share the core files, the best would be a DocX file… I can just create the graphics separately [My third party package allows me to create graphics within it, and control the entire document layout unlike Word ]

Now that is a water effect I like! and would totally use in one of my games! what is the resource drain?
I presume it is inside a sphere of sorts? [If not, would be amazing… like those spheres that you shake for the snow…]

I believe I asked once but forgot where, so this x2

One thing to note, I will more than likely start with the Physics library project before the networking one as the Physics is core to my first game, networking is secondary…

Gifs: With LiceCap. I found that tool to be amazing for casual gif taking, but it doesn’t have a lot of options.

Speaking of which

1 Like

What is it with some company naming choices…

http://www.cockos.com/licecap/

this right?

Why the sudden flip effect?

oh i change the parameters depending on where I click witht the mouse. I need to click to end the capture, and I didn’t setup my program so it only reacts when it is active

Yes I think this is the correct website

1 Like