[QUOTE=AlienCat;37408126]Okay I tried something simpler. I do this in the input manager:
code
And then at least I rotate the world:
[code]GL11.glLoadIdentity();
GL11.glRotatef(cameraComponent.getXRot(), 0.0f, 1.0f, 0.0f);
GL11.glRotatef(cameraComponent.getYRot(), 1.0f, 0.0f, 0.0f);[/code]
While this work, the rotation seem very odd, it is hard to describe but the yrotation depends on xrotation while I think that in a FPS game the different rotations occur independently.[/QUOTE]
I believe the thing you're trying to describe is [url=http://en.wikipedia.org/wiki/Gimbal_lock]gimbal lock[/url]
In case you want some 'rather' simple FPS camera style source code to look at, take a look at mine [url=http://pastebin.com/FbQuGdvi]here[/url]
does c++ automatically wrap text? the reason i am asking is because i am trying to convert python code to c++ for a trivia game. Since python doesn't wrap text automatically
[QUOTE=confinedUser;37411578]does c++ automatically wrap text? the reason i am asking is because i am trying to convert python code to c++ for a trivia game. Since python doesn't wrap text automatically[/QUOTE]
How do you mean?
[QUOTE=Richy19;37411678]How do you mean?[/QUOTE]
i'm converting a trivia game that was made in python from a book to c++, however in the python book it says python does not automatically wrap text. I'm trying to make sure c++ automatically wraps text to fit inside the console window
[editline]26th August 2012[/editline]
the program uses a normal text file that contains the questions and answers in it and prints it in the console. instead of hard coding the questions and answers in the program
[QUOTE=confinedUser;37411730]i'm converting a trivia game that was made in python from a book to c++, however in the python book it says python does not automatically wrap text. I'm trying to make sure c++ automatically wraps text to fit inside the console window
[editline]26th August 2012[/editline]
the program uses a normal text file that contains the questions and answers in it and prints it in the console. instead of hard coding the questions and answers in the program[/QUOTE]
Oh, yea I think it does, but then python does as well(atleast python 3 does)
Why not just make a quick test?
ok, tonight isn't a good night for me to program, i didn't take my multi-vitamin which the end results of incoherent thinking.
[QUOTE=Capsup;37408326]I believe the thing you're trying to describe is [url=http://en.wikipedia.org/wiki/Gimbal_lock]gimbal lock[/url]
In case you want some 'rather' simple FPS camera style source code to look at, take a look at mine [url=http://pastebin.com/FbQuGdvi]here[/url][/QUOTE]
No, as I understand, gimbal lock is impossible to get if you only can rotate in two axes.
i have created a grading system program, i have a switch but it seems to be a piece of shit that doesn't work I'd rather use arrays for this but i have to learn switches. Why do they even exist.
[QUOTE=confinedUser;37414195]i have created a grading system program, i have a switch but it seems to be a piece of shit that doesn't work I'd rather use arrays for this but i have to learn switches. Why do they even exist.[/QUOTE]
Switches are basically if-else if-else blocks that can (in certain cases) be quicker than a giant if-else if-else block. For example:
[code]int num = DoSomething();
switch (num)
{
case 0:
DoSomethingWith0();
break;
case 1:
DoSomethingWith1();
break;
case 2:
case 3:
DoSomethingWith2Or3();
break;
}[/code]
vs.
[code]int num = DoSomething();
if (num == 0)
{
DoSomethingWith0();
}
else if (num == 1)
{
DoSomethingWith1();
}
else if (num == 2 || num == 3)
{
DoSomethingWith2or3();
}[/code]
The switch statement can (in this case) be optimized into a jump table which has an O(1) lookup time where the if-else if-else block always has an O(n) lookup time. Also I find them easier to read when there are a ton of potential values.
thanks that helped a lot
I want to implement a type of frustrum culling, for it I wish to use this method [url]https://sites.google.com/site/letsmakeavoxelengine/home/frustum-culling[/url]
However im not sure how to calculate the plane values
So the planes should be like the pyramid on the left(tho the top plane woulndt be so big):
[quote][IMG]http://etc.usf.edu/clipart/42800/42825/frust-quad14_42825_lg.gif[/IMG][/quote]
And you would basically look down on it, so these are the values I currntly have access to:
[cpp]
glm::mat4 cameraMatrix;
glm::vec3 pos;
glm::vec3 lookAt;
glm::vec3 up;
float near, far;
float aspectRatio;
float fov;
[/cpp]
so if your looking farward I imagine the close plane would be:
[cpp]
pos + ( -0.1f, 0.1f, zNear) <-- top left
pos + ( -0.1f, -0.1f, zNear) <-- bottom left
pos + ( 0.1f, -0.1f, zNear) <-- bottom right
pos + ( 0.1f, 0.1f, zNear) <-- top right
[/cpp]
So using trig I can work out the value of the far plane and from there the value of all planes:
however this is only if you are facing straight ahead, what if your at an angle? I imagine you apply a rotationn matrix to the points of the plane?
[IMG]http://i.imgur.com/b1TXi.png[/IMG]
I have a bunch of points I need to export into some sort of voxel file format for visualization. Which format do you recommend and how exactly do I write it? I've read the documentation of the .binbox file format but I'm a huge retard.
EDIT: Oh, nevermind, I'll just export everything to POVray boxes :v:
I'm starting with C# forms and I am making 4 or so text boxes that I want to have a "default" value (what the textbox is for) and then once it's clicked that goes away. That's simple. Though with 4 of them, I don't want to create 2 event handlers (lost focus, got focus) for each textbox. I thought about sending all the events to two handlers, one for lost and another for got focus. I'm not sure how to go about getting which control lost/got focus. How would I do this?
More information:
[img]https://dl.dropbox.com/u/1439918/Pics/2012-08-26_17-24-19.png[/img] (not focused)
[img]https://dl.dropbox.com/u/1439918/Pics/2012-08-26_17-25-39.png[/img] (not focused with text in it)
[code]this.textBox3.GotFocus += new System.EventHandler(this.textBox_GotFocus);
this.textBox3.LostFocus += new System.EventHandler(this.textBox_LostFocus);[/code]
But I'm not sure what to do in here:
[code]private void textBox_GotFocus(object sender, EventArgs e)
{
}[/code]
[QUOTE=TehWhale;37419657]I'm starting with C# forms and I am making 4 or so text boxes that I want to have a "default" value (what the textbox is for) and then once it's clicked that goes away. That's simple. Though with 4 of them, I don't want to create 2 event handlers (lost focus, got focus) for each textbox. I thought about sending all the events to two handlers, one for lost and another for got focus. I'm not sure how to go about getting which control lost/got focus. How would I do this?
More information:
[img]https://dl.dropbox.com/u/1439918/Pics/2012-08-26_17-24-19.png[/img] (not focused)
[img]https://dl.dropbox.com/u/1439918/Pics/2012-08-26_17-25-39.png[/img] (not focused with text in it)
[code]this.textBox3.GotFocus += new System.EventHandler(this.textBox_GotFocus);
this.textBox3.LostFocus += new System.EventHandler(this.textBox_LostFocus);[/code]
But I'm not sure what to do in here:
[code]private void textBox_GotFocus(object sender, EventArgs e)
{
}[/code][/QUOTE]
When the textbox is focused and its text is the default text, clear it. When the textbox is blurred (loses focus) and the text is blank, fill in the default text.
I fixed my FPS camera not moving however i now have a new problem.
I posted it on the OTK forum first so I will just quote it if thats ok.
[quote]
I was trying to achieve a FPS style camera following this tutorial: [url]http://www.opengl-tutorial.org/beginners-tutorials/tutorial-6-keyboard-and-mouse/[/url] which I have used previously in c++ and it worked flawlessly, however after converting it to c# and getting the following code:
[csharp]
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using OpenTKGaem.GLUtilities;
namespace OpenTKGaem
{
public class DirectionalCamera
{
public static DirectionalCamera dc = new DirectionalCamera ();
Matrix4 View;
Matrix4 Persp;
Vector3 position;
Vector3 up = new Vector3 (0.0f, 1.0f, 0.0f);
float horizontalAngle = (float)Math.PI;
float verticalAngle = 0.0f;
float initialFoV = OpenTK.MathHelper.PiOver4;
float speed = 3.0f;
float mouseSpeed = 0.005f;
public DirectionalCamera ()
{
}
public void Init ()
{
position = new Vector3(0f ,0.0f, 10.0f);
View = Matrix4.LookAt (position, Vector3.Zero, up);
Persp = Matrix4.CreatePerspectiveFieldOfView (initialFoV, (float)Settings.width / Settings.height,
0.1f, 100.0f);
}
public void Update (float dt)
{
Vector2 hSS = new Vector2 (Settings.width / 2, Settings.height / 2);
Vector2 mouseP = new Vector2 (((int)Game.g.Mouse.X), ((int)Game.g.Mouse.Y));
Mouse.SetPosition (Game.g.X + hSS.X ,Game.g.Y + hSS.Y);
horizontalAngle += mouseSpeed * (float)dt * (hSS.X - mouseP.X);
verticalAngle += mouseSpeed * (float)dt * (hSS.Y - mouseP.Y);
Vector3 direction = new Vector3 (
(float)(Math.Cos (verticalAngle) * Math.Sin (horizontalAngle)),
(float)(Math.Sin (verticalAngle)),
(float)(Math.Cos (verticalAngle) * Math.Cos (horizontalAngle))
);
Vector3 right = new Vector3 (
(float)(Math.Sin (horizontalAngle - OpenTK.MathHelper.PiOver2)),
0.0f,
(float)(Math.Cos (horizontalAngle - OpenTK.MathHelper.PiOver2))
);
up = Vector3.Cross (right, direction);
Vector3 dts = new Vector3 (dt * speed);
if (Keyboard.GetState ().IsKeyDown (Key.W)) {
position.X += direction.X * dts.X;
position.Y += direction.Y * dts.Y;
position.Z += direction.Z * dts.Z;
}
if (Keyboard.GetState ().IsKeyDown (Key.S)) {
position.X -= direction.X * dts.X;
position.Y -= direction.Y * dts.Y;
position.Z -= direction.Z * dts.Z;
}
if (Keyboard.GetState ().IsKeyDown (Key.D)) {
position.X += right.X * dts.X;
position.Y += right.Y * dts.Y;
position.Z += right.Z * dts.Z;
}
if (Keyboard.GetState ().IsKeyDown (Key.A)) {
position.X -= right.X * dts.X;
position.Y -= right.Y * dts.Y;
position.Z -= right.Z * dts.Z;
}
View = Matrix4.LookAt (position, position + direction, up);
}
public void getMVP (ref Matrix4 MVP)
{
MVP = MVP * View * Persp;
}
public void getVP (out Matrix4 VP)
{
VP = View * Persp;
}
}
}
[/csharp]
It all works but, the lookat keeps moving up
To ilustrate this I have made a video of what happens
[video=youtube;1fBiwOEOlek]http://www.youtube.com/watch?v=1fBiwOEOlek[/video]
Dont know if this is a floating point issue or what
It could just be that im using one of the math functions wrong as im not used to C#/OpenTK as I come from C++/OpenGL/GLM
[/quote]
[QUOTE=Richy19;37423585]I fixed my FPS camera not moving however i now have a new problem.
I posted it on the OTK forum first so I will just quote it if thats ok.[/QUOTE]
Will be honest, too lazy to read your code. But I've done some [url=http://pastebin.com/xMAibp0N]experiments[/url] myself.
[QUOTE=Richy19;37417456]I want to implement a type of frustrum culling, for it I wish to use this method [url]https://sites.google.com/site/letsmakeavoxelengine/home/frustum-culling[/url]
However im not sure how to calculate the plane values
So the planes should be like the pyramid on the left(tho the top plane woulndt be so big):
And you would basically look down on it, so these are the values I currntly have access to:
[cpp]
glm::mat4 cameraMatrix;
glm::vec3 pos;
glm::vec3 lookAt;
glm::vec3 up;
float near, far;
float aspectRatio;
float fov;
[/cpp]
so if your looking farward I imagine the close plane would be:
[cpp]
pos + ( -0.1f, 0.1f, zNear) <-- top left
pos + ( -0.1f, -0.1f, zNear) <-- bottom left
pos + ( 0.1f, -0.1f, zNear) <-- bottom right
pos + ( 0.1f, 0.1f, zNear) <-- top right
[/cpp]
So using trig I can work out the value of the far plane and from there the value of all planes:
however this is only if you are facing straight ahead, what if your at an angle? I imagine you apply a rotationn matrix to the points of the plane?
[IMG]http://i.imgur.com/b1TXi.png[/IMG][/QUOTE]
[cpp]/* With the near plane representing your screen,
* screen_z points "into" the screen,
* screen_x points rightwards on the screen and
* screen_y points upwards on the screen */
vec3 screen_z = normalize(look_at - pos);
vec3 screen_x = normalize(cross_product(up, screen_z));
vec3 screen_y = normalize(cross_product(screen_x, screen_z));
/* Dimensions of the near and far planes */
float near_width = tan(fov / 2) * near_dist;
float near_height = near_width / aspect_ratio;
float far_width = tan(fov / 2) * far_dist;
float far_height = far_width / aspect_ratio;
vec3 near_x = near_width * screen_x;
vec3 near_y = near_height * screen_y;
/* The absolute middle point of the near plane */
vec3 near_mid = pos + near_dist * screen_z;
/* Calculate the 4 corners of the near plane of the view frustum */
vec3 near_top_left = near_mid - near_x + near_y;
vec3 near_top_right = near_mid + near_x + near_y;
vec3 near_bottom_left = near_mid - near_x - near_y;
vec3 near_bottom_right = near_mid + near_x - near_y;[/cpp]
[editline]27th August 2012[/editline]
Although to do culling, it's sufficient to calculate, for each of the 6 planes of the frustum, the normal of the plane and one point which lies on the plane. You don't need all the 8 corners.
Quick question. What is the format of those videos which play when you hover over them with the mouse on FP. I see them constantly, but now I need to use them myself.
Webm, I think
libvpx for video encoding and libvorbis for audio = webm format.
Miro Video Converter is the easiest program to make them with.
Just started doing Prolog at school. Any tips on how to quickly wrap your head around it.
I seriously feel like a retard when looking at next weeks problem.
[QUOTE=ralle105;37429386]Miro Video Converter is the easiest program to make them with.[/QUOTE]
I prefer VLC. Miro has absolutely no quality settings.
[QUOTE=ShaunOfTheLive;37430580]I prefer VLC. Miro has absolutely no quality settings.[/QUOTE]
Oh cool, didn't know you could do that with VLC.
I'm working on a fraction project for my data structs and algorithms class.
What the fuck is this code doing?
[code]const Fraction fr[] = {Fraction(4, 8), Fraction(-15,21),
Fraction(10), Fraction(12, -3),
Fraction(), Fraction(28, 6), Fraction(0, 12)};[/code]
I'm really confused if it's somehow storing that information in an array, because I have no clue how to set it up so it works with my class file.
[QUOTE=ThePuska;37426727][cpp]/* With the near plane representing your screen,
* screen_z points "into" the screen,
* screen_x points rightwards on the screen and
* screen_y points upwards on the screen */
vec3 screen_z = normalize(look_at - pos);
vec3 screen_x = normalize(cross_product(up, screen_z));
vec3 screen_y = normalize(cross_product(screen_x, screen_z));
/* Dimensions of the near and far planes */
float near_width = tan(fov / 2) * near_dist;
float near_height = near_width / aspect_ratio;
float far_width = tan(fov / 2) * far_dist;
float far_height = far_width / aspect_ratio;
vec3 near_x = near_width * screen_x;
vec3 near_y = near_height * screen_y;
/* The absolute middle point of the near plane */
vec3 near_mid = pos + near_dist * screen_z;
/* Calculate the 4 corners of the near plane of the view frustum */
vec3 near_top_left = near_mid - near_x + near_y;
vec3 near_top_right = near_mid + near_x + near_y;
vec3 near_bottom_left = near_mid - near_x - near_y;
vec3 near_bottom_right = near_mid + near_x - near_y;[/cpp]
[editline]27th August 2012[/editline]
Although to do culling, it's sufficient to calculate, for each of the 6 planes of the frustum, the normal of the plane and one point which lies on the plane. You don't need all the 8 corners.[/QUOTE]
What would be a better way of doing the frustruc culling then?
some user made a little sprite making program a while ago, does anyone know who he was or if there is a download
[QUOTE=DesolateGrun;37432594]some user made a little sprite making program a while ago, does anyone know who he was or if there is a download[/QUOTE]
was it lilkz
How can I divide a java project into multiple folders without actually changing any dependencies?
[QUOTE=DesolateGrun;37432594]some user made a little sprite making program a while ago, does anyone know who he was or if there is a download[/QUOTE]
[URL]https://github.com/Metapyziks/Spryt[/URL]
[URL="http://facepunch.com/showthread.php?t=1202224&p=37078090&viewfull=1#post37078090"]WAYWO Post[/URL]
But he hasn't posted any updates in WAYWO for a while, so I'm not sure of its current status.
Sorry, you need to Log In to post a reply to this thread.