Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

337 Neutral

About too_many_stars

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. too_many_stars

    Typedefing in a central *.h file

    Can you tell me what the purpose is of putting header file contents in a namespace please? I only ask because I have never heard of this before. The problem with the C++ books I have read (introductory to intermediate) is that often times they don't cover many of the aspects I find here on gamedev.net. Thanks so much for all the replies! Mike
  2. Hello Everyone, I am sure we have all seen things like const glm::vec2 & v or, std::unique_ptr< SomeObject > object; I was wondering if it's a good idea to perhaps make a typedef.h file and sprinkle it through out the project so I can save some typing. #ifndef TYPEDEF_H #define TYPEDEF_H typedef const glm::vec2 c_vec2; typedef std::unique_ptr< SomeObject > ptr_obj; typedef ... #endif Maybe like this... I am using typedefs, but in classes only. However, I would like to access those typedefs globally without having to call SomeClass::typedef. Is there anything wrong with this global approach? Are there some issues that can come crop up down the line which I am not considering? Please let me know, Thanks again, Mike
  3. too_many_stars

    const parameter good practice question

    I think you guys are right. It really does not add any value to const a primitive parameter variable for the sake of documentation to whomever the user might be. I have never seen it done that way but was just wondering if it might be good practice since I have very limited exposure to production level code. Thanks again, Mike
  4. Good Morning, I just have a quick question about good programming practice with parameter arguments in C++. Is it good programming practice to const all parameter arguments that will not be changed internally? For example. void Agent::setHealth( const int h ){ health = h; } However, if I have the same function, but this time wish to signify to users that the parameter value might not be what's assigned to a private/protected variable inside the class I could do something like this void Agent::setHealth( int h ){ health = glm::clamp( h , 0 , INT_MAX ); } I am also talking about primitive types available through C++ not const referenced variables passed as arguments. Is it a waste of time to 'const' and just use the variable with function documentation? Thanks so much for the time, Mike
  5. too_many_stars

    Dealing with Non Center of Mass Translations

    Thanks so much again for the help Randy, I will do as you suggest and try to make some sense out of it. Mike
  6. Hello Everyone, It's very common in 2D and 3D to use the center of mass ( COM ) as the point of rotation. This method additionally make it easy to fit the model into a bounding sphere, AABB, capsule whatever. This is what I have always done. However, now I am trying to model a 3D hinged door. This door, due to the nature of rotation, will not be centered at the COM, instead, it will have to be translated locally either to the left or right depending on where the hinge should be. My question is... What is the best way of dealing with Non-COM rotations? The problem is, once the symmetry is gone from Non-COM model my bounding volumes are thrown off as they rely on COM. And obviously now when I am transforming from local to world co-ords it becomes harder to gauge where the object will be and how it will fit into the rest of the world. Also, I have to introduce some new variables such as glm::vec3 local_position to keep track of the new object center. It makes everything a lot messier. Thanks again for all the help, Mike
  7. too_many_stars

    glsl - material, texture and light relationship

    Thanks for the response Silence, I do like the lookup idea. It's going on the to do list. Mike
  8. Hi Guys, A quick question. I have a 3d grid sector made out of AABB boxes ( see picture below ). When I turn the light on, I get the light catching the extremities of the boxes creating ugly line artifacts. Just wondering if there's a way to solve this problem. Thanks again, Mike
  9. too_many_stars

    glsl - material, texture and light relationship

    Thanks for the response Silence@Sid, The reason I want material with a texture is if I simply want to change the texture color. I guess I could introduce another RGB variable just to change the texture color but that seems like a waste of memory. Mike
  10. Hello Everyone, I am having a difficult time coming up with a relationship between light, material, and a texture inside a shader. I have a model that has the following properties. 1.) texture 2.) material and a world light source. If the light is on, inside the fragment shader, I do the following vec3 light_frag = phongADS( material ); gl_FragColor = vec4( light_frag , 1 ) * texture( sampler , uv ); This simply calculates the light fragment based on the material with an ambient, diffuse and specular component and the multiplies this by the texture fragment However, when the light is off, and I am only dealing with a material and a texture what is the relationship between the two? Does one just take for example the diffuse component of the material like so... gl_FragColor = vec4( material.diffuse , 1 ) * texture( sampler , uv ); More generally, my question is this: Given a model ( say an AABB ) with a material, a texture and a light source, what is the proper per fragment calculation ( if light is on or off ) that takes all three into account Thanks, Mike
  11. too_many_stars

    GLubyte array and getPixel function

    Hi Sponji, Thanks so much, that's the correct answer. I thought I was tying into the array properly ( I even did a few examples on paper to make sure it worked). Mike
  12. Hello Everyone, I am having issues with extracting a pixel from a GLubyte array. Here is what I have GLubyte* pixels = SOIL_load_image( file_path.c_str() , &width, &height, &channels, SOIL_LOAD_AUTO ); // load the pixel array //later in the code //RGB is holds GLint r, g, b RGB Texture::getPixel( const int x, const int y ) const{ if( x < 0 || x > width -1 || y < 0 || y > height -1 ) return RGB(); int w = channels * width; int idx = y * w + x; GLubyte r = pixels[ idx + 0 ]; GLubyte g = pixels[ idx + 1 ]; GLubyte b = pixels[ idx + 2 ]; return RGB( (GLint) r , (GLint) g , (GLint) b ); I think I am tying into the array correctly. I do get integer values for my RGB struct, but they are all wrong. I get colors that don't even appear on the texture. If anyone knows what I am doing wrong, please let me know. Thanks so much, Mike
  13. too_many_stars

    GLSL Rendering Mulptile Materials Across a Model

    Thank you so much Koen, that's a great answer. I figured there was going to have to be some kind of batching process. Mike
  14. Hello Everyone, Here is what I have so far when it comes to rendering a model with glsl glsl->setUniform( "Ka" , material.ambient ); glsl->setUniform( "Kd" , material.diffuse ); glsl->setUniform( "Ks" , material.specular ); glsl->setUniform( "mat_shine" , material.shininess ); glBindVertexArray( vao_id ); glDrawArrays( GL_TRIANGLES , 0 , vertices.size() ); glBindVertexArray( 0 ); This works fine for a single material applied across the entire model. However, I now import an .obj model with various materials from Blender. After mapping triangle faces to material ids I am unsure how the above call to glDrawArrays( GL_TRIANGLES , 0 , vertices.size() ); needs to change in order to render more than one material on a single model. Any help would be great appreciated, Mike
  15. too_many_stars

    Shader class instancing question

    Thanks for the reply. Maybe a singleton registry with std::map< std::string , GLSL > pair? That would give a quick look up table for a particular shader and would make it available in any render method. Thanks Mike
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!