Jump to content
  • Advertisement

Search the Community

Showing results for tags 'C++'.

The search index is currently processing. Current results may not be complete.


More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Product Groups

  • GDNet+
  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 640 results

  1. Shaarigan

    C++ Common Runtime

    Hey everyone, I was fiddling these days with Raspberry Pi and emulation software to run good old retro games from my childhood and came across the question why there isn't a common runtime for C++ code. I avoid the L (for language) because I know a lot about the .NET CLR and it's general assembly model. The idea for a C++ common runtime is to allow precompiled code to run everywhere, on whatever archcitecture like C# does. Why isn't there something like that so we won't need emulation software for our 20 year old games? To prevent the discussion for platform dependent code and C++ optimizations, those are done by the C# CLR too and STL is also similar to the Framework code so bases are there. What are your thoughts?
  2. Hi guys, I've been learning to make my SDL reusable framework from the book SDL game development (image below). And now I'm trying to understand the ScrollingBackground (page 206 - creating Alien attack) but I still haven't figured out the meaning of the code. If someone finished this book please show me a more specific meaning, idea of the code (sorry for my bad english)
  3. So have been struggeling with this issue now for 20 hours or so. I'm using DirectInput, I know it's not the best but I have tried other approaches aswell which yields me the same results. What is happening is that I'm orbiting around a sphere with my up and down cursor buttons. Nothing to complicated really. What my issue is however is that when I press the key and hold it for a while(atleast this seems to be when the issue occurs, I have seen it at other times aswell but not as common) the keystate I get from DirectInput doesn't recognize that I have released the key. I can see from my debugging that I get a new keyboardState, and I can also see that from that keyboardState the key is still down, even tho I don't press it. This lag, delay or freeze or whatever one wants to call it can be up to several seconds. Here is a hastebin that includes the code in question: https://hastebin.com/ayucajobaw.cpp Any kind of ideas what my issue could be, or pointers for me what to google, cause I'm really running out of ideas here Best Regards Toastmastern
  4. Hi Guys, I have a struct of int's which I am trying to initialise by pushing and popping a vector of integers. All is working well if I initialise manually from the vector (for example) options.vsync = boolQuery(optionsList.back(), mem); optionsList.pop_back(); Instead of doing this for every member I am trying to use a simple 'for loop'. (Ignore the name boolQuery - this actually returns an int 0 for false, 1 for true, and -1 for indeterminate). for (int i = 0; i < optionsList.size(); i++) { int value = boolQuery(optionsList.back(), mem); optionsList.pop_back(); memcpy(&options + (i * sizeof(int)), &value, sizeof(int)); } This works for the first member but the remainder stay uninitialised. Debugging shows that the expected values are occurring during the loop, but they just aren't getting stored in the member integers. It looks as though the way I am trying to access the memory for the memcpy seems to be wrong. Any advice would be hugely appreciated.
  5. Hi there, You don't hear much about the Nintendo 3DS, but it's alive! Just wanted to share my info on development on the Nintendo 3DS #Nindie (not homebrew!). It's mostly for C/C++ but there's also Unity3D support (YMMV). The LT;DR version is: Free to sign up Strong recent sales, a long life left in 3DS Library spanning 3 generations Good affordable hardware Great software features Sustainable ecosystem & eShop features: Developer friendly rating & review system Nintendo brand association Higher value proposition Not shovelware friendly Not a flooded Over saturated ecosystem QR Codes - a visibility tool Path way to Switch Launching on a console I go into more details about in my blog here: http://mgarcia.org/2018/04/10/why-indie-developers-should-consider-making-games-for-the-nintendo-3ds Really low barrier to entry, but high technical barrier to product IMO anyway. I'm also doing a monthly development blog updates. Happy to answer any questions! (non NDA related) PS: I'm a noob, 3D is hard, C/C++ is hard, console dev is a PITA! Cheers Mike.
  6. Reading through Stroustrup C++ Programming Language I arrived at some rather strange array arithmetic (without use of pointers). He says the following: This surprised me too. How 1. a[j]==j[a] and 2. 3["Texas"]=="Texas"[3]=='a' are possible? Isn't a usually (read always) implicitly converted to T*, so how [a] could point to something meaning able? Also if array has 10 elements, than j==10, how address of 10 could point to the same thing, or it does? If somebody could explain this through assembly or memory I would really appreciate it.
  7. In almost all (read all) tutorials and books I found that when they talk about object lifetime is that they say the same thing. That is that a variable, automatic variable (declared in local scope), is created when it's definition is encountered and destroyed when its name goes out of scope. I find this to not be true. Even Stroustrup mentions this in page 167 (C++ Programming Language). Usually this variable is allocated in a stack, called stack frame. Now, I wrote a few simple c++ code examples and opened them as MASM files. From what I know they are allocated immediately when stack frame is created, that is at some offset from base stack pointer (or whatever is called), for e.g. if we have two ints, the second one is located at [BSP-8] considering 32-bit wide ints. This also makes sense since the space for all local variables needs to be set once, at function beginning, instead of being created each time a variable is declared. This would also slow the execution since several variables would have to created at separate times in a function which would use additional instructions. The thing is that I don't understand why all the textbooks mention this as explained above? It used to confuse me at the beginning until I red several lower level (asm books). If I'm wrong in any way please correct me.
  8. I've noticed some rather annoying data alignment behavior with Microsoft C++ compiling for X64. Perhaps it's in the C++ standard but I don't see the logic behind it. Here's the situation. If I have a class, call it A, with a Vtable and a 4 byte integer, then sizeof(A) returns 16 which is what I would expect because of 8 byte alignment. Now if I add another four byte integer to class A, sizeof(A) still returns 16, which is again what I would expect. However if instead of adding the second four byte integer to A, I create a new class B which inherits from A and then I add the second four byte integer to B, sizeof(B) now returns 24. This I don't get. I mean I understand the initial 8 byte alignment, but since you can't possibly have a B without an A, I don't see why the start of B also has to also be aligned on 8 bytes. It's just wasted space. It means that sub-classing can now incur a space penalty for no apparent reason. Anyone have an explanation for this? I also tested this making the class non virtual, with simply a double instead, just to see if the Vtable was causing something odd to happen. However it exhibited the exact same behavior so it seems to be some standard data alignment thing.
  9. Hi there, I'm working on a game in C++ in which I'm implementing my own ECS model. I'm implementing a model where entities are simply IDs and each components contains an ID that determines which entity it belongs to. I've gotten a pretty good framework in place for creating/destroying and adding/removing entities and components. I'm now onto the implementation of systems. However, I've run into an issue where I don't know the best way to couple the data between each component. For example, lets say I have an entity that contains both a physics and render component. I have a physics system that rips through all the physics components and updates the physics data (position, velocity, etc.). I then have a render system that rips through all the render components and renders them to the screen. However, the render position is often dependent on the physics position. Thus for some entities, the render data is coupled to the physics data. I'm curious what some of the best/efficient methods are for handling coupling component data. I've got a few methods in mind: 1) Have the systems couple data. For example, the physics system would rip through and update all the physics data. The physics system would then go and access all of the render components and update the information appropriately. However, I don't really like this model as it forces certain system to take on responsibilities that it shouldn't need to. For example, why should my physics system be responsible for explicitly updating render component data? Why not leave that for the render system? Furthermore, as I add other components that are dependent on physics data (e.g. sound, lighting effects, etc.), having the physics system access more and more components seems messy. 2) Bake an observer model into my component. In this approach, I would give components the ability to subscribe to other components (e.g. render component could subscribe to physics component). This way the physics system does not have to be responsible for updating other components, it just has to worry about the physics component. However, this seems to to break the ECS idea of components only being data, not logic. By implementing an observer system, I feel like I'm putting to much logic into the components themselves. I'm curious what other people have done or aware of methods that I have not mentioned.
  10. I'm looking into CTTI, which provides some nifty compile-time type info resolution. However, it does so in a marginally inconvenient way (and by marginally I really do mean marginally) as it provides the class name in the form of a pointer and a length as opposed to a NULL-terminated copy. I figured this wouldn't be too difficult to change. In particular, my idea was to take the pointer to the type name and length that CTTI provides, copy the contents into a statically stored constexpr std::array and store a pointer into said array within the type info container. Now, I'm neither completely foreign nor a genius when it comes to template metaprogramming, but the fact is that after a few hours I'm staring at an "internal error" and am somewhat out of ideas. First the issue at hand. nameof.hpp contains the apply() function, which I've modified in the following way: namespace ctti { namespace detail { // this sub-detail snippet is mine... namespace detail { // the idea is to convert a pointer/string into a std::array template<std::size_t... Is> constexpr auto make_elements(const char* src, std::index_sequence<Is...>) -> std::array<char, sizeof...(Is)> { return std::array<char, sizeof...(Is)> {{ src[Is]... }}; } template<typename T, typename = void> struct nameof_impl { static constexpr ctti::detail::cstring apply() { // get the name as ctti currently does it... static constexpr const ctti::detail::cstring cst = ctti::detail::filter_typename_prefix( ctti::pretty_function::type<T>().pad( CTTI_TYPE_PRETTY_FUNCTION_LEFT, CTTI_TYPE_PRETTY_FUNCTION_RIGHT )); // the following is code I added (all of the involved functions are constexpr, so there should be no problem with compile time evaluation) // get the length of the type name static constexpr const std::size_t N = cst.length(); // copy the substring into an array and store it as a static member within this function for any type T static constexpr const std::array<char, N> arr = detail::make_elements(cst.begin(), std::make_index_sequence<N>()); // get the pointer to the name static constexpr const char const* arrData = arr.data(); // construct a new ctti string that contains a pointer to the to-be NULL-terminated name return ctti::detail::cstring(cst.begin(), cst.length(), arrData); } } } Note that I haven't gotten to NULL-terminating the array yet. Not entirely sure how to do it, but first things first. The problem arises when using arr (eg accessing the data pointer), which causes Visual Studio to presumably not optimize it and spit out a C1001 (internal compiler error). What am I doing wrong in my code? Is this a problem with the compiler or am I doing something inherently illegal? NOTE: I've modified ctti::detail::cstring to contain the additional pointer (not shown here). NOTE 2: Visual Studio currently chokes when using more than one template parameter pack, so in case you want to use the library, there's a modification that needs to be done in meta.hpp: NOTE 3: Additionally, by default CTTI will produce bad type information if you're using it with classes (as opposed to structs). To fix this, the following change needs to be made:
  11. CONUNDRUM I'm very new to DirectX C++ programming, I come from a unity background but I'm trying to optimize my procedural mesh generation system to run on the graphics card with the new Unity ECS and Jobs system. For that I need native access to the render API and I've settled on DirectX11, I spent the last week or so learning DirectX11 and implementing a Compute Shader marching cubes implementation to run in native code in a multi threaded environment. Everything seems to be working but because I don't have much experience implementing a Multi-threaded rendering system I thought I'd ask here if I was doing it right. I plan on running my own tests but nothing beats someone with years of experience, if anyone one has any advice to offer that would be amazing :). IMPLEMENTATION So for my rendering system I knew I had to minimize the amount of blocking going on between the processing job threads and the rendering thread if I wanted to get any performance out of this at all. I decided to follow a similar double buffer design as modern rendering APIs; I have one front queue of draw calls being rendered by the rendering thread, and then a back queue that is being allocated to from the processing threads. At the end of the frame on the main thread I "present" the back queue to the front queue and swap there pointer memories, I of course do this in a windows CRITICAL_SECTION lock. Then again in the render thread I use the same CRITICAL_SECTION and lock it while I access the front queue. I copy the contents from the front queue into a dynamic buffer and then release the lock, I then proceed to render using this copied version of the front queue buffer. I copy the buffer instead of rendering directly from it because I want to minimize the lock time for the main thread present task. On top of this I also have to guarantee that the resources in the front queue that are being rendered are not destroyed or corrupted while they are being accessed. To do this I implemented my own thread safe pinning system. It's like a reference counting system except it deletes the data whenever I tell it to delete it in the processing thread, but it does not delete the object holding the data so I can tell whatever other thread that is attempting to acquire the lock that that the data is gone. When all pins are released and the objects gpu data has been killed, the holding object is destroyed. I use another CRITICAL SECTION per renderable object to pin, unpin, and generally access and modify this holder data. PRESENT QUEUE EXECUTE DRAW QUESTIONS 1.) Is it reasonable to copy the whole front buffer, element by element, into a dynamic array and delete it after rendering? Will this be too much allocation? Would it be better to just lock the whole front queue while I am rendering and render directly from it. 2.) Is it reasonable to use a CRITICAL SECTION for every renderable object and for pinning and unpinning? Is that too many critical sections? Is there a possible workaround with atomic functions and would there be a way to do automated pinning and unpinning so I can use std::copy instead of manually going element by element and pinning the data. I feel more secure knowing exactly when the data is pinned and unpinned aswell as when it is alive or dead. (BTW the pin and unpin methods also unlock the CS, that's why you see a lock with no unlock) 3.) Is there a better method for threading that does not require 3 buffers at once or maybe just a better way of preserving the integrity of GPU data while it's in the render thread being rendered. 4.) Am I making any noob D3D11 mistakes . This is my first time using it. Everything seems to be working in the Unity Editor but I want to be sure before I continue and build off of this. THANKS
  12. All compiled using -std=c++2a. ------------------------- First - defining a constexpr member function of a template after use. template <typename tTYPE> struct SFoo { constexpr void foo(); }; int main() { SFoo<int> foo; foo.foo(); } template <typename tTYPE> constexpr void SFoo<tTYPE>::foo() {} GCC compiles and links this fine. Clang doesn't instantiate foo(), and thus fails to link. NOTE: constexpr implies inline. I think LLVM is wrong here - the definition just needs to be provided somewhere. Am I right? (From this post). ------------------------------------- Second, default initialization of unused constexpr template value. template <typename T> constexpr int n; int main() {} Again, GCC accepts it, but clang++ complains: If you want to only use specializations of n, requiring a value here is unnecessary (and could prevent detecting bugs at compile-time). -------------------------------------- Are both of these LLVM bugs?
  13. I know the basics of c++ and am currently learning SFML. I'd like to join a project as a programmer to get experience. I can quickly learn any c++ engine's syntax, I'd like any experience I can.
  14. This will be a post mortem explaining how i failed the game dev competition for a tower defense game, so here it goes. In the start of june 2018 i found the tower challenge post by accident, read the description and was really excited. So i decided to apply and started right away - without any planning whatsoever. I created a new visual c++ project and after 3 evenings with a couple of hours i got the basic game mechanics nailed down: Enemies could be spawned and moved from waypoint to waypoint along a direction and randomly placed towers could hit and destroy it. Everything (tiles/enemies/towers) was defined in static int arrays, so i can adjust it however i like. It was going very smoothly and i was very happy with it. The next 2 evenings was a nightmare. I made a new map and suddently everything was broken. All the towers was shooting randomly, the enemies was not following the waypoints anymore, bullets missed all the enemies and so on, even the spawning was behaving weirdly. So it took me 7 hours to find all those bugs and fix them. After that in the next evening i refactored the current code, made it more robust and fixed a few bugs. In addition i added basic HUD rendering to display lives, score, money, current wave, etc. Now it was looking really good so far and the game was already playable. The next day for whatever reason i decided to use the editor "TileD" to setup everything. I have no idea why i wanted that, maybe i thought it would save me time or something but i was wrong. Even after 5 evenings, i still couldnt´t figure out how to get towers/enemies/waves defined in the TMX file. So i partly gave up on that idea and ended up just defining the walkable tiles and the waypoints in the TMX file. In addition i created a shitton of code just to parse a TMX file - including writing a generic xml parser in C99. The only thing useful i made in that 5 evening was that parser 😞 This entire process took me ~20 hours -> 4*8 useless workhours minus 2 hours for writing the xml parser. After that the next 3 evenings i did of lot of refactoring needed to get the TMX loaded in the way i wanted. The result was not that bad. I now could define all the waypoints, the walkable and placeable tiles in the editor and setup as many spawners as i want. This took me about ~6 hours. The next 2 evenings was a blast! I was very productive and added a lot of functionality and fixed a lot of bugs. I now had a fine looking HUD , multliple waves with multiple spawners for each wave. In addition i improved almost every part of the game, even the towers was rotating smoothly against the target now and you could lose or win the game. The "game" finally started to take shape. Of course after a blast, there comes the opposite of that: Destroying and unproductivity! In one evening i broke the tower rotation, the enemy position prediction, the rendering and even the HUD. Why of a sudden did everything brake? It may be that i just wanted to make it "even better" -> Over complicating simple things! In the following evening i reverted everything and simplified a lot of the game mechanics. Now all of a sudden the enemy prediction worked and the tower rotation was correct and very smooth. But the font rendering seems to be totally broken now - after switching to a new font. So i had no choice to still use the old font 😞 Many evenings later with a lot of delays between, i finally fixed the nasty font rendering bug. It took me over 10 hours to find that bug and 5 seconds to fix it... Now the new font or any other font works just fine. In addition i made a few simple functions to render and handle UI buttons - to select the appropriate tower. Now i got sick i could barely do anything, so i was of for over a week. After that i wanted get rid of the ugly dev graphics, so in 2 hours i made a push rendering system + opengl implementation and changed everything to it. It looked exactly the same as it was before, but now it was much more flexible and i finally could add sprites to the game. The next day i successfully added loading and rendering of sprites in just about 30 minutes. Then i searched the net for a free tileset, which i can use to test the sprite rendering. After i found one, i changed the TMX map to use it. The following 4 evenings i have written a lot of code for parsing/converting/rendering the tilesets from the TMX, but with wrong results. All the UV´s was incorrect and even after spending hours of debugging i could not find the bug at all. Now there was a full week where i didn´t do anything. The motivation was gone. The first evening in the following week i was still not motivated at all, but i wanted to get this finally fixed so i forced myself to analyze the code again - searching for the UV bug and after a short amount of time, i finally found the bug... It was just a typo... After fixing that typo now all the UV´s was correct and everything looked fine. In the next evening i added 3 more layers to the TMX map, trying to make it look more prettier. But there was a problem, the fixed map dimension was not sufficient to make use of the tilesheet i was going for. So i decided to change the entire system from a fixed map size to a dynamic one and this was pretty expensive from a time perspective, it took me around 2-3 hours. Now i had just a few days left before the deadline. The following days i moved all the wave/enemy/tower definitions into separated xml files, so i can starting making the actual 20 waves/enemies and a few towers. Of course this required me to change a lot of the internal systems, but the written xml parser now payed of and in an hour it was changed very easialy. Now i started to fiddle around with the data, trying to add more waves, more towers... Such tasks are not my thing, so it took me two hours just to add another wave and another tower 😞 So now i had one day left before the deadline and the game was not even close to be finished. I had one level, two waves, two towers, two enemies and very basic game mechanics working, without upgradable towers. Also i had no final art, no sound or music, not even a menu 😞 The following days i was really depressed about it, so i was not working at the project at all, so i failed and missed the deadline. So now comes my reasons why i failed it: 1.) I didn´t plan anything I had no idea which art style i was going for I had not slicest idea what type of waves/towers/enemies i want I had no idea how the level should look like I didn´t set any goals or milestones or tasks whatsoever 2.) Forcing myself to use the TileD editor was a huge mistake For such a little project, one level should be just fine. So why the heck do i need a editor when i just want to have one level anyway? The only thing i needed to setup in the editor was the visual tiles, the walkable and placable areas and the positions for the spawners and thats it. 3.) I added a lot of complexity without thinking it through At work i always do that, but for some f*cking reason on private projects i never do that and that always kills me. I should have sticked with the simplest solution in all cases, then i may had finished it in time. 4.) I didn´t continously worked on the game There was too many days of me not working on the game at all. I should at least made one little thing each day or something like that. But not everything was bad, at various point i made a lot of progress and the last build i made was not that bad. It was playable, you can win or lose the game - it just lacks content in a all places, so i decided to finish the game to end of september - to have at least one finished game made in my life. Thats almost two month´s from today - counting just the days, that should be doable - even with my limited time budget.
  15. For a small C/C++ game project, I want to add some physics on a ball, to allow it to roll against the slopes of a 3d world, in the same way as the example visible in the image below: However I have very few skills in physics, and I have some trouble to understand which physical laws should be applied, and how concepts like energy, force and acceleration should be used here. As a beginner, I imagined the situation as follow: Where: N (in green) is the normal of the current polygon above the ball Fg (in red) is the gravitational force, which should be constant Ff (also in red) is the frictional force, which should be constant P (in blue) is the current ball position P' (also in blue) is the next point to calculate I also wrote a dedicated function to calculate the physics on my ball, which is called every time a frame is about to be rendered. When this function is called, I know: The elapsed time The current ball position Which polygon is currently below the ball (from which I can extract the N normal shown above, and thus the slope) The constant forces (Fg and Ff shown above) From these values I tried to calculate the next ball position (P' shown above) based on the physics law F = m * a This gave the following code: #define M_CSR_Gravitation 9.81f typedef struct { CSR_Vector3 m_AccumulatedForce; float m_Mass; } CSR_Body; typedef struct { CSR_Vector3 m_Position; CSR_Sphere m_Geometry; CSR_Body m_Body; } CSR_Ball; CSR_Ball g_Ball; void csrPhysicsGravity(float mass, CSR_Vector3* pF) { // the formula for the gravitation is F = m * g pF->m_X = 0.0f; pF->m_Y = mass * M_CSR_Gravitation; pF->m_Z = 0.0f; } void ApplyPhysics(float elapsedTime, CSR_Plane groundPlane, const CSR_Vector3& frictionForce) { float dirAngleX; float dirAngleZ; float velocityAngle; CSR_Vector3 planeNormal; CSR_Vector3 gravity; CSR_Vector3 xDir; CSR_Vector3 zDir; CSR_Vector3 up; CSR_Vector3 dropForce; CSR_Vector3 motionForce; CSR_Vector3 acceleration; CSR_Vector3 prevCenter; planeNormal.m_X = groundPlane.m_A; planeNormal.m_Y = groundPlane.m_B; planeNormal.m_Z = groundPlane.m_C; // calculate the gravity force applied on the ball csrPhysicsGravity(g_Ball.m_Body.m_Mass, &gravity); xDir.m_X = 1.0f; xDir.m_Y = 0.0f; xDir.m_Z = 0.0f; // calculate the angle to drift against the x axis csrVec3Dot(&xDir, &planeNormal, &dirAngleX); zDir.m_X = 0.0f; zDir.m_Y = 0.0f; zDir.m_Z = 1.0f; // calculate the angle to drift against the z axis csrVec3Dot(&zDir, &planeNormal, &dirAngleZ); up.m_X = 0.0f; up.m_Y = 1.0f; up.m_Z = 0.0f; // calculate the drift velocity (the steeper is the slope, the higher is the fall speed) csrVec3Dot(&up, &planeNormal, &velocityAngle); // calculate the drift offsets to apply on the next frame dropForce.m_X = dirAngleX * velocityAngle * -gravity.m_Y; dropForce.m_Y = 0.0f; dropForce.m_Z = dirAngleZ * velocityAngle * -gravity.m_Y; motionForce.m_X = g_Ball.m_Body.m_AccumulatedForce.m_X + dropForce.m_X - frictionForce.m_X; motionForce.m_Y = g_Ball.m_Body.m_AccumulatedForce.m_Y + dropForce.m_Y - frictionForce.m_Y; motionForce.m_Z = g_Ball.m_Body.m_AccumulatedForce.m_Z + dropForce.m_Z - frictionForce.m_Z; g_Ball.m_Body.m_AccumulatedForce = motionForce; acceleration.m_X = (motionForce.m_X / g_Ball.m_Body.m_Mass) * elapsedTime; acceleration.m_Y = (motionForce.m_Y / g_Ball.m_Body.m_Mass) * elapsedTime; acceleration.m_Z = (motionForce.m_Z / g_Ball.m_Body.m_Mass) * elapsedTime; prevCenter = g_Ball.m_Geometry.m_Center; g_Ball.m_Geometry.m_Center.m_X += -acceleration.m_X * elapsedTime; g_Ball.m_Geometry.m_Center.m_Y += -acceleration.m_Y * elapsedTime; g_Ball.m_Geometry.m_Center.m_Z += -acceleration.m_Z * elapsedTime; } It works very roughly. The ball actually rolls down the slope, but never stops. And if I try to throw the ball from the bottom of the slope, it accelerates instead of curbing. Obviously something is pretty wrong, but what? As I say above, I'm not an expert in physics and I think I tend to confuse notions such acceleration, force and energy. However I tried to resolve this system by myself, without success. So I would be thankful if somebody can explain to me: which concepts of physics are involved to resolve the above mentioned system How should I correct my code to reach the above described objective (of course as long as the code does not have to be rewritten entirely) And/Or an example of a such algorithm, even if written in pseudo-code or in another programming language IMPORTANT NOTE I know that there are many physics engines, commercial or open-source, like e.g. Bullet, Box2d or Havok, which I may use to resolve the above issue. THIS IS NOT MY OBJECTIVE, I wan't to use them, at least for now. I WANT TO LEARN AND UNDERSTAND how to resolve this issue before using such engines. And I think that the proposed problem is simple enough to serve for this purpose.
  16. Hello once again to this entry to our devblog. This one will show the basics how we reworked the compound clouds to look - let's be honest - a lot better than they did before. The last version consisted of one class CompoundCloud which was represented by a procedural mesh component. That one started out as a simple cube and then offset the positions of the vertices by a randomly chosen amount between two previously chosen values. That looked... functional at best. And interaction with the player was pretty much not practical and computationally expensive. So the next idea we came up with was to make a cloud of sphere meshes and just have the player collect every one of those. This resulted in a new hierarchy. At the top there's still the CompoundCloud but it now has an array of Compound_ParticleComponents for its representation. Each one of those has a sphere mesh to handle collision and a particle system to look pretty. A short demo of the new system can be found here. We should probably start with the particle system. Not many steps requiered here. 1. Create a new particle system 2. Click on "Required" and in the first section ("Emitter") set a material (will be shown later) and the Screen Alignment to "PSA Rectangle" (this might not make a difference to the standard but it's set to that for our system). Then scroll down and set a cutout testure in the section "Particle Cutout". We used our heart icon you might have seen in one of our update videos. (we also changed the background color to something light so you can actually see what is happening) 3. Click an Spawn. There's a little more to do here. First of all set the rate in the "Spawn" section to "Distribution Float Uniform". Same for the rate scale. Play around with the values a bit or just take what we got there. Next set the particle burst method to interplated. The burst scale distribution should be "Distribution Float Particle Parameter". Once again play around with the values until you have something you like. 4. Go into "Lifetime" and set Min to 2 and Max to 1.1 (Again, once you're done with this tutorial just play around with this values) 5. Go to "Initial Velocity" and reduce the Min and Max values. We recommend between 2 for all Max and -2 for all Min. This will keep your particles closer together and not have them shoot in one direction. 6. Next up add a seeded initial location and set its bounds to something you like. 7. And the final step is to add a seeded sphere. You should now have something roughly looking like this. The Material: (absolutly nothing special) Now for the interesing part: The code. This is perfectly doable in blueprints, too but since we're mostly working in C++ I'll show how we solved it in code. I'm also only gonna show the constructors of the CompoundCloud class and the Compound_ParticleComponent class since this tutorial mostly deals with the look of the clouds. If you're interested in how any other part works just let me know and maybe I'll make a short explanation for that in the future. The code then: uint8 particleCount = StaticMaths::RR(CLOUD_PARTICLE_MIN, CLOUD_PARTICLE_MAX); We get a random value for the number particle systems we want to use. In our case this is our own function that simply determines a number between two other numbers. std::string center = "CenterSystem"; UCompound_ParticleComponent_Cell* temp = CreateDefaultSubobject<UCompound_ParticleComponent_Cell>(FName(center.c_str())); particles.Add(temp); RootComponent = temp; Then we set up the center component. All the other systems will circle around this one. This also functions as the rootComponent for the actor. The UCompound_ParticleComponent_Cell is the second class and we will deal with it later. for (uint8 i = 0; i < 100; i++) { for (int j = 0; j < pow(i, 2); j++) { //define the name for the current particle system //ParticleSystem_<circleNum>_<Num>_<randomSeed> std::string name = "ParticleSystem_"; name.append({ static_cast<char>((i + 1)) }); name.append({ "_" }); name.append({ static_cast<char>(j + 1) }); name.append({ "_" }); name.append({ static_cast<char>(j + i) }); //create the particle system with the newly defined name UCompound_ParticleComponent_Cell* temp = CreateDefaultSubobject<UCompound_ParticleComponent_Cell>(name.c_str()); particles.Add(temp); temp->SetupAttachment(RootComponent); //set up random location within a circle double a = (((double)rand() / (RAND_MAX)) + 1) * 2 * PI; double r = (CLOUD_RADIUS_STEPS * (i + 1)) * sqrt(((double)rand() / (RAND_MAX)) + 1); double x = r * cos(a); double y = r * sin(a); FVector location = FVector(x, y, 0); temp->SetRelativeLocation(location); //finally: check if number of elements in array is particle count //if so, stop this loop if (particleCount - 1 == particles.Num()) { break; i = 100; j = pow(i, 2); } } if (particleCount - 1 == particles.Num()) { break; i = 100; } } This part is where the magic happens. Basically we want to have somewhat circular shapes around the center system. So the outer for-loop with i counts the circles. The 100 is a dummy value since there will never be that many circles and it would be a waste of resources to actually calculate the true number of circles. We only need to know the number of particleComponents which is our particleCount. The inner loop with j counts from 0 to i to the power of 2. So on every circle there are i*i particleComponents. Next up is a bit of naming. Not really relevant. Then we create another particleComponent and add it to the actor and the array. What comes next might be interesting for some: this formular basically determines a random position on a circle. So we take (i + 1) times our pre-defined cloud radius steps to get the radius of our current circle and we have all the data we need. Everything else can be determined from that and a random number. Whe then set that location for the particleComponent. At the end of the inner loop we check if we already have all the particles we need. If so set i and j to their max values so the loops stop. This is why we didn't need to calculate how many circles there will be when we start the loops. Don't worry, the particleComponent involves less maths. //instantiate mesh component and particle system component particleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("ParticleSystem")); mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh")); particleSystem->SetupAttachment(this); mesh->SetupAttachment(this); //Collision binding mesh->bGenerateOverlapEvents = true; mesh->OnComponentBeginOverlap.AddDynamic(this, &UCompound_ParticleComponent_Cell::BeginOverlap); mesh->OnComponentEndOverlap.AddDynamic(this, &UCompound_ParticleComponent_Cell::EndOverlap); We create default subobject for the mesh and the particles system and then bind the collision functions. Easy as that. //get the mesh and set it auto meshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Game/Meshes/ball.ball'")); if (meshAsset.Object != nullptr) { mesh->SetStaticMesh(meshAsset.Object); mesh->SetVisibility(false); mesh->RelativeScale3D = FVector(5.f); } else { Logging::Log("Could not find Asset 'ball' at path in Compound_ParticleComponent_Cell"); } Then we load the mesh and set it. We also scales up the sphere mesh since it turned out to be way too small and the player would miss it a lot of the time. (That Logging::Log there doesn't really concern you. It's a function we wrote that simple writes a message into a file and onto the screen. Helpful for debugging. I left it in there for this tutorial because I think you should always have something in your code tell you when something goes wrong.) //get the needed particle system and set it in the component try { //static ConstructorHelpers::FObjectFinder<UParticleSystem> psAsset(TEXT("ParticleSystem'/Game/ParticleSystems/PS_CompoundCloud_SingleCelled.PS_CompoundCloud_SingleCelled'")); auto psAsset = ConstructorHelpers::FObjectFinderOptional<UParticleSystem>(TEXT("ParticleSystem'/Game/ParticleSystems/PS_CompoundCloud.PS_CompoundCloud'")); if (psAsset.Succeeded()) { particleSystemType = psAsset.Get(); particleSystem->SetTemplate(particleSystemType); } else { Logging::Log("Could not find Asset 'PS_CompoundCloud_SingleCelled' at path in Compound_ParticleComponent_Cell"); } //particleSystem->Template = particleSystemType; } catch (int e) { Logging::Log("Could not find Asset 'PS_CompoundCloud_SingleCelled' at path in Compound_ParticleComponent_Cell\nCause: FObjectFinder Access Violation"); Logging::Log(e); } We had some trouble loading particleSystems this way so I left in both ways to do it and the try-catch block in case one of you might have a similar problem. So that's basically it. Bye and keep on evolving.
  17. I'm reading the book "Game Engine Architecture" where the author suggests declaring singletons as global variables, and later initialize each of them inside main() in the correct order. Example from the book: RenderManager gRenderManager; PhysicsManager gPhysicsManager; AnimationManager gAnimationManager; TextureManager gTextureManager; VideoManager gVideoManager; MemoryManager gMemoryManager; FileSystemManager gFileSystemManager; // ... int main( int argc, const char * argv ) { // Start up engine systems in the correct order. gMemoryManager.startUp(); gFileSystemManager.startUp(); gVideoManager.startUp(); gTextureManager.startUp(); gRenderManager.startUp(); gAnimationManager.startUp(); gPhysicsManager.startUp(); // ... // Run the game. gSimulationManager.run(); // Shut everything down, in reverse order. // ... gPhysicsManager.shutDown(); gAnimationManager.shutDown(); gRenderManager.shutDown(); gFileSystemManager.shutDown(); gMemoryManager.shutDown(); return 0; } Isn't it risky to create all these singletons on the stack? I mean, depending on the situation won't I get a stack overflow or something like that? I apologize if it's a silly question, I'm just a little confused about the topic of where and when to allocate memory.
  18. Hello, I'm implementing SSAO for my engine but I noticed the kernel wasn't rotating properly. What happens is when I sample my random-vector texture I always get the same result, regardless of input texture coordinates. Here's my shader: Texture2D randomTexture : register(t2); SamplerState smplr { Filter = D3D11_FILTER_ANISOTROPIC; AddressU = Wrap; AddressV = Wrap; }; float4 PS_main( in float4 screenPos : SV_Position) : SV_TARGET0 { //screensize 1280x720, randomTexture size 64x64 float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f); float3 rvec = randomTexture.Sample(smplr, rvecCoord).xyz; return float4(rvec, 1.0f); } Off-topic code omitted. I cant for the love of my life figure out why this sample would always give me the same result. Changing the line : float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f); to float2 rvecCoord = float2(screenPos.xy); seems to make no difference. Here's a print of the shader state. Any help appreciated! ❤️
  19. 3dBookman

    The 3D book

    After a break of several years the 3D book project is back on. A few short words now on what this blog is about. I have to deliver my wife to the bus station in a few minutes, then a week alone so may have the time then to explain things. But the 3D book is something I started in 014 and put several years into, then the break, now on again. A win32 app with a text window and an ogl window. I just remembered I had something written on this so here it is I write to see if anyone in this community of game developers, programmers, enthusiasts, may be interested in a project I have been developing[off and on] for several years now. So follows a short description of this project, which I call the 3D-Book project. The 3D-Format Reader: A new format of media. Imagine opening a book, the left page is conventional formatted text - on the right page a 3D animation of the subject of the text on the left hand page. The text page with user input from mouse and keyboard, the 3D page with user intput from a game pad. An anatomy text for a future surgeon, with the a beating heart in 3D animation. A childrens story adventure book with a 3D fantasy world to enter on the right page. ... Currently 3D-Format Reader consists of a C++ Windows program: Two "child" windows in a main window frame. Two windows: a text-2D rendering window and a 3D-rendering window. The text-2D window, as its' name implies, displays text and 2D graphics; it is programmed using Microsoft's DirectWrite text formatting API and Microsoft's Direct2D API for 2D graphics. The 3D-rendering window uses the OpenGL API. A 3DE-Book page is formatted in one of two possible modes: DW_MODE or GL_MODE. In GL_MODE both windows are shown; the text-2D rendering window is on the left and the 3D OpenGL window is on the right. In DW_MODE, only the text-2D rendering window is shown, the OpenGL window is hidden (Logically it is still there, it has just been given zero width). The 3D-Format Reader reads text files, which consists of the text of the book, control character for the formatting of text, (bold, underline, ...), display of tables, loading of images(.jpg .png ...), and control of 2D and 3D routines. 3D-Reader programming is based on a Model-View-Controller (MVC) architecture. The MVC design is modular: The Controller component handles user input from the operating system , the Model component processes the input, and the View component sends output back to the user on the display. Typical Parent-Child windows programs have multiple "call back" window procedures(winProcs): One for the parent window and one for child window. The MVC model, simplifies message routing by using a call-back window procedure which receives Windows messages for the main window, the text-2D window and the OGL window. A sample MVC program by Song Ho Ahn was used as a template for the 3DE-Reader. Rushed for time now, so a hasty sign off and thanks for reading.
  20. OpenMouthGaming

    where to start pls help

    so im going to be completely honest I have autism and adhd so my concentration and attention span is crap but in one month I have an interview for a game development school I need to be able to learn any or all of the programming languages in the tags in under a month at least just the basics so im able to make simple programs for a portfolio preferably the stuff will be free and interactive so not just videos and text thx
  21. Hi there, I'm currently working with SDL2 and have been able to successfully render textures to the screen. I've also been experimenting with the sound and event mechanisms in SDL2. I've recently been thinking about other aspects of game design, specifically UI design. As I've stared envisioning my game, I see there is need to handle text input, button clicking, dropdown menus, and more. I've done some UI programming in other languages (Java, C# winforms, etc.) and have even done some in Qt. These libraries often feature all the standard UI elements. As of currently, I'm trying to figure out what SDL2's role should be in the end application. Should SDL2 only be used for game rendering, sound handling, and game inputs? And then would it make sense to use an external GUI library to handle all of the other standard UI features? For those of you familiar with SDL2, what purpose do you believe it serves?
  22. When working on the project Asteroids there was quite a lot of learning especially concerning classes. What helped the most was the time period I was given by all of you for this project. My first reaction was "Oh, there is no way this can be complete in that amount of time." However, upon trying it was! Now, the following ten algorithms will be studied: Dijkstra's Algorithm Longest Common Subsequence Convex Hull (Graham Scan) Counting Sort Simplex Miller-Rabin Primality test Huffman coding Kruskal's algorithm Simple Greedy Divide and Conquer Algorithms The last two are algorithm types. This post is a request for experiential guidance for the time period recommended for the study of each of these subjects. Alleviating any sort of stress or anxiety that is not necessary is my goal. Each one does not need to be done in its solo entirety; however, being complete is desired. It is not believed that they should all be one exact equal time period but if that's what you have time for that's okay too! Thank you for your empathy, Josheir
  23. Hi! I'm currently looking for a side project to put my time into. I usually put my time into tinkering small features and want to add something into my portfolio later on. Thats why I'm interested to work on a project again that will result in some kind of game. My background with general game programming with focus on a homebrew engine along with homebrew rendering engine for 3D-games all done in C++. Now I just use my programming skills for educating future game developers. Tools that I've used before includes Unity, Unreal and also my own (pretty shitty) engine. I could probably could work on almost any kind of game that would need a programmer, preferably something that has co-op or some kind of multiplayer features. It doesn't need to be a project with motive to publish or anything, just for fun is all I look for Also open for gathering a group to together brainstorm something up
  24. Hello everyone! Lately in my spare time I have been working on the Houzi library, a C++ multimedia library for 2D games. I did it mainly for fun and exercise, but it has grown to have a respectable amount of functionalities, so I thought I would share it with the community. I am still working on it to iron out some rough edges and add some much needed features, therefore the code is not yet in a stable state, and I would appreciate any feedback you can give to improve it. Here is the link to the GitHub repository: https://github.com/DavideCorradiDev/houzi-game-engine The library comprises seven separate modules: - A core module providing some basic utilities, such as STL extensions, implementation of some concepts from the C++ core guidelines (e.g. span), a basic error handling framework, and so on. - A mathematics module providing simple classes for matrices, vectors, rotations, and transforms. - A system module abstracting window management and input for different OS (mostly a wrapper around SDL with some extras thrown in). - An OpenGL and an OpenAL module, providing a thin layer of abstraction between these libraries and the rest of the code. This abstraction layer is used, for example, to provide simpler error checking, better type safety, abstraction between different library specifications (e.g. OpenGL vs GL ES), and so on. - A graphics module, providing classes for easy sprite and text rendering. - An audio module, providing classes for easy audio file loading and sound playing. Thanks for any feedback!
  25. I've been going through this tutorial and understood it mostly except the highlighted part. The tutorial explains vpointer and vtables. Steps are as follows, vpointer hidden in first 4 bytes of the object will be fetched vTable of this class is accessed through the fetched vPointer Now from the vTable corresponding function’s address will be fetched Function will be executed from that function pointer What I don't understand is the 3rd (bold) part. How does the compiler know which function (function address) to call from its virtual table? Edit: I went through this tutorial too which explains it a bit further but the original question still holds. I guess that compiler knows how to get to specific function in vtable by some pointer indexing, like vptr+4 or something. But than how a compiler knows not to overflow and not do a vptr+12 if a +12 does not exist?
  • 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!