• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

MrDarkKnight

Members
  • Content count

    41
  • Joined

  • Last visited

Community Reputation

98 Neutral

About MrDarkKnight

  • Rank
    Member
  1. OpenGL

    Thank you. You were a lot of help. I didn't know that Matrix.CreateFromYawPitchRoll() expects the angles in radians. I should read the hints in VS2010 more often. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Anyways I just did the following and it fixed my problem. [CODE] public void Lock() { float Angle = 90.0f; Angle = MathHelper.ToRadians(Angle); if (Pitch > Angle) Pitch = Angle; if (Pitch < -Angle) Pitch = -Angle; if (Yaw > (Angle * 4) ) Yaw -= (Angle * 4); if(Yaw < (Angle - Angle) ) Yaw += (Angle * 4); } [/CODE] also I did what you said and changed the lock function place in my code. If i don't, crazy things happens [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] [CODE] public void Control(GraphicsDeviceManager graphics, GameTime gameTime, float Velocity, float MouseSensitivity) { ....... // Determine how much the camera should turn float deltaX = MouseSensitivity * (ScreenX - (float)mouseState.X); float deltaY = MouseSensitivity * (ScreenY - (float)mouseState.Y); Lock(); Mouse.SetPosition(ScreenX, ScreenY); // Rotate the camera Rotate(deltaX, deltaY); ...... } [/CODE]
  2. Hello I have a free camera in my game. My problem is the camera moves too fast when I move the mouse. Now if I slow down the camera the pitch and yaw in degrees also slow down. I want to slow down my camera movement but in the same time I don't want the Pitch and Yaw to slow down. If you look at the video the pitch and yaw are very slow, I can speed them up by increasing the mouse sensitivity variable but then the camera moves very fast. I just want to make a free camera that locks at 90 and -90 degrees when I move up and down. Sorry I’m not making a lot of sense but I don't know how to explain it. I already made a free camera in OpenGL and it works but I don't know what I’m doing wrong in XNA. XNA free camera problem [media]http://www.youtube.com/watch?v=bz98kF2xhS0[/media] OpenGL free camera locks at 90 and -90 degrees [media]http://www.youtube.com/watch?v=xxMT-faut2k&context=C3429d35ADOEgsToPDskIJvzwvczQF6wuNQv4QOhV5[/media] code FreeCamera class [CODE] using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace XNA_4._0_Tutorial { class FreeCamera : Camera { public float Pitch { get; set; } public float Yaw { get; set; } public Vector3 Position { get; set; } public Vector3 Target { get; set; } private Vector3 Translation; public FreeCamera(Vector3 Position, GraphicsDevice graphicsDevice) : base(graphicsDevice) { this.Position = Position; } public void Lock() { if(Pitch > 90.0f) Pitch = 90.0f; if(Pitch < -90.0f) Pitch = -90.0f; if(Yaw > 360.0f) Yaw -=360.0f; if(Yaw < 0.0f) Yaw +=360.0f; } public void Rotate(float YawOffset, float PitchOffset) { this.Yaw += MathHelper.ToDegrees(YawOffset); this.Pitch += MathHelper.ToDegrees(PitchOffset); } public void Move(Vector3 Translation) { this.Translation += Translation; } public void Control(GraphicsDeviceManager graphics, GameTime gameTime, float Velocity, float MouseSensitivity) { MouseState mouseState = Mouse.GetState(); KeyboardState keyState = Keyboard.GetState(); int ScreenX = graphics.PreferredBackBufferWidth / 2; int ScreenY = graphics.PreferredBackBufferHeight / 2; Lock(); // Determine how much the camera should turn float deltaX = MouseSensitivity * (ScreenX - (float)mouseState.X); float deltaY = MouseSensitivity * (ScreenY - (float)mouseState.Y); Mouse.SetPosition(ScreenX, ScreenY); // Rotate the camera Rotate(deltaX, deltaY); Vector3 translation = Vector3.Zero; // Determine in which direction to move the camera if (keyState.IsKeyDown(Keys.W)) translation += Vector3.Forward; if (keyState.IsKeyDown(Keys.S)) translation += Vector3.Backward; if (keyState.IsKeyDown(Keys.A)) translation += Vector3.Left; if (keyState.IsKeyDown(Keys.D)) translation += Vector3.Right; // Move 10 units per millisecond, independent of frame rate translation *= Velocity * (float)gameTime.ElapsedGameTime.TotalMilliseconds; // Move the camera Move(translation); // Update the camera Update(); } public override void Update() { // Calculate the rotation matrix Matrix Rrotation = Matrix.CreateFromYawPitchRoll(Yaw, Pitch, 0); // Offset the position and reset the translation Translation = Vector3.Transform(Translation, Rrotation); Position += Translation; Translation = Vector3.Zero; // Calculate the new target Vector3 forward = Vector3.Transform(Vector3.Forward, Rrotation); Target = Position + forward; // Calculate the up vector Vector3 up = Vector3.Transform(Vector3.Up, Rrotation); // Calculate the view matrix View = Matrix.CreateLookAt(Position, Target, up); } } } [/CODE]
  3. if you know nothing about programing, I would recommend going and buy a C# book and start learning programing first. If you don't want to buy a book I would highly recommend checking out [url="http://www.youtube.com/user/thenewboston"]the new boston[/url] YouTube channel, he has a lot of tutorials about programing. Then after that go and buy an XNA book to start learning game development. http://www.youtube.com/watch?v=x_9lfHjYtVg
  4. I went ahead and downloaded XNA and played with it a bit, and I have to say it’s a really good library. Microsoft did a really good job making it easy for relatively inexperienced developers to make games. Unlike OpenGL, XNA has everything from I/O, Sound, Model loader, 3D math library, Network etc... Don't get me wrong I really love OpenGL and it’s my first 3D API to learn and I know that’s its all about rendering 3D but it’s always nice to pack everything a game dev needs to make a great game in one library. However I really don't like C#, it’s very similar to Java and I hate java [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]. I have always been a C++ guy. C# is easy to learn and very nicely done but I just don't like it. The most thing I hate about C# is the foreach loop, I mean what the hell is all that about?! You can do the same thing in a normal for loop, so why use foreach ??!!!! Anyways I'll make few projects with XNA and then maybe go back to OpenGL and C++.
  5. I'm not sure if i understand your problem. I think you mean you are seeing white background behind you image or sprite. you can make the white background color of you sprite to disappear by making it transparent, you can do that by using the following like of code. [CODE] sf::Image Image; Image.CreateMaskFromColor(Color.White); //Or Image.CreateMaskFromColor(sf::Color(255, 255, 255)); [/CODE]
  6. Hey guys I worked with OpenGL and SFML and C++, and they are very good API/Library/Language. In OpenGL I had to write my own OBJ loader and Camera class and basically everything for 3D development. In SFML everything is there to use for 2D dev and I really liked the library a lot. Right now I'm using SFML and OpenGL to make a 3D game. I'm using SFML for Window handling, I/O, loading images, sound etc... I really like both SFML and OpenGL, but OpenGL require a lot of coding to be done before actually getting into game logic for a 3D game. So my question is, Is XNA easies to develop with? Does it provide everything for me to develop a 3D game? Is it faster to start actually making the game? I just want to hear your opinions guys. Thanks a lot.
  7. OpenGL

    Thank you very very much, that was really helpful. I googled View Frustum Culling and it look easy enough to implement. I was just drawing cubes as you said, for fun, and just to check how powerful my card is. Anyways I tried rendering with Immediate mode and with VBO and i have to say there is a huge performance difference between the two. I got 200FPS more with VBO rather than using Immediate mode. On unrelated topic, the only thing that scares the hell out of me in OpenGL 4.0 is shaders, they look hard and they look like you need to write 1000 line of code to do simple thing. And looks like everything moved from OpngGL to GLSL. anyways thanks guys for all of your help.
  8. OpenGL

    thank for the help. I just relized the way i'm drawing the 10000 cubes is very bad. I think there is a much much better way to draw 10000 cubes. I modified my Drawing code and i gained 700FPS !. now my FPS is ~780FPS. But its still bad considering there is only like 10 cubes show up on the screen at a time. I should get ~1500FPS. so is there a better way to draw the 10000 cubes? [CODE] void Engine::Render(sf::Window &Window) { .... // Same as old glBindVertexArray(VertexBufferID); for(int i=0; i<10000; i++) { glTranslatef(0.0f, 0.0f, Z * i); if(Camera1.Z >=Z * i) { glDrawArrays(GL_QUADS, 0, 24); } } glBindVertexArray(0); } [/CODE]
  9. Hello guys I have function which creates a cube using VBO. I call this function outside the game loop, in Init() function. I have a render() function that renders the cube. In this function I have a for loop that makes 10000 cubes and render them on the screen, everything shows up and works perfectly. Now if I don't render anything I get around ~1600FPS. But after rendering the 10000 cubes my FPS drops to ~80FPS. I also have a free camera class where I can move in the world. The problem now is even if I move so far and I don't see the cubes anymore, my FPS still stays at ~80FPS. How can make it, that if I move far away I don't render the cubes and make my FPS get back to 1600FPS ? [CODE] void Engine::Init() { ..... //Init OpenGL CreateCubeVBO(5); // create cube with size of 5 units } [/CODE] [CODE] void Engine::Render(sf::Window &Window) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glLoadIdentity(); Camera1.Control(Window, 0.2, 0.2, Camera1.IsMouseIn); SkyBox1.Draw(50.0); Camera1.Update(); for(int i=0; i<10000; i++) //Draw 10000 cubes a move each one 10 units in the Z axis { glTranslatef(0.0f, 0.0f, 10.0f * i); glBindVertexArray(VertexBufferID); glDrawArrays(GL_QUADS, 0, 24); glBindVertexArray(0); } } [/CODE] [CODE] void Engine::CreateCubeVBO(float Size) { GLfloat Vertices[] = { Size/2, Size/2, Size/2, -Size/2, Size/2, Size/2, -Size/2, -Size/2, Size/2, Size/2, -Size/2, Size/2, -Size/2, Size/2, Size/2, -Size/2, Size/2, -Size/2, -Size/2, -Size/2, -Size/2, -Size/2, -Size/2, Size/2, Size/2, Size/2, -Size/2, -Size/2, Size/2, -Size/2, -Size/2, -Size/2, -Size/2, Size/2, -Size/2, -Size/2, Size/2, Size/2, -Size/2, Size/2, Size/2, Size/2, Size/2, -Size/2, Size/2, Size/2, -Size/2, -Size/2, Size/2, Size/2, Size/2, -Size/2, Size/2, Size/2, -Size/2, Size/2, -Size/2, Size/2, Size/2, -Size/2, Size/2, -Size/2, Size/2, -Size/2, -Size/2, Size/2, -Size/2, -Size/2, -Size/2, Size/2, -Size/2, -Size/2 }; glGenVertexArrays(1, &VertexBufferID); glBindVertexArray(VertexBufferID); glGenBuffers(1, &VertexBufferID); glBindBuffer(GL_ARRAY_BUFFER, VertexBufferID); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); } [/CODE]
  10. Ok I have another question about maps, and I thought why create new topic. Anyways, right now I have a 3d camera and I can move around my 3d world. Its just a simple room and a hallway. The thing is, I create this world just by writing the vertices and it took me some time to do it. This is my game map. [CODE] 52 vertices -3.0 0.0 -3.0 -1.5 0.0 -3.0 0.0 0.0 -3.0 1.5 0.0 -3.0 3.0 0.0 -3.0 -3.0 0.0 -1.5 -1.5 0.0 -1.5 0.0 0.0 -1.5 1.5 0.0 -1.5 3.0 0.0 -3.0 -3.0 0.0 0.0 -1.5 0.0 0.0 0.0 0.0 0.0 1.5 0.0 0.0 3.0 0.0 0.0 -3.0 0.0 1.5 -1.5 0.0 1.5 0.0 0.0 1.5 1.5 0.0 1.5 3.0 0.0 1.5 -3.0 0.0 3.0 -1.5 0.0 3.0 0.0 0.0 3.0 1.5 0.0 3.0 3.0 0.0 3.0 -3.0 1.0 -3.0 -1.5 1.0 -3.0 0.0 1.5 -3.0 1.5 1.5 -3.0 3.0 1.5 -3.0 -3.0 1.0 -1.5 -1.5 1.0 -1.5 0.0 1.5 -1.5 1.5 1.5 -1.5 3.0 1.5 -1.5 -3.0 1.0 0.0 -1.5 1.0 0.0 0.0 1.5 0.0 1.5 1.5 0.0 3.0 1.5 0.0 -3.0 1.0 1.5 -1.5 1.0 1.5 0.0 1.0 1.5 1.5 1.0 1.5 3.0 1.0 1.5 -3.0 1.0 3.0 -1.5 1.0 3.0 0.0 1.0 3.0 1.5 1.0 3.0 0.0 1.5 1.5 1.5 1.5 1.5 3.0 1.5 1.5 [/CODE] My question is, how can I create a single simple room without the need of writing every vertices myself? Now all these vertices were hand written and it took some time to do them, what if I have a big world with 3 or 5 rooms, how can I build these rooms? Do I use software like blender 3d or 3dmax to create a room and load it into my game? And how do companies build their maps? How do they build the rooms and hallways etc... ?
  11. [quote name='japro' timestamp='1327512934' post='4906146'] OpenGL 4.2 pretty much deprecates the fixed pipeline so you have to write shaders. The way you do transforms then is by passing the transformation matrix to the shader which then applies it to the vertices during rendering. [/quote] oo ok thank you very much. i'll start working on shaders. thank you guys for all your help.
  12. thank you [url="../../user/110541-guptan/"]guptan[/url] but i would like to know how to rotate the cube using OpenGL Mathematics (GLM) library. can anyone tell me how can rotate my cube using OpenGL Mathematics (GLM) library?
  13. [quote name='guptan' timestamp='1327497688' post='4906090'] You must be knowing how to write shaders for opengl 4.2 and make it running. Try a port of the following code(most probably no change), for matrix calculations (translation, rotation, scaling etc.) to get the uniform variables that you pass to your shader. [url="http://opengles-book-samples.googlecode.com/svn/trunk/iPhone/Common/esTransform.c"]http://opengles-book...n/esTransform.c[/url] [/quote] so if i don't use shaders i can't do translation, rotation or scaling? what is sharder? what is the use of them? sorry for the newbie questions.
  14. Hello guys OpenGL 4.2 is basically killing me, I can't rotation, transformation or scaling, I have to use another library to do it, which is OpenGL mathematics. And I can't find any tutorials on how to do this. I miss OpenGL 2.1. Can you please guys help me out here. I have this cube and I want to rotate it how can I do that in OpenGL mathematics? [CODE] void Engine::CreateCube() { float* Vertices = new float[72]; // Vertices for our square Vertices[0] = -0.3f; Vertices[1] = -0.3f; Vertices[2] = 0.3f; Vertices[3] = 0.3f; Vertices[4] = -0.3f; Vertices[5] = 0.3f; Vertices[6] = 0.3f; Vertices[7] = 0.3f; Vertices[8] = 0.3f; Vertices[9] = -0.3f; Vertices[10] = 0.3f; Vertices[11] = 0.3f; Vertices[12] = -0.3f; Vertices[13] = -0.3f; Vertices[14] = -0.3f; Vertices[15] = -0.3f; Vertices[16] = 0.3f; Vertices[17] = -0.3f; Vertices[18] = 0.3f; Vertices[19] = 0.3f; Vertices[20] = -0.3f; Vertices[21] = 0.3f; Vertices[22] = -0.3f; Vertices[23] = -0.3f; Vertices[24] = -0.3f; Vertices[25] = 0.3f; Vertices[26] = -0.3f; Vertices[27] = -0.3f; Vertices[28] = 0.3f; Vertices[29] = 0.3f; Vertices[30] = 0.3f; Vertices[31] = 0.3f; Vertices[32] = 0.3f; Vertices[33] = 0.3f; Vertices[34] = 0.3f; Vertices[35] = -0.3f; Vertices[36] = -0.3f; Vertices[37] = -0.3f; Vertices[38] = -0.3f; Vertices[39] = 0.3f; Vertices[40] = -0.3f; Vertices[41] = -0.3f; Vertices[42] = 0.3f; Vertices[43] = -0.3f; Vertices[44] = 0.3f; Vertices[45] = -0.3f; Vertices[46] = -0.3f; Vertices[47] = 0.3f; Vertices[48] = 0.3f; Vertices[49] = -0.3f; Vertices[50] = -0.3f; Vertices[51] = 0.3f; Vertices[52] = 0.3f; Vertices[53] = -0.3f; Vertices[54] = 0.3f; Vertices[55] = 0.3f; Vertices[56] = 0.3f; Vertices[57] = 0.3f; Vertices[58] = -0.3f; Vertices[59] = 0.3f; Vertices[60] = -0.3f; Vertices[61] = -0.3f; Vertices[62] = -0.3f; Vertices[63] = -0.3f; Vertices[64] = -0.3f; Vertices[65] = 0.3f; Vertices[66] = -0.3f; Vertices[67] = 0.3f; Vertices[68] = 0.3f; Vertices[69] = -0.3f; Vertices[70] = 0.3f; Vertices[71] = -0.3f; glGenVertexArrays(1, &VAO_ID[0]); // Create our Vertex Array Object glBindVertexArray(VAO_ID[0]); // Bind our Vertex Array Object so we can use it glGenBuffers(1, VBO_ID); // Generate our Vertex Buffer Object glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[0]); // Bind our Vertex Buffer Object glBufferData(GL_ARRAY_BUFFER, 72 * sizeof(GLfloat), Vertices, GL_STATIC_DRAW); // Set the size and data of our VBO and set it to STATIC_DRAW glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0); // Set up our vertex attributes pointer glEnableVertexAttribArray(0); // Disable our Vertex Array Object glBindVertexArray(0); // Disable our Vertex Buffer Object delete [] Vertices; // Delete our vertices from memory } [/CODE] In my redner function which draws the cube i tried doing this but nothing changes. [CODE] void Engine::Render() { glViewport(0, 0, WindowWidth, WindowHeight); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); ViewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -5.f)); // Create our view matrix which will translate us back 5 units ModelMatrix = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); // Create our model matrix which will halve the size of our model glm::mat4 View = glm::mat4(1.); View = glm::rotate(View, angle * -1.0f, glm::vec3(1.f, 0.f, 0.f)); glBindVertexArray(VAO_ID[0]); // Bind our Vertex Array Object glDrawArrays(GL_QUADS, 0, 24); // Draw our cube glBindVertexArray(0); // Unbind our Vertex Array Object } [/CODE]
  15. OpenGL

    [quote name='Tsus' timestamp='1327425767' post='4905821'] Hi, Perhaps you forgot to initialize glew, before creating any resource? (When I comment this out in some working code of mine it throws me the exact same exception.) [CODE]if(glewInit() != GLEW_OK) cout << "GLEW init failed!" << endl;[/CODE] Cheers! [/quote] thank you so much. it works perfectly