[QUOTE=Overv;36149259]Why are you inverting the normals for the dot product calculation? It's like your entire shader code went through a human obfuscation program.[/QUOTE]
I was just following what this said: [url]http://ogldev.atspace.co.uk/www/tutorial18/tutorial18.html[/url]
[QUOTE=Richy19;36149325]I was just following what this said: [url]http://ogldev.atspace.co.uk/www/tutorial18/tutorial18.html[/url][/QUOTE]
Enable backface culling with
[code]glEnable ( GL_CULL_FACE );[/code]
The faces of your cubes that are incorrectly lit will disappear, because your triangles are facing the wrong direction. Turn around the order of the three vertices of the triangles that are facing the wrong direction and your problem will be solved.
When you developed the code that generated the triangles for the visible faces in a cube, you simply copied the code for triangles on one side and modified it to work for the other side by simply changing either the X, Y or Z values. This will move your triangles to the correct side of the block, but they will still be pointing the way they did before.
This is how I want you to change the order in your element buffer or general triangle code:
[code]Current order:
1, 2, 3
New order:
3, 2, 1[/code]
Cull_Face is enabled, and the triangles are facing the correct direction, if they werent then surelly they wouldnt be drawn
[editline]1st June 2012[/editline]
My current triangle code is:
[CODE]SOGLF::Triangle::Triangle(const SOGLF::Vertex &v1, const SOGLF::Vertex &v2, const SOGLF::Vertex &v3)
{
amount++;
SOGLF::Vertex v[3];
v[0] = v1;
v[1] = v2;
v[2] = v3;
if( !(v[0].HasNormals() && v[1].HasNormals() && v[2].HasNormals() ) )
{
glm::vec3 U = (v2.Position - v1.Position);
glm::vec3 V = (v3.Position - v1.Position);
glm::vec3 norm = glm::cross(U, V);
//norm.x = ((U.y * V.z) - (U.z * V.y));
//norm.y = ((U.z * V.x) - (U.x * V.z));
//norm.z = ((U.x * V.y) - (U.y * V.x));
v[0].Normal = norm;
v[1].Normal = norm;
v[2].Normal = norm;
}
vertex[0] = v[0];
vertex[1] = v[1];
vertex[2] = v[2];
}[/CODE]
Do I change the rotation of all triangles?
Then I'm clueless, sorry.
To give a better example of what happens:
I use these values.
[cpp]DirectionalLight light;
light.AmbientIntensity = 0.4f;
light.DiffuseIntensity = 0.8f;
light.Color = glm::vec3(1.f, 1.f, 1.f);
light.Direction = glm::vec3(0.0f, 1.0f, 1.0f);
chunk->SetLight(light);[/cpp]
[video=youtube;shAbQwyEgtQ]http://www.youtube.com/watch?v=shAbQwyEgtQ[/video]
[QUOTE=Overv;36149833]Then I'm clueless, sorry.[/QUOTE]
No problem man, thanks for trying :)
Does anyone have that great article that explains vectors really well?
Or just any article in general that explains vectors really well.
I have the player rotating towards the mouse, this works correctly and the player is towards the mouse.
[cpp]
void Player::setTarget()
{
sf::Vector2i mousePosition = sf::Mouse::getPosition(Main::GetWindow());
float radians = atan2((float)mousePosition.y - GetPosition().y,(float)mousePosition.x - GetPosition().x);
float degrees = (radians/pi) * 180;
GetSprite().setRotation(degrees);
}
[/cpp]
When a bullet is fired it is then added to the entity manger, its constructor passes in the position it should be fired from and the direction/rotation of the bullet.
[cpp]
Bullet::Bullet(int x, int y, float rotation)
{
Load("ball.png");
SetPosition(x,y);
GetSprite().setRotation(rotation);
GetSprite().setOrigin(GetSprite().getTextureRect().width / 2,GetSprite().getTextureRect().height / 2);
}
Bullet::~Bullet()
{
}
void Bullet::Update()
{
sf::Vector2f Direction = sf::Vector2f(sin(GetSprite().getRotation()) * 0.4, cos(GetSprite().getRotation()) * 0.4);
GetSprite().setPosition(GetPosition() += Direction);
}
[/cpp]
While this does fire a bullet from the players position, the direction of the bullet is completely wrong and I've no idea why. The video might explain my issue better.
[media][URL]http://www.youtube.com/watch?v=llJuZ2oatUo[/URL][/media]
sin and cos take radians, it appears you're feeding it degrees.
Hey, I was wondering if anyone ever got Gwen to work with a Source game.. AMC eventually?
Here's my old thread: [url]http://facepunch.com/threads/1133542[/url]
[QUOTE=Naelstrom;36156112]sin and cos take radians, it appears you're feeding it degrees.[/QUOTE]
You were correct, I changed the rotation from degree's to radians and now the bullets fire semi right.
[media]http://www.youtube.com/watch?v=eJVdiaDqdd8&[/media]
I have a feeling its because im doing doing -sin or -cos but I've tired every combination and nothing seems to work.
[cpp]
sf::Vector2f Direction = sf::Vector2f(-(float)sin(radian), -(float)cos(radian));
[/cpp]
Try using negative radians, by then you'll probably just need to add/subtract pi/2 to the radians as well.
I believe you have the cos and sin switched:
[code]sf::Vector2f Direction = sf::Vector2f((float)cos(radian), (float)sin(radian));[/code]
I'm assuming the negatives are there because in your game down on the screen is positive? But if right is still positive, your cos shouldn't be negative as it is in your snippet.
It's been a while since I've needed trig though, so I could be wrong.
edit: You actually probably don't need the negatives.
[QUOTE=Armandur;36065037]I'm trying to read a text file in java and tokenize each line and do a simple comparison of the last element on the line with a string. But it just won't work! The last element in the file is either IG, G, VG or MVG and I compare it in an if-else chain against "IG", "G" etc. but it doesn't match any of those...
Code: [url]http://pastebin.com/i5D4Tya5[/url][/QUOTE]
It could be that you're doing mystr == "mystr". In Java, == on reference types (which a string is) simply checks whether or not they are the same object in memory. Try mystr.equals("mystr") ?
Moving my openGL question here, should each object have a VAO with the data needed (normals, textures/colors, vertices)? Then when I want to draw an object I bind it's VAO and then draw as usual?
That's how I like to do it, and I think that's what VAOs were intended for, but it's not your [i]only[/i] option.
Do what you think is best.
I can't imagine any other way, so if you can enlighten me that would be great.
You could have one global VAO, and re-bind the VBOs for each object. Effectively emulating old-style OpenGL before the introduction of VAOs.
Sounds kinda stupid, IMO, but people actually do it because you need a VAO to be forward-compatible and some people who maintain old codebases can't be assed to refactor everything.
There's also other choices when you want to render the same model with different shaders that need different attributes. You could have multiple VAOs per model, one VAO per model (swapping vertex attribute bindings as necessary), or a single VAO with all the vertex attributes bound (ignoring the unnecessary attributes in the shader; dunno about overhead in this case).
[QUOTE=ROBO_DONUT;36160701]You could have one global VAO, and re-bind the VBOs for each object. Effectively emulating old-style OpenGL before the introduction of VAOs.
Sounds kinda stupid, IMO, but people actually do it because you need a VAO to be forward-compatible and some people who maintain old codebases can't be assed to refactor everything.
There's also other choices when you want to render the same model with different shaders that need different attributes. You could have multiple VAOs per model, one VAO per model (swapping vertex attribute bindings as necessary), or a single VAO with all the vertex attributes bound (ignoring the unnecessary attributes in the shader; dunno about overhead in this case).[/QUOTE]
I would have a VAO for each category of object and store it as a property of the model. Hell, the model loader could choose an optimized VAO based on the input attributes.
Disclaimer: I know nothing about writing graphics engines.
Ah, thanks for the info.
I got IQM models and anims working but I'm wondering if they can be used along side MD5 nicley.
The problem is that with IQM, when reading the anims I have to pass in a model so I can get the bind pose and inverse of it. I can probably do that at animation time but I'd need to save the bone parents. That's also fine but MD5 doesn't need to know the bone parents at animation time so it would'nt be used.
I'm not even sure it's possible to read anims without a models bind pose because of the order of the matrices that need to be concatenated. If that's the case, I can't share anims across multiple models without loading them for each one. I may aswell just stick with MD5.
[QUOTE=Asgard;36154348]Does anyone have that great article that explains vectors really well?
Or just any article in general that explains vectors really well.[/QUOTE]
[url]http://www.j3d.org/matrix_faq/[/url]
Hey, I've got a question which isn't really related to actual coding but programming in general.
At the moment my college is teaching C# as mandatory which I find okay, I am not struggling with or anything like that, It's all good. But they are offering extra courses in C++ and I was wondering if it's worth it to take the extra work load and learn 2 languages at the same time? Is C++ that important to learn or could I just stick to C# until I can grasp it completely?
Should I take the extra course in C++?
Didn't really feel the need to start a thread about this so I posted it here, I hope you don't mind.
[QUOTE=Robbi;36164938]Hey, I've got a question which isn't really related to actual coding but programming in general.
At the moment my college is teaching C# as mandatory which I find okay, I am not struggling with or anything like that, It's all good. But they are offering extra courses in C++ and I was wondering if it's worth it to take the extra work load and learn 2 languages at the same time? Is C++ that important to learn or could I just stick to C# until I can grasp it completely?
Should I take the extra course in C++?
Didn't really feel the need to start a thread about this so I posted it here, I hope you don't mind.[/QUOTE]
Its hardly a huge gap. Its not like you're learning Russian and Japanese at the same time. You'll be fine. Get as much experience as you can get.
Does anyone know why some obj models are drawn like this?
[IMG]http://i.imgur.com/qBaVP.png[/IMG]
[QUOTE=Richy19;36167357]Does anyone know why some obj models are drawn like this?
[IMG]http://i.imgur.com/qBaVP.png[/IMG][/QUOTE]
Looks like 1.) you're only drawing one triangle when two (or a quad, but please use triangles if you can) is required and 2.) your textures are royally fucked.
[QUOTE=Chris220;36167529]Looks like 1.) you're only drawing one triangle when two (or a quad, but please use triangles if you can) is required and 2.) your textures are royally fucked.[/QUOTE]
Oh the texture is just that im not using the right texture image.
But I dont know what is up with the triangles, some obj files are fine(like the gun) but some are fucked like the trees
[QUOTE=Richy19;36167583]Oh the texture is just that im not using the right texture image.
But I dont know what is up with the triangles, some obj files are fine(like the gun) but some are fucked like the trees[/QUOTE]
It looks like the obj files are fine, but the textures are fucked.
[QUOTE=Richy19;36167583]Oh the texture is just that im not using the right texture image.
But I dont know what is up with the triangles, some obj files are fine(like the gun) but some are fucked like the trees[/QUOTE]
Are you handling face definitions containing more than three vertices? If so, check the files themselves for any irregularities your loader may have missed. It's also worth looking at the models in an established model viewer to check if the models themselves have the issues.
[QUOTE=Chris220;36167753]Are you handling face definitions containing more than three vertices? If so, check the files themselves for any irregularities your loader may have missed. It's also worth looking at the models in an established model viewer to check if the models themselves have the issues.[/QUOTE]
[code]f 1/1/1 2/2/2 14/3/3 15/4/4
f 2/2/2 3/5/5 13/6/6 14/3/3
f 3/5/5 4/7/7 12/8/8 13/6/6
...[/code]
Ahh the model seems to use quads where as my loader assumes its triangles.
Is there any line in the obj file that identifies if its using quads or triangles? I cant find anything in the specification
Sorry, you need to Log In to post a reply to this thread.