Saturday, March 31, 2018

Finger tips to add "es" and "s" to an action verb to convert a base form into a third person singular form


Please let me know, when we should add es or s to an action verb to convert a base form into a third person singular form? I meant to ask are there any finger tips we can follow?


Examples:


go = goes


Walk = walks



Answer



Keep in mind that there are both regular and irregular verbs. If we just go by the examples you've provided, we could hypothesize that the "s" ending follows a (regular) verb root that ends with a consonant and "es" goes with a (regular) verb root that ends with a vowel--usually an 'o'. Verbs that end with 'y,' like "to fly" become "flies." Verbs that already end with an "e" just need an 's' to conjugate in the third person. I'd say that those are decent rules of thumb.


meaning - Difference between "illegal" and "very illegal"


From my understanding of English, "very" means "more than the usual" or "to a higher extent".


I've seen on several places the expression "very illegal", such as here as an example: https://youtu.be/ytDamqTjPwg?t=8m23s




The bigger point here is, [the Pump & Dump scheme] is very illegal!



However, I don't understand the meaning here. If I apply my previous knowledge, it would mean it's "more illegal than usual", and from the context of the example quote above we're talking about illegal stock exchange practices.


But "more illegal than usual"? It just doesn't make sense to me, something is either illegal or it's legal. I can understand some crimes might be considered more damaging than other crimes. It leads me to think "very illegal" is a particular expression, plus it doesn't fit in the example context above.


I am not familiar with the literal translation of "very illegal" that would be "très illégal" in French. The closest meaningful expression I could find appended around the word "illégal" is "vraiment illégal", which would mean "it's illegal but you might have thought it isn't". In English without being certain about the expression, I would translate that as "really illegal", or "truly illegal", or "actually illegal" (even though I dislike the word "actually").


I wasn't able to find a definition on Google.


What is the difference between "illegal" and "very illegal" in general?




I've been monitoring the answers and considering each one, and it seems clear that very is an emphasis on the illegality. Even though I do not know if all of the following is relevant as some answers have low votes, from all answers so far various facets appear as I interpreted:





  • very might emphasize the likelihood of being prosecuted for the crime (-> several mentions (A, B, C, maybe D)




  • very might emphasize how flagrant or unambiguous a crime is (-> several mentions (A, B, C)




  • very might emphasize the morality of the crime (-> most upvoted answer)





  • very might emphasize the severity of punishment of the crime (-> one answer with high votes)




  • very illegal might highlight that a illegal activity that doesn't immediately stand out as illegal for a target audience is not only illegal, but is also emphasized in some way (-> some mentions A, B)




The following do not answer the question but are interesting nonetheless:





  • Prefixing very might not be necessarily needed for crimes in which morality, severity of punishment or likelihood of being pursued are obvious to the targeted audience; adding it should be meaningful for the interpretation by the target audience as opposed to if it wasn't prefixed.




  • very illegal is informal (A, B), there are much better words for some situations (misdemeanor, felony, capital offense...)




  • One answer mentions highly illegal. As it stands out I cannot summarize it here.




There does not seem to be a strong pattern emerging from the answers for which facet everyone agrees about. I have the disturbing feeling that maybe my objective question is unexpectedly leading to subjective but valid answers. Even though the currently most upvoted answer may be the best answer, it might only reflect some valid facets of a more complete answer.



However it clearly highlights the emphasis aspect that seems to be common to all facets so I'm accepting that answer.



Answer



Sometimes, not only in English but in all languages, we want to emphasize certain situations. And then the language itself gives us devices that aren't always common, but we use them anyways, based on known and meaningful expressions.



I am very hungry



We can depict that the subject has surpassed the status of just "hungry" for they must have stayed a long time without eating. This is a known meaningful expression.



Murder is very illegal




From this, even if it doesn't make much sense in the binary nature of the word "legal", we can depict that "murder" is a crime that, morally or ethically, has surpassed the status of "illegal".


We can state that by looking at another not-so-serious crime:



Parking on the sidewalk is illegal



Yeah, we all know it is illegal and wrong. But it is a petty crime compared to murder. In some countries murder is penalized with life imprisonment, even with death penalty, while parking on the sidewalk gives you a fine and, in the worst of the cases, your car is towed.


We can still say that "Murder is illegal", of course it is, but in the sentence, the "very illegal" was made to emphasize.


marketing - Promoting a Browser Game?




I have a new browser based game that I've worked on for a few months. Obviously all that effort goes to waste if no one sees it.


I know there's topics to do with games promotion, but browser games are a different field entirely.


How can I promote my browser game?




Answer



Have a look at some similar questions under the marketing tag.


Here are some things to do:



  1. Make the game worth playing (see comment)

  2. Get friends, family, colleagues, anyone to play it and tell people about it. This kicks off your initial word of mouth campaign.

  3. Social media. Facebook site, twitter account, blog, there are loads now. This will increase the visibility of your game and start organic growth.

  4. Incentivise playing if possible. Do you offer in-game credit/coins/points etc.? Give your first set of users a bonus for playing.

  5. Incentivise word-of-mouth. Give your players an in-game (or other) bonus for bringing people to your game.

  6. Targeted Adwords. If you have a budget, great! Target google and facebook users with keywords, etc.


  7. Link-sharing. Forums and game blogs will have link-sharing schemes. You promote someone else's site, someone else promotes yours.

  8. Tell people about it. You can do this without spamming. For example, you could add a comment under your question with a link to the game. I'd have a look and who knows - I might like it and tell people about it. Be wary though - you need to be considerate of how much you "push" your game in this way.

  9. Submit your game to review sites. You get good feedback and linked traffic.

  10. Create a community for your game. Not only will these guys tell you about bugs and suggest features, they'll also become evangelists for your game. (added May 15)

  11. Read and apply lessons from The Zero Budget Indie Marketing Guide. (added May 19)


I'll add more when I think of some but hopefully this should be some good initial food for thought.


Friday, March 30, 2018

When to use an object pronoun or a possessive adjective before a gerund


The rule says that we can use a possessive adjective or an object pronoun before a gerund. Is there a rule that says when to use each or are they interchangeable? Some say that it's wrong to use an object pronoun before a gerund.



Answer




The basic "rule" is that formal written English prefers the possessive in all circumstances, while informal, conversational speech prefers the objective. Generally, the more formal the register, the more likely it is that the possessive will be used. However




  • Formal English is becoming less rigid. It now tolerates the objective in many circumstances—for instance, a transitive gerund clause which acts as the complement of a matrix verb, as in snailplane's example:



    Do you mind me asking a question?





  • Likewise, the possessive is hardly rare in informal English; it is particularly frequent when the gerund clause is the first constituent in a matrix clause:




    My kids KNEW their dad as they had lived with him and me until the separation... but, his leaving like that was tough on them. —from CafeMom, a meeting place for moms.



    What seems to govern colloquial use is the syntax; a gerund which plays a particularly ‘un-verbish’ and ‘noun-y’ role is more likely to take the possessive.


    So although some dogmatic ‘descriptivists’ claim that the possessive sounds ‘stilted’, in my experience this isn’t true; colloquial English tolerates a wide variety of usages.




Under the circumstances, I would advise you to stick to the possessive, particularly if you are in school or are in a field which demands a lot of formal writing. It’s easier to make a habit of using just one form instead of trying to juggle two; and the possessive will never get you into trouble.


grammar - what is the difference between " when it rains" and "when it is going to rain"




  1. I will buy an umbrella when it rains.





  2. I will buy an umbrella when it is going to rain.




What is the difference between the first one and the second one?


Besides, can I change it to "when it is raining" in the first sentence?


Thanks a lot!




unity - 2D Spaceship Thruster Movement - Turning


I have a spacecraft (shown in the image) built out of ‘blocks’ / 3D planes. It is drawn within a 3D space, but I’m ignoring the Y axis for now and keeping things on a “2D” XZ axis.


Top-down view of spaceship


The ship has a number of thruster blocks (represented in blue); each of which should fire depending on user input (does the user want to go forward? or turn left? etc).


Although the image doesn’t show it, each thruster is oriented in a logical direction; i.e the thrusters labelled A & E point left, B & F point right, thrusters G & H point down, thrusters C & D point up.


Thrusters are placed arbitrarily around the ship. There is no actual 'Thruster A' or 'Thruster B'; I'm just using the spacecraft in the above image as an example.


I already have the following which works for forward/backward thrust and strafing (in pseudo code):


foreach(thruster in ship.thrusters) {

// Forward thrust

if(keyPressed W) && thruster.direction == ShipLocalSOUTH) {

thruster.fire();
}

// Backward thrust
if(keyPressed S) && thruster.direction == ShipLocalNORTH) {

thruster.fire();
}


// Strafe Left
if(keyPressed Q) && thruster.direction == ShipLocalEAST) {

thruster.fire();
}

// Strafe right
if(keyPressed E) && thruster.direction == ShipLocalWEST) {


thruster.fire();
}

// Turn left
if(keyPressed A && ??) {

// ??
}

// Turn right

if(keyPressed D && ??) {

//??
}
}

class Thruster {

private thrusterPower = 10;


public void fire() {

shipRigidbody.AddForceAtPosition (thruster.transform.forward * thrusterPower, thruster.transform.position);
}
}

My problem lies in determining which thrusters to fire to turn the ship.


I’ve done a lot of googling on this and have found quite a lot of info already. I.e:


Using Torque and Thrusters to Move and Rotate a Player-Designed Spaceship


However my maths/trig skills are - to be blunt - crap and so I’m hoping to get a somewhat simpler explanation or even some code to help me understand and solve this problem. I'm not aiming for superbly accurate physics, just something that is fun to play.




Answer



If you know the center, you have to find out if the thruster is above or below and left or right of your center.


public class Thruster : MonoBehaviour {

public Transform center;
public ThrusterType type;

public bool IsBelowCenterAxis {
get {
return transform.localPosition.z
}
}

public bool IsLeftOfCenterAxis {
get {
return transform.localPosition.x }
}

public bool IsAboveCenterAxis {

get {
return transform.localPosition.z>center.localPosition.z;
}
}

public bool IsRightOfCenterAxis {
get {
return transform.localPosition.x>center.localPosition.x;
}
}


public void fire() {

}

}

and then :


if(Input.GetKey(KeyCode.A) && 
((thruster.type == ThrusterType.LEFT && thruster.IsBelowCenterAxis) ||

(thruster.type == ThrusterType.RIGHT && thruster.IsAboveCenterAxis) ||
(thruster.type == ThrusterType.UP && thruster.IsLeftOfCenterAxis) ||
(thruster.type == ThrusterType.DOWN && thruster.IsRightOfCenterAxis))) {

thruster.fire();
}

if(Input.GetKey(KeyCode.D) &&
((thruster.type == ThrusterType.RIGHT && thruster.IsBelowCenterAxis) ||
(thruster.type == ThrusterType.LEFT && thruster.IsAboveCenterAxis) ||

(thruster.type == ThrusterType.DOWN && thruster.IsLeftOfCenterAxis) ||
(thruster.type == ThrusterType.UP && thruster.IsRightOfCenterAxis))) {

thruster.fire();
}

Now you just need to know the force with which to fire, but that's a different question.


algorithm - Procedural... house with rooms generator



I've been looking at some algorithms and articles about procedurally generating a dungeon. The problem is, I'm trying to generate a house with rooms, and they don't seem to fit my requirements.


For one, dungeons have corridors, where houses have halls. And while initially they might seem the same, a hall is nothing more than the area that isn't a room, whereas a corridor is specifically designed to connect one area to another.


Another important difference with a house is that you have a specific width and height, and you have to fill the entire thing with rooms and halls, whereas with a dungeon, there is empty space.


I think halls in a house is something in between a dungeon corridor (gets you to other rooms) and an empty space in the dungeon (it's not explicitly defined in code).


More specifically, the requirements are:



  • There is a set of predefined rooms
    I cannot create walls and doors on the fly.

  • Rooms can be rotated but not resized
    Again, because I have a predefined set of rooms, I can only rotate them, not resize them.


  • The house dimensions are set and has to be entirely filled with rooms (or halls)
    I.e. I want to fill a 14x20 house with the available rooms making sure there is no empty space.


Here are some images to make this a little more clear:


Typical dungeon generator Dungeon with no corridors House generator result


As you can see, in the house, the "empty space" is still walkable and it gets you from one room to another.


So, having said all this, maybe a house is just a really really tightly packed dungeon with corridors. Or it's something easier than a dungeon. Maybe there is something out there and I haven't found it because I don't really know what to search for.


This is where I'd like your help: could you give me pointers on how to design this algorithm? Any thoughts on what steps it will take? If you have created a dungeon generator, how would you modify it to fit my requirements? You can be as specific or as generic as you like. I'm looking to pick your brains, really.



Answer



So, here is how I solved this problem. But first, I'd like to thank both @Shadows In Rain and @egarcia for their answers. They gave me a good direction which helped me get some results.



I used Shadows In Rain's space partitioning to generate a basic house and then followed egarcia's advice to fill in the area with rooms.


The space partitioning was pretty straightforward since 90% of the code was done by Shadows. The "fill in the rooms" part was a little more challenging. I decided to use a pseudo AI Planning system that uses A* to position the rooms appropriately. The good thing about using planning instead of just A* is that the preconditions help cut down the search space significantly.


Here are some screenshots with the results:


Floor plan generation phase Floor plan generation phase


Room placement phase Room placement phase


Now with connecting doors!
Now with connecting doors!


2d - How to correctly implement player acceleration caused by player input


In my game I implement movement in the Player class like so:


// called from Player's update() method, which is called from the gameloop.
void move(){
velocity.x += acceleration.x;
velocity.y += acceleration.y;
position.x += velocity.x;

position.y += velocity.y;
}

Keyboard input affects the acceleration directly, for example:


// in Player, called from main gameloop.
void update(){
if(playerInput.rightPressed()) (acceleration.x += 2);
// .. etc
move();
}


I think so far this is standard (if not, please say so).


Now my question:


During movement invoked by player input, I want the acceleration to be constant. So when the player presses the right arrow key, the acceleration.x will always be 2 - and not 2, and then 4, and then 6, etc.


I could easily acheive this be having if(playerInput.rightPressed())(acceleration.x = 2), but then other forces acting on the entity will be ignored.


What is the standard way to implement this?




Is there any difference in pronunciation between the words "fiancé (a male)" and "fiancée (a female)"?


I see no difference between transcriptions above-mentioned words, and what words / variants would be better to use in those meanings?



  • fiancé /fɪˈɑːnseɪ/ /fɪˈɒnseɪ/ /fɪˈɒ̃seɪ/ - ODO

  • fiancée /fɪˈɒnseɪ/ /fɪˈɑːnseɪ/ /fɪˈɒ̃seɪ/ - ODO





Thursday, March 29, 2018

meaning in context - Using "please" when assigning tasks


As a manager I frequently have to assign tasks to my subordinates. I often waver between:




  1. "Can you please do X"



and





  1. "Can you do X"



I don't have a good feeling for what the difference is, however someone pointed out to me that #1 might sound condescending which is not my intention at all.


The top rated answer in this previous question seems to corroborate my impression even though the context is ambiguous.


Ultimately, what I'm trying to achieve is be polite and respectful when delegating tasks. Perhaps I should be using different phrasing?



Answer



Students need to be very careful about where they put the word please. This is even more important when they are writing. (When you are writing, no-one can see your friendly smile. They can't hear your tone of voice either). If you put it in the wrong place, and people misread your tone of voice, it can cause a lot of problems, and probably neither you nor the person you're talking to will understand exactly where the problem came from.


Please




  • Could you slice it, please?

  • Please could you slice it?

  • Could you please slice it!


Generally speaking, the natural place for please is at the end of the sentence. When we put it here, it is low pitch and quite quiet. The main musical stress in the sentence will come before the word please. This is the most polite and friendly place to put it. Note that you cannot stress the word please in this position - and if you do you will annoy your listeners.


If you really want to draw attention to your request, or if it is urgent, you can put please at the beginning of the sentence. If you stress the word please here, it will sound as if you are pleading or begging your listener to give you something or do something:



  • Mum please can I have another ice-cream.


If you aren't begging, then be a little careful about putting please at the front of your sentence. If you stress the please, you will sound like a child begging their parents to do something. If you don't stress it, it sounds a bit impersonal. It is a bit business-like, and is not as friendly as putting it at the end. This is probably because it is more difficult for the listener to say 'no' when you put the please at the beginning. This isn't a problem if you are in a business-like situation or, for example, if you are giving instructions to an employee. Putting please at the beginning of your sentence can be a good signal that this is a serious request.



WARNING: be very careful about putting please in the middle of your sentence. When you do this, you have changed the feeling of the sentence completely. If you put please in the post auxiliary verb position, it is more like an order than a request:



  • Would you please be quiet!

  • Can you please give me a hand!

  • Could you please stop!


You can do this, if you want, if you are somebody's parent, or if you have some kind of authority over them. Remember though, that although it may look like a request, this has the function of an order, not a request. It can also sound as if you are annoyed with the person you're speaking to:



  • Would you please slice it. [and why haven't you already done that!]



In terms of politeness and or friendliness, it is more polite and friendly not to use please at all than to put it in this position in the sentence:



  • Could you slice it?


The Original Poster's question


It's a good idea to use please as a matter of habit. But it's a bad idea to always put it in the middle of the sentence. It can really upset people sometimes.


A good business-like place to put it, if your someone's manager, is at the beginning of the sentence. But if you're asking someone to do something as a favour, or perhaps something they may not want to do, or don't normally have to do, it's probably best to put it at the end. If I was in the Original Poster's position, I'd use the end position for normal directions, and the front position for more serious or urgent ones.


Lastly, as StoneyB says in his excellent answer, it's our attitude and tone of voice that matters most in these situations. But still be careful with the position of please, it carries extra meaning.


An anecdote


There was a really friendly student in one of the language schools I used to work for. She was very popular with the students and teachers and when she applied for a job in the Admin office at the school at the end of her course everybody was very happy that she got the job.



After about a month all the teachers hated her. It was very confusing because she still seemed to be being very nice to people when she spoke to them and the students still all really liked her. I'm going to call her Caroline, but that wasn't her real name.


A friend of mine and I realised that the teachers were getting really upset by the notes she was sending them, which used to appear in a sealed envelope stuck in their pigeon holes during their coffee break.


Now Caroline had a lot of administration to do. And she needed to get various bits of information from the teachers, who needed to fill in different forms and registers and stuff like that. Now the teachers were very busy and occasionally they would forget this or that bit of paper and so forth. At other times someone in a different department might need some help or something like that and the Powers That Be would ask her to ask a teacher if they could help. Because Caroline was very busy her notes were always very short. They read a bit like this:



Dear Bob,


Could you please bring your form into the office. I really need to put it into the computer!






Dear Mrs Hall,



Could you please help J.R. tidy the library during the break. We have a function there this afternoon.



These little notes seemed a bit officious and unfriendly, especially as she was about thirty years younger than many of the teachers she was writing to. Of course she actually wanted to sound like this:



Dear Bob,


Could you bring your form into the office, please? I really need to put it into the computer!






Dear Mrs Hall,



Could you help J.R. tidy the library during the break, please? We have a function there this afternoon.



We did help Caroline sort it out, but it took a week or so for the other teachers to come round!


physics - How can I implement rectangle collision response?


I am working on a game in JavaScript and my current implementation of collision uses the shortest distance to push the intersecting object away, which isn't always correct. I've made this diagram of the ideal collision. The red box represents the starting position, the green box represents the proper position and the black box represents the static object it is colliding against. The blue arrow is the velocity vector. With my current implementation, the object would be placed in its final position and pushed out (and in this case it would be pushed left)


Diagram of collision


How can I fix this?



Answer



You can procedurally find out how to do a moving AABB/AABB trace with the formulas on this page.


http://www.realtimerendering.com/intersections.html


Basically those equations will tell you what percentage of your move you should do that frame, which will allow you to place your square at the correct location.



word request - Term for someone who has lost his immediate family


I've come across someone trying to write about a man who lost his wife and child to the 2011 Tohoku earthquake and tsunami. Is there any term like "widower" or "orphan" but for describing someone who has lost his wife and children?


(As far as I'm aware, his parents aren't alive.)



Answer



In obituaries, the terms "survived" and "survivor" are often used. I don't know of a single word to express this, but you could say that he is "the family's only survivor" or "the family is survived by only one member."


meaning - What is humorous about calling people "mortals"?


The following definition of mortal is from Oxford Dictionaries Online:



[humorous] a person contrasted with others regarded as being of higher status or ability



It gives this sentence as an example:



an ambassador had to live in a style which was not expected of lesser mortals




Where is the humorous point of it? I can't see it.



Answer



This sense is a play on the contrast between mortals and immortals (specifically, the gods). By calling ordinary people mortals and contrasting them to someone else (such as ambassadors), the speaker is implying that the "immortals" think they're like the gods.


Wednesday, March 28, 2018

grammar - Can "short of" be used with a specific amount (cash)?


In another question regarding a difference between short on and short of, the answer says the following:



... But this is not always the case. A person can be short on/of money, but lacking a specific amount, someone can only be €10 short or short €10. This construction never uses a preposition.



but is that really true? I can see sentences like "I am short of 10 dollars" quite often.




unity - Why particle effect alway rendered after UI though they have same sorting layer and same sorting order?


Why particle effect alway rendered after UI though they have same sorting layer and same sorting order?
I searched a lot of information about it,every one said that both of effect and UI are controlled by sorting order and sorting layer.If UI's sorting layer is same to effects' and sorting order is bigger then effects', then UI will render after effect and the result is that UI cover effect.
But what they will do if they have the same sorting layer and the same sorting order?I found that effect alway cover UI in this case.I think this is because effect render after UI. But why?
There are some pictures below:
hierawchy picture particle system setting SubCanvas setting
Hope anyone could answer me.Thanks.



Answer



After your question I was curious about why particles system always render in front of the UI when both UI and Particles system are having same sorting layer and sorting order.



So I find out some thing interesting:


Project Hierarchy: same project hierarchy is used for both situations.


enter image description here


Situation # 1: Canvas (Render Mode : Screen space overlay):


screen shot:


enter image description here


Frame debugger: enter image description here


So from frame debugger its clear that if Canvas render mode is Screen space overlay the all of the scene objects are rendered before canvas.







Situation # 2: Canvas (Render Mode : Screen space Camera):


screen shot: enter image description here


Frame debugger: enter image description here


So frame debugger making things clear that canvas is rendered prier then particles if Canvas render mode is Screen space camera.






Summery: As for both of the Canvas and Particles sorting layer was "Default" and sorting Order was "0".


But in screen space camera particles was rendered after canvas so we see prticels in front of the UI.


while in case of the screen space overlay UI was rendered after Particles , so we saw canvas in front of the Particles.


Which means Unity do change rendering order for in different situation. I hope this will clear your confusion.



scene graph - How to avoid game objects accidentally deleting themselves in C++


Let's say my game has a monster that can kamikaze explode on the player. Let's pick a name for this monster at random: a Creeper. So, the Creeper class has a method that looks something like this:


void Creeper::kamikaze() {
EventSystem::postEvent(ENTITY_DEATH, this);

Explosion* e = new Explosion;
e->setLocation(this->location());
this->world->addEntity(e);
}


The events are not queued, they get dispatched immediately. This causes the Creeper object to get deleted somewhere inside the call to postEvent. Something like this:


void World::handleEvent(int type, void* context) {
if(type == ENTITY_DEATH){
Entity* ent = dynamic_cast(context);
removeEntity(ent);
delete ent;
}
}

Because the Creeper object gets deleted while the kamikaze method is still running, it will crash when it tries to access this->location().



One solution is to queue the events into a buffer and dispatch them later. Is that the common solution in C++ games? It feels like a bit of a hack, but that might just be because of my experience with other languages with different memory management practices.


In C++, is there a better general solution to this problem where an object accidentally deletes itself from inside one of its methods?




unity - How do you animate/collide against a tessellated mesh?


Now that I have a implemented tessellation for my mesh, I am trying to understand how I can leverage the generated primitives.


Example:


I have the following track mesh generated procedurally, it consists of quads, in the first picture you can see one of them I am highlighting using the mouse.


enter image description here



In the following picture, the shader applies some tessellation, you can see that now a quad has generated 16 quads.


enter image description here


Question (two-folded):


Now that I have more control points for each of my quad, suppose I want to deform one of them, for instance, to look like the following:


enter image description here




  1. How is one supposed to apply such transformation ?



    • basically, what in terms of code-behind / shader code infrastructure is required to achieve such thing.





  2. How can collisions be checked for against that deformed mesh ?



    • from what I've understood, a mesh collider would be unpractical since it's a heavy operation that just forbids real-time updates





Answer




In general, you should avoid asking two separate questions in one post on StackExchange. I'll focus on your second question as it's the meatier of the two, and give a quick overview of the first:



How is one supposed to apply such transformation?



There are a few places you can do this:




  • Domain Shader



    • interpolate vertex from tesselator using hull information


    • modify vertex position <--- here

    • return tesselated vertex




  • Vertex Shader



    • process input vertex

    • modify position <--- or here

    • transform position to clip space


    • return transformed vertex




  • Geometry Shader



    • process input primitive...

    • write vertex position <--- or even here

    • emit vertex

    • next vertex...


    • output primitive




In any of these marked places, you can replace the position read from the input vertex/buffer or computed from your interpolation function with a new position of your choosing. Typically you'd calculate the new position as a function of the original vertex parameters (eg. looking up a value from a displacement map texture and offsetting the vertex along its normal by the computed distance) along with any other variables you like (eg. time, intensity parameters...)


Check out tutorials on vertex displacement for code examples in your shader dialect of choice.



How can collisions be checked for against that deformed mesh?



Generally speaking, you don't.



Mesh collisions are already expensive, to the extent that games will often use one mesh for visual display, and a separate, lower-detail mesh (or collection of primitives) for collision - even when we're not applying dynamic tesselation to increase the visual detail further.


Wherever you can, I'd recommend making your collision geometry just detailed enough for "plausible" physics behaviour, and keeping it constant.


There are some cases where that's not practical however. Depending on what you need, we'll come up with different solutions. Here are a few examples of the kinds of things we might do:




  • We need objects to follow a dynamically moving surface, like the roiling waves of a dynamically tesselated ocean.


    Here, we'll often attach invisible "floater" objects to the bodies that need buoyancy. These will typically have a simple shape we can work with analytically, like a sphere, and we'll place multiple floaters with different positions/sizes/density to approximate the shape of a ship's hull.


    Each physics step, we can query the depth of each floater below the water's surface by evaluating the same wave height function used in our dynamic tesselation / vertex displacement shader. (So we're not reading back the triangles from the GPU, just performing the same math with the same inputs to get the same result, but for a few point samples instead of the entire water surface mesh) Based on this depth, and possibly a surface normal, we can compute the buoyancy forces to apply to our parent body.


    This method isn't rigidly accurate, but for a fluid surface with some "slosh" it's plausible enough, and very flexible for a variety of collider shapes / configurations and surface behaviours.





  • We need visually-correct collisions specifically for content we're looking at (eg. correct snap-to-surface for content under the cursor, or on-screen character feet, or visible particles bouncing off a surface instead of passing through it)


    Here, we can render the tesselated mesh to a depth texture, and query it to find the exact collision point along a ray from the camera. For content like particles, we can simulate their physics and collisions wholly on the GPU this way to save expensive synchronization & readback to the CPU for collision-handling there.


    The downside is that it works only for stuff the camera sees, and it does not correctly handle physics behind occluder objects. For off-screen objects we can fall back on a simpler collision model that might not capture all the detail, but this is usually forgivable since the errors happen out of sight.




  • We need precise matching between the rendered polygons and logical collisions everywhere (DANGER)!!


    In this case, there's not a lot we can do but duplicate the tesselation & displacement logic CPU-side, and use it to re-generate the collision mesh when it changes. As you say, this is expensive, so we should avoid this wherever possible, and minimize how frequently / how many polygons worth of collision data we update this way. Dividing the mesh into chunks may be one way to do that - localizing updates to just one chunk at a time.





Why is it a bad idea to store methods in Entities and Components? (Along with some other Entity System questions.)


This is a followup to this question, which I answered, but this one tackles with a much more specific subject.



This answer helped me understand Entity Systems even better than the article.


I've read the (yes, the) article about Entity Systems, and it told me the following:


Entities are just an id and an array of components (the articles says that storing entities in components isn't a good way of doing things, but doesn't provide an alternative).
Components are pieces of data, that indicate what can be done with a certain entity.
Systems are the "methods", they perform manipulation of data on entities.


This seems really practical in many situations, but the part about components being just data classes is bothering me. For example, how could I implement my Vector2D class (Position) in an Entity System?


The Vector2D class holds data: x and y coordinates, but it also has methods, which are crucial to its usefulness and distinguish the class from just a two element array. Example methods are: add(), rotate(point, r, angle), substract(), normalize(), and all other standard, useful, and absolutely needed methods that positions (which are instances of the Vector2D class) should have.


If the component was just a data holder, it wouldn't be able to have these methods!


One solution that could probably pop up would be to implement them inside systems, but that seems very counter-intuitive. These methods are things that I want to perform now, have them be complete and ready to use. I don't want to wait for the MovementSystem to read some expensive set of messages that instruct it to perform a calculation on the position of an entity!


And, the article very clearly states that only systems should have any functionality, and the only explanation for that, which I could find, was "to avoid OOP". First of all, I don't understand why should I refrain from using methods in entities and components. The memory overhead is practically the same, and when coupled with systems these should be very easy to implement and combine in interesting ways. The systems, for example, could only provide basic logic to entities/components, which know the implementation themselves. If you ask me - this is basically taking the goodies from both ES and OOP, something that can't be done according to the author of the article, but to me seems like a good practice.



Think about it this way; there are many different types of drawable objects in a game. Plain old images, animations (update(), getCurrentFrame(), etc), combinations of these primitive types, and all of them could simply provide a draw() method to the render system, which then doesn't need to care about how the sprite of an entity is implemented, only about the interface (draw) and the position. And then, I would only need an animation system which would call animation-specific methods that have nothing to do with the rendering.


And just one other thing... Is there really an alternative to arrays when it comes to storing components? I see no other place for components to be stored other than arrays inside an Entity class...


Maybe, this is a better approach: store components as simple properties of entities. For example, a position component would be glued to entity.position.


The only other way would be to have some kind of a strange lookup table inside systems, that references different entities. But that seems very inefficient and more complicated to develop than simply storing components in the entity.



Answer



I think it's totally fine to have simple methods for accessing, updating or manipulating the data in components. I think the functionality that should stay out of components is logical functionality. Utility functions are just fine. Remember, the entity-component system is just a guideline, not strict rules you need to follow. Don't go out of your way to follow them. If you think it makes more sense to do it one way, then do it that way :)


EDIT


To clarify, you're goal is not to avoid OOP. That would be pretty difficult in most of the common languages used these days. You're trying to minimize inheritance, which is a large aspect of OOP, but not required. You want to get rid of the Object->MobileObject->Creature->Bipedal->Human type inheritance.


However, it's OK to have some inheritance! You're dealing with a language that's heavily influenced by inheritance, it's very difficult to not use any of it. For example, you can have a Component class or interface that all your other components extend or implement. Same deal with your System class. This makes things a lot easier. I strongly recommend you take a look at the Artemis framework. It's open source and it has some example projects. Open those things up and see how it works.


For Artemis, entities are stored in an array, simple. However, their components are stored in an array or arrays (separate from the entities). The top level array groups the lower level array by component type. So each component type has its own array. The lower level array is indexed by entity ID. (Now I'm not sure if I'd do it that way, but that's the way it's done here). Artemis reuses entity IDs, so the max entity ID doesn't get larger than your current number of entities, but you can still have sparse arrays if the component is not a frequently used component. Anyway, I won't pick that apart too much. This method for storing entities and their components seems to work. I think it would make a great first pass at implementing your own system.



The entities and components are stored in an separate manager.


The strategy you mention, making entities store their own components (entity.position), is kind of against the entity component theme, but it's totally acceptable if you feel that makes the most sense.


xna - In a semi-infinite procedural (chunk based) map, how do you handle objects larger than a single chunk?


I'll use an example to try and be more specific. Assume this is for a 2D top-down game. Chunks in this are made up of 32x32 tiles.


If procedural buildings were to be generated based on some kind of noise algorithm and a building was typically 3x3 chunks in size, how do you ensure the seed for this map will always produce the same buildings?


Given two adjacent chunks: chunk A and chunk B, what if they both meet the noise algorithm's requirement for being a spawn point for a building?


If they are both far from the player's current view range, it could depend on how the player approaches these chunks as far as which one gets generated first.


My first thought was to only check for buildings every so many chunks, however, I'd also like to have some objects that may span tens of chunks. I don't think this is a proper solution.


Should I simply be using a different type of algorithm to identify where buildings should be able to be spawned at, an ever expanding Voronoi diagram as an example, or is there something else I'm just not considering with how I'm already trying to attempt this? Perhaps I should be handling cross chunk objects on a grander scale (like a collection of 32x32 chunks)?



Thanks!



Answer



First, your generator(s) should definitely be working at the global, world scale and then applied at the chunk scale. You saw that already and it was a great observation. Here are some notes on working with procedurally generated content that will hopefully make sense. I think that you're confusing "Random World" with "Procedural World," and they're related but not the same. What you want is a Procedural World that can be always be the same if you want, or different each time you run.


Noise is not random. Noise output is always the same from the same input parameters. The great thing about noise is that it is 100% repeatable.


You control the input parameters, this is how you come up with different noise fields and the only place randomness occurs!


It's very common for one, single seed to change the base set of numbers and then everything else is based on those. In an example case, the input parameters to the noise would be based on chunk location in global space modified by that global base set. It doesn't matter which chunk gets created first since the chunk is always in the same place and parameters are always the same for the same seed.


Noise does not have to stand alone. You can have one noise controlling your chunks, another noise controlling your building placement, and so on. This allows you to tweak buildings without messing with your terrain. Each of these noise fields can be at different scales, etc...


You can use more than one random number generator. You can seed multiple generators and use each one independently. Random numbers come in a variety of styles depending on what you want from them, it's a deep subject with lots of statistics involved, but something to consider in the future.


In general the idea is that everything your algorithms based on noise create should be 100% repeatable and independent of anything else. Your choice of seed guarantees not that each run will be different, but that each run will be the same until a different seed is chosen.


It is this repeatable behavior combined with working globally and applying locally that will solve your buildings problem.



Tuesday, March 27, 2018

opengl - How do you determine which object/surface the user's pointing at with lwjgl?


Title pretty much says it all. I'm working on a simple 'lets get used to lwjgl' project involving manipulation of a rubik's cube, and I can't figure out how to tell which side/square the user's pointing at.




phrase meaning - Would saying "who is this" in normal tone be rude in an occasion not on the phone?


I am not a native English speaker; I am not sure how to interpret such an event. For example, suppose I approach my friend to say hello; suppose he is together with someone I don't know; suppose this someone says "who is this" in normal tone to us. Then should I assume that this someone is not a friendly one? Or is it just a way to start a conversation popular for young people?


Knowing the underlying implicit rule is not just about I-assuring-myself thing; I do not hope I misuse this phrase to offend someone else unknowingly to myself :).



Answer



This is a fairly nuanced question and warrants a more detailed answer, in my opinion. None of the other answers address passive-aggression. I know this is a lot of information, but I hope it helps some.


Short Answer



  • This is, by definition, not rudeness. It is likely either adherence to traditional norms (expecting an introduction via your friend), introversion (a personality trait), professionalism (a set of social norms specific to the workplace), or passive-aggressive behavior (hostility without confrontation).

  • Try to give people the benefit of the doubt. If you're going to make an assumption, assume the best possible interpretation of an interaction is true until you find reason to do otherwise.

  • Given the above two points: your friend's friend is either old-fashioned (see comments) or an introvert. Either way, I see this as harmless.



Definitions


These are fairly complex concepts; there's no need to read the entire articles. However, if you want to get better at interpreting people's social behavior, you would do well to understand these things on a basic level.



Rudeness


A display of disrespect by not complying with the social norms or etiquette of a group or culture. Rudeness, particularly with respect to speech, is necessarily confrontational at its core.


Passive-aggressive behavior


The indirect expression of hostility, such as through [...] deliberate [...] failure to accomplish requested tasks for which one is (often explicitly) responsible (i.e. social norms)


Introversion


Introversion is the state of being predominantly interested in one's own mental self. Introverts are typically perceived as more reserved or reflective. Some popular psychologists have characterized introverts as people whose energy tends to expand through reflection and dwindle during interaction.




Note that while introversion is not necessarily rude or passive-aggressive, the behaviors of introverted people are often interpreted as such, which is why I've defined all three here. It's perhaps the most difficult of the three to understand.


More Detail


Given the above definitions and what you've described, this does not sound rude to me, as the person in question was not confrontational. It would have been rude to say to you, "What do you want?!", or, "Who's this schmuck?" as those are confrontational.


Turning to your friend and asking for your name could simply be preparation for formalities. If it's in a professional setting, it could simply be the person wanting to address you by your name, know your position/department, or something similar. They wouldn't want to be overly casual with a director or manager, or overly formal with an intern.


If you sensed hostility from the person, passive-aggressive behavior more closely fits the bill in the situation you've described. While it is sadly common among American young people, this is dangerous to assume.


In general, try to give the benefit of the doubt (i.e. take the most positive interpretation in uncertain situations) when meeting new people. I would interpret this as introversion until they display signs of one of the other two descriptions (i.e. rudeness or passive-aggressive). It's quite harsh to judge a person as "unfriendly" in general based on such a short interaction. It depends quite a bit on the context and the person's body language/tone, as others have said. I think you'll know with more certainty which it was once you know the person better.


The "Expected Behavior"


The "proper" thing for this person to do, in modern society, would have been to address you directly with an introduction. Something like:




Hello! I don't believe we've met. I'm CaptainMarvel, and you are?



As pointed out by @StephenR (in the comments), it's more traditional for your friend to make the introduction.


meaning in context - What does "it" refer to in, "Strange as it may seem..."?



I have a sentence below and some say it means "the Sahara" but I doubt it as it doesn't make sense if it does. Does anyone have any idea about it?



Strange as it may seem, the Sahara was once an expanse of grassland supported the kind of animal life associated with the African plains.





mmo - Could this MMORPG project-model work?



This is an extension of my previous question.



Recently I had an idea of making an, as I could describe it, agile open-source player-financial-profitable MMORPG, which has an interesting (from my POV) project and development model.


Agile means that development should be iterative, with world extending every fixed period of time. And maybe even game universe\plot may be based on iterative development.


Open-source means that everybody can participate, but, obviously, I wish to establish some kind of core team. I estimate that about 0,01% of players will contribute. And this is where I want to make the number grow to about 0,1%.


That's third part: player-financial-profitable means that every player that has outgrown some reputation ceiling (level or another kind) could contribute some kind of *thing to the game. I think about things as special items for now, but they could be transformed into anything on later architecture stage. Special items can be obtained without any financial donations, of course, but if one player wish to buy it from another, it should be sold for real money, presented as some special "platinum coins" in the game. Money should be parted between solder and creator of the item.


But there is one rule — the item, that one creates, must be unique. Under unique I mean unique. It should have unique look, unique animation, and, most importantly, unique ability, that was not presented by any other item so far, not just exterminator sword with +10000 damage. And unique ability should be coded and designed uniquely. That means, that if creator player is not a one-person collaboration between designer and programmer, he should appeal to off-site labour, or to the core team itself. Working places are created and everybody is happy.


So, that is the model as I see it now (and I invented it yesterday night). The main question is:


1) Should I even bother? The idea is so ambitious, that could be interpreted as flying in the sky with the help of no wings. And I don't want to spend next ten years of my life (that's the minimum period in which I expect the project to become successful) working on unfortunate from the beginning project.


I have many other questions, but this text already gone too big, so I'll ask only most important:


2) Isn't there some similar game project-model already? I've seen PlaneShift, but they definitely aren't what I'm talking about.


3) Are open-source practices suitable for game development? There are so few good professionals in the field, will they bother to contribute?



4) On how many people should I count on early development stage? Later?


5) How to do all this thing without any reasonable budget?


6) Where do I begin without XP in game development, but with XP in programming per se?


Note to moderators: Please make this community wiki, I don't see my checkbox.



Answer




"Should I even bother?" + "Where do I begin without XP in game development"



Sorry, but the simple answer is No


The long answer is that MMO's are the hardest possible type of game to develop, with open-world titles being the only other thing close to as difficult. They often take teams of several hundred people with a wide range of skills, massive costs in server/back-end investments, and an ludicrously large amount of content.



The development scene is littered with teams filled with people with over a decade of experience in game development who tried and failed to build an MMO. Realtime Worlds being the most recent, and painfully expensive ($100m down the drain for APB) example.


There are some exceptions if you set your sights low enough. Text/webpage based MMO's like Urban Dead or the various projects from Gameforge are in theory, buildable by a single individual or a small group of people. These games are mostly giant databases with a pretty web interface.


This doesn't even address the inherent security issues of a P2P financial economy paired with open source development which is a recipe for extreme direct financial griefing.


Don't be discouraged though


If you really want to learn how to make games that's great, and right now is one of the easiest times in the world to both build games and distribute them to people. You've got the indie channel of XBLA, iPhone app stores, Facebook, Flash portals. All of which are fantastic places to start and don't require you to spend either the time, money, or find the people needed to make a big project.


I encourage you to build games, but start small.


american english - Can relative pronouns be omitted in some regions?



“I guess it was Cal asked Lee.” (Aron, born in California)
. . . . . .
“That’s a smell could raise me out of a concrete grave.” (Adam, born in Connecticut)

(John Steinbeck, East of Eden)



In the ‘it is’ or ‘there is’ constructions, relative pronouns can be omitted, says my Korean grammar book. In this context, is the second sentence an example of regional dialect?



Answer



Deleting a relativizer which stands as the subject of a relative clause is not acceptable in formal English, but it is very common in US spoken English. I believe it is to be found in all US dialects, but there are two different processes at work here, and I am not expert enough to say which governs outside my own region:




  • In the Southern dialects I am natively familiar with (and probably in those Afro-American dialects which have 'descended' from Southern speech) this is often a simple deletion, just like the universally accepted omission of a relativizer which stands for an object of a relative clause. It is not, I think, a 'mistake' or an innovation but a dialect survival from Middle and Early Modern English.





  • There is also a phonological elision so extreme that it is practically indistinguishable from frank syntactic deletion. Function words like relativizers are almost always unstressed, and therefore reduced to a 'weak' form. With the weak form of that—which is far and away the most common spoken relativizer—there is reduction in all three components:



    • The initial /ð/ is dropped.

    • The vowel is reduced to /ᵻ/.

    • The /t/ loses its alveolar articulation and is reduced to the glottal stop which usually accompanies word-terminal voiceless stops.


    But if the the previous syllable ends on a vowel or on a consonant which joins with /t/ in an acceptable syllable coda, the reduced vowel is elided altogether—which reduces that to a single phonetic element, the glottal stop [ʔ]. And [ʔ] is not an English phoneme; it isn't actually 'heard' by native speakers.


    In effect, the word that disappears, phonologically.





word request - When you don't understand a joke right away



In my native language we have lots of ways (some of them very funny) of saying that you, or someone else didn't understand a joke right away. That is, he/she needed some time to figure it out.


I wonder if there's any idiomatic way of expressing that in English.



Answer



The word get is particularly used these days in the context of understanding jokes - and even more particularly in the negative, for not understanding. With no other context...



"I don't get it", "He doesn't get it!", "Don't you get it?", etc.



...are very likely to be assumed to be in reference to a joke that wasn't understood.


enter image description here


Monday, March 26, 2018

tiles - Smoothing edges on procedural terrain


Using perlin noise to create a procedural island for a tile-based game. My map is stored in a 2d array, with each tile having a type (deep water, shallow water, beach, grass, forest, hill, mountain).


What would be the most efficient way to go through my map, after it's generated, and smooth out the edges of the terrain? Using a tileset, we run into issues with a 1x1 tile that sticks out by itself.


island




word request - How can you describe (in AmE) an aggressive guy who tends to fight with people most of the time?


What do you call someone who is an aggressive guy who is always making some kind of trouble which usually leads to a fight? Such a guy tends to turn a small issue into a fight. I found two terms and I was wondering if someone could let me know which one works here in a natural way:






  • He is a trouble.




  • He is a hell-on-wheels.





For me they both work properly, but I didn't find any reference showing that "trouble" works in this sense. Urban dictionary and some other sources somehow refer to the meaning in my question, though not completely.


I would appreciate it if they do not work properly here, someone could let me know what native speakers would call such a person in AmE.



Added: what I need is an AmE informal term.



Answer



The problem with your two suggestions:




  • He is a trouble.

  • He is a hell-on-wheels.



is that we do not use an indefinite article when using these terms. Instead, we could say:





  • He is trouble.

  • He is hell on wheels.



or maybe:




  • He is nothing but trouble.




If you wanted to use a noun with an indefinite article, we might say:




  • He is a troublemaker.





Incidentally, “hell on wheels” is an idiom, so the term needn’t be hyphenated. Also, I’m not sure it fits exactly what you describe in your question. Yes, it is used to describe a person or situation that is difficult to handle, but it doesn’t necessarily imply an argumentative spirit.



unity - Unity3D Joystick Buttons Xbox360 & PS3 have Inconsistent Button Inputs?



I've been browsing through Google and researching button inputs in Unity, and I came across this page. When looking at it I noticed that the B button on the Xbox360 controller is set to Button 1, but Button 1 on the PS3 controller is set to X.
On a side-note, I noticed that BlazBlue: Continuum Shift EXTEND on Steam also has this issue when it comes to button inputs as an Xbox360 Controller inputs exactly as shown and a PS3 controller uses Square for Confirm and X for Cancel.
Does this inconsistency in buttons exist and how can I fix this problem so that A=X, B=O, X=Square, and Y=Triangle for my Windows-distributed game if it does? I guess a more appropriate question would be what the button mappings are for PS3 and Xbox360 formatted controllers?



Answer



Yes, PS3 controllers are a different configuration than the Xbox controllers. XBox maps to XInput while PS3 is proprietary.


If you treat Button 1 on all joysticks as the fire button, then yes it will be inconsistent. The problem gets even worse if you assume the axis's are the same.


Fortunately, you can map them however you want in Unity's Input Manager. Just don't rely on the ordering of buttons. Map the controllers to actions and then you don't need to worry about if the controllers match or not.


On the downside, if you want to support many different controllers that may have varying configurations, then you may be limited by using the input manager. This isn't a problem though until you have 80 mappings or more than 17 different controller devices to support.


Fortunately, most aftermarket controllers are DirectX compatible, meaning they will conform to the xbox configuration.


In the unlikely event you need to support lots of different devices, you might want to look at Unity Custom Input Manager. It's free, and even if you don't need to support so many devices, it's worth investigating. It lets you do some things that the builtin Input Manager won't. Like modifying the mappings at runtime (EG, let the player customize the mappings in-game).



mathematics - Explain this line segment intersection code


I've been reading this article on pathfinding over polygon meshes using line-of-sight, and in the article are several code snippets. One of them, the one I'm trying to understand, is a simple function that determines whether two line segments intersect.


Here is that function from the article (in C#, though that isn't important to me):


public static bool LineSegmentsCross(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
{
float denominator = ((b.X - a.X) * (d.Y - c.Y)) - ((b.Y - a.Y) * (d.X - c.X));

if (denominator == 0)

{
return false;
}

float numerator1 = ((a.Y - c.Y) * (d.X - c.X)) - ((a.X - c.X) * (d.Y - c.Y));

float numerator2 = ((a.Y - c.Y) * (b.X - a.X)) - ((a.X - c.X) * (b.Y - a.Y));

if (numerator1 == 0 || numerator2 == 0)
{

return false;
}

float r = numerator1 / denominator;
float s = numerator2 / denominator;

return (r > 0 && r < 1) && (s > 0 && s < 1);
}

Without any explanation, I assume that the function accepts two line segments, a-b and c-d. I know the first part checks whether the two lines are parallel, in which case they don't intersect. After that, I'm not sure. I suspect the next bit checks whether the two segments are out of range of each other? The code talks about numerators and denominators, so maybe it's dealing with slope comparisons?



In any case, I'd like to understand the math used here for determining line intersections. I know there's an algorithm that this code is following, but I don't know what it is. How does the formula used in the first part determine that the lines are parallel? I know it works, but why does it work? And what does the function do after that? Why?


I'd much rather understand how the code works, and then write my own code from that knowledge, than just blindly copy someone else's code.



Answer



First, the value called denominator is something that you might call the "two-dimensional cross product" of the vectors b - a and d - c. You can see that it corresponds to what would be the z-component of the cross product if these were 3D vectors. The "2D cross product", like the 3D one, represents the (signed) area of the parallelogram spanned by the two vectors. If the two vectors are parallel or antiparallel, the parallelogram squashes down to nothing and its area is zero.


The two numerators are another pair of 2D cross products. In particular, numerator1 is the cross of the vectors d - c and a - c, that is a vector along one line with a vector pointing from that line toward the other line. So this calculates a parallelogram that spans between the two lines.


At this point it's helpful to sit down and draw a few diagrams, but the key thing to realize is that when the two line segments are barely touching—i.e. when they touch only at an endpoint—the parallelogram spanned by d - c and a - c is either squashed down to nothing, or it's equal to the previous parallelogram (the one calculated in denominator). In other words, in these barely-touching cases, numerator1 is either zero or equal to denominator.


It's not too hard to convince yourself, then, that intermediate cases where the line segments intersect somewhere in the middle result in parallelogram areas somewhere between 0 and denominator, or in other words, numerator1 / denominator should be between 0 and 1.


Then numerator2 is calculated the same way, but just swapping segments. It's necessary to check both directions because there are cases where the line segments don't intersect, but one of the two numerator parallelograms is stretched long and thin, so its area gets small and this would be detected as a false intersection if we didn't check both cases.


algorithm - How do I calculate paths for objects with limited acceleration?



For example, say I have a car and a car has a specific minimum turning radius and I want to drive that car from point a to point b, but the car isn't facing point b. How do I compute a path to point b? Being able to specify the orientation at the point b would also be good (say you want to drive to your driveway and then pull in to your garage -- it doesn't do much good if you got to your driveway by driving over your lawn and are facing sideways :)


A pointer to documentation (or even just a name) would be perfectly fine -- I'm having trouble finding anything at all.


In my attempts, they work in simple cases, but fail miserably in situations such as when point b is closer to a than the minimum turning radius.


For example, how would you determine a path similar to this (the bold path):


Just a curved path for illustrative purposes


edit: In my actual problem, there are some simple pathing constraints, but I already have an A* algorithm in place that works, but it allows things to make instantaneous heading changes, so it looks silly seeing a car suddenly make a 90˚ turn on a dime when they get to a turn point.



Answer



I haven't worked through the full equations for this yet, but here's some visuals to help wrap our heads around the problem. It boils down to some geometry:


A car with circles indicating its turning radius. (Car icons via Kenney)


From any given starting point and orientation, we can draw two circles with our minimum turning radius - one on the left, one on the right. These describe the points on the tightest possible start to our path.



We can do the same for any desired end position and orientation. These circles describe the tightest possible end to our path.


Now the problem reduces to finding a path that joins one of the start circles to one of the end circles, kissing each one along its tangent.


(This is assuming we don't need to pathfind around obstacles in-between, which wasn't mentioned in the question. Stormwind's answer gets into how we can use navigation graph information for these types of problems. Once we have the sequence of nodes to pass through, we can apply the method below to each segment of the plan.)


If, for simplicity, we use straight lines, we get something like this:


Diagram showing various paths a car could take.


This gives us the limiting case. Once you've found a path by this method, you can artificially inflate one or both start & end circles to get a less direct but smoother path, up until the point where the two circles kiss.


Computing these paths


Let's work out the cases for one turning direction - say we begin our path by turning right.


The center of our right turning circle is:


startRightCenter = carStart.position + carStart.right * minRadius



Let's call the angle of the straight section of our path (measured from the positive x-axis) pathAngle


If we draw a vector from rightCenter to the point where we leave the turning circle (at which point we must be facing pathAngle), then that vector is...


startOffset = minRadius * (-cos(pathAngle), sin(pathAngle))


That means the point where we leave the circle must be...


departure = startRightCenter + startOffset


The point where we re-enter a turning circle depends on whether we're aiming to end with a left or a right turn:


// To end with a right turn:
reentry = endRightCenter + startOffset

// To end with a left turn: (crossover)

reentry = endLeftCenter - startOffset

Now, if we've done our job right, the line joining departure to reentry ought to be perpendicular to startOffset:


dot(reentry - departure,  startOffset) = 0

And solving this equation will give us the angle(s) at which this is true. (I use a plural here because technically there are two such angles, but one of them involves driving in reverse which is usually not what we want)


Let's substitute the right turn to right turn case as an example:


dot(endRightCenter + startOffset - startRightCenter - startOffset, startOffset) = 0
dot(endRightCenter - startRightCenter, startOffset) = 0
pathAngle = atan2(endRightCenter - startRightCenter)


The crossover case is more complicated - it's the one I haven't worked out all the math for yet. I'll post the answer without for now, in case it's useful to you while I work out the remaining details.


Edit: Destination inside minimum turning radius


It turns out, this method often works out-of-the box even when the destination is closer than our minimum turning distance. At least some part of one of the re-entry circles ends up outside the turn radius, letting us find a viable path as long as we don't mind it getting a bit pretzel-like...


Demonstrating options when path-planning to a close destination.


If we don't like the path we get that way (or if one isn't feasible - I haven't checked every case exhaustively - maybe there are impossible ones), we can always drive straight forward or back until we get a suitable kissing contact between a start & end circle, as diagrammed above.


Sunday, March 25, 2018

past perfect - Why is this correct? "I met you before you had met her."



I met you before you had met her.


I had met you before you met her.



I asked a native speaker from America about these two sentences. He said that they are both grammatically correct, but he prefers the first one. (Though he described them as very busy -- too much information is included.)



I can't understand why the first one is correct -- I use the Past Perfect in the second clause (you had met) despite the fact that it happens after the event from the first clause (I met you). Can you explain this?



Answer



The first and most important thing you need to understand about using the past perfect was expressed by FumbleFingers here.



The guiding principle should be don’t use Past Perfect unless you really have to.



The reason your friend found your sentences ‘busy’ is probably that the word before expresses everything you want the past perfect to express.



I met you before you met her. You could also express this as
I met you and then you met her.




The second thing to understand, about perfect constructions in general, is that a perfect construction does not narrate a prior event, it expresses a current state which exists as a consequence of the prior event. For instance:



We arrived at the cave, only to find that the mouth was blocked by six feet of sand. Luckily, I had packed a shovel, so we were able to clear an entrance.



That is, the past perfect expresses the fact that when you arrived you had a shovel in your possession, because earlier you had packed one. In cinematic terms, it's not a ‘flashback’, a jump backward in time, but a sort of temporal ‘pull out’—the ‘camera’ backs up so the field of vision brings the past into view, but it remains as it were focused on the point at which you discovered the sand.


Consequently, the past perfect should be used only when your narrative has defined a specific point in time (the technical term is Reference Time) at which the state established by the prior event becomes relevant. This is not the case with your two sentences:



I met you before you had met her. ... there is no Reference Time after their meeting to which the past perfect is related.
I had met you before you met her. ... This is closer to working, but it still does not define a time at which your earlier acquaintance became relevant. This might be established (and usually would be) by further context:




I met her—it was the first time the three of us were together—at that dinner at Spiro's. The two of you were just becoming a thing, but I had met you long before you met her, so you and I were more relaxed with each other. I think that bothered her, and is why she still resents me.




meaning - What does "in a nut shell" mean in this context?


I know what a nut shell is:


a walnut shell


But what is its meaning in this sentence:



In a nut shell I'm trapped mentally and physically.




In this a common expression? Does it mean that he's closed in himself?



Answer



This is quite a common expression. This is similar to saying ... in short... But I understand that the confusion is due to nut shell and trap. He's not trapped into the nutshell!


TheFreeDictionary has an entry for that and it is an idiomatic way to say that.



in a nutshell - In a few words; concisely



So, he's not fitting himself into that little space but comprising the matter that might fit well into it! :) Said that, he's telling something in short without adding much explanation.


It's often used when you don't want to get into a long description or explanation.



grammaticality - Should I use part participle form of every verb that follow "would have"?


I wrote a sentence on my own jokingly.



How cool would it be, if I could have infiltrated the Kremlin, steal the Tsar's throne and return to my peaceful home unharmed



Regarding that sentence my friend told me, it would have been grammatical if I wrote it in the following way



How cool would it be, if I could have infiltrated the Kremlin, stolen the Tsar's throne and returned to my peaceful home unharmed




The BOLD parts are changed in the last sentence. The reason he told me was that the could have part should be followed by past participle form of every verbs. So as I had written "could have infiltrated", I should have used stolen and returned for the same reason. Is it true?


To me, if I could have infiltrated the Kremlin, I am like gone to the fictional time and now what I was about to do is like happening in the present of that time. So I used present tense.



Answer



Look at it this way:



How cool would it be if I could have infiltrated the Kremlin! (what you already had)


How cool would it be if I could have stolen the Tsar's throne!


How cool would it be if I could have returned home!



The 'present tense' alternatives are wrong:




How cool would it be if I could have infiltrate the Kremlin!*


How cool would it be if I could have steal the throne!*


How cool would it be if I could have return home!*



As you see, the real problem is that "could have" is part of the verb phrase of infiltrate, and of steal, and of return.


Compare:


I had heard and seen him (correct).


I had heard and saw him* (incorrect).


I had heard him, but now I saw him (correct).



Saturday, March 24, 2018

libgdx - How do I properly load maps?


I'm trying to load my map properly, but it takes some time (after the games has been started) to be how it should. Am I doing something wrong? Why is this happening?


AndroidStudio: AndroidStudio


Tiled (map editor): Tiled (map editor)



public class GameScreen extends Screen{
private TmxMapLoader maploader;
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;

public GameScreen(Game game){
maploader = new TmxMapLoader();
map = maploader.load("level1.tmx");
renderer = new OrthogonalTiledMapRenderer(map, 1);


sentence construction - Grammar issues need help


Can you tell me?




"I saw you close the door."
"I saw you closing the door."



These two are correct, but:



"I saw you were closing the door."



Is this one correct?




capitalization - Is the name of a disease considered a proper noun?



I've never really thought about it before now, but is the name of a disease considered a proper noun, and thus, should the first letters be capitalized?


For example: Would it be "celiac disease" or "Celiac Disease"? I've seen it capitalized in some places and not in others.



Answer



No, disease names are not proper nouns, although diseases named after people keep the capitalization of the person's name (Münchausen syndrome). The scientific (Latin) names of disease-causing organisms follow the standard rule of Genus species.


If you've seen "Celiac Disease", it's just because of an unfortunate tendency some People have to capitalize Random Nouns as if English were half German.


Adjective or verb?


Participles can be used both as verbs and adjectives. But I get confused sometimes and struggle to understand the role the participles play in a given sentence, like this one:



The man, who was robbed, went to the King and pleaded for help.




Is robbed an adjective or a verb in this context?




2d - Algorithm for randomly generating reachable platforms


I want to randomly generate reachable platforms on the fly for a 2D game. Right now, I am just creating platforms at random x,y positions. Only 4 platforms can exist at once, so once the 5th one is generated the 1st one is removed (fifo).


So, I want to ensure that the player can jump from his current platform to at least one other at any given time.


I was thinking of using some variant of the distance formula to calculate the location of the next platform being generated. I was hoping someone could help me out with the formula for calculating the next platforms possible x,y positions.


The player variables I am assuming will be important are speedX, speedY, and gravity.


From here, I should be able to calculate the maximum distance to plug into the distance formula.



enter image description here


However, I am thinking that some variation of the distance formula that contains a variable for slope would be better in my case.


I want to ensure that the player will never get stuck on a platform with no where it can jump. Also, I want to ensure that platforms aren't generated on top of each other.


Formulas/images/code are a huge plus.


Here is how jumping is currently working.


Field speedY:Float = 4
Field GRAVITY:Float = .05

Method Update:Void()
If KeyDown(KEY_SPACE) And not jumping Then

dy=-speedY
jumping = true
EndIf


If jumping
dy += GRAVITY
local tempY:Float = y + dy
y = tempy
Endif

End Method

Edit: I now understand that the formula is just the displacement of basic projectile motion. enter image description here


enter image description here


Except, in my case, we don't care about cos/sin because the angle will always be the same.



Answer



New Answer: Lets look at the image. The player (represented by a circle) can jump to the left or to the right. What makes the difference is how much time passes since the moment the play jumps until the moments she lands on another platform.


player jump


If we randomize a direction, either left or right and a value for time t than we can place a platform in that direction in the correct position.


let:



g = Gravity
vx, vy = speedX, speedY
x, y = currentX, currentY // either on the left or the right side of the platform

The equation is:


ypos = (g * t^2) / 2 + vy * t + y
xpos = vx * t + x

Again, all you need to do is randomize a value for t and compute the new position. Remember that ought to keep it small enough so the new platform is within the screen.


Old Answer: The general idea is checking how much distance you can cover on x-axis before reaching a certain y altitude (on the way down) that is too low for the platform you want to jump onto.



First, anything within the x0, x1 bounds of the platform the player is standing on is reachable if it is bellow maximal jump height. If you are using gravity as a simple acceleration downwards then the time it takes a player to reach the peak of his jump is:


t = speedY / GRAVITY


This means the player will reach:


OrigY + t * speedY / 2 at her peak (where OrigY is the altitude you jump from). This also means you can have a shot at reaching any platform that is that high if it's t * speedX units away on x-axis.


To figure out the equation for lower platforms maximal distance on x-axis, you need to remeber you can cover about t * speedX by the time you reach your maximal jump height and then begin to fall (GRAVITY takes over). Reaching a certain y that is delta bellow your max height will take:


(gt'^2)/2 = delta
t'^2 = (2 * delta) / g
t' = sqrt(2 * delta / g)

So if a point is delta bellow max height, it can be reached if it is less than (t + t') * speedX units away. The equation is:



speedX * ((speedY / GRAVITY) + sqrt(2 * delta / GRAVITY))

This is of course a "best pixel perfect jump ever" approximation. You may want to give the player a better chance by reducing her speedY and speedX to 80% or 90% when you compute. Also, it does not take into consideration the possibility of blocking platforms.


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...