I've been trying to figure out a solution for this math problem. It might be simple, it might be impossible. I don't know because I am still very inexperienced in this domain.
I will be referring to this drawing:
This drawing depicts two rectangles lying on the x-z plane. Think of it like you are looking at them top-down (down the -y axis). The black points (H, I, and J) are given as input. The width of the rectangle is always 4. I need to compute the positions of each green point (A through G).
My Partial Solution:
Computing points D through G is easy:
vec3 forward = normalize(I-J); // direction from J to I
vec3 right = cross(forward, vec3(0,1,0)); // direction from F to G
G = J + (right * 2); // 2 = width/2
F = J - (right * 2);
Hey guys I'm trying to implement a simple ray picker in Opengl. In my little scene I have a green house that I would like to detect when the user clicks it. I am drawing the rays to the screen so I can debug them, so please have a look at these screenshots:
The red lines are the rays I have cast. The places I clicked are in the first screenshot on the outer endpoints of each ray. The problem is this projection to the far plane does not give accurate results if my goal is to determine if the user clicked the house or not. Should I be orthogonally projecting the rays from their origins? What can I do to fix this? Here is my code:
Hey guys I have been following the terrain tutorials on Rastertek.com. I'm on Tutorial #3 http://www.rastertek.com/tertut03.html where he teaches how to add basic lighting to terrain. What I have been doing is following his code examples and putting it into my code base which is basically the same as his but slightly more compact. Right Now I have a terrain class named TerrainComponent.cpp and it handles loading the terrain from a heightmap, creating the pixel and vertex shaders for the terrain, and rendering it.The problem is that my terrain is coming out completely white with no lighting at all! Here is a solid and a wire frame screenshot of my terrain:
Here is the screenshot from Rastertek's tutorial:
The code is a little long so I attached a zip file containing TerrainComponent.cpp and the terrain vertex and pixel shaders. I have compared my code to his for hours and hours and I cannot find what I am doing wrong. Please help!!
I am fairly new to game programming and I am trying to build a simple system where I can construct a road on a plane. I would like to implement a road building tool similar to Cities XL's road tool where you can click and drag the mouse to create curved roads on a terrain.
At this point I know how to get the coordinates of the on the plane according to the mouse click by casting a ray and gathering the result. My first thought is to collect the coordinates and create an array of road models and place them between the mouse clicks, I just don't know how to implement the curve. I googled various curve algorithms but I don't know how to implement them and I don't know if this is the best approach to solving the problem. I'm just looking for advise on how to approach this. Thanks in advance.