• Advertisement

Search the Community

Showing results for tags 'Algorithm'.



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

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • GameDev Unboxed

Categories

  • Game Dev Loadout

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
  • Topical
    • Virtual and Augmented Reality
    • News
  • Community
    • GameDev Challenges
    • For Beginners
    • 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
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams

Blogs

There are no results to display.

There are no results to display.

Marker Groups

  • Members

Developers

Developers


Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 76 results

  1. This is my first time building a game engine, albeit a 2D one for Android. I've decided to build a simple ECS engine. The game I'm trying to *almost* duplicate at the moment is Doodle Jump. I currently have the following systems running in my update loop, in the given order: 1) Physics (applies gravity) 2) Collision (works by predicting next position based on current position and velocity, and updates the current position on collision) 3) Transform Update (updates all entities based on their current velocities) 4) Render System (Draws to canvas) I have the following questions: I want to write a manager that generates obstacles at, say, fixed gaps and when the player reaches the middle of the screen. This manager will need the current position and velocity of the player. (It finds the player by quering the ComponentManager for all entities having a PlayerComponent) 1) Where should this manager be placed in the game loop? 2) Should it even be a manager? Can such logic lie in systems? 3) Extending upon 2, what really are Systems supposed to handle? Any help is appreciated!
  2. I'm looking for solutions to a Line of Effect system I'm creating. Specifically, I'm looking for a real-time algorithm that helps an AI unit find the closest tile in range that has a line of effect to its target At the moment, I'm using raycasting (in Unity) to determine what tiles have lines of effect (no obstructions) to each other. This information is then used by the AI to locate an unobstructed targeting position within range. The end result is that every tile has a list of other tile locations it has a clear line of effect to. The problem is that it takes forever to scan and makes the map far too static for my needs. Anyone implement something similar? Thanks
  3. A texture rectangle, texture type is RGBA. the alpha channel like this: (0=0,x=255) [0][0][0][0][0][0][0] [0][0][x][x][0][0][0] [0][x][x][x][0][0][0] [0][x][x][x][x][x][0] [0][0][0][x][x][x][0] [0][0][0][x][x][0][0] [0][0][0][0][0][0][0] I want a function to picking. now I have a very clumsy solutions: //system Init............. //.......... //pixel buffer to texture....... (texture is handle, a number.cannot get pixel matrix.) //.......... BYTE pixel_alpha[7][7];//save alpha channel matrix //.......... texture.draw(30,30);//draw the picture in the window x=30 , y=30 //.......... if(picking(GetMouseX,GetMouseY))MessageBox("click!"); // picking functio //.......... /*picking function*/ bool picking(int x,int y) { int mouse_to_image_x, mouse_to_image_y;//get mouse position in the image mouse_to_image_x = 30 - x; mouse_to_image_y = 30 - y; if((mouse_to_image_x < 0 && mouse_to_image_x > 7) && (mouse_to_image_y < 0 && mouse_to_image_y > 7))return false;//mouse is not in the image for(int i = 0; i < 7 * 7; i++) { if(pixel_alpha[mouse_to_image_x][mouse_to_image_y] == 255)return true;//in the image and alpha channel is 255 } return false; } //============================================================================================= but...... 1.an excessive amount of memory in alpha channel matrix. 2.i think efficiency is not high. so, how to do? not is ray picking, What is this technology called?
  4. Hi, I am looking for an algorithm that takes as input a point cloud and generates a list tetrahedrons (Delaunay?). I would like to use said tetrahedrons as a mean to interpolate the point cloud values at given points in space. Can anyone point me toward some resources? Cheers!
  5. I make a one game, and i want to do a sistem of tree feling, like in Lumber Tycon 2.But i do not know how do this. If anyone has any ideas how to do this, please write!
  6. Hello, I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL". All OpenGL issues works fine for me, all rendering etc. But when I started implement the boid's algorithm it was getting worse and worse. I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code (here: https://github.com/jyanar/Boids/tree/master/src) but it still doesn't work like in tutorials and videos. For example the main problem: when I apply Cohesion (one of three main laws of boids) it makes some "cycling knot". Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. I followed many tutorials, change a try everything but it isn't so smooth, without lags like in another videos. I really need your help. My code (optimalizing branch): https://github.com/pr033r/BachelorProject/tree/Optimalizing Exe file (if you want to look) and models folder (for those who will download the sources): http://leteckaposta.cz/367190436 Thanks for any help...
  7. Hi all, We do these internal game jams from time to time. One of us created a multiplayer game that we had enough fun playing in the office that we thought we would just stick it in a browser for the world to enjoy, and just use ads to pay for it's running costs. The game is kazap.io. I thought I would share with you how we handled making the motion smooth and keeping a 'snappy' feel. Here is the video, and there is also a blog post with code!
  8. I am programming boolean operations on 3D meshes which are described by sphere trees. They do not deform, nor change in time anyhow. However to generate the environments I need to perform boolean operations on them as fast as possible. I need to find all the collisions between polygons (triangles). What is the best approach / algorithm for that purpose? I haven't found anything particularly useful via Google. In detail: I am in need for an algorithm that will take two sphere trees and return the buffer of all collisions. I do not have much experience in using sphere trees so my idea is to check every polygon from the first mesh with the second mesh sphere tree and vice versa. Somehow I feel that is a waste of CPU power. Could anyone give me a description of better approach or some useful links?
  9. Hello, I would like to implement continuous point-triangle collision detection as part of a cloth simulation. What robust implementations of this are used in practice? For example it is simple to use a ray-triangle intersection with q (particle start) and q1 (particle end) defining the ray relative to the triangle. Though I find this is not robust as the simulation can force the particles into an implausible state, which once it occurs even by the slightest margin, is unrecoverable. Over-correcting the particles helps somewhat, but introduces oscillations. This could be combined with a closest-point-to-triangle test that runs if the ray-intersection fails, but this seems to me very expensive and is essentially running two collision detection algorithms in one. Is there not a better way to combine them? I have searched for a long time this but most resources are concerned with improved culling, or improved primitive tests. I've found only one paper that specifically addresses combining CCD & DCD for point-triangle tests (Wang, Y., Meng, Y., Du, P., & Zhao, J. (2014). Fast Collision Detection and Response for Vertex / Face Coupling Notations. Journal of Computational Information Systems, 10(16), 7101–7108. http://doi.org/10.12733/jcis11492), which uses an iterative search with a thickness parameter. Is there anything beyond what I have described for this? Sj EDIT: I am familiar with Bridson, Du, Tang, et al. and the vertex-face penalty force computation, but I don't see how this is fundamentally different from the ray+closest-point test, other than the cubic formulation allows both the triangle and vertex to change in time. Though Du et al's Dilated Continuous Contact Detection seems like it should do both, so maybe I need to read it again..
  10. Recently I have this problem at work that I've been looking and reading some solutions for. I would like to get some others ideas and thoughts on this to have them going through my mind to hopefully come up with a good solution that could be implemented into the system. The Problem: We have X amount of people that need to be put into Y amount of rooms. Each room can hold a certain amount of people, and can be different per room. I need to automatically assign these people to rooms. General Rules: Certain groups of people can only room with their group. There can not be more than a ± 2 year age difference in room mates. You can only room with the people of the same gender. People can request a roommate (can assume this room mate already fits the rules as above), system should attempt to fulfill roommate requests, but it doesn't have too if can't. So far I currently have a prototype solution working though I feel it does not really come up with an optimal solution, as I am getting a lot of rooms that only get one person rooming in them. Currently I am just dividing everyone that can be roomed with each other into groups. Then for each person inside of each group I just assign them the next available room. This just feels too "greedy" I guess and I don't think I can rely on this to come up with an optimal solution (not in terms of time complexity, but in terms of a not having a lot of people rooming with each other). So I was wondering what are some ideas others may have had. I am looking for some ideas to talk it out really. I am not looking for code solutions. Small pseudo code solutions at the most. Thanks for any ideas anyone may have.
  11. I want to create terrain that has sharply defined features, but still has the flexibility of a height map. Though a height map must be defined by a grid, I don't want to terrain to look like a grid. All my previous approaches to this problem tend to look like grids, so now I'm aiming to allow for completely arbitrary discontinuities in the height map. It should be possible to split a cell of the grid between two or more elevations and along curved boundaries. The discontinuities should be independent of the height map grid. Here is a hand-made illustration of the kind of terrain we're aiming for: On the left is a curve of discontinuity that has been drawn onto a height map grid. On the right is a rendering of height map terrain that has been split along the same discontinuity curve. Wherever a discontinuity is found, the terrain represents a difference in elevation by a vertical wall instead of the usual slope. The idea is to get an automated system for putting this sort of terrain into a game. I have considered allowing the discontinuities to be an unrestrained set of line segments with floating-point 2D vertices. We'd have total freedom to draw any discontinuities we could imagine, such as splitting a single grid cell into a dozen pieces. This introduces many complexities, such as forcing us to use procedural triangulation to determine how each cell should be rendered. Here is a link to a pdf guide to the Ear Clipping algorithm which we might use for this triangulation: Triangulation By Ear Clipping It also makes navigating the terrain tricky. At a minimum we need to determine if one of the player's moves would cross a discontinuity. That in itself is not too hard, but we wouldn't want the player to be stopped dead just by brushing a discontinuity. We want the player to slide along these barriers when appropriate, and the math behind doing that is not at all obvious. We also need a way for computer-controlled enemies to navigate this world, perhaps by automatically generating a navigation mesh. Perhaps the problem should be simplified by restricting the discontinuities in ways that have no significant impact on the resulting terrain. We don't particularly want a cell to be split into a dozen pieces, so maybe there should be a limit to how many discontinuities can pass through a single cell. We might be limited to certain vertices within each cell, such as a vertex on each corner, a vertex somewhere on each edge, and a 9th vertex floating somewhere in the interior of the cell. With that sort of restriction, triangulation should be greatly simplified. What sort of algorithms and approaches would you use to create this effect? Are there any other ways to simplify the problem?
  12. uastar - Simple A* path finder in C

    There are a bunch of path finding implementations online. But, to be honest, I wasn't much satisfied with most of them, for one of these reasons: Dynamic memory allocation in the middle of the algorithm Algorithm that does too much (more than what is needed) Too many files for just a single task So I made this two-files (`uastar.c` and `uastar.h`) library: https://github.com/ferreiradaselva/uastar No memory dynamic allocation. Straight to the point (the README.md explains how to use). It's nothing biggie, but certainly useful. Path finder at work: I'm leaving this in announcements, because I probably won't add more features (it's pretty much done).
  13. Hi, I have a triangle,oriented in a 3D Plane i.e. I have my vertices as (x1,y1,z1) ; (x2,y2,z2) and (x3,y3,z3) I am trying to convert this triangular facet to voxelised model i.e. Along each edge,I am applying Bresenhams 3D Line algorithm and generating intermediate points.After generating intermediate points, I want to fill the inside region. I have been searching for some algorithm like flood filling,but did not find anything relevant till now. I would be really glad,if some one can provide an algorithm for achieving this. I basically have a List of tuple for storing all the (x,y,z) data created along the edges.(generated using Brsenhams 3D Line algorithm). Now,I want an algorithm,which creates cubes in the inside region.
  14. I am coding the rasterization of triangles by the baricentric coordinate method. Look a lot of code and tutorials that are on the web about the optimization of this algorithm. I found a way to optimize it that I did not see it anywhere. I Only code the painting of triangles without Zbuffer and without textures. I am not comparing speeds and I am not interested in doing them, I am simply reducing the amount of instructions that are executed in the internal loop. The idea is simple, someone must have done it before but he did not publish the code or maybe in hardware it is already that way too. It should be noted that for each horizontal line drawn, of the three segments, you only need to look at one when going from negative to positive to start drawing and you only need to look at one when it goes from positive to negative when you stop drawing. I try it and it works well, now I am implementing a regular version with texture and zbuffer to realize how to add it to this optimization. Does anyone know if this optimization is already done? The code is in https://github.com/phreda4/reda4/blob/master/r4/Dev/graficos/rasterize2.txt From line 92 to 155
  15. Hello, when I have multiple Threads, reading and writing to a scene graph, how do I synchronize data over several nodes? I.e. when a character with a gun moves, the gun moves with him. A thread dedicated to calculating matrices of both objects might update the character first but before it is able to recalculate the gun's matrix the render thread is already drawing both. Inevitably this causes the character and the gun to be out of sync... Now this doesn't only apply to the renderer but for the other threads, too.
  16. This is for a dissertation im working on regarding procedural generation directed towards indie Developers so if you're an indie dev please feel free to share your thoughts Does run-time procedural generation limit the designer's freedom and flexibility? if( Have you ever implemented procedural generation ==true){ talk about some of the useful algorithms used} else {explain why you haven't} Do you think indie Devs are taking advantage of the benefits provided by procedural generation? What are some of the games that inspired you to take up procedural content generation? If there is anyway i can see your work regarding proc gen please mention the link ( cz i need actual indie developers to make a valid point in my dissertation) Thank You So Much
  17. Algorithm The best Android app

    I recently bought a new mobile phone (Samsung Galaxy Note 8) , i just want to know , which the best Andriod app ? I am going to install some app to manage phone , it is mainly aimed at data management and cell phone space optimization, my phone has enough memory to store them What do you recommend ?
  18. Hey folks, I'm about to start work on a system that involves grouping NPCs located within a certain distance from the player in to cells; eventually each cell may exhibit different behaviors based on the 'mood' of the contained NPCs, although the NPCs themselves will have control over their own position & orientation (so no flocking). Before I begin work on this system I wanted to reach out and see if there are any algorithms that I should check out with regard to creating the NPC cells. At the moment my plan is pick a random NPC from a list of those around the player, and search within a small radius (from the chosen NPC) to find other nearby NPCs and create a cell. For each NPC added to a cell I repeat this radius check until there are no more valid NPCs for the current cell. Then repeat the cell creation process for any remaining NPCs in my list of those around the player: Example! So is that a reasonable approach to take? Thanks for the advice!
  19. Character Solver

    So right now for my character solver I compute the time of impact of a character AABB and convex polygons using an algorithm based on "Robust Continuous Collision Detection Between Arbitrary Polyhedra Using Trajectory Parameterization of Polyhedral Features" by J.M.P van Waveren (link) Doom 3 uses this for all of it's collisions so it never has to deal with penetration. This seems undesireable for a couple of reasons so I've decided I'm going to switch to a position solver instead. After some googling I came across Erin Catto's 2014 GDC presention "Understanding Constraints" (link) where he briefly describes how his character solver works. I've written a simple C program (attached to this post) to play around with these concepts and I have some questions that hopefuly I will be able to get answered here. Keys for the test program: ESC - quit r - reset s - step 1-8 - switch to setup 1-8 Here's how I intepret the algorithm: Let's call the current position of the character the 'initial position'. This position never changes during the algorithm. Let's call the position we are trying to move the character to the 'target position'. This position also never changes during the algorithm. Scan the environment for overlap with the capsule at the initial position and construct a list of contact planes. Perform a plane solve on the target position to get the first solve position. Perform a shape cast from the initial position to the solve position. Move to the first hit point and collect new contact planes there. Add these new planes to the list. Perform a plane solve on the target position to get the next solve point. If the distance between the new solve point and the old one is within some epsilon, we are done. Otherwise go back to step 3. Plane solve code: vec3_t p = target_position; vec3_t a = p + local_capsule_a; vec3_t b = p + local_capsule_b; for(uint32_t i = 0; i < max_iter; i++) { vec3_t last_p = p; for(uint32_t j = 0; j < plane_count; j++) { const plane3_t &plane = planes[j]; float d1 = point_distance(plane, a); float d2 = point_distance(plane, b); float dist; if(d1 < d2) dist = d1; else dist = d2; dist -= capsule_radius; if(dist < 0.0f) { p -= dist * plane.n; a = p + local_capsule_a; b = p + local_capsule_b; } } vec3_t delta = p - last_p; if(dot(delta, delta) < epsilon) break; } solve_position = p; Couple of issues: 1. Is this interpretation correct? 2. In the test program I am only adding one new plane per shape cast, is there a reason to collect more (all touching planes)? 3. In the test program I am using the segment planes directly. In 3D I would directly use the polygon planes. If I use the direction from the closest point on the segment to the circle centre I get into situations like this, where the character ends up away from the collision geometry: 4. If I naively add all overlapping planes during step 1 I get into sitations like this: The green circle is at the source position. Step 1 will find both planes and the character will end up in the corner, not touching either segment. In the test program I solve this problem by clearing the plane list after step 2, but this is insufficient as I also need to select the proper planes after a shape cast. I can think of some approaches to solving this problem, but instead of experimenting right away, I'd like to know how other people have solved this. What is a good way to determine which planes to actually use? test.c
  20. Hello everybody, 5 new video are available on my youtube channel: -Video 4 Candy's Space Mysteries- | -Video 2 Lights of Dreams IV- | -Video 3 Candy to the Rescue IV- -Video 13 Candy World II- | -Video 3 Candy Racing Cup- | -My Xilvan Design Youtube Channel- Thanks for Watching! Friendly, Xylvan, Xilvan Design
  21. Hello, I am sending compressed json data from the UE4 client to a C++ server made with boost. I am using ZLib to compress and decompress all json but it doesn't work. I am now encoding it in base64 to avoid some issues but that doesn't change a thing. I currently stopped trying to send the data and I am writing it in a file from the client and trying to read the file and decompress on the server side. When the server is trying to decompress it I get an error from ZLib : zlib error: iostream error My question is the following : Did anyone manage to compress and decompress data between a UE4 client and a C++ server ? I cannot really configure anything on the server side (because boost has its ZLib compressor) and I don't know what is wrong with the decompression. Any idea ? rXp
  22. I am currently attempting to make a navigation mesh for our 2D top down game, which is a multiplayer game using Node.js as the server communication. At the moment, I have implemented A* over an obstacle hardnessmap, which is awfully slow and laggy at times when we test our game on Heroku. I have been trying to find an algorithm to automatically generate the navmesh after map creation, instead of me having to do this manually. I am currently attempting to use Delaunay's Triangulation Divide and Conquer algorithm, but I am running into some issues. I have already asked a question on StackOverflow and am not getting many suggestions and help from it, so I figured I would come here. Is there another algorithm that might be better to use for the navmesh generation in comparison to Deluanay's Triangulation? My current implementation seems extremely buggy during the merge step and I cannot find the error. I have checked over the code countless times, comparing it to the description of the algorithm from http://www.geom.uiuc.edu/~samuelp/del_project.html. My current code is this: class MapNode { constructor(x, y) { this.position = new Vector(x, y); this.neighbors = []; } distance(n) { return this.position.distance(n.position); } inNeighbor(n) { for (let i = 0; i < this.neighbors.length; i++) { if (this.neighbors[i] === n) return true; } return false; } addNeighbor(n) { this.neighbors = this.neighbors.filter((node) => node != n); this.neighbors.push(n); } addNeighbors(arr) { let self = this; arr.forEach((n) => self.neighbors.push(n)); } removeNeighbor(n) { this.neighbors = this.neighbors.filter((neighbor) => neighbor != n); } } class Triangle { constructor(p1, p2, p3) { this.p1 = p1; this.p2 = p2; this.p3 = p3; this.neighbors = []; } addNeighbors(n) { this.neighbors.push(n); } } function genSubMat(matrix, ignoreCol) { let r = []; for (let i = 0; i < matrix.length - 1; i++) { r.push([]); for (let j = 0; j < matrix[0].length; j++) { if (j != ignoreCol) r[i].push(matrix[i + 1][j]); } } return r; } function determinantSqMat(matrix) { if (matrix.length != matrix[0].length) return false; if (matrix.length === 2) return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; let det = 0; for (let i = 0; i < matrix.length; i++) { let r = genSubMat(matrix, i); let tmp = matrix[0][i] * determinantSqMat(r); if (i % 2 == 0) det += tmp; else det -= tmp; } return -det; } // if d is in the circle formed by points a, b, and c, return > 0 // d is on circle, return 0 // d is outside of circle, return < 0 function inCircle(a, b, c, d) { let arr = [a, b, c, d]; let mat = [ [], [], [], [] ]; for (let i = 0; i < arr.length; i++) { mat[i][0] = 1; mat[i][1] = arr[i].position.x; mat[i][2] = arr[i].position.y; mat[i][3] = arr[i].position.x * arr[i].position.x + arr[i].position.y * arr[i].position.y; } return determinantSqMat(mat); } function walkable(from, to, hardnessMap) { let diff = new Vector(to.x - from.x, to.y - from.y); if (Math.abs(diff.x) > Math.abs(diff.y)) diff.scale(Math.abs(1 / diff.x)); else diff.scale(Math.abs(1 / diff.y)); let current = new Vector(from.x + diff.x, from.y + diff.y); while (Math.round(current.x) != to.x || Math.round(current.y) != to.y) { if (hardnessMap[Math.floor(current.y)][Math.floor(current.x)] === 1) return false; current.x += diff.x; current.y += diff.y; } return true; } function getLowest(nodes) { let lowest = nodes[0]; for (let i = 1; i < nodes.length; i++) { if (nodes[i].position.y < lowest.position.y) lowest = nodes[i]; } return lowest; } // returns the angle between 2 vectors, if cw is true, then return clockwise angle between, // else return the ccw angle between. b is the "hinge" point function angleBetween(a, b, c, cw) { let ba = new Vector(a.position.x - b.position.x, a.position.y - b.position.y); let bc = new Vector(c.position.x - b.position.x, c.position.y - b.position.y); let v0 = new Vector(0, 1); let angleBA = v0.angleBetween(ba) * 180 / Math.PI; if (angleBA < 0) angleBA += 360; let angleBC = v0.angleBetween(bc) * 180 / Math.PI; if (angleBC < 0) angleBC += 360; let smallest = Math.min(angleBA, angleBC); let largest = Math.max(angleBA, angleBC); let angle = largest - smallest; return (cw) ? angle : 360 - angle; } function sortSmallestAngle(a, b, list, cw) { list.sort((m, n) => { let vab = new Vector(a.position.x - b.position.x, a.position.y - b.position.y); let vmb = new Vector(m.position.x - b.position.x, m.position.y - b.position.y); let vnb = new Vector(n.position.x - b.position.x, n.position.y - b.position.y); if (cw) return vab.angleBetween(vmb, cw) - vab.angleBetween(vnb, cw); else return vab.angleBetween(vnb, cw) - vab.angleBetween(vmb, cw); }); } // a is in list, b is in the other list function getPotential(a, b, list, cw) { sortSmallestAngle(b, a, list, cw); for (let i = 0; i < list.length - 1; i++) { let angle = angleBetween(b, a, list[i], cw); if (angle > 180) return false; else if (inCircle(a, b, list[i], list[i + 1]) <= 0) return list[i]; else { a.removeNeighbor(list[i]); list[i].removeNeighbor(a); } } let potential = list[list.length - 1]; if (potential) { let angle = angleBetween(a, b, potential, cw); if (angle > 180) return false; return potential; } return false; } function merge(leftNodes, rightNodes, leftBase, rightBase, hardnessMap) { leftBase.addNeighbor(rightBase); rightBase.addNeighbor(leftBase); let newLeft = leftNodes.filter((n) => n != leftBase); let newRight = rightNodes.filter((n) => n != rightBase); let potentialLeft = getPotential(leftBase, rightBase, newLeft, false); let potentialRight = getPotential(rightBase, leftBase, newRight, true); if (!potentialLeft && !potentialRight) return; else if (potentialLeft && !potentialRight) merge(newLeft, newRight, potentialLeft, rightBase, hardnessMap); else if (potentialRight && !potentialLeft) merge(newLeft, newRight, leftBase, potentialRight, hardnessMap); else { if (inCircle(leftBase, rightBase, potentialLeft, potentialRight) <= 0) merge(newLeft, newRight, potentialLeft, rightBase, hardnessMap); if (inCircle(leftBase, rightBase, potentialRight, potentialLeft) <= 0) merge(newLeft, newRight, leftBase, potentialRight, hardnessMap); } } // divide and conquer algorithm function delaunay(nodes, hardnessMap) { if (nodes.length <= 3) { for (let i = 0; i < nodes.length; i++) for (let j = 0; j < nodes.length; j++) if (i != j) nodes[i].addNeighbor(nodes[j]); return nodes; } else { nodes.sort((a, b) => { let tmp = a.position.x - b.position.x; if (tmp === 0) return b.position.y - a.position.y; return tmp; }); let l = nodes.length; let leftNodes; let rightNodes; if (l === 4) { leftNodes = delaunay(nodes.slice(0, 3), hardnessMap); rightNodes = delaunay(nodes.slice(3, 4), hardnessMap); } else { leftNodes = delaunay(nodes.slice(0, Math.floor(nodes.length / 2)), hardnessMap); rightNodes = delaunay(nodes.slice(Math.floor(nodes.length / 2), nodes.length), hardnessMap); } let leftBase = getLowest(leftNodes); let rightBase = getLowest(rightNodes); merge(leftNodes, rightNodes, leftBase, rightBase, hardnessMap); console.log("=============================MergeComplete================================"); return nodes; } }
  23. I am working on a game in which we control a rectangular box at the bottom of the screen. Three sphere which has alphabets in it fall down. When the game starts, a word is generated from the predefined list of words(which I'll give) and we are supposed to touch the correct sphere having the alphabet based on that word. The question is how to detect if I have touched the correct sphere. secondly, if I have touched a correct sphere before and there is no recurrence of that alphabet in that word then during the second wave the game should not proceed if I touch the same alphabet again. Looking forward to your answers, i have to submit this project in a couple of days. please help! (Working on Unity 3D) Thanks
  24. Hi there everyone! I'm trying to implement SPH using CPU single core. I'm having troubles in making it stable. I'd like some help in order to understand what is wrong and how could I fix it. Please, take a look at the following videos: Water inside sphere using Kelager's parameters Water inside big box Water inside thinner box I've already tried using XSPH, the hash method to find the neighbors (now I'm using the regular grid, because the hash method didn't work for me) and two different ways of calculating the pressure force. I'm using mostly the following articles: Particle-Based Fluid Simulation for Interactive Applications, Matthias Müller, David Charypar and Markus Gross Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics, Micky Kelager Smoothed Particle Hydrodynamics Real-Time Fluid Simulation Approach, David Staubach Fluid Simulation using Smoothed Particle Hydrodynamics, Burak Ertekin 3D Langrangian Fluid Solver using SPH approximations, Chris Priscott Any ideas? Thanks!
  25. Video tutorial for coding physics from scratch:
  • Advertisement