OpenGL do stuff when player don't look [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm facing this kind of problem: I would like to do something, when player isn't looking. For instance, like in SCP, move monster towards player. My question is: How can I check if player does see an object?

Assuming the player is in control of the camera. The camera has a front vector. Using that front vector and the normal of the object, in this case the monster, you can find out whether he is looking or not.
You can take the dot product of the object normal and the front vector. If it is negative or equal to 0, the angle is perpendicular and the player can't see the object.

Related

OpenGL - How to track a moving object? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to learn how I can track a moving object in OpenGL. The position of the object will be a continuous input. Also, what if when the object moves out of the screen?
You have to position and orient your camera towards the object. That means you will have to provide the correct View Matrix.
You can use functions such as gluLookAt() to generate a View Matrix that points towards a specific object.
If you don't know what a view matrix is, I suggest looking at this tutorial (http://learnopengl.com). Check out this page which explains cameras matrices work in openGL

State Pattern Design using OOP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
A simple example of how you would structure this would be particularly useful.
This is how I would do it:
MyMotor is an instance of the class Motor. This class has four functions idle(), accelerate(), flat(), decelerate(). (I assume you know how to build a basic class with private members and its constructors)
Then in main(), I create MyMotor and control it based on states. States can be controlled/monitored using Boolean Values. Whatever state I am in and whenever, certain function will be called.
Next time give it a try before you ask here, in order to get better responses.

Calculating a coordinate from 2 given 1-dimensional lines [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What is the and optimal method, if not the best, for doing it?
Assume that I have an object that has 2 wheels. The only information I have available is how far the wheels have rolled at any time.
Basically, I want to know how to calculate the coordinates (x2,y2)
I put this question on the programming section because I want to solve this with an algorithm or plainly put, by programming (in c++).
Given that you have how far the wheels have rolled at any time, it means that you have two functions of time w1(t) w2(t) giving the distance covered by the wheels.
from that you may by derivation get the scalar velocity of each wheel as v1(t) and v2(t).
As your object position is the mean between the position of those two wheels, the velocity of your object is the mean of those two velocities, but the difference of the velocities gives the speed of rotation of the object. So you have essentially a velocity described as a scalar velocity plus a rotation speed.
By integrating that vectorial quantity you may arrive to the current position of your object.
Details must be thought carefully, but the idea I think is that.

C++: what is Mat3f? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I try to solve a task for my studies. We got a little framework in which we are asked to put our solution to. There is a line that I don't understand:
Mat3f R (conf.R);
Part of the task is to multiply matrices. So I guess Mat3f stands for a float matrix. But what stands the number 3 for? And what is the conf.R argument for? What will be the dimensions of the resulting matrix?
Thanks in advance!
The exact meaning of the 3 in Mat3f is library-specific, but a normal games programmer seeing it for the first time would expect Mat3f to be a 3x3 matrix.

OpenGL Translate weird behavior [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm developing an application in java that uses openGL (JOGL) to draw a pyramid. When I try to make a translation on the pyramid in direction X, what I see, is that my pyramid was translated in direction Z also. Same thing happens when I try to translate the pyramid in direction Y. Translation in direction Z seems to work without problems. What causes this behavior?
This behaviour can be caused by many different factors.
You might have:
Set up your camera wrong (very likely)
Made matrix transformations, which you didn't reset using glLoadIdentity or glPushMatrix / glPopMatrix.