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
Physical
Sep 26, 2007

by T. Finninho
Stupid question but how do I format a couple of if/else statements if each of them have the same code in the else? e.g.
code:
Dictionary<int, Dictionary<int, BlockType[, ,]>> Pangea = new Dictionary<int, Dictionary<int, BlockType[, ,]>> { };

//check if the entry exists in the dictionary object Pangea, if it doesnt create the dictionary entry
if (Pangea.ContainsKey(_x))
{
    //x exists check if z exists
    
    if (Pangea[_x].ContainsKey(_z))
    {

    }
    else //Failure! Entry doesnt exist so create it
    {
        //create the z chunk
        //if z entry doesnt exists create the entry and thusly both the x and z elements
        ChunkMaker mkr = new ChunkMaker(msgSender, this, netServer, _x, _z);

    }

}
else //Failure! Entry doesnt exist so create it
{
    //if x entry doesnt exist create the entry and both x and z elements
    ChunkMaker mkr = new ChunkMaker(msgSender, this, netServer, _x, _z);
}
The thing I am getting hung up on is I cant do
code:
if( Pangea.ContainsKey(_x) && Pangea[_x].ContainsKey(_z))
Because the [_x] entry must exist before I can check if _z exists, otherwise a runtime error gets thrown. This kind of thing comes up at other times too so I'd like to know a better way to format the if/elses without using break;/continue; or some variable that tells me if both things passed/failed

I want to avoid this
code:
                                                                bool bCreateChunk = false;
                                                                if (Pangea.ContainsKey(_x))
                                                                {
                                                                    if(!Pangea[_x].ContainsKey(_z))
                                                                    {
                                                                        bCreateChunk = true;
                                                                    }
                                                                }else
                                                                {
                                                                    bCreateChunk = true;
                                                                }
I feel like the bCreateChunk = true; bit needs to be written only once but am not sure how to structure this, especially since I have to do two checks anyway and the second check is dependent on the first.

Physical fucked around with this message at 23:09 on Sep 7, 2011

Adbot
ADBOT LOVES YOU

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Physical posted:


The thing I am getting hung up on is I cant do
code:
if( Pangea.ContainsKey(_x) && Pangea[_x].ContainsKey(_z))
Because the [_x] entry must exist before I can check if _z exists, otherwise a runtime error gets thrown. This kind of thing comes up at other times too so I'd like to know a better way to format the if/elses without using break;/continue; or some variable that tells me if both things passed/failed


Is this true? I thought if the first statement was false then it didn't bother to check the second statement after a && because the whole thing is false if the first statement is false. I do this in javascript all the time to save time doing validation. Is this not true in other languages?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Physical posted:

The thing I am getting hung up on is I cant do
code:
if( Pangea.ContainsKey(_x) && Pangea[_x].ContainsKey(_z))
Because the [_x] entry must exist before I can check if _z exists, otherwise a runtime error gets thrown.
C#'s && and || won't evaluate the second expression if the first determines the truth of the whole expression (derive some truth tables to see when this is possible), so you can do that.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
The same is true of VB.NET if you use AndAlso/OrElse.

In scenarios where early-outs don't play in your favor, the general correct answer is "make a function or use a boolean variable."

Physical
Sep 26, 2007

by T. Finninho

Mustach posted:

C#'s && and || won't evaluate the second expression if the first determines the truth of the whole expression (derive some truth tables to see when this is possible), so you can do that.

Oh cool. Well how would I do it if c# wasn't so nice.

edit: Wait || would have to evaluate either wouldn't it since it returns true if either entry returns true?

Physical fucked around with this message at 23:59 on Sep 7, 2011

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Physical posted:

Oh cool. Well how would I do it if c# wasn't so nice.

Basically what you posted as "want to avoid."

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Physical posted:

edit: Wait || would have to evaluate either wouldn't it since it returns true if either entry returns true?
Things that cause subexpressions to early-out:
- && skips the second expression if the first is false
- || skips the second expression if the first is true
- ? : returns the second expression if the first is true and returns the third expression if the first is false, whichever of the second or third is not used is not evaluated

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Physical posted:

Oh cool. Well how would I do it if c# wasn't so nice.

edit: Wait || would have to evaluate either wouldn't it since it returns true if either entry returns true?

True if either entry returns true, but remember if the first is true, why even bother checking the second? It's a waste of resources.

Physical
Sep 26, 2007

by T. Finninho

poemdexter posted:

True if either entry returns true, but remember if the first is true, why even bother checking the second? It's a waste of resources.

Oh ya durp I was only thinking of falses.

poemdexter posted:

Basically what you posted as "want to avoid."
Really? Isn't there a slicker, more efficient way to do it that someone smarter than me came up with forever ago?

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Physical posted:

Oh ya durp I was only thinking of falses.

Really? Isn't there a slicker, more efficient way to do it that someone smarter than me came up with forever ago?

Yes, the statement you were hung up on. Are you looking for the magical 3rd option that isn't the efficient way or the nested if statement way? I'm sure someone can write a one line zinger that uses threads and flipping bits or something. :pwn:

Physical
Sep 26, 2007

by T. Finninho
I want them to both share the same else statement. Like if there is a failure it collapses to the same else (kind of like a switch statement without a "break;" for a couple of the cases in a consecutively.

I guess a "try/catch" would work since if there is a failure the same catch expression can be run on both.

edit:

poemdexter posted:

Yes, the statement you were hung up on.
I mean in the context of a language that doesn't support that like C++ or maybe AS3

Physical fucked around with this message at 00:34 on Sep 8, 2011

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Physical posted:

I want them to both share the same else statement. Like if there is a failure it collapses to the same else (kind of like a switch statement without a "break;" for a couple of the cases in a consecutively.

I guess a "try/catch" would work since if there is a failure the same catch expression can be run on both.

edit:

I mean in the context of a language that doesn't support that like C++ or maybe AS3

Bah, don't use try/catch like that. Really, the "hung up" code is the best since it fills your requirements of "on false of either, go to else". I'm interested to know if ANY language actually executes both statements in an && or || situation where the first statement is false or true respectively.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

poemdexter posted:

Bah, don't use try/catch like that. Really, the "hung up" code is the best since it fills your requirements of "on false of either, go to else". I'm interested to know if ANY language actually executes both statements in an && or || situation where the first statement is false or true respectively.
VB.NET does with the default constructs And, Or, and IIf.

New constructs AndAlso, OrElse, and parametrized If were added for early-outs.

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!
:confused:

You could set a boolean flag in each of the fail cases, I guess. (If we are looking for different ways to solve the same problem.) Then just check that boolean at the end of the function. I worked at a shop for a while that would not allow code out of their doors if a function had more than one return statement, and this was the solution I settled on. (FYI, that made some recursive functions way more verbose than they needed to be.)

Paniolo
Oct 9, 2007

Heads will roll.

Physical posted:

I mean in the context of a language that doesn't support that like C++ or maybe AS3

Uh, both of those languages use short-circuit evaluation for || and &&. You'd have to really go looking to find one that doesn't... maybe an old BASIC.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
Can anyone recommend any good books or articles on 2D physics? I'm working with that a little and have been hitting a couple weird bits that I'm not entirely sure how to handle.

e: Actually, I suppose I could just ask what I'm currently stuck on here. Basically, I've got it set up so each object has a Vector2 that represents its net velocity and, every update cycle, it moves based on that velocity. What's currently got me stumped is how to handle something like the following: Say I've got an object moving along x, with a current x value of 12.3. Its x velocity is 4.6, but there's only 2.4 units between it and an impeding object. How can I handle the object knowing how far to move save from testing every possible position until an appropriate one is found? For something this linear, I can receive an "okay" position from the colliding object based on its size, but when you start throwing in movement on y as well, that all goes out the window.

e2: Thinking about it, I guess I could use interval halving and that'd cut down on a lot of the tests, and make it easier to incorporate a threshold on precision. Still not crazy about it but it'd work.

Mr.Hotkeys fucked around with this message at 04:32 on Sep 8, 2011

Paniolo
Oct 9, 2007

Heads will roll.
Anyone know if it's possible to use a D3D11 compute shader with an append buffer to simulate the functionality of a geometry shader but with fewer restrictions?

In particular I'm wondering what the procedure would be for getting data in an append buffer to bind as a vertex buffer. Is that kind of reuse possible or would I need to create a new vertex buffer the same size as the append buffer and then copy the data over? (Preferably without needing to copy it to the CPU.)

It occurred to me tonight that the main issue with my geometry shader based marching cubes implementation - that it generated data structures which consumed huge amounts of memory due to limitations on the formats that GS can output - could be greatly improved by using a compute shader.

Facejar
Apr 28, 2008

Mr.Hotkeys posted:

Can anyone recommend any good books or articles on 2D physics? I'm working with that a little and have been hitting a couple weird bits that I'm not entirely sure how to handle.

Depending on the game, you might want to use a physics library. Box2D has been used in quite a few games. It can give you a dynamic response to any collision, so objects can bounce off each other, slide around, have gravity, etc. Alternatively, you can just create objects and use its collision detection, and handle moving the objects and their collision responses yourself.

If you want to implement it yourself, you'll need an algorithm for each pair of shapes you're looking to test. For example, if your moving objects are circles and your static environment is made out of edges, you could search for "moving circle against line segment".

The type of test that gives you an exact (besides floating-point inaccuracy) position for a collision is known as a swept test, or continuous collision detection.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
More questions about my favorite topic in this thread: component-based design. I now have entities and components and they're working together for the most part. I foresee some dependency problems though. I have one component that represents position and some other components are interested in position within the entity. I define the position first, so I get lucky here, and I also try to make sure any components relying on information from other ones will not fall apart if the information is not there yet. I wondered at a more general design level if there's something better I could be doing.

The one thought I had was each component would get a message when there were live. At that moment they then should be able to get all the information they needed. I can think of hypothetical situations with things like circular dependencies where this still might not work.

At this point I think it's not really worth the effort to worry about though. Where I think problems might show up is when I get entities loading from templates. There I don't think I can always guarantee a safe order anymore.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Rocko Bonaparte posted:

More questions about my favorite topic in this thread: component-based design. I now have entities and components and they're working together for the most part. I foresee some dependency problems though. I have one component that represents position and some other components are interested in position within the entity. I define the position first, so I get lucky here, and I also try to make sure any components relying on information from other ones will not fall apart if the information is not there yet. I wondered at a more general design level if there's something better I could be doing.

The one thought I had was each component would get a message when there were live. At that moment they then should be able to get all the information they needed. I can think of hypothetical situations with things like circular dependencies where this still might not work.

At this point I think it's not really worth the effort to worry about though. Where I think problems might show up is when I get entities loading from templates. There I don't think I can always guarantee a safe order anymore.

You can always force a certain order when loading from templates.

Also, most of the components that need to know about each other can be handled with the actions. So player.do("TakeDamage", 5) would do the TakeDamage Action which would go through and modify the player HP component as well as take into account if the entity has a shield or resistances or whatever other components. And all of that is just if this.getComponent("Shield") != null.

For other dependency issues, you could create managers like a Collision manager that would fire off the needed actions that modify velocity, acceleration, and HP for collided entities on impact. So instead of trying to fire off these yourself, you can have a manager have a method called checkCollision(entity a, entity b) and then handle all your dependency stuff inside so the components never need to worry about other components since that's the method's job to make sure they exist or handle cases where something might not exist.

Hughlander
May 11, 2005

Rocko Bonaparte posted:

More questions about my favorite topic in this thread: component-based design. I now have entities and components and they're working together for the most part. I foresee some dependency problems though. I have one component that represents position and some other components are interested in position within the entity. I define the position first, so I get lucky here, and I also try to make sure any components relying on information from other ones will not fall apart if the information is not there yet. I wondered at a more general design level if there's something better I could be doing.

The one thought I had was each component would get a message when there were live. At that moment they then should be able to get all the information they needed. I can think of hypothetical situations with things like circular dependencies where this still might not work.

At this point I think it's not really worth the effort to worry about though. Where I think problems might show up is when I get entities loading from templates. There I don't think I can always guarantee a safe order anymore.

One consideration for that specific issue though not the problem itself. Many proponents of an entity system place the position in the world in the game object, not in any of the components. I remember reading one paper where it was basically "Position, and list of components" was the entirety of the object.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Hughlander posted:

One consideration for that specific issue though not the problem itself. Many proponents of an entity system place the position in the world in the game object, not in any of the components. I remember reading one paper where it was basically "Position, and list of components" was the entirety of the object.

Interesting. But what about inventory items? Or NPC chat messages, or things that don't require a position?

Hughlander
May 11, 2005

poemdexter posted:

Interesting. But what about inventory items? Or NPC chat messages, or things that don't require a position?

I think his definition of a game object started with "Things that are in the scene graph." As such any object that's in the scene graph has a position. I'll dig up the paper I read it in, I read a bunch of them over the weekend so off hand can't remember which it was...

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Hughlander posted:

I think his definition of a game object started with "Things that are in the scene graph." As such any object that's in the scene graph has a position. I'll dig up the paper I read it in, I read a bunch of them over the weekend so off hand can't remember which it was...
Scene graphs are another cringe-worthy topic, but anywho:

It isn't a bad approach, and often you take it a step further and put additional information on the entity bucket. A name/ID usually makes sense, for instance.

If you get clever with your data store and virtualize it (hashmap, etc), you can also store ALL data on the entity, and position just happens to be one piece of data that a great many of your components expect to be there and that at least one of your components (physics usually) places there. In this approach, the entity becomes a list of components and a data bucket for medium-speed data storage/retrieval usable by all components. Components still maintain internal state in fast native variables, but use the hashmap for persistence and intra-entity communication.


EDIT: I realize it's totally tangential, but anyone else using Mercurial... man, they aren't kidding when they say "just use command line." Commit's syntax is a little squirrely, but for push/pull, it's waaaay nicer at command line than using that terrible "Synchronize" UI that TortoiseHg has.

Pity. TortoiseSVN was honestly pretty great. No idea why TortoiseHg sucks so bad.

Shalinor fucked around with this message at 01:10 on Sep 9, 2011

Your Computer
Oct 3, 2008




Grimey Drawer
Does anyone know how easy/feasible it is to go from libtcod to sprites? Same "system", just sprites instead of ASCII characters. I figured since I haven't actually played any roguelikes it'd be kinda silly for me to make one. I've always been tremendously fond of adventure games though, so I'm thinking of converting to one of those instead. So far I've got a messaging system with a textbox that scrolls and accepts ~*~colored text~*~, and I've also made a map-system that can load maps from text files.


Also got collision with terrain and cross-entity collision in which such things as writing to the screen is possible (as these two fellows do.)

The graphic part shouldn't be too hard to rewrite if I absolutely have to, but I'd hate to rewrite the messagebox-code since it relies on console-behaviour.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

Facejar posted:

Depending on the game, you might want to use a physics library. Box2D has been used in quite a few games. It can give you a dynamic response to any collision, so objects can bounce off each other, slide around, have gravity, etc. Alternatively, you can just create objects and use its collision detection, and handle moving the objects and their collision responses yourself.

If you want to implement it yourself, you'll need an algorithm for each pair of shapes you're looking to test. For example, if your moving objects are circles and your static environment is made out of edges, you could search for "moving circle against line segment".

The type of test that gives you an exact (besides floating-point inaccuracy) position for a collision is known as a swept test, or continuous collision detection.

Yeah I've got the collision detection part down, it's just stuff like what I posted up there and then other general topics pertaining to implementing physics that have got me stumped. Stuff that isn't necessarily unique to physics but that can be easily applied in the field.

The problem I'm having, and maybe it's just how I've got it set up, but objects don't move in small enough bits where there'd be one point of collision. There will be, in most cases, a big overlap and I don't know how to set it up in a way that works better.

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!

Mr.Hotkeys posted:

Yeah I've got the collision detection part down, it's just stuff like what I posted up there and then other general topics pertaining to implementing physics that have got me stumped. Stuff that isn't necessarily unique to physics but that can be easily applied in the field.
That's why he was telling you about swept collision detection. "Swept" means essentially that you don't just check the new object positions for collision, you check the area they moved through (like they 'swept' a trail). A good swept collision detection algorithm will give you the point of impact and the time of impact, so you can recalculate the 'remainder' of the frame for them after the collision is resolved. (Though sometimes you might not want to play out the remainder because it can look a bit weird if you have things bounce off each other and no frame in which they're touching.)

Edit: plus, playing it out can make for horrible situations where you're resolving a few collisions back and forth, not that that isn't a problem with every solution, but it's more of a problem if you try to just play out the last part of a frame for a couple of objects when everything else is already resolved.

roomforthetuna fucked around with this message at 02:25 on Sep 9, 2011

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
Oh, duh. Totally didn't get that. I'll look into it, thanks guys.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
Kind of a general design question.

In a fighting-game style melee system, wherein you have moves that move the attacker as well as the attackee, is it better to go with purely physical impulses, or take direct control of velocity and do things more specifically?

Normally, I'm a fan of pure physicality, but I worry it'll introduce timing problems into the game. Simple stuff like a "pop" move that you want to follow up with an air attack will potentially get odd if everything, including yourself, is pure ballistic. But, it will also be way cooler, and allow for more emergent gameplay (you pop someone into a breakable wall and - it just breaks, naturally, due to a force being applied).

The other weirdness is that all acceleration is front-loaded when you're using impulses. You don't smoothly accelerate, you launch, that's it.

'ST
Jul 24, 2003

"The world has nothing to fear from military ambition in our Government."

Your Computer posted:

Does anyone know how easy/feasible it is to go from libtcod to sprites? Same "system", just sprites instead of ASCII characters.
Check out the forums for http://www.goblincamp.com/ specifically the attempts at tile implementation.

Here is my basic recollection of the major issues involved. One option is to make the interface and the scene in your new sprite-based system, but you have to re-implement the functionality for convenience things like libtcod's interfaces and windowing. Another option is to replace only the scene with sprites but keep libtcod for interface rendering. If you do this, you need to get an additional handle on SDL for sprite rendering while libtcod keeps its own. You'll have to figure out when and what to draw, and what state the buffer is in, etc. Some of the details are in the Goblin Camp forum, I'm pretty sure.

I assume you've used a search engine already. I do recall seeing a few discussions of how to do it in the past. It's also possible that there's a recent effort at a fork/mod of libtcod that has sprite support.

Physical
Sep 26, 2007

by T. Finninho
I am trying to track down a link to a semesters worth of free programming vidoes from like Stanford or MIT? Was it posted in this thread? I think it was about AI or something cool.

eidt: found it! Just signed up so I don't forget.


This Post Sucks posted:

Cool, good to know.

I've got a copy of Flash Builder 4.5 (what Flex Builder is called now), so I've got a nice IDE to work in.

Working through some docs and examples now!

Edit: Oh, hey, I guess this would be as good as place as any to post this, and it may be helpful to some folks in here.

Stanford University is offering a free Artificial Intelligence class online. You can sign up here: http://www.ai-class.com/

It's actually what got me to start thinking about game development again.

Physical fucked around with this message at 06:07 on Sep 9, 2011

Relaxodon
Oct 2, 2010
Hey guys,

I am thinking about starting a general game engine, not for something specific but to learn about all the different components that go into it. (learn best practices etc.)

I want to try and be as platform independent as possible. As Graphics API this already narrows me down to OpenGL, which is fine as i have used it before. Since i want to play around with Tessellation and GPU computation i am gonna go for 4.1.

Now the language to program in isn't just as easy. C# is out. Actually all of .Net is out as Microsoft only does it for windows.

C++ seams a good choice, but i find the language to be a bit of a hassle compared to the likes of Java, which would be my second contender. I don't know much about python, how well supported is it on different platforms? Is it suitable for such lower level stuff?

What would you more experienced guys advice me?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Yes, you should at least have a game in mind or you'll end up with a bunch of useless abstract stuff. You'll also probably burn out because for most people the part that keeps it fun and keeps you going is the actual *game*.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Regarding component-based design, position would be part of an object's physical simulation component and/or the rendering component. Both can exist without the other! Held weapons are normally not physically simulated, but are rendered. Invisible blockers, triggers, and occasionally weather manipulators are not rendered, but are physically simulated.

The design I've found I like most tends to be having a "brain" or "controller" component that acts as the interaction processor and destroys the other components if it dies. If you were to make a vehicle, for example, you could break it up as:

- Several renderable model components
- A physical simulation component
- A rigging component that keeps the renderable and physical simulations in sync
- A controller component that decides how various vehicular controls should affect the physical simulation and how impacts with things should affect the vehicle
- A network replication component that determines how information about the vehicle should be sent and parsed in a multiplayer match
etc.

An important thing with these components is that they're distinct and tend to avoid 1:1 relations to things. Like if you're running a dedicated server, the renderable and rigging components can be ignored. If you want the vehicle to transform into Megatron, you can disable the rig and physical simulation. If you don't want to network it, you can ignore the network replicator.

The lack of 1:1 relations is important because if you have a game that assumes, for example, that all objects are free-floating and have a distinct position and single collision hull, then you wind up not having an answer for what to do about wheels that bounce with the suspension, or objects that are distinct but attached to each other, and so on.

Shalinor posted:

In a fighting-game style melee system, wherein you have moves that move the attacker as well as the attackee, is it better to go with purely physical impulses, or take direct control of velocity and do things more specifically?
There are pretty much three ways you can do it:
- All impulses reset the character velocity to zero before being applied.
- The first impulse that causes a character to lose control resets their velocity to zero.
- All animation/movement momentum is preserved through control loss.

Nearly all fighting games do the first for the sake of predictability. There isn't any "best" way to do it, it's purely a design choice. Mass Effect 2 for example is very unpredictable in how biotic skills will work because they're based on throwing ragdolls around map geometry, whether that's better than just lifting them straight up or throwing them straight back or something is purely subjective.

Orzo posted:

Yes, you should at least have a game in mind or you'll end up with a bunch of useless abstract stuff. You'll also probably burn out because for most people the part that keeps it fun and keeps you going is the actual *game*.
It's fine to make a game engine if that's what you intend on making. Irrlicht and Ogre have their place in the world. You do need to pick your focus though: Completing a game heavily favors treating the engine as disposable by committing to a feature freeze and making design decisions that will speed up completion at the expense of being fairly reliant on the frozen feature set. This is exactly the opposite of what you want to do if you're making an engine.

Mike1o1
Sep 5, 2004
Tiluvas
I'm working on C# and XNA 4.0, but in general, what is the best approach to take when designing different visible armor pieces, from both a content creation and programming perspective? I'm having a little bit of trouble understanding the concepts behind it.

Some armor pieces such as a helmet or shield hasn't been too difficult, as I am displaying those in relation to certain bones of the player model. I'm running into issues when displaying items that are more impacted by player animation such as boots or chest pieces. I'm not sure what to do when I want more visible change than just changing the texture for that portion of the mesh.

My first idea was to use a custom PlayerModel class which would then have a Model head, Model torso, etc. I would then draw each portion of the model, so this would allow me to easily do things like head = helmetArmor01, torso = chestPlate01 and so on. Though now I'm not so sure how doing any type of skinned animation would work?

From a content creation perspective, I would want to have a single skeleton with multiple bones, and then those bones have different vertex weights attached to it. When I modify the underlying chest armor, for example, doesn't that completely mess up my vertex weights of the underlying animation? This is the part that has me confused and unclear.

The skinned animation is the part that is throwing me off the most, as I'm using the built in SkinnedEffect and I'm a bit unclear on how the vertex weights work.

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
You should be able to swap out the vertex weights the same time you swap out the model. I haven't gotten to that point yet, but it should work in theory. Whether or not the joints between models will look nice or not is another question that I don't have an answer for, though.

Shameproof
Mar 23, 2011

So I'm beginning work on a Voxel-based game*, and am attempting to up the amount of voxels that can be simulated/drawn. So far my ideas are:

1) Rather than have a continuous streaming world, divide it into square-kilometer cells, with loading screens in between. This has some other benefits to it, so I'm adamant about keeping this idea.

2) Generate the whole cell upon loading and place the voxels into an octree (since i know how many of them there are this should be less expensive than it would be for an infinite world).

3) Use nearest-neighbor interpolation to render distant terrain at lower detail. For example, if I have four red blocks and four green blocks in an octree, then when you are 128m away from that octree it will show up as a yellow block.

So here's my first question: will any of these NOT work and just waste my time?

My second question is: apparently you can render voxels in way more efficient ways than just converting them to geometry? Would it be possible to perform ray-tracing in a minecraft knockoff?



*under the belief that history will remember Minecraft as not just a good game but as genre-starter like Doom and GTA.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Shameproof posted:

So I'm beginning work on a Voxel-based game*, and am attempting to up the amount of voxels that can be simulated/drawn. So far my ideas are:

1) Rather than have a continuous streaming world, divide it into square-kilometer cells, with loading screens in between. This has some other benefits to it, so I'm adamant about keeping this idea.

2) Generate the whole cell upon loading and place the voxels into an octree (since i know how many of them there are this should be less expensive than it would be for an infinite world).

3) Use nearest-neighbor interpolation to render distant terrain at lower detail. For example, if I have four red blocks and four green blocks in an octree, then when you are 128m away from that octree it will show up as a yellow block.

So here's my first question: will any of these NOT work and just waste my time?

My second question is: apparently you can render voxels in way more efficient ways than just converting them to geometry? Would it be possible to perform ray-tracing in a minecraft knockoff?



*under the belief that history will remember Minecraft as not just a good game but as genre-starter like Doom and GTA.

You should look at Sparse Voxel Octrees

The idea is basically

1) Generate your voxels at some minimum resolution. *

2) Group voxels into an octree (although really, this is un-necessary since the tree is regular, so the octree can just be implicit)

3) Starting with the smallest nodes, if all the children of the node are of the same time (or empty), delete the children (compressing your data by 8x). Continue until there are no more nodes you can collapse.

4) When rendering or intersecting, you can now use the octree directly, treating each node as a giant cube of appropriate scale.

*: Actually, one of the nice things about SVO is that there doesn't need to be a minimum resolution. You can zoom in and subdivide as deep as you want wherever you want more detail, and just divide up the node that contains that point accordingly. However, for a minecraft-like, you'll probably want to start with a fixed grid. You can still use the subdivide trick later for splitting higher level blocks.

Shameproof
Mar 23, 2011

Hubis posted:

You should look at Sparse Voxel Octrees
That's the technique I was thinking of using. And yeah, I'd like to keep the minimum resolution to 1m... I think that's a "sweet spot" which makes Minecraft's gameplay feel fluid and natural, as compared to say, Ace of Spades. I'm not trying to make good-looking terrain, I'm trying to make terrain that won't have to be hidden behind thick fog (though lighting is a priority).

Adbot
ADBOT LOVES YOU

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Shameproof posted:

That's the technique I was thinking of using. And yeah, I'd like to keep the minimum resolution to 1m... I think that's a "sweet spot" which makes Minecraft's gameplay feel fluid and natural, as compared to say, Ace of Spades. I'm not trying to make good-looking terrain, I'm trying to make terrain that won't have to be hidden behind thick fog (though lighting is a priority).

It's really not that hard to render a pretty huge cube-world in pre-generated vertex buffers. The real trick, I found, is re-calculating them in real time without hitching when cubes are created and destroyed.

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