Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

174 Neutral

About iwoplaza

  • Rank

Personal Information

  • Interests
  1. There probably are, but writing your own .obj file loader is a good challenge :). I wrote my own some time ago, and I even have my own model format now xD.   I used stdio's FILE to load the file line by line, and then check if the line starts with "v" (for the verticies), and if yes, it used fscanf to get the rest of the data in the line :).
  2. You have to devide it by two, because you are actually trying to get the average of these two textures. Imagine that you have a red texture and a black texture. By mixing these two you would expect it to turn out as a darker red. It wouldn't, because you are not getting the average of them, you are just adding them together, so: (red: 1.0, green: 0.0, blue: 0.0) + (red: 0.0, green: 0.0, blue: 0.0) ==(red: 1.0, green: 0.0, blue: 0.0) BUT (red: 1.0, green: 0.0, blue: 0.0)/2 + (red: 0.0, green: 0.0, blue: 0.0)/2 ==(red: 0.5, green: 0.0, blue: 0.0)   I hope it helped :).
  3. Hello everybody.   As I said in the topic, I have a problem with my shader for point lights. I followed a ton of tutorials about phong lighting and per fragment point lighting. Still, after all these tutorials, I still have this problem:   The light only lits up objects in the positive X direction.   Here is my shader code: VERTEX SHADER #version 120 varying vec2 texCoord; varying vec3 position; varying vec3 normal; varying vec3 tangentSurf2light; varying vec3 tangentSurf2view; uniform vec3 lightPos; void main() { gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; position = vec3(gl_ModelViewMatrix * gl_Vertex); normal = normalize(gl_NormalMatrix * gl_Normal); texCoord=gl_MultiTexCoord0.xy; vec3 tangent; vec3 v1=cross(gl_Normal,vec3(0.0,0.0,-1.0)); vec3 v2=cross(gl_Normal,vec3(0.0,-1.0,0.0)); if(length(v1)>length(v2)){ tangent=v1; }else{ tangent=v2; } vec3 t = normalize(gl_NormalMatrix * tangent); vec3 b = cross(normal,t); mat3 mat = mat3(t.x,b.x,normal.x, t.y,b.y,normal.y, t.z,b.z,normal.z); vec4 var = vec4(lightPos,1.0); vec3 lightLoc = vec3(gl_ModelViewMatrix * var); vec3 vector = normalize(lightLoc-position); tangentSurf2light=mat*vector; vector=normalize(-position); tangentSurf2view=mat*vector; } FRAGMENT SHADER #version 120 uniform sampler2D texture; uniform sampler2D normalmap; uniform sampler2D specularmap; uniform vec3 lightPos; varying vec2 texCoord; varying vec3 position; varying vec3 normal; uniform vec3 matDiffuse; uniform vec3 matSpecular; uniform vec3 lightAmbient; uniform vec3 lightDiffuse; uniform vec3 lightSpecular; varying vec3 tangentSurf2light; varying vec3 tangentSurf2view; void main(){ vec4 var = vec4(lightPos,1.0); vec3 lightLoc = vec3(gl_ModelViewMatrix * var); float dist=length(position-lightLoc); float att=1.0/(1.0+0.1*dist+0.01*dist*dist); vec3 ambient = vec3(texture2D(texture,texCoord)) * lightAmbient; vec3 surf2light = normalize(tangentSurf2light); vec3 norm = normalize(texture2D(normalmap,texCoord).xyz*2.0-1.0); float dcont = max(0.0, dot(norm,surf2light)); vec3 diffuse = dcont * vec3(texture2D(texture,texCoord)) * lightDiffuse; vec3 surf2view = normalize(tangentSurf2view); vec3 reflection = reflect(-surf2light,norm); float scont = pow(max(0.0,dot(surf2view,reflection)),texture2D(specularmap,texCoord).x*50); vec3 specular = scont*lightSpecular*matSpecular*att; gl_FragColor = vec4(ambient+diffuse+specular,1.0); } Thanks in advance!
  4. Thank you very much :D! +1 for you. But what if I had a vector of 2D points, and I would want all of them to make holes in "the texture", and the number of the points is specified in a variable, so it can change anytime? Can I add multiple textures of "the hole" to the multitexture? Or is it possible to combine all of the "holes" that point made into one texture, and use it in the multi-texture?   Thanks in advance :)
  5. Hello everybody!   Okay, let's say that my application screen looks like that:       And I want it to look like this:     The scenery at the first picture contains of two planes on top of each other that have different textures.   What I want is the thing that happened at the second picture. It want it to cut the part of the plane wherever I want based of this texture:   I am using SDL for handling events, and OpenGL for drawing.   Thanks in advance .  
  6. So I should use this method right? vector<Entity*> entities   Well, if yes, than I still have problems with it. Sure, it works for the aspect of overriding the functions properly, but sometimes when I try to render it or just add another entity, it doesn't show up, or just doesn't add to the vector.   Is this method of adding the Entity into the vector correct? EntityArrow arrow = EntityArrow(); entities.push_back(&arrow);
  7. Hello there.   I want to make a list of entities that are gonna be updated every tick. So, I created a class named Entity, and gave it a couple of functions: class Entity{ public: int uniqueID; Vec3f loc; Vec2f res; Vec2f vel; float rot; virtual void onUpdate(); virtual void onSpawned(); virtual string getNameID(); vector<GameData> gameData; }; Then, I created a vector of these entities: vector<Entity> entities; After that, I wanted an arrow entity, so I created a new class EntityArrow that is an extension of Entity: class EntityArrow : public Entity{ public: EntityArrow(); EntityArrow(Vec3f argLoc,Vec2f argRes); string getNameID(); void onUpdate(); void onSpawned(); }; And now comes the problem, when I try to add a new EnttiyArrow to the entities list: entities.push_back(EntityArrow()); it is still treated as an Entity. For instance, if I overrided the onUpdate() function in EntityArrow to print out something in the console, it would do something that is in the Entity's onUpdate() , and not the EntityArrow's. I have already tried to make a vector out of references to Entity class : vector<Entity*> entities , but I still have a lot of problems with it.   Is there a better way to do it? Thanks in advance :).
  8. iwoplaza

    In need of an algorythm!

    Thanks a lot man, that got me on the track :).
  9. iwoplaza

    In need of an algorythm!

    Hi. The picture shows a point and a line in a 2d space. Does someone know what algorythm do I use to calculate the '?' in the picture? It is the distance between the 'point' and the line, but the angle between the line and the "distance line" has to be 90 degrees. I want to use that in my physics engine. And can someone help me find the 3D equivalent of that as well?   Thanks in advance!  
  10. Hello everyone. My problem is that on my computer, eveything works fine, I mean, all of the textures are working, fps is great and all. Here comes the problem... on other computers, it doesn't, some of the textures aren't working, and FPS is horrible. The texture thing is probably a power of two thingy, cuz every power of two resolution texture is working, but others are not. What is wrong with the FPS's?   Drawing: OpenGL Texture Loading: DevIL Language: C++   Thanks in advance!
  11. Than let's begin. First I will show you how my GUI works and looks.Then you can choose what you want to learn. Here is my GUI: And about library that is made for GUI. Like you, I've been searching the simple way to do it, but I couldn't find it. So I begun to make my own code to render these GUI things. Tell me what things you'd like to learn.
  12. I maked rendered text and own GUI for myself . I can tell you how to do that.If you are interested , tell me and I will help you.
  13. I have a question. How can I get vertex positions from camera view in OpenGL. Example: Wherever the camera is, I want to get vertex positions from camera view. I'm using OpenGL for drawing. I'm from Poland so if you could use some clear language. Thanks in advance.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!