Thursday, April 30, 2015

How do I efficiently sort objects by draw order when rendering a 2D game?


I need to render a "tile" game with objects that overlap, because they are taller than the tile they stand on, like the games in these screenshots:


enter image description here


enter image description here



enter image description here


I don't know how to render them in the correct order. I intend to perform a sorting operation before every rendering, depending on the object's Y position. However, I'm worried it'll be too expensive, especially since very few objects change their Y positions.


Is sorting the most performant way? Is there any other way? What algorithm or data structure should I use?



Answer



When you have mobile objects and you want to get their draw order, there are two possible approaches how you can preprocess them before drawing:




  1. Add a list of objects to each map tile. Iterate all objects and add them to the object list of the tile they are on. When you draw each tile, you first draw the tile itself, then sort its object list, then draw the objects, then delete the object list.





  2. sort all objects by draw order. Then draw them all after drawing the map. Map tiles which obscure objects behind them need to be treated like objects in this case.




Option 1 is best when the objects move so quickly so they are in a different order every frame or when you have a lot of immobile objects, because you can then treat them like tiles.


Option 2 seems slow at first, but in most games you can make it a lot faster by using the right sorting algorithm.


In the majority of games, most of the time the object order will be the same or almost the same between two frames. In that case I would recommend you to use Insertion Sort. Usually it is considered a sub-par algorithm, but in the special case of data which is already nearly sorted it greatly outperforms all general-purpose sorting algorithms like quick-sort or merge-sort. I am using this method in the game I am currently developing. By replacing the standard Javascript sort with an own insertion-sort implementation I was able to reduce the execution time spent on object sorting from 3% to 0.2%, even though the default sort has the advantage of being implemented natively (measured in Firefox using the profiler of the Firebug extension).


2d - What's the most efficient way to find the intersection point of a missile and a bitmap terrain?


Following up on my earlier question about finding the slope of a 2D bitmap terrain I now need to know the best way of finding the point on the 2D terrain that the missile hit. Obviously, I can see if any pixels under the missile intersect terrain, but say it has moved quite deep into the terrain.



What is the best way to step back to find where it initially collided? I could move back X pixels at a time towards the missile's previous position, but what would be a good value of X? And is there a smarter way? Maybe moving half the distance, then a quarter etc?




grammar - What tense should I use to describe something in the past but probably is still true?


The title may be a bit confusing. See the below example:




The movie (was/is) so good.



The simplest guideline on deciding which tense to use, past tense or present tense, to describe an object comes down to whether the description was only true that that time or is true even to the present point of time.


But now we talking about literary work(movies,books,etc) of which quality tend to stay the same over time, which tense should we use?



Answer



As far as I know, both (was/is) are possible.


If you say "the movie was good," it would mean that you pictured yourself watching the movie, and at that time you thought it was good. However, whether you are still thinking it is good is unclear, and many might interpret it as: you don't think it is good anymore.


On the other hand, if you say "the movie is good," it is clear that you currently think it is good. However, it is unclear whether you think that way from the start or not. (It's possible that you might hate it at first, and then developed your favor toward it later.)


Disclaimer: I'm a non-native speaker, so you might need second opinions from others.


singular vs plural - A problem with "news"


I know news doesn't have a plural, but what is correct in the following example:


We must recognize real news from fake one.


or


We must recognize real news from fake ones.


Thank you in advance




Wednesday, April 29, 2015

libgdx - Why is my sprite displayed offset from its Box2D body?



I found out about this using a debug renderer. When the game starts, everything is in order. But when a collision happens, the sprite's rotation is way larger than its body. The sprite and body match when the body is completely horizontal.


sprites with Box2D body outlines as overlay


The sprite's rotation origin seems far distant from where it should be. Here's my code:


Sprite sprite = data.sprite;
position = body.getPosition();
sprite.setPosition(
position.x - sprite.getWidth() / 2,
position.y - sprite.getHeight() / 2
);
sprite.setOrigin(position.x, position.y);

sprite.setRotation(MathUtils.radiansToDegrees * body.getAngle());

As you can see, I am even trying to set center of its rotation with setOrigin without success. How can I fix this?



Answer



Most APIs represent the Sprite's origin in local space, not in world space. This is supported by libgdx's documentation which states:



A Sprite also has an origin around which rotations and scaling are performed (that is, the origin is not modified by rotation and scaling). The origin is given relative to the bottom left corner of the Sprite, its position.



So I think that if you want rotations to happen around the center of the sprite, you should be using the following origin instead:


sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);

grammaticality - Necessity of using "had had" when a single "had" could have sufficed?



If Sir John had had the slightest idea what was going to be the devastating effect of his son's handsome looks upon a certain beautiful courtesan and the tragedy which would ensue, he might have had second thought about continuing his journey without him. (Source: Vengeful Ghosts by Vida Derry)



I am having problem with this use of "had" (BOLD). How I understand using had is that it is used if some action (action 1) precedes another action (action 2) and "had" accompanies the first action (A perfect Past Perfect scenario). For example:




I had done it, before you did that.



Now in the highlighted text, Sir John did not have the slightest idea, he did not take his son with him and the devastating effects of his son's looks did happen. So how can "had" here be used when the action i.e. having a slightest idea has never happened to Sir John?


In my opinion, a single "had" (simple past) would have sufficed.



Answer



You are confused here by the fact that a past form may be used in two ways: as a marker of past tense and as a marker of counterfactuality. In this case, it must serve both uses, and it is that which requires the past perfect form.


Let's consider this in the present tense, and then 'backshift' it to the past. There are two constructions:






  1. Sir John is a judicious man. If he has the slightest idea of the result he may have second thoughts.



    This employs the simple present of HAVE and MAY to express a condition regarded as possible or plausible. Backshift that into the past—as reported speech, for instance—and you get this:



    Lord West told me that Sir John was a judicious man and if he had the slightest idea of the result he might have second thoughts.





  2. Note, however, that exactly the same constructions are used to express a present counterfactual:




    Sir John is an idiot. If he had the slightest idea of the result he might have second thoughts. But he has no such idea.



    The second sentence there has already used up all its available past forms to mark counterfactuality. To backshift it into the past you must add some sort of past marker. By convention, those markers are supplied by converting the past forms into past perfects:



    Lord West told me that Sir John was an idiot; if he had had the slightest idea of the result he might have had second thoughts. But he had no such idea.





c++ - RTS Engine or DotA-like game



Is there any good documented and simple Game engine for RTS games, especially for building DotA-like game?


I know I can use Crystal Space, Irrlicht or another Game Engine. But I need most similar game or engine to DotA gameplay.




unity - Throwing a grabbed object


I'm trying to throw the carried object in the direction of the first person controller, but unable to make it. I could make the carried object drop, but the same time i need to instantiate velocity to the carried object, so that i could forward. I'm building up a bowling game and trying to make the ball behave like the same when the player throws the ball. It should hit the alley and move forward to hit the pins. Below is what so far I've tried.


using System;
using System.Collections;
using System.Collections.Generic;

using UnityEngine;

public class pickupobject : MonoBehaviour {
GameObject mainCamera;
//public GameObject empty;
bool carrying;
public GameObject carriedObject;
// Camera cam;
public float distances;
public float smooth;

float speed = 1000f;

// Use this for initialization
void Start()
{
//cam = GameObject.Find("MainCamera").GetComponent();
mainCamera = GameObject.FindWithTag("MainCamera");
}

// Update is called once per frame

void Update () {
if (carrying)
{
carry(carriedObject);
CheckDrop();
}
else
{
pickup();
}



}

private void pickup()
{
if(Input.GetKeyDown(KeyCode.E))
{
int x = Screen.width / 2;
int y = Screen.height / 2;

Ray ray = mainCamera.GetComponent().ScreenPointToRay(new Vector3(x, y));
RaycastHit hit;
if(Physics.Raycast(ray, out hit))
{
pickupable p = hit.collider.GetComponent();
if(p!=null)
{
carrying = true;
carriedObject = p.gameObject;
}

}
}
}

void carry(GameObject o)
{
o.GetComponent().isKinematic = true;
o.transform.position = mainCamera.transform.position + mainCamera.transform.forward * distances;

}


//void ThrowBall()
//{
// GameObject go = (GameObject)Instantiate(carriedObject,transform.forward, Quaternion.identity);
// pickupable to = go.GetComponent();
// to.Throw(carriedObject.transform.forward * speed);
//}

void CheckDrop()
{

if(Input.GetKeyDown(KeyCode.U))
{
Drop();
}
}

void Drop()
{
carrying = false;
// carriedObject = Instantiate(carriedObject, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation);

carriedObject.GetComponent().isKinematic = false;
gameObject.GetComponent().AddForce(carriedObject.transform.forward * 100);
// carriedObject.GetComponent().AddForce(0,0,1f);
//carriedObject.gameObject.GetComponent().isKinematic = false;
carriedObject = null;

}
}

Thanks in advance!




Answer



Continuing my comment: you need some changes in your code to check when to throw the object.


I've updated the code to account for those changes, it should work as expected now.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pickupable : MonoBehaviour
{
//GameObject mainCamera;

bool carrying;
GameObject carriedObject;
Camera cam;
public float distances;
public float smooth;

// Use this for initialization
void Start()
{
cam = GameObject.Find("MainCamera").GetComponent();

}

// Update is called once per frame
void Update()
{
//Check for user input ('T' key here) and make sure the object is being carried
if(Input.GetKeyDown(KeyCode.T) && carrying)
{
carrying = !carrying;
ThrowBall();

}
if (carrying)
{
carry(carriedObject);
}
else
{
pickup();
}


}

private void pickup()
{
if (Input.GetKeyDown(KeyCode.E))
{
int x = Screen.width / 2;
int y = Screen.height / 2;
Ray ray = cam.ScreenPointToRay(new Vector3(x, y));
RaycastHit hit;

if (Physics.Raycast(ray, out hit))
{
Pickupable p = hit.collider.GetComponent();
if (p != null)
{
carrying = true;
carriedObject = p.gameObject;
}
}
}

}

void carry(GameObject o)
{
o.GetComponent().isKinematic = true;
o.transform.position = cam.transform.position + new Vector3(0f,0f, 10f);
}

void ThrowBall()
{

carriedObject.GetComponent().isKinematic = false;
carriedObject.GetComponent().AddForce(0f, 0f, 100f);
}
}

mathematics - How do I sort isometric sprites into the correct order?


In a normal top-down 2D game one could use the screen y axis to sort the images. In this example the trees are properly sorted but the isometric walls are not:


Example image: sorted by screen y


Wall 2 is one pixel below wall 1 therefore it is drawn after wall 1, and ends up on top.


If I sort by the isometric y axis the walls appear in the correct order but the trees do not:


Example image: sorted by isometric y


How do I do this correctly?




c# - Unable to use Maya animation with scripts when imported to Unity


I am testing to import Maya animation over to Unity. I set up a simple cylinder with 2 bones and an IK handle. Made a simple animation where the cylinder bends and goes back to straight position over 24 frames.


Following that, I selected everything and baked, all bones,ik,(animation by selecting all at the graph editor) and even the cylinder. I saved the scene and then select all and export as FBX with animation and bake checked.



In unity imported it and at the preview able to see the animation. When I load the model into scene and play (after assigning the controller), able to see animation too.


But now when I try to script it and control the animation, nothing happens. Even to test, I tried the following under the Update method.


if(animation.isPlaying)
Debug.Log("Animation Works");
else
Debug.Log("Animation not working");

The bool doesn't even return true nor false. My animation is called "bend", thus just for try I did the following and nothing happens.


animation.Play("bend");


Can please advice based on my steps, am I missing something. Do I need to add the controller or is that an unnecessary step? Did I screw up on the Maya part or the Unity part. Thanks for help.



Answer



Ok your first problem is that the code there is for Legacy animation, and you probably imported as the default which is Mecanim (actually, in comments we already determined that; just leaving this note here for future visitors). Unity has an older animation system that is still around for legacy reasons, but you shouldn't use that for future projects. However for reference you can switch between animation systems in the Rig tab of the model; there is a drop-down to switch between Humanoid and Generic rigs (both of which fall under the umbrella of Mecanim), or you can set to Legacy.




Anyway, at a high-level the way you use the new animation system is by setting up a bunch of animation states in an Animator controller, assign parameters to transition between those animation states, and then when your code passes values to the animator it will transition between animations. Whereas in Legacy the animations are attached to the model directly and your code plays animations by name, in Mecanim the animations are used in an Animator and the Animator is attached to the model. This indirection is the first thing to understand; it can seem a bit odd since the animation clips can be part of the model (ie. part of the fbx file that was imported) but this indirection also allows you to share animations from other models.


refer to http://docs.unity3d.com/Manual/AnimationParameters.html


Create a new Animator controller, and then open the Animator window to edit it. First click the + button in the lower-left to setup parameters you'll use (eg. a float called Speed). You can drag animation clips into the Animator (click the right arrow on a model asset to see the animation clips) and then right-click the animations to set transitions between them (eg. from Idle animation to Run animation when Speed is greater than 1). Finally select the model in the sene and drag the Animator asset to the animator slot in the Inspector.


At this point the code to trigger animations is pretty simple; Mecanim is designed to handle for you all the complex work of deciding which animation to play and transitioning between them. In your code you need a reference to the Animator component; there are a variety of ways to do that, one of the simplest being GetComponent (this is C# code):


private Animator _animator;


...

void Start() {
_animator = GetComponent();
}

Now passing values to the animator is simply done with commands like:


_animator.SetFloat("Speed", 1.5f);

or



_animator.SetBool("Jumping", true);

This might seem like a lot of rigamarole for just testing an arm bending, and well it is a lot for just that. However Mecanim was designed for the complex animations that happens in games, where you want a character to fluidly transition between a bunch of aniamtions. With animation clips set in the imported model, and animation states set in the Animator controller, there's very little your code needs to do to run the animations.


Why do GPUs require game specific drivers?


PC GPU driver updates often cite improvements made to performance of specific, recently released games. Why is this game-specific updating needed? How do the game-specific changes interact with the game code?



Answer



As someone with a few years of driver development, I see this as two separate issues.



A graphics driver is a very complicated beast. To implement everything in a optimal way would be a simply impossible task; it's a big enough hurdle just to make a driver that actually follows the specs - and the specs keep getting increasingly more complex. So, you develop your driver based on the spec, and a handful of test applications (as, in many cases, there's no real software yet).


Along comes a real game (or benchmark, or some other use case for the driver, like video decoding) that exposes a bottleneck in the driver. In you go, figuring out how to smooth things out and make that use case faster. You can easily report that game XYZ is 27.3% faster, but in reality every application that has said use case (say, dynamic texture update) gets faster.


Then there's the ugly side, real per-application optimizations, wherein the driver detects what application is being run (or which shader is being compiled) and does something non-generic. There's been plenty of publicized cases of this, where, for example, renaming 3dmark executable suddenly changes the results.


I feel these kinds of optimizations are a waste of everybody's time - you lie to your customers in the case of benchmarks, and you may change the way a shader behaves from what the developer actually wants. I recall a case where a shader was changed from a texture lookup to a in-shader calculation (which only worked for said manufacturer's hardware) which was close, but not exactly the same result, and the developer balked that this wasn't a legal optimization.


Tuesday, April 28, 2015

rpg - Will the inclusion of LGBT characters in my game detract from possible sales?



As we all know, the inclusion of LGBT characters has been a mighty controversial topic in recent film and literature (Beauty and the Beast probably being the premier example). Some love it with every fiber of their being, while others absolutely detest the very thought of it. Now, keep in mind that I am not here to start a political firestorm nor am I here to preach my own personal beliefs regarding this, I'm simply asking the question: will the inclusion of LGBT characters decrease potential sales?


In our game, a pseudo-'90s JRPG, one of our main story writers added two consuls (of a civilization with heavy Roman influence, but with different laws), both female, married. Originally hailing from an area in which LGBT relationships are looked down upon, I was quick to note that it may be too much controversy, but it truly depends on where you live—for him it was almost completely normal.


As I see it, we have three choices.




  • We can keep the characters just as they are.

  • We can keep the characters, but only imply their relationship.

  • We can alter the relationship entirely, changing one to a male.


Right now, our main goal is to satisfy the general public while still strongly appealing to those who actually played JRPG's such as Dragon Quest or Final Fantasy back in the day. Which of these three options should we choose to best enhance our sales, or, if it's not up there, what is the wisest way to go about doing this? I am looking for facts and data if possible and/or applicable.


EDIT: Our target audience is Everyone! Like we said, we’re aiming to satisfy the general public while still appealing to those who played JRPG’s back in the ‘90s.


EDIT II: Wow. Every almost answer here contained a wealth of information, and I'd like to formally thank all that contributed. I will be using the information from just about all of these answers, and I'm sure may others facing this issue may as well.


EDIT III: If you have comments that aren’t answers or you’d like to further discuss this, please refer to the official chat room as opposed to commenting. Thanks!



Answer



I come from a place in the Internet most people deem to be horrible in every single way. While I generally don't agree with most of the stuff said in that website, I can provide some insight on what happens around there when a pro-LGBT game is released.




  • A small but very vocal group of (probable) trolls will complain about it, no matter the way they are depicted, under the argument that it's "degenerate", "pozzed" and a thousand other descriptors usually containing the word "cuck" in them. They swear they won't ever buy the game because of these small details, and will generally attempt to derail any serious discussion about the game, but they are a really tiny percentage of the population that just happens to invade any threads made about games like these.

  • Some users, the less sarcastical version of the above, will automatically qualify whether it's cute or "degenerate" exclusively depending on whether the game was made in Japan or not. It's as dumb as arbitrary, but they are somewhat grounded in reality considering the vast majority of Japanese depictions of LGBT people is very different from the vast majority of their western counterparts.

  • Some users will only care about whether the girls and the relationship are cute and whether it comes of as preachy or not.

  • Some users will only care about whether the game presents this plot point as preachy or very "in your face". Probably the biggest demographic around these places.


Some research on Gamergate and its slow declive into the alt-right should give some light on the above positions, but the general idea is, they are tired of games being marketed on their "progressiveness", which usually tends to overinflate their scores in game journalism sites even though the games are not that good (in the case of Gone Home, some people don't even consider it a game, yet it managed to score a 10/10 in many reviews, which didn't sit well with many gamers). This resulted in an influx of games with progressive values being thrown in your face in the most preachy and obnoxious way possible just to achieve "brownie points" in attempts to replicate the success of previous games who did this, something they didn't like because it went against their beliefs and political stances. This may seem inmature, but nobody likes to feel like the games they are playing are going directly against them, so it is kind of logical to expect such an outcome.


Thing is, these gamers are very wary of these topics because they feel "stiff" and "fake", as in, so shoehorned it becomes obvious the devs are trying to virtue signal in hopes their game gets noticed by the games journalism crowd. Most of the LGBT character depictions shown on many recent games seem to default to the "accepted" representations of their gender or sexuality (how many characters would describe "strong independent lesbian woman who needs no man, is snarky towards everyone, always looks angry and has short hair", despite that description being very specific?), so many of these characters end up having the same personalities, same background and sometimes even same questlines, which to these people smells like mass produced token LGBT. The queer characters are often presented as borderline Mary Sue saints who could do no wrong, but are always wronged by (most of the time, and I think this is your game's case as well) white cishet males just because they are hateful mysoginistic beings or something like that, even when they are not. Queer people are still people after all, so they should probably have as many flaws as the non-queer people, and you should contemplate that into writing them as actual characters and not "that lesbian couple" in that game.


But people will always find a way to complain. This is a "damned if you do, damned if you don't" situation in which incorporating LGBT characters or not, making them flawed or not, making it an extremely secondary trait or their whole personality, making them evil or good, making them stereotypical or not, will result in outrage from certain demographics. My advice is, just do whatever you think will be best for your game without thinking of sales, reviews or prohibitions, because there are not enough cotton gloves in the world to tackle these topics without offending anyone.


If all you want to know is whether this will boost sales or not, it all depends on your target. As people mentioned before, do you want this game not o be 18 or not? Do you plan on translating it to Russian and selling it there? Do you want to target hardcore gamers who most often than not despise preachy politics in their games? If the answer to any of these is "yes", you may want to just leave it as heavily implied at best. Do you want to target fans of JRPG, who are very likely to like Japanese media in general? As stupid as it seems, your best bet is sexualizing them (people will get mad about this, but if they are outside of your target demographic, it doesn't really matter). Otherwise, if you want to target a more casual (not in a bad sense, not even as in people who only play Candy Crush on their phones - still "core" gamers, just not as fixated on videogames that take a lot of effort to play) or modern demographic, such as the people who played and liked Life is Strange, Gone Home, or Dragon Age: Inquisition, making them blatantly gay could even boost your sales.



EDIT: I remember Dofus had two NPC, a major and her secretary, named Mayor Cantille and Lou Bricante (yes, that's probably a sexual pun; game is full of them), who were very explicitly implicitly closet lesbians for each other. People talked a bit about this, but nobody seemed to care because it was cute and both girls were cute. Villagers would often gossip about it for comedic purposes. It wasn't given much relevance, and it was always treated in a very lighthearted tone -like the rest of the game-, so it simply happened to be a very secondary side story that was consistent with the setting, so I guess people simply accepted it; which brings me to the point that, if it is not a relevant plot point, just mention it in passing just like you would comment on any plot point of little relevancy.


I guess your case with the consul could be similar, but keep in mind that, depending on how directly based on Roman society the society in your game is, some people could complain about lack of realism (yeah, even if otherwise your game contains dragons and magic crystals). While ancient Rome didn't really treat homosexual relationships much differently to heterosexual relationships, they did treat women, and whoever they deemed to fulfill the role of the woman in a relationship, as inferior. I am unsure how would have ancient Rome reacted to a masculine lesbian consul, considering information on lesbians in ancient Rome is scarce, but chances are she would have stood no chance against other male politicians.


To avoid these complaints, either try to show (don't just tell!) in which ways this society distanced itself from our ancient Rome, and try to justify how could this happen, and of course, what could the possible reactions to this be, or just treat it in a consistent manner (if it isn't something people usually accept, why would they be telling anyone but people they utterly trust?).


Part of why people disliked the transsexual character in Baldur's Gate: Siege of Dragonspear is because they were out of place. It's already weird enough to bump into a stranger and casually start talking about stuff, so don't make it any weirder by talking about personal stuff most people have no bussiness knowing. This, combined by the fact that it just comes out of the blue (shoehorning), that the universe has genderbending magic that's apparently not in play here (inconsistency), that the topic isn't relevant at all to the plot or worldbuilding at al (virtue signaling at its finest), and that it's one of the only dialogues that doesn't let you any agency at all on how to react to this (which comes out as inconsistent, preachy and gives the impression Mizhena is above other characters just because she is trans) made several people, including trans people themselves, angry about the inclusion of just a token LGBT character for the sake of having a token LGBT character, above the normal rules of the world and dialog mechanics.


grammar - Where should I use “that is”, “it is” and “to be”?


I just asked about the use of "to be", I think it is more clear to me, but I still have doubts. For instance I just saw a movie when someone said


"I want a room that is clean"


but sometimes the use "it is" instead of "that is" and sometimes they use "to be"


in spanish all that options means the same


Where should I use each?




free relative clauses - "How it works?" vs. "How does it work?"


What is the difference between:




  1. "How it works?"




and




  1. "How does it work?"




Answer



SHORT ANSWER:
Your first example, how it works, is a free relative clause which cannot be used as a question. Your second, How does it work?, is an ordinary question.



LONGER ANSWER:
What I’m going to call an “interrogative phrase” (IP) is a sort of ‘variable’ which stands for an unknown ‘value’. The IP is headed by a word which defines the ‘type’ of value for which it stands: who, what, which define the type as nominal, how, where, why define the type as adverbial, and the construction what ... do defines the type as a verbal. The IP may also be followed by additional terms which further restrict the type—how many or what sort of machine.


Two sorts of clause employ IPs: questions and free relative clauses. In both sorts of clause the IP represents a constituent of an ordinary declarative clause, ‘moved’ to the beginning of the clause from the place where the constituent would normally stand:
IP Movement


But the two sorts of clause play very different roles, and have different syntactic structures:




  1. A question asks the hearer to supply the value for the variable named by the IP and defined by the remainder of the clause. A question is an independent clause—it can stand on its own.


    The first syntactic rule is that first constituent1 after the IP must be a tensed verb. If the IP stands for the Subject of the clause, nothing has to move, because the IP and the verb are already in these positions:
    Q-SubjIP



    But if the IP stands for some other constituent, the tensed verb must fall before the Subject, and a second rule comes into play: the tensed verb must be an Auxiliary. (Grammarians call this subject-auxiliary inversion.) If the ‘canonical’ statement version of the clause does not have an Auxiliary verb, the appropriate form of DO is pressed into service. (Grammarians call this DO-support.)
    Q-AuxInv Thus the proper form for a question using how is this, with both subject-auxiliary inversion and DO-support:  Q-How 1Note that an adjunct—a non-essential syntactic component—is allowed to fall between the IP and the tensed verb: Who recently wrote an app?




  2. A free relative clause does not ask for the value of the IP but designates it—hearers may fill it in from their own knowledge, but an actual value is not required.


    A free relative clause does not call for either inversion or DO-support, regardless of which constituent the IP stands for. After the IP at the beginning, the ‘natural’ order of a declarative sentence is maintained, Subject-Verb-Objects/Complements; the only thing that signals that this is not an ordinary declarative sentence is that something is missing where a constituent was ‘replaced’ by the IP and ‘moved’ to the front.


    A free relative clause is always a dependent clause—it is embedded inside a ‘head’ clause and acts as a noun phrase. In these three examples, the head clause is in ordinary black type; the free relative acts as Direct Object, as Subject, and as the Object of the preposition about.
      (Since DO-support is not in play here the tensed verbs are not distinguished.)FR-Syn How it works, then, with the subject before the verb, is a free relative clause. Here are some examples of how it might be used:  FR-How





publishing - Tips / pitfalls in selecting and working with publishers?


I am thinking about working with a publisher for an iPhone game that I have developed. I have been independent until now, but want to look into the publishing route because I just don't have the resources to market the game myself, and I would rather not take outside investment.


So, those of you who have gone this route, what should I be looking for in a publisher? What should I avoid?



Answer



You mention that you're looking for a publisher primarily for marketing (rather than funding) your iPhone game, so if I understand correctly, you're looking at companies such as Chillingo (if I recall correctly, they'll take finished titles and expose them to hungry gamers).


We've worked with publishers such as Steam, D2D, and OnLive, all of which have been really great for us as indies. Here are some rules-of-thumb that have helped us navigate that:



  • Contracts: We always, always, always, get a lawyer to review the publishing contract. Sometimes, this is a formal, lengthy back-and-forth process, but in the past, we've even relied on family friends (who were lawyers) for a simple review that turned up things we'd missed. And if a publisher refuses to sign a contract to which we've made reasonable changes, we run away.

  • Audience: We do better if our publisher's audience is aligned with our own. This seems a no-brainer, but we didn't realize how pronounced the effect would be. We thought we'd sell (perhaps) twice as many units on one platform as on another. That discrepancy turned out to be two or three orders of magnitude.


  • PR: A good publisher will get your game in front of as many (receptive) eyes as possible. Still, we get good results by doing some of the PR push, ourselves. No other company loves our games as much as ours does; and no other company is as invested in seeing them do well! To wit, we'll go above and beyond what publishers do. For example, if they're pushing our game primarily to their existing customers, we'll hit the press with a humble press release ourselves.

  • Making Friends: Small game development studios tend to help each other out, so if we have questions about a publisher, we'll talk to other groups they've worked with. Cold calls work here! These studios can't say everything, as they'll be bound by a nondisclosure agreement, but "We love this publisher!" or "Beware!" goes a long way.


Good luck!


opengl es - Tile map/terrain implementation with differing heights of neighbouring tiles


Ahoy!


I'm looking for some information about tile maps, or rather, what a specific type of tile map is called.



I'm interested in the kind of implementation used in rollercoaster tycoon, or the transport tycoon series of games and have been looking into vector field terrain and height map terrain but i'm not sure they're suitable for what i'm looking to develop.


It's been a struggle to find any decent info as most people refer to it as an isometric tile map, but I'm looking to create something in 3D with a fixed orthographic perspective. I understand that the underlying storage of the tile map has nothing to do with how it is rendered but i'm not looking to create a 2D tile map like old school pokemon/zelda games, more along the lines of diablo with the capability to include overhanging cliffs and sloping terrain.


I'm just trying to find the right terms to search google and stackoverflow for resources to help me decide which path to proceed.


So far i've managed to flesh out a basic tile map without using the height/y component stored in a VBO and rendered as a wireframe. This looks fine so far but I envisage that I will encounter problems when trying to manipulate a single vertex to create cliffs and slopes without affecting a neighbouring tile.


Is there a specific type of implementation I should be looking into? I thought i'd cracked it when I found a fair amount if info on vector field terrain but i'm not sure this would yield the correct results either.


If anyone can shed some light on this for me please, the help would be greatly appreciated :)


Update


I've included an image for further clarification as to what i'd like to achieve:


2.5D tile map


Image borrowed from How to create tilted (height) isometric tiles



This image shows the type of terrain i'd like to generate but doesn't include the "cliffs" or overhanging terrain types i'm interested in modelling. It does however raise a few other questions I hadn't considered, namely;



  • How would 'layers' such as the water (top left of the image) be handled to include the visible ground underneath the water?

  • How would the "edges" of the map be catered for so that the earth/mud is rendered to depict the world as a non-flat entity?

  • Could the underlying storage for this kind of terrain be used to model physics such as a ball rolling down a hill or movement speeds of a player traversing a slope?


I had an idea in that each tile of the terrain could be modelled with 8 vertices where the 4 main vertices cover the actual tile itself and the remaining 4 vertices are used to model the sides/walls of each tile. The two problems I see with this implementation is that a) the world map is essentially doubled in size and b) given that not all tiles will include "walls", some tiles will end up with redundant vertices which are not used.


I'd like to create a terrain editor which allows for each tile to be deformed as well as including the ability to change the terrain during game play. This in itself poses additional questions such as; Can a VBO be used to store and render the terrain whilst being modified on the fly and also, is it possible to modify vertices without affecting neighbouring tiles?


I'm under the impression that i'm either over-complicating things or running into analysis-paralysis in that i'm neglecting to write any code to solve the problem without having a clear idea of how I would achieve what I want.


Again, i'm really just looking for a shove in the right direction with this. Is there a specific type of tilemap/terrain implementation that would cater for a 3D map to be deformed by both a map editor as well as during gameplay or do I have to roll my own, so to speak? I'm not trying to reinvent the wheel here but I am struggling to find any resources given that I'm not sure what to be searching for.



If anyone can provide any info, resources or snippets of code, that would be hugely appreciated as i'm eager to get my hands dirty and start producing something other than the flat wireframe I currently have.


Thanks for reading!



Answer



If I were you I'd look into voxels, more specifically Minecraft-type cube rendering. Unlike heightmaps, they can handle overhangs, caverns, buildings with multiple floors, etc.


You'd store your terrain in a 3D array of integers, where numbers are mapped to a certain type of terrain: 0=air, 1=dirt, 2=water, etc. Then, to create the mesh to render, you'd create the faces of a cube for each non-empty voxel.


This tutorial is a great explanation of how to do this in C++ using Ogre3D. I presume you'd have to go a little more low-level in OpenGL.


After creating the cubes, you'd want to smooth the edges to create the kind of fluid terrain shown in your image. I believe PolyVox (also in C++) does this; you could take a look at their code. I think you basically do in 3D what the image shows in 2D: average the surrounding cube positions to know where to place each vertex.


EDIT:



  • Generate the faces for the cubes adjacent to water as if the water tile was empty, and render the water faces transparently.


  • Faces on the "edge" can be generated just like regular faces, if you consider voxels outside the world to be empty.

  • Physics: You can probably feed the rendered mesh to your physics engine as a static object.

  • Map editor: You'd want to edit the underlying voxel data, not the mesh itself! (The mesh should mirror the data, so editing the voxels should produce changes in your mesh.) You might want to look up Model, View, Controller (MVC) if you're not familiar with it.


If you have more questions, feel free to leave a comment. Welcome to gamedev.SE!


Monday, April 27, 2015

word usage - What is the difference between 'remember' and 'remembered'?



In the following context:



Holly begins by telling the narrator about a man named Sally Tomato who is a member of the Mafia. She remembered seeing this man at Joe Bell's bar as a regular before he was arrested. Holly Golightly describes how a lawyer pays her $100 to speak to Sally every week. Holly eventually drifts off to sleep, but gets annoyed when she starts speaking in her sleep and leaves the narrator's room.



In general, the tense used in the above context is present tense except the sentence in bold, which is past tense.


My question is that can I apply present tense to this sentence in this paragraph?


Further more


When I'm having a conversation with someone, which one of the two sentences is more proper?


1): I remember you have two boys.


2): I remembered you have two boys.



According to my own understanding about the word 'remember'. When present tense is used, it is to emphasize the action of the verb which happens now. And when past tense is used, it is to emphasize the fact that I have remembered something. Is this correct?*




c++ - ECS: is it beneficial to manage the data organisation of components before updating a system?


When I process a bunch of component data, I'd like that data to be sorted in such a way that I can iterate through the component buffers linearly. For instance when I want to update the physics system, in an ideal world the buffers for the TransformComponent, MovementComponent and PhysicsBodyComponent are structured in such a way that I would be able to iterate over the entities like this:


for(int i = 0; i < m_numEntitiesInSystem; i++)
{
Transform& transform = g_transformBuffer[i];
MovementComponent& movement = g_movementBuffer[i];

PhysicsBodyComponent& body = g_physicsBodyBuffer[i];
// ... update physics ...
}

The main advantage of this is that I would have next to no cache misses for this system. Because different systems require different (combinations of) components, this would imply that before every system update, I would either have to sort the respective component buffers so that they are aligned or I would have to use a cache that is local to the system only (this cache would need to be synced every time a component changes).


Of course both approaches come at a cost as well, sorting the component buffers could affect the ability to execute systems on separate threads. Not to mention that the sorting process itself might have its own performance drawbacks. Syncing the component data implies that some components might need to be copied over possibly several times per frame which again might come with its own performance drawbacks.


My question is: is the price of sorting or syncing worth being able to process data linearly? Or is it wiser to try organise the data in such a way that the most executed/expensive systems perform optimally and others potentially less so. If the former, would it be preferable to use the sorting method or the syncing method?


Also please don't tell me that "premature optimization is evil". Since this is more or less the foundation of my engine, I want it to be as well written and designed as I can. Or at least I want to understand the consequences of picking one method over the other.


Thank you so much!



Answer




It's difficult to say which way is best, since we don't know how prone your setup is to cache misses without this.


I think I remember Jonathan Blow describing doing this type of sort-before-update on one of his developer streams, as a way to improve performance late in a project, so there certainly could be cases where it's beneficial. Without profiling data though, it's not clear how much net savings you'd get, and whether it's worth the cost in complexity or threading flexibility as you mentioned.


One thing to consider is that just iterating in a sorted order, even with gaps, can still be a lot better than a random zig-zag backwards and forwards through memory!


So you might not need to re-sort for every system to get the lion's share of the cache miss savings. A single shared sort order that tends to keep clusters of entities close together for one or a few of your highest-throughput systems might be enough to keep your game running smoothly, even if most / all systems still encounter some gaps in their iteration.


But again, we can't really quantify this to test it without knowing the typical distributions of your data at runtime. There are use patterns under which this will perform at efficiency approaching the theoretical maximum, and other use patterns under which it will suffer as badly as pointer-chasing. So there's really no substitute for building tests and profiling, even if it means you go down the wrong road at first and need to refactor once you know in detail what your runtime data characteristics are like.


grammar - what if I + what, past tense or present tense?



what's the correct tense here: Is it "the past tense" or "the present tense"? "What if I miss the bus?" "What if I were late to dinner?" "What if I called her tomorrow?" "What if I don't understand?"




meaning in context - Does "That bridge has been repaired for the past ten years." mean the repairs were completed 10 years ago?


Please have a look at the below image and for more details, please find below the link, https://english.stackexchange.com/questions/282335/how-to-use-present-perfect-continuous-in-passive-form


enter image description here


The above answer was given by a person to describe "How to use Present Perfect Continuous in Passive form?"


I understand that his first example



"That bridge has been being repaired for the past ten years."



means the repair works were started ten years ago and are not yet completed and still going on. I think he also meant the same meaning.



But he stated that his second example



"That bridge has been repaired for the past ten years."



means the repairs were completed ten years ago.


Is that right? To me, his second example means the repair works has been done for the past ten years and completed recently.


I think the active form of his second example is "They have repaired the bridge for the past ten years" which looks like Present Perfect and that means the action was started ten year ago and now finished recently.


And if I need to make a sentence with the meaning of "the repairs were completed ten years ago", then I would say that in passive form as "The Bridge was repaired by them ten year ago"


May be I'm wrong.


So please help me understand. Thanks in advance.



I don't have much reputation to comment there and also that was a two year old post. So that, I've created a new question here to ask about this.



Answer



The sentence ""That bridge has been being repaired for the past ten years" is ambiguous. It is unclear if the work started 10 years ago and has not been completed, or if multiple repairs have been made over the ten year span. Furthermore if multiple repairs have been made, it is unclear if the bridge is now repaired or not.


The sentence "That bridge has been repaired for the past ten years" is ambiguous to me too. It definitely means that the bridge is now repaired. But it is unclear if the repairs were completed 10 years ago or if the bridge has been repaired multiple times within the ten year span.




Ok, let's beat this to death so more.


The bridge was repaired 10 years ago.



It is isn't clear if this was the first repair of the bridge, the last, or some intermediate repair. It is also unclear if the bridge needs repair now or not. But 10 years some repairs were made and completed.




The bridge was last repaired 10 years ago.



The last time the bridge was repaired was 10 years ago and those repairs were completed. There may have been previous repairs. It is unclear if the bridge needs repair now or not.



The bridge was last repaired 10 years ago and it is still serviceable.



The last time the bridge was repaired was 10 years ago. There may have been previous repairs. The bridge does not need repair now.



The bridge, now repaired, ...




The bridge does not need repairs now.



The repairs on that bridge started ten years ago and the repairs are still are not finished.



The repairs started 10 years ago and were never completed over the 10 year span.



That bridge started "being repaired" ten years ago.



Repairs were started 10 years ago and have never been finished.




That bridge has been being repaired multiple times over the past ten years.



Over the last 10 years multiple repairs have been completed on the bridge. It is unclear if the bridge needs repair now or not.



word usage - How can you recognize "uncle" is father's brother or mother's brother? (Is there any "default option"? )


Sometimes the speaker(or author) specifies what he/she means when he/she uses the word "uncle" for example:



The gelding was mine, a gift from a great-uncle on my mother’s side.(Educated by Tara Westover)



but suppose that you read about someone's uncle in a certain text and the writer doesn't mention if the uncle is:




  • his father's brother

  • or his mother's brother

  • or his father's sister's husband

  • or his mother's sister's husband


Could you please tell me how you can recognize which one is the "uncle"?


Basically, is there any "default option" in the absence of uncertain answer?




PS: In some languages like Albanian, Arabic, Persian, and Polish, unlike the English language, no single inclusive term describing both a person's kinship to their parental male sibling or parental male in-law exists. Instead, there are specific terms describing a person's kinship. For example, the Persian language has a special word for the uncle of the father side (amou-عمو) and the uncle of the mother side (daiyee-دایی)


*This postscript was added after some fine answers had been offered.




Answer



You can't. There is no "default". If it's not clearly stated, you have to ask. Generally, if it's not clarified in the text, it's probably not important.


This may seem odd from the point of view of someone coming from a language where the difference is part of the terminology used but as with many familial terms like grandmother/father, cousin, or nephew, only the direct relationship in English is there without adding modifiers.



  • My mother's mother -> my grandmother on my mother's side or maternal grandmother

  • My father's brother -> my uncle on my father's side or paternal uncle

  • My father's brother's son -> my cousin who is the son of my father's brother


It gets a bit wordy but, there you have it. We don't really have a better way of doing it.


When it comes to aunts and uncles by marriage - the spouse of your parent's brother or sister - one might use "uncle-in-law" but (as a native American English speaker) this seems silly and would likely be something I would only do when joking or teasing that person... and it still doesn't solve the problem of whether it's your father's or mother's sibling's spouse.



legalese - 3 ambiguous pronouns by Justice Antonin Scalia


Source: *Agency For International Development Et Al. v. Alliance For Open Society International, Inc., Et Al, Justice Scalia's dissent



[Start from last para on p 19 of 25 of this PDF.] The First Amendment does not mandate a viewpoint-neutral government. Government must choose between rival ideas and adopt some as its own: competition over cartels, solar energy over coal, weapon development over disarmament, and so forth. Moreover, the government may enlist the assistance of those who believe in its ideas to carry them to fruition; and it need not enlist for that purpose those who oppose or do not support the ideas. That seems to me a matter of the most common common sense. For example: One of the purposes of America’s foreign-aid programs is the fostering of good will towards this country. If the organization Hamas—reputed to have an efficient system for delivering welfare—were excluded from a program for the distribution of U. S. food assistance, no one could reasonably object. And that would remain true if Hamas were an organization of United States citizens entitled to the protection of the Constitution. So long as the unfunded organization remains free to engage in its activities (including anti-American propaganda) “without federal assistance,” United States v. American Library Assn., Inc., 539 U. S. 194, 212 (2003) (plurality), refusing to make use of [1.] its assistance for an enterprise to which [2.] it is opposed does not abridge [3.] its speech. And the same is true when the rejected organization is not affirmatively opposed to, but merely unsupportive of, the object of the federal program, which appears to be the case here. (Respondents do not promote prostitution, but neither do they wish to oppose it.) A federal program to encourage healthy eating habits need not be administered by the American Gourmet Society, which has nothing against healthy food but does not insist upon it.



I'm only guessing, so further to checking my guesses, please explain how to determine/deduce the right antecedent? Is Justice Scalia's pronoun use truly ambiguous here, or is my naivety the problem? For brevity, abbreviate 'government' as govt and the unfunded organisation orgn.



  1. its = the US government's (assistance)?


  2. it = the US government





  3. its = the unfunded organization's?




Update Dec 16 2014: How can [1.] mean the orgn? Does it only make sense for the orgn to refuse the govt assistance? Why would the govt refuse the orgn's assistance?




c# - Collision Detection problems in Voxel Engine (XNA)


I am creating a minecraft like terrain engine in XNA and have had some collision problems for quite some time. I have checked and changed my code based on other peoples collision code and I still have the same problem. It always seems to be off by about a block. for instance, if I walk across a bridge which is one block high I fall through it. Also, if you walk towards a "row" of blocks like this:


enter image description here


You are able to stand "inside" the left most one, and you collide with nothing in the right most side (where there is no block and is not visible on this image).


Here is all my collision code:


    private void Move(GameTime gameTime, Vector3 direction)
{
float speed = playermovespeed * (float)gameTime.ElapsedGameTime.TotalSeconds;


Matrix rotationMatrix = Matrix.CreateRotationY(player.Camera.LeftRightRotation);
Vector3 rotatedVector = Vector3.Transform(direction, rotationMatrix);

rotatedVector.Normalize();

Vector3 testVector = rotatedVector;
testVector.Normalize();

Vector3 movePosition = player.position + testVector * speed;
Vector3 midBodyPoint = movePosition + new Vector3(0, -0.7f, 0);

Vector3 headPosition = movePosition + new Vector3(0, 0.1f, 0);

if (!world.GetBlock(movePosition).IsSolid &&
!world.GetBlock(midBodyPoint).IsSolid &&
!world.GetBlock(headPosition).IsSolid)
{
player.position += rotatedVector * speed;
}

//player.position += rotatedVector * speed;

}

...


    public void UpdatePosition(GameTime gameTime)
{
player.velocity.Y += playergravity * (float)gameTime.ElapsedGameTime.TotalSeconds;

Vector3 footPosition = player.Position + new Vector3(0f, -1.5f, 0f);
Vector3 headPosition = player.Position + new Vector3(0f, 0.1f, 0f);


// If the block below the player is solid the Y velocity should be zero
if (world.GetBlock(footPosition).IsSolid ||
world.GetBlock(headPosition).IsSolid)
{
player.velocity.Y = 0;
}

UpdateJump(gameTime);
UpdateCounter(gameTime);
ProcessInput(gameTime);


player.Position = player.Position + player.velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
velocity = Vector3.Zero;
}

and the one and only function in the camera class:


    protected void CalculateView()
{
Matrix rotationMatrix = Matrix.CreateRotationX(upDownRotation) * Matrix.CreateRotationY(leftRightRotation);
lookVector = Vector3.Transform(Vector3.Forward, rotationMatrix);


cameraFinalTarget = Position + lookVector;

Vector3 cameraRotatedUpVector = Vector3.Transform(Vector3.Up, rotationMatrix);
viewMatrix = Matrix.CreateLookAt(Position, cameraFinalTarget, cameraRotatedUpVector);
}

which is called when the rotation variables are changed:


    public float LeftRightRotation
{

get { return leftRightRotation; }
set
{
leftRightRotation = value;
CalculateView();
}
}

public float UpDownRotation
{

get { return upDownRotation; }
set
{
upDownRotation = value;
CalculateView();
}
}

World class:


    public Block GetBlock(int x, int y, int z)

{
if (InBounds(x, y, z))
{
Vector3i regionalPosition = GetRegionalPosition(x, y, z);
Vector3i region = GetRegionPosition(x, y, z);

return regions[region.X, region.Y, region.Z].Blocks[regionalPosition.X, regionalPosition.Y, regionalPosition.Z];
}

return new Block(BlockType.none);

}

public Vector3i GetRegionPosition(int x, int y, int z)
{
int regionx = x == 0 ? 0 : x / Variables.REGION_SIZE_X;
int regiony = y == 0 ? 0 : y / Variables.REGION_SIZE_Y;
int regionz = z == 0 ? 0 : z / Variables.REGION_SIZE_Z;

return new Vector3i(regionx, regiony, regionz);
}


public Vector3i GetRegionalPosition(int x, int y, int z)
{
int regionx = x == 0 ? 0 : x / Variables.REGION_SIZE_X;
int X = x % Variables.REGION_SIZE_X;

int regiony = y == 0 ? 0 : y / Variables.REGION_SIZE_Y;
int Y = y % Variables.REGION_SIZE_Y;

int regionz = z == 0 ? 0 : z / Variables.REGION_SIZE_Z;

int Z = z % Variables.REGION_SIZE_Z;

return new Vector3i(X, Y, Z);
}

Any ideas how to fix this problem?


EDIT 1:


Graphic of the problem:


enter image description here


EDIT 2



GetBlock, Vector3 version:


    public Block GetBlock(Vector3 position)
{
int x = (int)Math.Floor(position.X);
int y = (int)Math.Floor(position.Y);
int z = (int)Math.Ceiling(position.Z);

Block block = GetBlock(x, y, z);

return block;

}

Now, the thing is I tested the theroy that the Z is always "off by one" and by ceiling the value it actually works as intended. Altough it still could be greatly more accurate (when you go down holes you can see through the sides, and I doubt it will work with negitive positions). I also does not feel clean Flooring the X and Y values and just Ceiling the Z. I am surely not doing something correctly still.



Answer



A few things I noticed you can check:



  • In Move() you subtract 1.4 to get the head position while in UpdatePosition() you add 0.1. Double-check that this calculation is correct as I would have assumed you should be adding the same value in the same direction.

  • Is the collision issue the same in each direction (+/-, X/Y/Z) or does it matter which direction you're going? For example, if the collision issue was different while travelling in +X vs -X I would guess there's a mismatch between where the collision detection thinks a voxel is and where the game actually displays it. In other words, does you voxel at (0,0) occupy (0,0)-(1,1) or (-0.5, -0.5)-(0.5, 0.5) or (-1,-1)-(0,0). If you make a mistake here you will be off by as much as one block which sounds close to the issue you describe.

  • Drawing your collision box may be helpful in debugging as can be stepping through and observing what the variables are and what you think they should be.

  • I assume player.position vs player.Position is just a typo (though I've been bitten by dynamic case-sensitive languages before).



Edit: The way you describe it sounds exactly like an "off-by-one" type error. You also use GetBlock(Vector3) but posted code for GetBlock(int, int, int). If you are relying on automatic conversion from float to int it may round/truncate in ways you aren't expecting.


Edit 2: I would follow MindWorX's comment about specifically using floor()/ceil() when you convert from float to int. This may or may not be the issue you are having. You really need to add some diagnostic output to the display (player position, camera position, collision boxes, selected block info, etc...) and trace through everything to make sure it does what it should. At this stage it is dangerous to think "it can't be X". Don't assume anything and make sure you actually read what the code does and not what you think it does.


Sunday, April 26, 2015

grammaticality - Can a noun follow 'to intend'?


Source: p 12 and 48, The Law of Contract, 5 ed (2012), O’Sullivan and Hilliard




p 12: In order to work out whether there was a valid off er in our car example, we ask whether it should have appeared to you that I was off ering to sell my car, not whether it was my actual intention to do this. Th is is known as the principle of ‘objective intention’ and is discussed further later. So a party might be bound by a contract even though this is the last thing he intends.


p 48: Even if certain terms of economic or other signifi cance to the parties have not been fi nalised, an objective appraisal of their words and conduct may lead to the conclusion that they did not intend agreement of such terms to be a precondition to a concluded and legally binding agreement...



Googling "intend a contract" produces limited, inconclusive results, but 'intend disrespect' less so. Neither the ODO nor Merriam answers this question definitively.



Answer



"Intend" is sometimes used as a transitive verb, that is, it is followed with a noun that is a thing that you want to do or have. The most common example is, "I intended no harm."


Usually, though, it is followed by an infinitive verb. "Bob intended to run to the store", "We intended to complete the project by November." Etc.


As FumbleFingers says, in this case the writer may have intended (!) to mean, "he intended to be bound by a contract" rather than "he intended a contract". Either way the meaning should be clear.


c++ - Planning Class Inheritance for Game Objects



This is specifically about the development and planning direction of the game development.


I'm creating a fairly basic RPG and am wondering about the approach that I should take. I've been trying to outline it all in a flow chart first, but want to see if this is a good way of going about it.


For example, I've created a class called "items", which then currently derives into "Weapons" "Armor" and "Potions". I then derive these classes further into specific types and I keep going and going, basically as specific as I want to get.


Before I get too deep into this (again, I'm still planning) - I just want to know if this is a good way of approaching this problem.




modal verbs - just in case VS. should



I'll be at my uncle's house just in case you need to reach me.


I'll be at my uncle's house should you need to reach me.



Could you tell me what is the difference between those?




2d - Sidescroller variable terrain heightmap for walking/collision


I've been fooling around with moving on sloped tiles in XNA and it is semi-working but not completely satisfactory. I also have been thinking that having sets of predetermined slopes might not give me terrain that looks "organic" enough. There is also the problem of having to construct several different types of tile for each slope when they're chained together (only 45 degree tiles will chain perfectly as I understand it).


I had thought of somehow scanning for connected chains of sloped tiles and treating it as a new large triangle, as I was having trouble with glitching at the edges where sloped tiles connect. But, this leads back to the problem of limiting the curvature of the terrain.


So...what I'd like to do now is create a simple image or texture of the terrain of a level (or section of the level) and generate a simple heightmap (of the Y's for each X) for the terrain. The player's Y position would then just be updated based on their X position.


Is there a simple way of doing this (or a better way of solving this problem)? The main problem I can see with this method is the case where there are areas above the ground that can be walked on. Maybe there is a way to just map all walkable ground areas?


I've been looking at this helpful bit of code: http://thirdpartyninjas.com/blog/2010/07/28/sloped-platform-collision/ but need a way to generate the actual points/vectors.



EDIT: I did try pregenerating sloped paths using the link I posted but now I'm convinced I should use per-pixel collision as you suggested. I've been looking at the example at: http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel and am trying to figure out how to adjust the sprite once a collision has been detected. As David suggested, I made a few sensor points (feet, sides, bottom center, etc.) and can easily detect when these points actually collide with non-transparent portions of a second texture (simple slope). I'm having trouble with the algorithm of how I would actually adjust the sprite position based on a collision.


Say I detect a collision with the slope at the sprite's right foot. How can I scan the slope texture data to find the Y position to place the sprite's foot so it is no longer inside the slope? The way it is stored as a 1D array in the example is a bit confusing, should I try to store the data as a 2D array instead?


I also noticed several people mention that it's best to separate collision checks horizontally and vertically, why is that exactly?



Answer



I don't think you should try converting the entire map into a single height map, exactly because of the problem you described. Maps can have arbitrary complexity which you wouldn't be able to represent in a height map.


But you don't need to have a fixed slope for each type of tile either. You could store collision information on a per pixel basis for each type of tile or compute it from the tile's alpha channel and use it to determine where the character should stand at each moment based on the tiles he's currently intersecting. Here's an example of the collision data for one tile:


enter image description here


Using this scheme you can have any type of slope you want just by varying the tile's collision mask. This is how Sonic games were implemented back in the day, and as such I suggest reading the following page in its entirety for a better understanding:


http://info.sonicretro.org/SPG:Solid_Tiles#Slopes_And_Curves


Then in order to process collisions between your character and the environment, I suggest defining a few sensors or collision points on your character, such as the magenta dots on the image below:



enter image description here


For instance, the top sensors could be used to detect and react to collisions with the ceiling, the middle sensors could be used to detect and react to collisions against walls, and the bottom sensors could be used to detect collisions with the floor and determine the correct height for the player. By moving the middle sensors up and down you can control how steep a slope has to be before the player can no longer climb it.


Another neat trick you can do with the bottom sensors, is depending on how many of them are colliding with the floor, you can detect when the player is near a ledge and possibly play a different animation such as the image below.


enter image description here


Saturday, April 25, 2015

gerunds - What is the grammar of: "You being the fish"?


Source: The Big Bang Theory transcript season 2, episode 1


I found it weird when I heard it in a tv series. 'Being' is not preceded by a 'to be verb' and also comes after a subject.



How is it possible? Shouldn't it be "You are being a fish"?



Leonard: Okay, so, she said she wants to slow things down. It’s like saying “I’m really enjoying this meal, I’m going to slow down and savour it.”
Howard: No, it’s like “this fish tastes bad, so I’m going to slow down and spit it out.”
Raj: You being the fish.
Leonard: I'm not the fish.





graphics - What is the name of the perspective style of games like Final Fantasy 6, Chrono Trigger or Alundra?



What is the actual term for the 'top-down' style of the Super Nintendo games such as Final Fantasy 6, Chrono Trigger, et cetera. I'm looking for the equivalent term of:



  • 'isometric' - (Jaggered Alliance, Final Fantasy Tactics, Fallout),

  • 'first person' - (Half Life, Doom, Quake),

  • 'birds eye' - (Grand Theft Auto)

  • ? insert term here ? - (Final Fantasy 6, Chrono Trigger)



Answer



The terms you have used in your question are more colloquial than precise or definitive, so comparing against them is not necessarily useful. Technically you're comparing different types of 'projection', plus the viewpoint that the projection is done onto.


Final Fantasy 6 uses an orthographic projection, though a very specific one that is perhaps easiest described as a degenerate oblique projection where the receding surfaces are drawn at a 0° angle rather than a more illustrative 30° or 45° (as in Ultima VII). The viewpoint is typically from above and offset somewhat from the area being viewed.



GTA1 uses a fairly standard orthographic projection. The viewpoint is directly above the subject.


First person games use perspective projection. This projection is also used for most third person games rendered in 3D. In 1st person games the viewpoint is placed at roughly head height on a notional person, but in 3rd person games the viewpoint might be placed behind a person's shoulder, or high above the world, or in any arbitrary position.


Isometric games are, of course, in an isometric projection. However, Fallout 1 and 2 are not technically isometric - they are trimetric projections. You can see the difference in how Fallout is slightly rotated compared to a typical isometric game. For a game to be isometric, the angles between the 3 axes need to be equal, ie. 120°. Examples are Final Fantasy Tactics and Sim City 2000. The viewpoint is pretty much the same as for the oblique projections.


Oblique, orthographic, and isometric are all types of parallel projection where lines that would appear to converge in real life when viewed in perspective, are rendered as parallel lines instead.


Is it possible to use C++ with Unity instead of C#?


The title kind of says it all. Is it possible to replace C# with C++ on a game using Unity?



Answer



It is possible to use C++ with the Free version of Unity, although it is easier to work with if you have a Unity Pro license. All you have to do is wrap it up in a DLL and follow the instructions below on where to place it.


I wrote an article that covers this topic: Unity and DLLs: C# (managed) and C++ (unmanaged)



For Unity 4 Free:




  • Add unmanaged code to the Unity Project Root: UnityProject

  • Add managed code to the Plugins folder: UnityProject->Plugins

  • When you build a project, copy the unmanaged code to BuildRoot->Data->Plugins


For Unity 4 Pro and any Unity 5:



  • Just copy the DLLs into UnityProject->Plugins




Unmanaged means C++ and Managed means C#


word order - Make up something or make something up?


Another murky subject arose today:


Would like to know, which one is appropriate:



I am unable to attend the mandatory meeting; I will make up some excuse.



Or:



I am unable to attend the mandatory meeting; I will make some excuse up.






Accessing DualShock 4 motion sensor in Windows (ideally Unity)


I'm trying to use a DualShock 4's IMU as a motion controller in Unity, under Windows 7.


So far I've tried:



  • DS4Windows (1.5.11): reads motion sensor data, but does not expose them to Unity as axes unless I map them to the left & right sticks. This is not enough since I lose use of the sticks, I can only fit 4 of the 6 channels of data, and the values coming through are clipped into a narrow range.

  • Motioninjoy (0.7.1001): does not appear to detect the DS4 as a controller (latest docs refer only to DS3 and prior)


  • GlovePIE (0.43): after following instructions for using the DualShock 3 with LibUSB-Win32 (a long shot), SixAxis properties are all blank.


In the past I've used external programs like GlovePIE to capture Wii remote motion sensor data and pass it to Unity via OSC messages, so I'd be open to an approach like this if I can't get Unity to read the controller's sensors directly through its Input system.


Anyone had luck with this?



Answer



I've found a workable approach. I grabbed the DS4Tool source and copied the bits I needed into my Unity project so I could read the reports from the device directly.


(That's the NativeMethods class to interface with Kernel32.dll, the device enumeration from HidDevices, and reading the report from the HidDevice class. I cut out the rest to keep things as simple as possible - I've just got a thread polling for new data as fast as it can.)


This guide told me where to find the motion sensor data within the 64-byte report. A little empirical testing and it looks like this gets the data into gs and radians/sec:


accel = new Vector3(
System.BitConverter.ToInt16(_inputBuffer, 19),

System.BitConverter.ToInt16(_inputBuffer, 21),
System.BitConverter.ToInt16(_inputBuffer, 23)
)/8192f;

gyro = new Vector3(
System.BitConverter.ToInt16(_inputBuffer, 13),
System.BitConverter.ToInt16(_inputBuffer, 15),
System.BitConverter.ToInt16(_inputBuffer, 17)
)/1024f;


It's a right-handed coordinate system with x+ right, y+ up, and z+ pointing toward the player.


Fetching the data this way doesn't interfere with Unity's InputManager, which will still pick up the buttons & sticks as expected, without needing to download non-standard drivers or run extra software in the background.




Update: Wireless (Bluetooth)


I found two problems extending this to work wirelessly (and two solutions):




  1. DualShock 4s don't like to stay paired to Windows (prior to Windows 8). This silly procedure seems to work around that on Windows 7.





  2. No motion sensor data when connected via Bluetooth. I discovered you need to write an Output Report to the device (see HidDevice for the method and DS4Device for the magic numbers) in order to coax it into sending motion data. Once this is done, the input reports you get back will be shifted by 2 bytes.




c# - Control animation using animator control class



I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given the screen short of the animation enter image description here


Then I have attached the following code to it


Animator animator;

int eatHash=Animator.StringToHash("ideal");

int stateHash=Animator.StringToHash("Base Layer.pickbothfork");

void Start () {
animator = GetComponent();

}

// Update is called once per frame
void Update () {
//animator.SetBool ("isEat", true);
float move = Input.GetAxis ("Vertical");
animator.SetFloat ("Speed",move);

AnimatorStateInfo stateinfo = animator.GetCurrentAnimatorStateInfo (0);
if (Input.GetKeyDown(KeyCode.Space))

{
Debug.Log ("clicked spacebar");
animator.SetTrigger(eatHash);
}
}

The problem here is the above code is working,when I run the project the animation is getting played one after the another according to the state diagram.But when I click on the space bar the trigger function(jump animation ) is not working


if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log ("clicked spacebar");

animator.SetTrigger(eatHash);
}

Can anybody please help me finding solution for it




Friday, April 24, 2015

3d - How to generate caves that resemble those of Minecraft?


I've been working on a 3D procedural world for a while now and am wanting to start adding cave systems. I'm currently using 2D/3D Perlin Noise for the terrain generation in combination with Marching Cubes for smoother terrain. I'm just getting stumped when it comes to long interconnecting caves.



I'm hoping to get something more like Minecraft's cave systems. They seem to be very connected, branch off randomly in nearly any direction, and nearly any point in the cave would have a fairly circular look with a fairly equal radius throughout (not the best wording, but not quite sure how else to put it).


The biggest challenge for generating caves like I'm wanting is that I want to generate the world on the fly. The world is generated chunk by chunk currently, starting where the player is and it generates outwards from there. I would NOT want to generate any of the world and then dig the caves out using a wandering pattern, cellular automata, etc.


Are there any well known algorithms that can be used for this? If so, does anyone want to share how they do something similar? I'd greatly appreciate any help.


A good example: enter image description here



Answer



Minecraft's caves are generated by "perlin worms" method. The generator snakes through terrain and caves out a tunnel. Minecraft does not use 3d perlin noise for cave generation, because it tends to leave unconnected pockets in the terrain. Minecraft caves have not been generated through 3d Perlin noise since very early Alpha versions.


Here are caves in Gnomescroll generated from the "perlin worm" method.


Gnomescroll Cave System First Person View 1


Gnomescroll Cave System First Person View 2


Gnomescroll Cave System Third Person View 2



These are the libnoise "Perlin Worms" from the libnoise tutorial. The technique closely reproduces the caves generated in Minecraft.


Linoise Tutorial Perlin Worms


The snaking parameters affects the quality of the cave system and determine how vertical the caves are and how fast they change direction. Caves in minecraft branch and the radius of the cave tunnel is varied over the length of the caves.


Minecraft generates the caves on a chunk by chunk basis. The approach required is complicated and no one has perfectly reverse engineered Minecraft's cave generator yet, despite interest by server modders.


The most likely approach generates the snaking caves chunk by chunk as the infinite map is generated and expands outward. The caves on the current chunk are functions of the cave seeds on the closest N chunks for some N. Using a random number generator which is a function of chunk coordinates to seed the caves it is possible to compute the caves on the current chunk for an infinite map while only evaluating the chunks within a finite chunk radius.


Should I always be checking every neighbor when building voxel meshes?


I've been playing around with Unity3d, seeing if I can make a voxel-based engine out of it (a la Castle Story, or Minecraft).


I've dynamically built a mesh from a volume of cubes, and now I'm looking into reducing the number of vertices built into each mesh, as right now, I'm "rendering" vertices and triangles for cubes that are fully hidden within the larger voxel volume.


The simple solution is to check each of the 6 directions for each cube, and only add the face to the mesh if the neighboring voxel in that direction is "empty". Parsing a voxel volume is BigO(N^3), and checking the 6 neighbors keeps it BigO(7*N^3)->BigO(N^3).


The one thing this results in is a lot of redundant calls, as the same voxel will be polled up to 7 times, just to build the mesh.



My question, then, is:


Is there a way to parse a cubic volume (and find which faces have neighbors) with fewer redundant calls? And perhaps more importantly, does it matter (as BigO complexity is the same in both cases)?



Answer



Yes, you can make fewer calls. You can give each voxel data containing it's face information. Then go through and set the face data of all the voxels. The simple solid or not situation produces 4 cases:


for each voxel
for each face not set
if thisVoxel is solid
if oppositeVoxel is solid
// both voxels are solid and touching, no faces
set thisFace to zero

set oppositeVoxelFace to zero
else
// this voxel is solid, other is not, this voxel has a face
set thisFace to one
set oppositeVoxelFace to zero
else
if oppositeVoxel is solid
// this voxel is not solid, other is, other has face
set thisFace to zero
set oppositeVoxelFace to one

else
// both voxels are not solid no faces
set thisFace to zero
set oppositeVoxleFace to zero

As you can see, you'll cut out at least one check for the opposite voxel by setting both at the same time. Ensure that you only loop over faces not set. This will reduce the number of checks you need to do.


Additionally, when rebuilding the mesh, you can reuse almost all the face data. When a voxel is added or removed, reset it's face data and the face data of those voxels surrounding it.


You probably realize that this is a trade off. You either get faster execution, or more memory usage. This will take more memory.


Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...