[QUOTE=Pat.Lithium;44724766]How do I apply a translate matrix to a vector? If I multiply it like my other matrices it just works the same as my scale matrix.[/QUOTE]
It should be by multiplication. You probably set up one of them wrong.
Ah, I see. In your matrix/vector multiplication. You should be multiplying by x, y, z, then w, instead of the same one each time.
[cpp]
Vec4 Mat4::operator*(const Vec4& v) const
{
Vec4 tmp;
tmp.x = (this->data[0] * v.x) + (this->data[4] * v.y) + (this->data[8] * v.z) + (this->data[12] * v.w);
tmp.y = (this->data[1] * v.x) + (this->data[5] * v.y) + (this->data[9] * v.z) + (this->data[13] * v.w);
tmp.z = (this->data[2] * v.x) + (this->data[6] * v.y) + (this->data[10] * v.z) + (this->data[14] * v.w);
tmp.w = (this->data[3] * v.x) + (this->data[7] * v.y) + (this->data[11] * v.z) + (this->data[15] * v.w);
return tmp;
}
[/cpp]
Wow thank you so much. I've got just under 11 hours to submit this assignment and that had my progress stuck.
Would it be a good idea to learn Java through Android development? Has anyone got any good resources? That's where I'd like to go with it.
Oh god it's starting to look possible to finish my assignment before the due date (midnight tonight, 7 and a half hours away). My transformation matrices work, my .obj loader works, all I have to do is fix my program because it isn't drawing the cube and clipping doesn't work (it draws predefined triangles and I can transform them just fine), then it's projection and then I'll have to quickly write up documentation.
[editline]5th May 2014[/editline]
[QUOTE=Foxtrot200;44725831]Would it be a good idea to learn Java through Android development? Has anyone got any good resources? That's where I'd like to go with it.[/QUOTE]
It's good to learn a language through something you're interested in.
[editline]5th May 2014[/editline]
My translate matrix doesn't work on positions equal to 0 (10 * 0 = 0)
Matrix * Vector
[code]Vec4 Mat4::operator*(const Vec4& v) const
{
Vec4 tmp(0, 0, 0, 0, 255, 255, 255, 255);
tmp.x = (this->data[0] * v.x) + (this->data[4] * v.y) + (this->data[8] * v.z) + (this->data[12] * v.w);
tmp.y = (this->data[1] * v.x) + (this->data[5] * v.y) + (this->data[9] * v.z) + (this->data[13] * v.w);
tmp.z = (this->data[2] * v.x) + (this->data[6] * v.y) + (this->data[10] * v.z) + (this->data[14] * v.w);
tmp.w = (this->data[3] * v.x) + (this->data[7] * v.y) + (this->data[11] * v.z) + (this->data[15] * v.w);
return tmp;
}[/code]
Translate Matrix
[code]Mat4 Mat4::translate(float x, float y, float z)
{
Mat4 tmp;
tmp.data[12] = x;
tmp.data[13] = y;
tmp.data[14] = z;
return tmp;
}[/code]
if a Vec4 lies at (0, 0, 0) and I translate it (10, 10, 10) it stays at (0, 0, 0)
[editline]5th May 2014[/editline]
Apart from that it's working pretty okay, even looks like my clipping might be working! (I haven't figured out why it's not drawing scan lines for the triangles).
This is a cube scaled * 100 and rotated 5 degrees on every axis.
[img]http://i.imgur.com/pqSASAm.png[/img]
[QUOTE=Foxtrot200;44725831]Would it be a good idea to learn Java through Android development? Has anyone got any good resources? That's where I'd like to go with it.[/QUOTE]
I'd nail the basics first if I were you by making some simple console based applications with Java on PC. It will help you to understand the language before you impose the structure of Android on it.
Never mind about my questions, my assignment isn't going to be finished before the deadline. Thanks to everyone who helped me get it to where it is, I wouldn't have progressed at all if it weren't for you guys. I'm gonna fix triangle drawing, do documentation and submit what I have.
[QUOTE=Pat.Lithium;44727101]Never mind about my questions, my assignment isn't going to be finished before the deadline. Thanks to everyone who helped me get it to where it is, I wouldn't have progressed at all if it weren't for you guys. I'm gonna fix triangle drawing, do documentation and submit what I have.[/QUOTE]
Your screenshot looks like you have an orthogonal projection matrix with 1 unit = 1 pixel, basically what you'd use for 3D.
Set up one for perspective projection for 3D and you should get the correct cube at the centre without scaling it up.
[QUOTE=Tamschi;44727369]Your screenshot looks like you have an orthogonal projection matrix with 1 unit = 1 pixel, basically what you'd use for 3D.
Set up one for perspective projection for 3D and you should get the correct cube at the centre without scaling it up.[/QUOTE]
it's too late to do anything further on it, I have only time left to do documentation. I would have continued work on it but I was disheartened by the fact that methods I thought worked didn't work:
[t]http://i.imgur.com/KFolMt0.png[/t]
[t]http://i.imgur.com/FQX8Kqg.png[/t]
You can see here the cube's faces not rendering, next to 2 triangles using the same render method working correctly (they have a wireframe under them using a linear line drawing method which is why you see a white line beside them). My loading method messes up the last face as you can see with the vert that is at 0,0,0.
I only wished I had worked harder on it so I could have finished it in time. There's no reason why I couldn't have made what I currently have a week ago.
[editline]5th May 2014[/editline]
I'm going to work harder an the next assignment so that I can have it done in time, I have about 4 weeks to complete it and I'm allowed to use OpenGL, if I get 100% in that and ace the final exam I'll have over 50% in total for the course. I had hoped to get 100% in this so I could get the max amount of marks for the course but I didn't deserve it with the amount of work I had put into it.
[editline]5th May 2014[/editline]
Submitted what I had, fingers crossed for at least some of the marks.
Hey guys. I was wondering could anybody who knows OpenGL have a look at my code and give me hand?
[url]http://pastebin.com/7gsnF4Ps[/url]
It's my first time using OpenGL and basically the lighting looks off or something when you run the program and look at the world. Textures I had weren't working correctly so I had to get other ones and thought maybe somebody here would have a better idea of what I did wrong
[QUOTE=Over-Run;44728797]Hey guys. I was wondering could anybody who knows OpenGL have a look at my code and give me hand?
[url]http://pastebin.com/7gsnF4Ps[/url]
It's my first time using OpenGL and basically the lighting looks off or something when you run the program and look at the world. Textures I had weren't working correctly so I had to get other ones and thought maybe somebody here would have a better idea of what I did wrong[/QUOTE]
1. you use glut ...
2. you use old fixed function pipeline,which is OLD and OLD
3. if you would use the new programmable pipeline you might understand what's goin on there :)
[QUOTE=Pappschachtel;44728924]1. you use glut ...
2. you use old fixed function pipeline,which is OLD and OLD
3. if you would use the new programmable pipeline you might understand what's goin on there :)[/QUOTE]
Just to add onto that, the OpenGL you should be learning is here: [url]http://open.gl/[/url]
Jeez I didn't know ha I was just going by what the lecturer was using in his notes.
Would it take a lot of work to move it to the new OpenGL.
What would I use instead of glut.
Where is a good place to learn this new pipeline
[QUOTE=Over-Run;44729125]Jeez I didn't know ha I was just going by what the lecturer was using in his notes.
Would it take a lot of work to move it to the new OpenGL.
What would I use instead of glut.
Where is a good place to learn this new pipeline[/QUOTE]
Well if you lean this stuff at school or university, we have again proof about the quality of those institutions :D
GLEW and GLFW in combination are pretty good and stay rather minimalistic without extra stuff except context creation and window,keyboard,mouse, generally input and window event stuff
EDIT:
And yes i think it takes way more to understand if you move from the old stuff to the new one... but i also think it is more than worth it.
[QUOTE=Over-Run;44729125]Jeez I didn't know ha I was just going by what the lecturer was using in his notes.
Would it take a lot of work to move it to the new OpenGL. [b]Yes, but it's worth it.[/b]
What would I use instead of glut. [b]GLFW is a decent choice.[/b]
Where is a good place to learn this new pipeline [b][url]http://open.gl[/url][/b][/QUOTE]
Thanks for the information.
I'm not sure if I can change to use GLFW or anything. Apparently the lecturer last year didn't grade anybody who didn't use glut because he couldn't run them or something. Also the assignment is due tomorrow so I can't spend loads of time to transfer to GLFW. I will check them out though if it's what I should be doing once the assignment is done.
Other than that though, can you see how I can fix up my code to make it work?
[QUOTE=Over-Run;44729206]Thanks for the information.
I'm not sure if I can change to use GLFW or anything. Apparently the lecturer last year didn't grade anybody who didn't use glut because he couldn't run them or something. Also the assignment is due tomorrow so I can't spend loads of time to transfer to GLFW. I will check them out though if it's what I should be doing once the assignment is done.
Other than that though, can you see how I can fix up my code to make it work?[/QUOTE]
Well if you include the dlls it should run.
Anyways, show us some screens of the "not working" part.
I know but its just risky from what I heard about him grading last year.
Here is a picture
[IMG]http://puu.sh/8ApoD.jpg[/IMG]
I just think the back of the table and front of the chairs look a bit off, like the light shouldn't be lighting them up in that manner. Not sure if you can tell from the code what causes it
glEnable(GL_COLOR_MATERIAL) missing ?
How does that work exactly? I added it to my main and it just made the reddish tint from the light disappear, however the problem still remained.
[QUOTE=Over-Run;44730296]How does that work exactly? I added it to my main and it just made the reddish tint from the light disappear, however the problem still remained.[/QUOTE]
it was missing anyways, but other than that... i dont get what should be wrong with the scene...
Hmm how come it removes the red light when I add it in?
I don't know I think the lighting on some of the vertexes looks a bit off or something, do you not agree?
Anyway I have another question. We have to add in some forms of interactivity to the scene. Any ideas?
It has to be easy enough to do as its due tomorrow. I can already move around the level using the arrow keys and look left and right with the right mouse button.
What else could give some form of "wow" factor
[QUOTE=Over-Run;44730340]Hmm how come it removes the red light when I add it in?
I don't know I think the lighting on some of the vertexes looks a bit off or something, do you not agree?
Anyway I have another question. We have to add in some forms of interactivity to the scene. Any ideas?
It has to be easy enough to do as its due tomorrow. I can already move around the level using the arrow keys and look left and right with the right mouse button.
What else could give some form of "wow" factor[/QUOTE]
thats actually how you define your light and the material:
[CODE]
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);[/CODE]
And rendering a stationary light:
[CODE]
glLoadIdentity();
//..glRotatef, glTransaltef.. for camera
glLightfv(GL_LIGHT0, GL_POSITION, position);
glPushMatrix();
//..glRotatef, glTransaltef.. for Objects
DrawObjects();
glPopMatrix();
[/CODE]
[QUOTE=Pappschachtel;44730412]thats actually how you define your light and the material:
[CODE]
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);[/CODE]
And rendering a stationary light:
[CODE]
glLoadIdentity();
//..glRotatef, glTransaltef.. for camera
glLightfv(GL_LIGHT0, GL_POSITION, position);
glPushMatrix();
//..glRotatef, glTransaltef.. for Objects
DrawObjects();
glPopMatrix();
[/CODE][/QUOTE]
So is the way I have it okay?
Can somebody explain how
[code]
float tempreal = real;
float tempimag = imag;
real = (tempreal * tempreal) - (tempimag * tempimag);
imag = 2.0 * tempreal * tempimag;
real += Creal;
imag += Cimag;
r2 = (real * real) + (imag * imag);
[/code]
Is the same as
[code]
R = R^2 + C
[/code]
When making a Mandelbrot? Or explain what the first snippet of code is doing to calculate the Mandelbrot set point?
I must be missing something elementary, but how is Z^2 this:
[code]
vec2(Z.x * Z.x - Z.y * Z.y, 2.0 * Z.x * Z.y);
[/code]
Finally made the switch to C#, using monodevelop and editing key bindings to fit the ones I've used from my netbeans origins. How do I do auto code insert with little things like making for loops? In netbeans it was for + tab. Or does mono not have a way to do this?
[QUOTE=Asgard;44731518]
[code]
R = R^2 + C
[/code][/QUOTE]
The Mandelbrot equation is operating on complex numbers. Complex numbers are made up of an imaginary and real component. If you look up how those operators work on complex numbers, your code snippet will make sense.
While slightly cheesy, [URL="http://www.mandelbrotset.net/tutorial.html"]this video[/URL] is a pretty good explanation of the Mandelbrot set.
FYI Many languages have a complex number type which you could use instead to implement the equation as above.
[QUOTE=bean_xp;44732033]The Mandelbrot equation is operating on complex numbers. Complex numbers are made up of an imaginary and real component. If you look up how those operators work on complex numbers, your code snippet will make sense.[/QUOTE]
I don't understand mathematics, but can't you just imagine complex numbers are 2D points?
[QUOTE=Asgard;44731518]
I must be missing something elementary, but how is Z^2 this:
[code]
vec2(Z.x * Z.x - Z.y * Z.y, 2.0 * Z.x * Z.y);
[/code][/QUOTE]
Brush up on complex arithmetic, more specifically represent a complex number in its real and imaginary parts and look what happens when you multiply it with itself. If you know what (a+b)*(a+b) is, you should be able to figure that out if you know that i^2=-1
Sorry, you need to Log In to post a reply to this thread.