False 3D programming without OpenGL - opengl

I'm actually looking after technical solutions to program a study assistant for the game of Go. What annoy me in existing programs is tha fact that the real life perspective of the player's eye looking at a Goban isn't respected.
GlGo exists, but while the number of stones increases, the rendering dramatically slows down due to the number of stones, disabling to possibility to add frames with statistical information on to of the Goban, that would break the real-timeness of the application.
So, my Question is:
Would it be possible to realize an interpolation of a simple 2D Goban to make the board & stones looks-like 3D, but without 3D rendering engine? The board movement would only be along one axis.

Certainly: All you have to do is doing the 3D to 2D transformation. Then simply draw your stones using sprites. If you scale them, you only need a white and a black one.
As for transformation, a simple one could be something like this:
x = left_border + board_x * gridwidth;
y = top_border + board_y * gridwidth / 2;
If you want perspective etc. it's getting a bit more complicated, but in general it shouldn't slow you down significantly unless you're doing something wrong.

Related

Water rendering in opengl [duplicate]

This question already has answers here:
How to render ocean wave using opengl in 3D? [closed]
(2 answers)
Closed 7 years ago.
I have absolutely no idea how to render water sources (ocean, lake, etc). It's like every tutorial I come across assumes I have the basic knowledge in this subject, and therefore speaks abstractly about the issue, but I don't.
My goal is to have a height based water level in my terrain.
I can't find any good article that will help me get started.
The question is quite broad. I'd split it up into separate components and get each working in turn. Hopefully this will help narrow down what those might be, unfortunately I can only offer the higher level discussion you aren't directly after.
The wave simulation (geometry and animation):
A procedural method will give a fixed height for a position and time based on some noise function.
A very basic idea is y = sin(x) + cos(z). Some more elaborate examples are in GPUGems.
Just like in the image, you can render geometry by creating a grid, sampling heights (y) at the grid x,y positions and connecting those points with triangles.
If you explicitly store all the heights in a 2D array, you can create some pretty decent looking waves and ripples. The idea here is to update height based on the neighbouring heights, using a few simple rules. For example, each height moves towards the average neighbouring height but also tends towards the equilibrium height equals zero. For this to work well, heights will need a velocity value to give the water momentum.
I found some examples of this kind of dynamic water here:
height_v[i][j] += ((height_west+ height_east + height_south + height_north)/4 - height[i][j]);
height_v[i][j] *= damping;
height[i][j] += height_v[i][j];
Rendering:
Using alpha transparency is a great first step for water. I'd start here until your simulation is running OK. The primary effect you'll want is reflection, so I'll just cover that. Further on you'll want to scale the reflection value using the Fresnel ratio. You may want an absorption effect (like fog) underwater based on distance (see Beer's law, essentially exp(-distance * density)). Getting really fancy, you might want to render the underneath parts of the water with refraction. But back to reflections...
Probably the simplest way to render a planar reflection is stencil reflections, where you'd draw the scene from underneath the water and use the stencil buffer to only affect pixels where you've previously drawn water.
An example is here.
However, this method doesn't work when you have a bumpy surface and the reflection rays are perturbed.
Rather than render the underwater reflection view directly to the screen, you can render it to a texture. Then you have the colour information for the reflection when you render the water. The tricky part is working out where in the texture to sample after calculating the reflection vector.
An example is here.
This uses textures but just for a perfectly planar reflection.
See also: How do I draw a mirror mirroring something in OpenGL?

How flexible is OpenGL's quadric functionality and transformation matrices?

To give you an idea of where I'm coming from, this started as a teaching exercise to get a 12-year-old video game addict into coding. The 2D games, I did in SDL with him and that was fine because I wasn't planning on going into 3D. Yeah, right! So now I'm in at the deep end in OpenGL and mainly trying to figure out exactly what it can and cannot do. I understand the theory (still working on beziers and nurbs if the truth be told) and could code the whole thing by hand in calculated triangular vertices but I'd hate to spend days on that only to be told that there's a built in function/library that does the whole thing faster and easier.
Quadrics seem to be extremely powerful but not terribly flexible. Consider the human head - roughly speaking a 3x4x3 sphere or a torso as a truncated cone that's taller than it is wide than it is thick. Again, a quadric shape with independent x,y and z radii. Since only one radius is provided, am I right in thinking that I would have to generate it around the origin and then apply a scaling matrix to adjust them? Furthermore, if this is so, am I also correct in thinking that saving the results into a vertex array rather than a frame list results in the system neither knowing or caring how they got there?
Transitions: I'm familiar with the basic transitions but, again, consider the torso. It can achieve, maybe, a 45 degree twist from the hips to the shoulders that is distributed linearly across the entire length or even the sideways lean. This is applied around the Y or Z axis respectively but I've obviously missed something about applying transformations that are based on an independent value. (eg rot = dist x (max_rot/max_dist). Again, I could do this by hand (and will probably have to in order to apply the correct physics) but does OpenGL have this functionality built in somewhere?
Any other areas of research I need to put in would be appreciated in the notes.

A* pathfinding work with big open list

I work on a project which demands to use A* algorithm. In this project you select your player with the left click and you guide him in the map with the right click, like the gameplay of thousand strategy game. The graphics are 2D, a little like the game Don't Starve and the game is developped with SFML / C++.
I need to use A* for the deplacement of the player, indeed if an obstacle appears on his road he has to avoid it. But for the moment, i don't know how to apply a grid to the map, i want to place any tree / rocks and other stuff anywhere in order not to see the grid cells. For now the open list is only composed of pixels, which is not the good solution I think ^^, the algorithm is pretty slow. If you have any solution for a realistic rendering while keeping a fast algorithm I'd be happy to hear it. :)
Thank you in advance,
Do you have a screenshot?
The pathfinding grid, and rendering grid can be different. Zelda used different sized tiles for movement and rendering.
navigation mesh
This may be overkill for your map structure, but you may use a navigation mesh.
,
edit: If you haven't read it, Amit has a great resource: http://theory.stanford.edu/~amitp/GameProgramming/
What you're looking for is discretization. Behind this obscene name stands a simple principle : you can't deal with an infinite amount of data.
You need then to perform a transformation on your world : instead of allowing your character/unit to go at any location (x and y being real numbers), you can divide your world into some sort of a grid (this is what the navigation mesh and waypoints are doing), and only allow your char to go on these cells (or points, you can see it as you want). This is discretising : you are going from continuous values (real coordinates) to discrete values (integer coordinates / point). The more precise you go, the nicer it'll look.
After doing this, assigning moving costs between cells/points is rather simple, and performing A* on it as well.

Polygon at position x,y at time T

I am trying to make polygon A be at position (x,y) at time= 1 sec for example. Then it should be at position (x,y+2) when time = 2 sec. Then I plan to make more polygons like this. I also want this to be animated and the polygon to smoothly move from the first position to the second, not a polygon jumping a round.
Now thus far, I have learned about the glutTimerFunction, however, from my understanding, I cannot individually tell polygons to be at position (x,y) and time T. But rather it seems like I have to make every polygon that i desire(around 500) and then have timer cycle through all the polygons at once.
Is there a way to explicitly tell the polygon to be at position (x,y) at time T using the glutTimerFunc?
OpenGL is a low level API, not an engine or a framework. It has no built-in method for automatically doing interpolation between positions over time, that's up to you as the engine writer to implement as you see fit. Linear interpolation between two points over time is fairly easy (ie, in pseudocode position = startPos + ((endPos - startPos) * timeElapsed). Interpolation along a more complex curve is essentially the same, just the math is a little more involved to represent the desired curve.
You are correct that you must iterate through all of your polygons by hand and position them. This is another feature of using the low level graphics API instead of a pre-written engine.
There are a number of engines of varying complexity (and price) available that abstract away these details for you, however, if your goal is to learn graphics programming I would suggest shying away from them and plowing through.

Collision Detection Techniques to Generate Sloping Planes between two Mesh

I've asked this question both at game SE and math SE, but the response were not so encouraging. So I reasked again, with a bit more of a twist.
I have a terrain, which is defined by mesh. And there are a lot of other polygonal faces scattered throughout the terrain, they can be located above, or below or cutting through the terrain. You can think of those faces as platforms.
A screenshot below should clarify what I mean. Despite looking smooth, all the mesh are actually consist of small elements (number> 10k) combined together, giving the false appearance of smoothness. The obvious disconnected area are platforms.
My question is, how can I generate the planes that connect between the platforms and other platforms/ terrain? Here are the rules to generate the series of sloped planes:
They could go up or down, depending on which direction will make them hit the terrain/neigbouring platform first.
The plane generation rule is that, the plane will start at the edge of a platform, and moving 45 degree upward/downward with respect to z axis for a certain length, then it will move 0 degree with respect to z axis for another certain length, and repeat. So it will be a series of piecemeal planes until at some points of the planes, obstacles are hit.
The algorithm should be focused on plane generation and plane generation alone; I don't want it to be tied to any renderer ( e.g, opengl and whatnot), I can render it myself.
In short, I want to generate a set of "planes" that is actually something like a flight of stairs or a piece of corrugated paper, leading up or down from one point in space until it makes contact with a given mesh
Sounds like a straight forward collision detection problem that are frequent in physics simulation, right? Is there any game/physics libraries that I can use to attack this problem?
Note that since I am not doing any animation, so frame-by-frame update and all those stuffs are not relevant to me; this is why I am hesitant to use existing game physics library like bullet. What is relevant to me is how to use existing libraries to generate those connecting planes according to the above rules.