2d

How to tell if a line intersects a polygon in C#?

可紊 提交于 2019-11-30 09:19:15
I have a question very similar to this: How to know if a line intersects a plane in C#? I am searching for a method (in C#) that tells if a line is intersecting an arbitrary polygon. I think the algorithm by Chris Marasti-Georg was very helpful, but missing the most important method, i.e. line to line intersection. Does anyone know of a line intersection method to complete Chris Marasti-Georg's code or have anything similar? Is there a built-in code for this in C#? This method is for use with the Bing Maps algorithm enhanced with a forbidden area feature. The resulting path must not pass

Flipping a 2D Sprite Animation in Unity 2D

亡梦爱人 提交于 2019-11-30 08:47:16
I've got a quick question regarding 2D Sprite animations that I haven't been able to find specifically answered anywhere: I have a sprite with walk animations to the right. However, I obviously want to flip the animation to the left when he walks left (2D side-scroller). I can easily flip the sprite itself, using transform.localscale.x , however, that only flips the sprite. Not the animation clip. (This no longer happens in Unity) So, while the sprite flips, the minute the animation clip begins playing, it flips back right (as the only animation clip I have is for the right facing sprite). Is

Best way to detect collision between sprites?

最后都变了- 提交于 2019-11-30 07:43:53
问题 Whats the best way to detect collisions in a 2d game sprites? I am currently working in allegro and G++ 回答1: There are a plethora of ways to detect collision detection. The methods you use will be slightly altered if depending on if your using a 2d or 3d environment. Also remember when instituting a collision detection system, to take into account any physics you may want to implement in the game (needed for most descent 3d games) in order to enhance the reality of it. The short version is to

Want an OpenGL 2D example (VC++, draw a rectangle)

非 Y 不嫁゛ 提交于 2019-11-30 05:42:34
问题 I want to create a high performace 2D program. I'm using VC++2008. Suppose I have created the main window. What I want is to draw a red rectangle (top left: 10,20, bottom right: 200, 300) in the main window's client area like what FillRect() API does but using OpenGL. void InitOpenGL(HWND hwnd) { .... // What should I do? // Only for 2D drawing, and the (0,0) should be the top left point. } // the function below will be called in the WM_PAINT handler void DrawRectWithOpenGL(RECT* pRect) { ...

How do I use OpenGL 3.x VBOs to render a dynamic world?

心已入冬 提交于 2019-11-30 04:12:58
Although there seem to be very few up to date references for OpenGL 3.x itself, the actual low level manipulation of OpenGL is relatively straight forward. However I am having serious trouble trying to even conceptualise how one would manipulate VBOs in order to render a dynamic world. Obviously the immediate mode ways of old are non applicable, but from there where do I go? Do I write some kind of scene structure and then convert that to a set of vertices and stream that to the VBO, how would I store translation data? If so how would that look code wise? Basically really unsure how to

Why do 2D transformations need 3x3 matrices?

瘦欲@ 提交于 2019-11-30 03:47:01
I want to do some 2D drawing and thus want to implement some matrix transformations. With my light mathematics background I am trying to understand how to do so in C# (any other oop language would do it obviously). All I read is explaining that we need to work with 3x3 matrices to be able to cope with the translations. Because you cannot make translation with multiplications. But this is with multiplications of the matrices that we create our transformations. So we work with something like: { x1, x2, tx } { y1, y2, ty } { 0, 0, 1 } I understand the mean of the third column, but why do we need

How to draw a Perspective-Correct Grid in 2D

99封情书 提交于 2019-11-30 02:27:55
I have an application that defines a real world rectangle on top of an image/photograph, of course in 2D it may not be a rectangle because you are looking at it from an angle. The problem is, say that the rectangle needs to have grid lines drawn on it, for example if it is 3x5 so I need to draw 2 lines from side 1 to side 3, and 4 lines from side 2 to side 4. As of right now I am breaking up each line into equidistant parts, to get the start and end point of all the grid lines. However the more of an angle the rectangle is on, the more "incorrect" these lines become, as horizontal lines

Simple 2d polygon triangulation

我是研究僧i 提交于 2019-11-30 02:20:44
Trying to triangulate a set of simple 2d polygons , I've come up with this algorithm: 1) For each vertex in the polygon, compute the angle between the two linked edges 2) Sort vertices by decreasing angle relative to the interior of the polygon 3) If there is less than 3 vertices in the set, we're done 4) Take the last vertex in the set and output the triangle formed by it and its two neighbours 5) Remove the vertex from the set 6) Update the angle of the two neighbours 7) Jump to 2 I've tested it, and found it to work even on really big and complicated simple 2d polygon (it don't work for

How to make a smooth camera follow algorithm?

大城市里の小女人 提交于 2019-11-30 01:47:58
I am making a game with LibGDX (Java). I need the camera to follow a fast moving character. The easiest way to do it is to just write this: this.getCamera().position.set(obj.x, obj.y, 0); But, is there any algorithm to make this more smooth? Like when camera is not that strict, and is always a bit late: character goes quick right, camera follows with slight delay, or if you suddenly appeared somewhere far, camera doesn't teleport instantly but travels at a top speed to you when it comes closer it slows down a bit and finds you again. Is there any libgdx libs that do that or anyone had this

Convert 2d images to 3d model [closed]

☆樱花仙子☆ 提交于 2019-11-30 00:40:34
I need to display 3d sculptures in my application, but all I will have initially is 2d images of sculpture from different angles( angle and count of images is under our control) 1. Is there any library which can do that, e.g. take 8 images from all side and stitch it into a 3D model? Any opensource/commercial library/product is ok. 2. Alternatively how difficult it would be to do if I start from scratch? what direction you would take e.g. Simple solution one 3D model is not a strict requirement, but the end result should be that user can rotate the object and see it from different angles so a