I'm starting to code my first game and I want to make simple 2D sprite game. However I want to simulate 3D space & physics and am searching for some tutorial/guide/algorithms that would teach me the basics... but so far without luck.
Do you have any recommendations? Books? I don't care about programming language, any language will do as I can read algorithms in most languages and for start I just want to understand exiting solutions for 3D -> 2D problem.
Thanks!
Edit: I am not so much looking into physics for now as for projecting 3D space onto 2D
This is the best article I've found on subject: http://www.create-games.com/article.asp?id=2138
Another great article: http://pixwiki.bafsoft.com/mags/5/articles/circle/sincos.htm
1980's games systems used parallax techniques to give a feeling of depth with 2D implementations.
If you're talking about the process of rendering a 3D scene as a 2D image (i.e. on a screen), then you'll want to look at perspective projections. It's quite heavy on maths, though, and involves a lot of work with transformation matrices and linear algebra.
You should make sure you're up to scratch on both linear algebra and calculus if you're planning on creating a 3D physics-based game.
If you're doing 2D, you might like to start with simple 2D physics. I'd especially recommend Box2D for that purpose! It's easy to learn and integrate, and it's tutorials will let you on the basics of physics in games.
You don't say what language you're using, but OpenGL and variants of it exist, I believe from internet search, for several common programming environments.
It provides some very powerful tools for creating 3D objects, setting viewports into the virtual 3D space, placing lights, defining textures. It might take a couple weeks of spare time to master, but it certainly spares you doing much of the perspective math you would need to roll your own 3D tools. There are good tutorials on the intenet.
Good luck
Related
Disclaimer: I'm not 100% on whether this is a well-formed question, so please feel free to comment and suggest improvements. I'll be actively looking out for ways to improve this question.
I have a triangle mesh, let's say the Stanford Bunny. Now, I want to raycast a ray from a source point in 3D along a 3D direction vector, and identify just the first intersection of that ray with the triangle mesh.
I already have a naive implementation cooked up. However, I'm looking for a more advanced implementation. In particular, I'll be casting many millions of rays in many directions, so I'm looking for a multi-threaded or GPU-accelerated implementation.
I have to believe that there must be some pretty complete projects online, as raycasting triangle meshes is a fundamental part of 3D computer graphics. However, I can't find anything beyond personal projects, which leads me to believe that I am using the wrong search terms, or something pretty simple along those lines.
I am looking for suggestions on existing tools that can raytrace polygonal meshes.
If all you need to do is find the distance to the mesh for millions of rays. Then it might be a good idea to look up CUDA raytracing tutorial online. This will show you how to cast many millions of rays. In most tutorials, raytracing is used to render to the screen with the camera matrix. However, this is not necessary. Simply adjust the rays starting parameters to what you need them to be such as 3D vector and position. Then output the data back to the CPU. Be weary of the bandwidth between the GPU and CPU sending millions of intersection points between the CPU and GPU can make the program run exceptionally slow.
I was wondering what procedure a simple 3d program uses to draw 2d pixels so that they appear 3d. I'm really interested in this for drawing purposes since if a program can figure out how to use a flat screen to produce images with depth then maybe I could use those techniques in my drawing.
Are there any basic 3d engine out there I can look at? Without any 2d to 3d abstractions?
Two notions may interest you:
The perspective projection, which is the mathematical transformation which takes 3D points (or vertices) and the characteristics of your camera (position, orientation, frustrum, ...) and gives you the 2D projection of the point on your chosen medium (screen).
Wikipedia - 3D Projection
StackOverflow - Transform GPS-Points to Screen-Points with Perspective Projection in Android (I made a detailed answer)
The Painter's algorithm (since you seem to ask for drawing-related techniques), a rendering method which sorts by depth all the elements of your scene after their projection, and draws them on your medium by decreasing depth, to ensure a realistic output ("far objects hidden behind closer ones" - imitating painters method). This algorithm has however some limits (far from efficient in its basic implementation, can't easily deal with elements intersecting or circularly overlapping each others), so most of the days a more efficient method is used, the Z-buffering, which deals with depth conflicts on a pixel-to-pixel basis.
Wikipedia - Painter's algorithm
Wikipedia - Z-buffering
By combining those notions, you can actually implement your own simple 3D engine (in the other StackOverflow thread I'm pointing, I gave a link to an article I made about creating such an engine easily).
If you want to look at more complex engines and notions, you can take a look at the GPU Gems 3 by Nvidia for instance, or look at articles about OpenGL.
Hope it helped, bye !
So, I'm currently developing a puzzle game of sorts, and I came upon something I'm not sure how to approach.
As you can see from the screenshot below, the text on the sides next to the main square is distorted along the diagonal of the quadrilateral. This is because this is not a screenshot of a 3D environment, but rather a 2D environment where the squares have been stretched in such a way that it looks like it's 3D.
I have tried using 3D perspective and changing depths, and while it solves the issue of the distorted sides, I was wondering if it's possible to fix this issue without doing 3D perspectives. Mainly because the current mesh transformation scheme took a while to get to, and converting that to something that works on 3D space is extra effort that might be avoidable.
I have a feeling this is unavoidable, but I'm curious if anyone knows a solution. I'm currently using OpenGL ES 1.
Probably not the answer you wanted, but I'd go with the 3d transformation because it will save you not only this distortion, but will simplify many other things down the road and give you opportunities to do nice effects.
What you are lacking in this scene is "perspective-correct interpolation", which is slightly non-linear, and is done automatically when you provide coordinates with depth information.
It may be possible to emulate it another way (though your options are limited since you do not have shaders available) but they will all likely be less efficient than using the dedicated functionality of your GPU. I recommend that you switch to using 3D coordinates.
Actually, I just found the answer. Turns out there's a Q coordinate which you can use to play around with trapezoidal texture distortion:
texture mapping a trapezoid with a square texture in OpenGL
http://www.xyzw.us/~cass/qcoord/
http://hacksoflife.blogspot.com.au/2008/08/perspective-correct-texturing-in-opengl.html
Looks like it won't be as correct as doing it 3D, but I suppose it will be easier for my use right now.
I have many 3D vectors. I want to plot them in a cube so that each dimension is on a particular side of the cube.
Now, I am looking for some visualization/tool or library that lets me rotate this cube in 3D and see the vectors in various different angles.
Thanks
Abhishek S
Try Processing, it is somewhat intended for data visualization and in addition to simple control over 3D drawing, it also has the full power of Java programming language. You can see numerous works, done by other people on OpenProcessing.
However, if you are into anything serious, I would suggest you to use some ohter IDE than the default one. I use Eclipse for that, importing Processing as a library into my project. It requires a tiny boilerplate to work, but then you're happy!
I've been working on 2D games for a long time now (because 2D is all I know how to do) and want to step it up a notch. I don't want to go fully 3D because I don't think I have the mathematical knowledge to work with 3D graphics, but instead want to start developing some graphics that lie somewhere inbetween.
By inbetween I mean graphics that will still render as 2D, but may have been created using 3D software and then exported at various angles. Some examples of the style could include:
Age of Empires 1.
Diablo 1 & 2.
Starcraft 1.
Is there any software used specifically for creating a 3D model and then generating a 2D sprite-sheet from it? Here is an example of such graphics that may help in making sense:
Blender is free 3D modeling tool, where you can make sprite sheet out of the model. I don't know how to do this but I know it's possible, because my friend is using it for our game (he is making 3D spaceship models and transforming them into 2D sprites)
http://www.blender.org/
I am not aware of such a specialized software, but have you considered simply using a 3d engine with a fixed camera looking at the scene from above and all objects at ground level?
That way you can use regular tools for modeling and still have the logic and (with a few settings to the physics engine) physics of a of a 2D game.
Unity engine might be able to help you.