Jump to content

SpiderPig

Members
  • Posts

    2,348
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. if (Time::Millisecs() > lastTime + 1000L) { velChange = entity->GetVelocity(true) - lastVelocity; lastVelocity = entity->GetVelocity(true); lastTime = Time::Millisecs(); } I used this code to verify how fast it was accelerating per second, after setting Damping to 0 the change in velocity was a constant 9.8ms per second. So the original code works now. float _force = -9.8f * entity->GetMass(); entity->AddForce(0.0f, _force, 0,0f); Though it still seems too slow. The object just isn't falling fast enough. I could make it higher to it look right but I'd like to know why 9.8ms isn't enough...
  2. From what I can tell, the acceleration starts off fast, then the faster the object gets the slower it accelerates... EDIT : SetDamping(0, 0); fixed that
  3. For gravity I was using this code; float _force = -9.8f * entity->GetMass(); entity->AddForce(0.0f, _force, 0,0f); But I have to increase the mass to big numbers in order to achieve realism and the formula is wrong anyway. Every second, the object should be going 9.8ms faster than before (ignoring friction) and the acceleration should be regardless of weight. The force on the earths surface is mass x acceleration, however acceleration in free fall is the same for each object. float _force = -9.8f; Vec3 _entityVelocity = entity->GetVelocity(true); entity->SetVelocity(_entityVelocity.x, _entityVelocity.y + (_force), _entityVelocity.z, true); This code is better but maybe a little too fast, it's hard to tell. I'm calling it in the objects Actor in the update-physics loop, as far as I'm aware this runs at 60FPS regardless of frame rate. So that means that _force should be equal to "9.8 / 60" but that's too slow... I'd like to use AddForce() but the numbers don't seem right. Any physics gurus here that might know why AddForce() doesn't do the job? And why 9.8 / 60 is too slow?
  4. Yes you can do that. I did that for some animated images.
  5. I'm not sure if you can play a video cut scene but you can make code to show one. You can easily draw some black rectangles at the top and bottom of the screen to show that it is a cutscene (as I've seen some games do). But the rest is up to your coding abilities.
  6. Would be handy for SetMousePosition() to take a Vec3 argument. I use this a lot; lastMousePos = window->GetMousePosition(); .... window->SetMousePosition(lastMousePos.x,lastMousePos.y,lastMousePos.z);
  7. Should be about 11 AM for you. http://www.timebie.com/timezone/pacificcolombia.php
  8. After three weeks of work, Pre-Alpha v1.1 is ready. Terrain The terrain has seen some behind the scenes improvements with speed as well as visual improvements to geometry and texturing. When I manage to get Texture Arrays working I will be able to finish of the new texturing shader that will include Tessellation and over 16 different texture maps as well as various masks that will paint according to erosion and forest locations. An image of one of the mountains randomly placed in the First World, textured with two 4k textures. The way the generator works is there is a predefined list of terrain features, like mountains, rivers and valleys. Based on a low resolution base map which is unique for each fragment, these features are placed at different scales, positions and rotations. They will also merge with one another to provide enough variation that it will be hard to see any similarities. At the moment though there are not enough maps to make this unnoticeable. Saving and Loading I have now implemented the ability to save and load a game. Currently the only states that are saved are the players position, stats and inventory. Each slot shows the date and time that it was saved on as well as the save name and version number. Slots can be deleted and overwritten. The version number will change over the course of the updates, but the ability to load older versions will always be available. And to save a new game, click the empty slot then click save. Now that this mechanic is done I can work on more game play. What's Next The next step is to improve the blacksmith and general store. These two places will be the first to provide work opportunities for the player. These opportunities will improve skill and eventually allow you to buy and use crafting equipment outside of the towns. I will also be implementing some other mercenary characters and animals to hunt. The mercenaries will just offer some fun conflict to begin with and the animals will offer another source of income. I hope to have a deer and wolf done by the next update in a few weeks. The full change log is packaged with the game, here.
  9. Thanks. I was getting the size of a compressed image for one of the tests, so that was one issue. But still having no success even with defining the pixels manually. int _width = 1024; int _height = 1024; unsigned char* buf = new unsigned char[_width * _height * 4]; int index = 0; for (int x = 0; x < _width; x++) { for (int y = 0; y < _height; y++) { buf[index] = 255; buf[index + 1] = 255; buf[index + 2] = 255; buf[index + 3] = 255; index+=4; } } OpenGLShader* shader = (OpenGLShader*)mat->GetShader(); glUseProgram(shader->program); GLuint _buffer; glGenTextures(1, &_buffer); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_ARRAY, _buffer); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, _width, _height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 1, GL_RGBA, GL_UNSIGNED_BYTE, buf); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  10. Okay I solved the crash; Changed this; texture->GetMipmapSize(0) * 4 To this; texture->GetMipmapSize(0) * 8 Curious as to why I need to multiple by 8 though... Is GetMipmapSize() in bytes? After fixing the crash the result was still black... I will conquer this...
  11. Ah okay. I thought it was an index referring to the position in the array, 0 being the start. But that would probably be the zoffset? So I set depth to 1; glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 1, GL_RGBA, GL_UNSIGNED_BYTE, buf); But now glTexSubImage3D() throws this error every time; Exception thrown at 0x04BF5160 (nvoglv32.dll) in TestingGrounds.debug.exe: 0xC0000005: Access violation reading location 0x0CCF1000. I will google the error after work. Thanks. I'll use this one instead.
  12. Thanks, but still no joy. It's odd, I've been able to use GL commands to set a shader_storage_object before. But not textures... sampler_2D or arrays... Model* box = Model::Box(); box->Move(0, 1, 0); Material* mat = Material::Load("Materials\\Test.mat"); box->SetMaterial(mat); Texture* texture = Texture::Load("Materials\\bluegrid.tex"); int _width = texture->GetWidth(); int _height = texture->GetHeight(); char* buf = new char[texture->GetMipmapSize(0) * 4]; texture->GetPixels(buf); OpenGLShader* shader = (OpenGLShader*)mat->GetShader(); glUseProgram(shader->program); GLuint _buffer; glGenTextures(1, &_buffer); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_ARRAY, _buffer); GLenum e4 = glGetError(); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, _width, _height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); GLenum e5 = glGetError(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); GLenum e7 = glGetError(); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLenum e8 = glGetError();
  13. It's amazing how much a little detail can add to a scene
  14. I'd be up for that. Depends on time in the land of AUS of course
  15. Awsome news! I'm excited about the 64 bit worlds. I've got plenty of uses for it ?
  16. I googled "texture arrays are black" and found this... So it may need more mipmaps at least, or other information about how to use the image...
  17. It's a shame. I really wanted this for the terrain. Atlases are a bit finicky.
  18. Ah okay. Yeah I tried 4.2 and 4.3 so I could use the layout parameter. It doesn't work with it or without it. I also tried just sending the image as a regular TEXTURE_2D but still no success.
  19. Thanks. But still nothing. OpenGLShader* shader = (OpenGLShader*)mat->GetShader(); Uniform* uniform = shader->GetUniform("arrayMap"); glUseProgram(shader->program); GLuint _buffer; glGenTextures(1, &_buffer); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_ARRAY, _buffer); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, _width, _height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); glUniform1i(uniform->index, 0);
  20. Found this on how to do it, but still no success. http://gaarlicbread.com/post/gl_2d_array
  21. Yeah. I do it all the time. Just keep the names the same and simply replace the files. Leadwerks will detect and convert the updated file. Depending on the model you may need to reapply materials. But the model will stay in the exact place you left it. Also providing origin points are the same.
  22. I can see how it's supposed to work, but I can tell why it's not... ? Texture* texture = Texture::Load("Materials\\bluegrid.tex"); int _width = texture->GetWidth(); int _height = texture->GetHeight(); char* buf = new char[texture->GetMipmapSize(0) * 4]; texture->GetPixels(buf); OpenGLShader* shader = (OpenGLShader*)mat->GetShader(); Uniform* uniform = shader->GetUniform("arrayMap"); glUseProgram(shader->program); GLuint _buffer; glGenTextures(1, &_buffer); glBindTexture(GL_TEXTURE_2D_ARRAY, _buffer); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, _width, _height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); glUniform1i(uniform->index, _buffer); uniform sampler2DArray arrayMap; //main outcolor *= texture(arrayMap,vec3(ex_texcoords0.x,ex_texcoords0.y,0)); _buffer is an unsigned int, but when I use glUnfiorm1ui() it throws an GL_INVAILD_VALUE error. buf is a SIGNED_BYTE array but passing it to the OpenGL commands you recommend GL_UNSIGNED_BYTE. The texture is uncompressed and has no mipmaps. uniform->index is 0. So the uniform is being found because uniform is not equal to NULL. As far as I can tell the arguments for glTexImage3D and glTexSubImage3D conform to what the wiki says. Nothing is throwing an error. Maybe there's something overwriting it later on as the program runs?
×
×
  • Create New...