• Content count

  • Joined

  • Last visited

Community Reputation

142 Neutral

About Checkmate_001

  • Rank
  1. How to implement wave equation?

    I'm using OpenGL, GLFW and GLEW to create a simulation of water waves for a school project. When I use the old vertex shader without the function, the grid renders as expected, but with the new shader it shows a blank grey background. I created a grid in the xz-plane and created a shader to manipulate the grid based on an equation I found from some resources I found online are at the end:   Here are the relevant snippets of code:   Rendering code while(!glfwWindowShouldClose(window))     {         // Set frame time         GLfloat currentFrame = glfwGetTime();         deltaTime = currentFrame - lastFrame;         lastFrame = currentFrame;         // Check and call events         glfwPollEvents();         Do_Movement();         // Clear the colorbuffer         glClearColor(0.2f, 0.2f, 0.2f, 1.0f);        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);         // Draw objects         shader.Use();         //Set Uniforms         GLint locTime = glGetUniformLocation(shader.Program, "time");         if (locTime != -1)             glUniform1f(locTime, (float)glfwGetTime());         GLint locWLength = glGetUniformLocation(shader.Program, "wavelength");         if (locWLength != -1)             glUniform1f(locWLength, 1.0f);         GLint locPeak = glGetUniformLocation(shader.Program, "peak");         if (locPeak != -1)             glUniform1f(locPeak, 3.0f);         glm::mat4 model;         glm::mat4 view = camera.GetViewMatrix();         glm::mat4 projection = glm::perspective(camera.Zoom, (float)screenWidth/(float)screenHeight, 0.1f, 100.0f);         glUniformMatrix4fv(glGetUniformLocation(shader.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));         glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));         // Grid         glBindVertexArray(planeVAO);         glBindTexture(GL_TEXTURE_2D, floorTexture);         model = glm::mat4();         glUniformMatrix4fv(glGetUniformLocation(shader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));         //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);         glDrawElements(GL_LINES, 3*grid.Indices.size(), GL_UNSIGNED_INT, 0);         glBindVertexArray(0);                         // Swap the buffers        glfwSwapBuffers(window);     } Vertex Shader #version 430 core layout (location = 0) in vec3 position; layout (location = 1) in vec2 texCoords; out vec2 TexCoords; const float pi = 3.14159265; uniform mat4 model; uniform mat4 view; uniform mat4 projection; uniform float wavelength; uniform float peak; uniform float time; void main() {     float a = position.x;     float b = peak - 1.0f;     float k = (2.0f * pi) / wavelength;     float c = sqrt(9.81f/k);     float wave_dx = (exp(k * b)/ k) * sin(k * (a + c * time));     float wave_dy = (-exp(k * b)/ k) * cos(k * (a + c * time));         gl_Position = projection * view * model * vec4( (position.x + wave_dx), (position.y + wave_dy), position.z, 1.0f);     TexCoords = texCoords; } oldVertex Shader   #version 430 core layout (location = 0) in vec3 position; layout (location = 1) in vec2 texCoords; out vec2 TexCoords; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() {     gl_Position = projection * view * model * vec4(position, 1.0f);     TexCoords = texCoords; } Here is the correct static output:   [attachment=32470:output_4.png] [attachment=32471:realOutput.png]   This is where I got my equation/ implementation.   Thanks in advance!  
  2. Load Meshes

    I've been working through GEA and re-reading "Introduction to 3D Game Programming with DirectX 11" and have recently also been making some demos based on the further exercises from each chapter.   I wanted to improve these demos by adding some models/ meshes around the environment and including a skybox. Although the book only covers how to load the custom .m3d format. I could create a Python script in blender, but I really wanted to load the models another way. The book recommends, MeshFromOBJ10, but having researched it, the results seem to complicated to include in my code. I did, however, find this (, which I have reason to belive is not functional.   Should I include the code from there in two files - OBJLoader.cpp and OBJLoader.h? Or is there any other place I should be looking to load meshes?   P.S. I'm open to any file format that would be good for me. Be it .OBJ or anything else (.max or .3ds would be great though).
  3. Where do I go beyond Graphics Programming?

    Hello and thank you for the quick reply.   I would in the long run want to build an engine, but I'm sure as a beginner an engine would not be the best starting point. Would jMonkey be a good starting point? Or is there something that I could extend based on my needs (LWJGL)?   If I do decide to start with an engine like jMonkey or Torque 3D, would I continue reading the books I've started or should I just look at the documentation and tutorials for the engine? What is the distinction between the graphics engine, and graphics programming?      In response to that, yes I have in HTML, CSS and JS (pong and snakes and I was working on a racing game), but I'm not sure if that counts.    However, thanks to your reply I think that I will have a look at the GEA book and definitely try to start with Torque3D or jMonkey, if you think it is a good option.
  4. Hello,   I have been programming for a few years now and started trying to make my first 3D game about a year ago. (and yes I have done 2D games before) I started off with Direct3D and C++ using "Introduction to 3D Game Programming with DirectX 11" as it was recommended to me as "the bible". This book is - I must say - THE best resource I have found for 3D mathematics, even having baffled my teacher when I brought up some of the topics. I worked my way through the book getting pretty far into it (up to Chapter 16), but I started to realize that the book was only teaching me how to make very nice graphics and not a game.   With more research I looked into the book "Game Coding Complete, 4th Edition", which I find to be a very misleading title. I, however, did not get very far in this book but I did quickly realize it was very specific and not what I was looking for.   And so I have made my next attempt at Game programming with OpenGL and possibly Java (JOGL). I have bought "Beginning OpenGL Game Programming", with plans to look at NeHe resources after reading the book, and have been consolidating my C++ and Java knowledge. The question I beg of you to answer is am I going down the right path? And is there a resource In have looked over/ am missing?   I have also looked at this site, however old this particular article may be:   Thanks in Advanced,   P.S: If you have any questions you need to give a better answer, please do ask I would be extremely grateful.  
  5. Snowman Stalker

    Hi,   I am making a 3D game in DirectX11. The idea of the game is a snowball fight between two snowmen. One is controlled by the player and the other is controlled with AI.   It's my first proper game, so I wanted to keep it as simple as possible, and the only thing I wanted the AI to do was: How would I code the opponent to move towards the player for five seconds, then stop for two seconds, fire one snowball and then repeat until either the opponent or they are dead?   The problems I had were how to get the AI snowman to react to the players location and go towards them.   Thanks in Advanced, Checkmate_001
  6. Hi,   I was wondering How I would represent distance and velocity very simply for my first game. I needed to have a system for distances to accurately model projectiles.   Should I have (1, 0, 0) = 1 meter from the origin? Or is there a system/ systems that people usually use?   And once I have decided how to model the distance, How would I change my models to fit this? Could I specify the y co-ordinates, in a program like Blender, to scale the model accurately? Or would I have to scale it in code?   Thanks In Advanced, Checkmate_001
  7. Hi,   I am making a Christmas game for my school competition. My plan is to make a snowball fight but I ran into a problem with the snowballs. I am using DirectX11, of which I know enough to make the game.   Once I have loaded the snowball mesh how do I: Create them in the world - How do I create an object based on user input? Specify their flight path - or do I do this at creation, as in their velocity. Destroy them - Once they have hit the ground or the enemy.   Thanks in Advanced,
  8. What steps?

    Hi,    Thanks for the reply, however, I have experience in 2D games already and I would like to move on from that to 3D games with DirectX. Although I am still open for any 3D suggestions.
  9. What steps?

    Hello,   I have been coding in C++ and C# for a couple of years now, so I'm not looking for a C++ tutorial but I recently started learning DirectX for 3D games with C++.   So I bought Frank Luna's "Introduction to 3D Game Programming with DirectX 11" and I'm over half way through. It is thorough but it seems to be very graphics orientated.   If I wanted to move forward with programming a game itself and not graphics what book(s) do you think I should buy?   For example I was looking for: user interface(start up menu, pause menu), using sprites, making a map, granting achievements, character movement (like climbing ladders, balance beams and swimming) and more info on HLSL.   My short term goal is to be able to make a short 1 level single player demo in 3D. Where a character fights 5 or so low health enemies with a sword in a small open field. Once the enemies are dead the game congratulates the player and ends. I would want to have a start menu, health bar, pause menu and maybe if possible a very basic map in the bottom corner that shows his/her current position.     I know I might be a bit optimistic and that it won't be easy but I'm willing to learn. I have the time I just don't have the tools.   Please could you recommend any recent book(s) on DirectX 11 that you use that could be remotely helpful. Any recent DirectX 11 book suggestion would be very much appreciated.   Thanks in Advanced.