Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Princess Kakorin
Nov 4, 2010

A real Japanese Princess

Princess Kakorin posted:

It makes sense, I'll throw something together when I get home. If it does work, I wish the blogs/tutorials I've read would have stated that in the begining.

Well, the good news is that it kinda works.
But now, when I try to make a Reader/Writer class, it freaks the gently caress out and crashes the IDE.
I've gone back through and made a program from scratch and followed tutorials exactly, but this stuff apparently doesn't work.
gently caress XML and having it "being easy to implement with XNA!"

Princess Kakorin fucked around with this message at 02:19 on May 20, 2011

Adbot
ADBOT LOVES YOU

Ben Nerevarine
Apr 14, 2006
Does anyone have any experience with both pymunk and/or pybox2d? I'm looking into making a 2D physics-enabled game in Python using PyGame and I'm trying to figure out which library is easier/faster/supported/more fully featured.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Princess Kakorin posted:

Anybody know what the deal is when you get this error when _trying_ to use XML?
The class does have the Serializable attribute, right?

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(
I'm working on a Marble Madness clone using OpenGL + SDL. Basically I have a grid with varying heights and a ball which you control with the arrow keys and you can use the mouse to zoom in/out and rotate the view around the center of the grid.

My question is concerning the movement of the ball. If I press up or down / left or right the ball will move along the z or x axis (see mspaint drawing), but I'd like it to move along the axes drawn in green. I guess I have to use the camara position somehow to calculate the new axes which I want to use for the ball movement but my stupid brain can't figure it out. I've tried some stuff with no luck.

Any tips or guide?

Vino
Aug 11, 2010
If the camera is always fixed then you can hack it by just replacing the down input with a 45 degree motion output. Otherwise you'll have to do a little trig involving rotating the input to the camera's view vector. The way I do it in my game is to build a euler angle (pitch yaw roll) and then convert that into a matrix (that function is part of my math library) and then your new velocity is m * v where m is that matrix and v is the old velocity.

Does that make sense?

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(
I think I get it.
So, let's say an arrow key is pressed so I set the velocity v to v = (vx,0,vz) (the ball rolls on the y = 0 plane). Then I'd use the rotation of the camera (I have this stored) to generate a rotation matrix (r) and I'd multiply them to get the actual velocity relative to the camera.

Vino
Aug 11, 2010
Yep, exactly.

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(
Great, I'll try this later and hopefully won't gently caress it up. Thanks!

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.
Has anyone implemented rewind-the-world synchronization for a real-time online game? In Valve's model, they record what they call a snapshot on each frame, which I take to be a record of the entire game state. Then when they want to update a player's state, they send the delta between the snapshot that the player last confirmed receipt of and the current snapshot.

The part that I'm wondering about is snapshot creation and delta compression. Are they serializing the entire game world and then finding the delta between the two serializations, or are they making some sort of copy of the world and then creating a delta that is a set of steps for going from one state to the next? Are there other implementations?

shrughes
Oct 11, 2008

(call/cc call/cc)

Twernmilt posted:

The part that I'm wondering about is snapshot creation and delta compression. Are they serializing the entire game world and then finding the delta between the two serializations, or are they making some sort of copy of the world and then creating a delta that is a set of steps for going from one state to the next? Are there other implementations?

If you use immutable data structures, making a "copy" of an object is a no-op, and making a "modified copy" of the object means you make a value which shares a lot of substructure with a preexisting value. Then you can look at two values and see what subtrees of the data have changed by comparing pointers or version numbers or some other technique. So you don't serialize or traverse the entire state of the game, you just traverse proportionally to the size of the difference.

Another implementation is to just make a list of changes.

Both can be useful.

Vino
Aug 11, 2010
Source stores only player positions and model animation information. They have a rotating vector of the last x frames. They do no delta compressions but the structure is not so big anyway. When they want to know what a player was shooting at x seconds ago they find the appropriate entry and rebuild the model data for that past frame.

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.

http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking posted:

Game data is compressed using delta compression to reduce network load. That means the server doesn't send a full world snapshot each time, but rather only changes (a delta snapshot) that happened since the last acknowledged update. With each packet sent between the client and server, acknowledge numbers are attached to keep track of their data flow. Usually full (non-delta) snapshots are only sent when a game starts or a client suffers from heavy packet loss for a couple of seconds. Clients can request a full snapshot manually with the cl_fullupdate command.

Is this wrong?

Vino
Aug 11, 2010
That's talking about updating entities over the network. I thought you were talking about storing player past positions for purposes of lag compensation. Lag compensation happens completely on the server with no network traffic involved. It's really just a modification of the raytrace routine when someone shoots a gun.

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.
Oh, I'm talking about keeping all of the players in sync with the game world. Sorry for the confusion.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I've been working on a 2D graphics library in C# that will work well with OpenTK. I'm fine tuning the sprite batching, but the cool thing about mine is how it handles drawing the sprites.

The idea is to make calls that look like this.

code:
_context.Draw( sprite.Translate(64,64));
_context.Draw( sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30));

or

_bakedSprite = sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30);

_context.Draw( _bakedSprite);
If anybody is interested in trying it out, here is the codeplex for it. http://mannagum.codeplex.com/

http://mannagum.codeplex.com/releases/view/66880 -- release files

There is documentation, and the sampler project contains a few examples (switch screens by pressing 1-3)

Thanks.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

PnP Bios posted:

I've been working on a 2D graphics library in C# that will work well with OpenTK. I'm fine tuning the sprite batching, but the cool thing about mine is how it handles drawing the sprites.

The idea is to make calls that look like this.

code:
_context.Draw( sprite.Translate(64,64));
_context.Draw( sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30));

or

_bakedSprite = sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30);

_context.Draw( _bakedSprite);
If anybody is interested in trying it out, here is the codeplex for it. http://mannagum.codeplex.com/

http://mannagum.codeplex.com/releases/view/66880 -- release files

There is documentation, and the sampler project contains a few examples (switch screens by pressing 1-3)

Thanks.

I really like this idea instead of having a draw method that is overwritten like 7 times and takes anywhere from 1 to 9 parameters.

The Saddest Robot
Apr 17, 2007

HolaMundo posted:

I'm working on a Marble Madness clone using OpenGL + SDL. Basically I have a grid with varying heights and a ball which you control with the arrow keys and you can use the mouse to zoom in/out and rotate the view around the center of the grid.

My question is concerning the movement of the ball. If I press up or down / left or right the ball will move along the z or x axis (see mspaint drawing), but I'd like it to move along the axes drawn in green. I guess I have to use the camara position somehow to calculate the new axes which I want to use for the ball movement but my stupid brain can't figure it out. I've tried some stuff with no luck.

Any tips or guide?



I think that the simplest would be some vector math. If you want to move it "down", simply create a vector pointing it in the direction you need it to move, normalize it and scale it by how much you want it to move. This has the added bonus of being able to add movement in any direction if you decide to add mouse or gamepad input.

It's been ages since I've done OpenGL so I don't know what it's structures are, but in XNA it would be something like:

code:
// create a vector pointing in the direction of +x,+z
Vector3 dir = new Vector3(1f, 0, 1f);
dir.Normalize();
dir *= movementAmount;
// marble.Position is a Vector3
Marble.Position += dir;

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

poemdexter posted:

I really like this idea instead of having a draw method that is overwritten like 7 times and takes anywhere from 1 to 9 parameters.

The only problem I can see is that it's creating a lot of objects so the garbage collector is going to be working overtime.

But I figure anybody who is worrying about cache misses would be writing their game in C already.

I would definitely appreciate a second set of eyes to see if I'm missing anything obvious.

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(

The Saddest Robot posted:

I think that the simplest would be some vector math. If you want to move it "down", simply create a vector pointing it in the direction you need it to move, normalize it and scale it by how much you want it to move. This has the added bonus of being able to add movement in any direction if you decide to add mouse or gamepad input.

It's been ages since I've done OpenGL so I don't know what it's structures are, but in XNA it would be something like:

code:
// create a vector pointing in the direction of +x,+z
Vector3 dir = new Vector3(1f, 0, 1f);
dir.Normalize();
dir *= movementAmount;
// marble.Position is a Vector3
Marble.Position += dir;

The problem was I didn't actually knew which direction was "down". I solved this by doing what Vino posted and it's working. Thanks anyways.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

PnP Bios posted:

The only problem I can see is that it's creating a lot of objects so the garbage collector is going to be working overtime.

But I figure anybody who is worrying about cache misses would be writing their game in C already.

I would definitely appreciate a second set of eyes to see if I'm missing anything obvious.

Is there any reason you have to copy the entire object every time you do a transformation instead of just transforming in place and returning a reference? For example the code

code:
        public Sprite Rotate(double degrees)
        {
            var c = Copy();
            c.TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return c;
        }
could get changed to

code:
        public Sprite Rotate(double degrees)
        {
            TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return this;
        }
and you'll still get the kind of method call format that you're going for without working the GC so hard. You might need to make the final Draw call reset the transformations to a neutral starting state but that's not too terrible.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

PDP-1 posted:

Is there any reason you have to copy the entire object every time you do a transformation instead of just transforming in place and returning a reference? For example the code

code:
        public Sprite Rotate(double degrees)
        {
            var c = Copy();
            c.TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return c;
        }
could get changed to

code:
        public Sprite Rotate(double degrees)
        {
            TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return this;
        }
and you'll still get the kind of method call format that you're going for without working the GC so hard. You might need to make the final Draw call reset the transformations to a neutral starting state but that's not too terrible.

The question then becomes, how do you know which is the last call?
No drawing actually takes place during the draw command. It just queues everything up, and all the magic happens in EndSpriteBatch()

One option I do see is only making one clone. You don't want to pollute the original sprite. I will play around with this idea tonight and see if it works. Thanks for the feedback!

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

PnP Bios posted:

The question then becomes, how do you know which is the last call?
No drawing actually takes place during the draw command. It just queues everything up, and all the magic happens in EndSpriteBatch()

One option I do see is only making one clone. You don't want to pollute the original sprite. I will play around with this idea tonight and see if it works. Thanks for the feedback!

This sorta works... Just not if you plan on retaining the state after making the call. You'll need to some how mark it back as not a clone.

xgalaxy
Jan 27, 2004
i write code

PnP Bios posted:

The only problem I can see is that it's creating a lot of objects so the garbage collector is going to be working overtime.

But I figure anybody who is worrying about cache misses would be writing their game in C already.

I would definitely appreciate a second set of eyes to see if I'm missing anything obvious.


Garbage collection issues and cache misses are completely different set of performance issues. Just because someone is using C# doesn't mean they aren't concerned with performance. Especially where the garbage collector is concerned.

I would not use a library, especially one designed to be used in a tight drawing loop, that is willy nilly creating tons of garbage. I would find a way to either not create the garbage in the first place, or find a way to recycle it so the gc doesn't kick in.

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.

PnP Bios posted:

The only problem I can see is that it's creating a lot of objects so the garbage collector is going to be working overtime.

You could have a different object that gets instantiated and returned when you invoke any of the transforms on a sprite and then send that through the pipeline.

So calling my_sprite.rotate(1.7) would create and return a new object that is just like the original sprite except it handles the transformations by returning self instead of a new object. That way you're only creating one new object for every set of transformations.

I don't know C#, so this may not be syntactically correct, but something like this:

code:
class Sprite {
    public TransformedSprite Rotate(double degrees) {
        var sprite_clone = new TransformedSprite(this);
        return sprite_clone.Rotate(degrees);
    }
}

class TransformedSprite inherits Sprite {
    public TransformedSprite(Sprite original_sprite) {
        // Perform cloning here
    }

    public TransformTransformedSprite Rotate(double degrees) {
        // Rotate the sprite
        return this;
    }
}

Twernmilt fucked around with this message at 16:51 on May 25, 2011

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
I think you could even use a static transformedsprite there, rather than instantiating once each time, so long as there's no circumstance in which you pass two transforming sprites to the same function. And it even just naturally works with the "pre_transformed_sprite = sprite.Rotate(n).Translate(x,y);" idea too.

(If you want to be a bit crazy about it and allow for passing a few transforming sprites at a time, you could use a little static array of say 8 transformedsprite objects and cycle which one you're using each time you call regular_sprite.AnyTransform)

Paniolo
Oct 9, 2007

Heads will roll.
Or you could just drop the fancy interface and just make a Draw(Sprite, float, float, float, float, float) function so all the parameters are passed on the stack.

In C++ you could design a class with that kind of interface and it would have zero performance overhead. I don't know C# well enough to say otherwise but my gut feeling is that you can't, and if you're adding any kind of object creation/gc overhead just so the programmers can use a slightly fancier interface that's a bad call.

Goreld
May 8, 2002

"Identity Crisis" MurdererWild Guess Bizarro #1Bizarro"Me am first one I suspect!"

HolaMundo posted:

I'm working on a Marble Madness clone using OpenGL + SDL. Basically I have a grid with varying heights and a ball which you control with the arrow keys and you can use the mouse to zoom in/out and rotate the view around the center of the grid.

My question is concerning the movement of the ball. If I press up or down / left or right the ball will move along the z or x axis (see mspaint drawing), but I'd like it to move along the axes drawn in green. I guess I have to use the camara position somehow to calculate the new axes which I want to use for the ball movement but my stupid brain can't figure it out. I've tried some stuff with no luck.

Any tips or guide?




What you're wanting to do, technically speaking, is project your controls into "marble-space" (ie. that xz-plane)

Short-form answer - use dot products.

Long-form answer - (I'm doing this without pen and paper so it may not be exactly correct :o )
Say you know each of the 4 'controller' directions, ie. each is a vector in screen-space. If you know your camera orientation, you can find these in world-space. So in worldspace you'd have {joyUp, joyDown, joyLeft, joyRight}

The xz-plane is just another coordinate system (with an irrelevant y-axis) you're projecting to. Say it's 3 vectors, {marbleX, marbleY, marbleZ} So to find the projected vector of 'up' just do this

newX,Y, and Z are scalars - joy? and marble? are vectors
newX = joyUp . marbleX
newY = 0
newZ = joyUp . marbleZ

finalVec = newX * marbleX + newY * marbleY + newZ * marbleZ

and you'd probably want to re-normalize it as well.


edit: this is all based on a very important concept to realize about dot products - they're related to the cosine between angles, such that two vectors that are orthogonal/perpendicular will have a dot product of zero, and if they're parallel they have a dot product of 1. More or less, a dot product tells you how well two vectors 'align' because the angle between them is 0 at perfect alignment, cos(0) = 1, and all that jazz.

edit of edit: Btw this assumes your vectors are all unit length to begin with.

Goreld fucked around with this message at 17:47 on May 25, 2011

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
Working with RenderTargets, is there any way to switch between them and not lose everything in the old one when you do?

mellowjournalism
Jul 31, 2004

helllooo
Goons, what 3D modeling program would you recommend off the top of your head? I have some experience with Maya and Blender and I want to just pick a program and get decent with it, I just want to make sure I invest time in a program that has decent longevity and compatibility.

Vino
Aug 11, 2010
If you're not doing animation and you like manipulating the bare polygons to make low-res meshes or simple mockups, SILO. I loving love Silo, it's easy to use and cheap. The devs aren't really supporting it these days though.

If you're not doing animation and you want a powerful tool and you don't mind the learning curve, Zbrush.

Otherwise, Maya.

cultureulterior
Jan 27, 2004
I like wings3d. It's quite easy to learn by exploring, since all operations are in modal menus.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Another game networking question.

We want to keep the game logic seperate from the networking logic So our dedicated server will create 2 threads, a networking thread that handles incoming and outgoing messages and a game logic thread that will handle each tick of game and updating objects in the game. The two will talk to each other via event handlers/delegates. This is all XNA/C# with the libgren lib for networking (not using the built in networking since we aren't doing GFWL).

My question is this:

Is this the best way to do a dedicated server? We've been looking for dedicated server architecture examples or tutorials or blog posts or something, but we're coming up short.

Paniolo
Oct 9, 2007

Heads will roll.

poemdexter posted:

The two will talk to each other via event handlers/delegates.

I don't see that working very well. Not only would you need locks everywhere but you would need to code your entire game engine with the assumption that state can change at any given time which is pretty much impossible. Look into using buffered states or message queues instead.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Anybody here played around with the Bullet physics library? I was asking some of the Irrlicht people for examples of collision detection for making sure entities don't fall through the game world but do honor gravity, and pretty much they steered me right to that. I assume it's because of the Irrlicht bindings that come with it. The response seemed a little :smug: at the time but I guess it makes sense; I'd probably end up bringing in physics in some fashion so I might as well grab the bull by the horns. It did solve my problem in just a few lines of code. But I wonder if I'm going to get into a quagmire when I try to do stuff like check if stuff is successfully smacking down other stuff, projectiles, or generally other stuff that might happen in a game I haven't tried to do.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Paniolo posted:

I don't see that working very well. Not only would you need locks everywhere but you would need to code your entire game engine with the assumption that state can change at any given time which is pretty much impossible. Look into using buffered states or message queues instead.

each thread would use events to fill each other's message queue. How's that?

ShinAli
May 2, 2003

The Kid better watch his step.

Rocko Bonaparte posted:

Anybody here played around with the Bullet physics library? I was asking some of the Irrlicht people for examples of collision detection for making sure entities don't fall through the game world but do honor gravity, and pretty much they steered me right to that. I assume it's because of the Irrlicht bindings that come with it. The response seemed a little :smug: at the time but I guess it makes sense; I'd probably end up bringing in physics in some fashion so I might as well grab the bull by the horns. It did solve my problem in just a few lines of code. But I wonder if I'm going to get into a quagmire when I try to do stuff like check if stuff is successfully smacking down other stuff, projectiles, or generally other stuff that might happen in a game I haven't tried to do.

Pretty much the only documentation is in the demo code (as well as API docs which is pretty good), which thankfully it has a lot of. I remember checking collisions between two objects required me creating a struct inheriting another provided by Bullet and passing that in some function. I thought it was a little ugly but it did tell me if the objects were colliding.

General idea is easy to wrap your head around but Bullet does things that I wasn't used to. Then again, I never really started extensively coding in C++ until recently.

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.

Paniolo posted:

I don't see that working very well. Not only would you need locks everywhere but you would need to code your entire game engine with the assumption that state can change at any given time which is pretty much impossible. Look into using buffered states or message queues instead.

You don't need to lock anything if you use message passing to have the network and game logic communicate and avoid mutating those messages, which isn't difficult. It sounds like that's what he's doing with handlers.

poemdexter: If you find any good guides, be sure to post them here. I've been pretty much winging it because I can't find any solid examples. I've been piecing things together from Valve's wiki about the networking infrastructure in Source and blogs.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

poemdexter posted:

Is this the best way to do a dedicated server? We've been looking for dedicated server architecture examples or tutorials or blog posts or something, but we're coming up short.
What kind of game is this?

Integration of networking with the gamecode has actually been getting tighter because if there's any place to classify how important it is that clients are aware of certain things happening in the world, it's the gamecode.

Bungie made a publication about Halo 3's networking containing some useful insights and photos of a very large beard. You obviously don't need to grow it as long go as deep into it as they did, but it really shows why the two need to be so close: How important an object is is a gameplay decision, when to create objects to minimize lag is a gameplay decision, and deciding what to tell clients is happening and what to leave to prediction is a gameplay decision.

State/event architectures work really well and you should probably look in to them.


To summarize their architecture a bit, everything in the world has state. Information about state that clients need to know about to display them properly is guaranteed to be updated eventually. Objects are assigned priority, the highest-priority objects that fit into a packet are sent every frame, objects can also have a value which causes their priority to increase by an amount every time they're not sent.

Objects that don't receive updates get predicted instead. i.e. if a grenade is flying through the air, and the client doesn't get an update for it in a frame, it guesses that it continued flying. Most Quake series games use delta compression, which is essentially predicting that all objects are identical to their state in the previous frame.

Events can be handled as objects with one state and if they can't be sent by the time they expire, they are not sent at all.

That's pretty much your modern networked real-time game in a nutshell.

OneEightHundred fucked around with this message at 21:02 on May 26, 2011

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

OneEightHundred posted:

What kind of game is this?

It's multiplayer asteroids with a dedicated server and clients that act like dummy terminals sending keyboard inputs to the server. I understand the architecture of how things work. I'm actually just looking for implementation guidelines/best practices.

Server with 2 threads? Server with no threads and 2 objects inside a loop? Event handlers for recieving messages passing messages between objects or just straight up call a updateGame() method passing what I'm parsing from messages?

Adbot
ADBOT LOVES YOU

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Twernmilt posted:

You don't need to lock anything if you use message passing to have the network and game logic communicate and avoid mutating those messages, which isn't difficult. It sounds like that's what he's doing with handlers.

poemdexter: If you find any good guides, be sure to post them here. I've been pretty much winging it because I can't find any solid examples. I've been piecing things together from Valve's wiki about the networking infrastructure in Source and blogs.

I saw that wiki as well! I understand the why for networking, just need a little guidance on the how.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply