# Search the Community

Showing results for tags 'Algorithm'.

• ### Search By Tags

Type tags separated by commas.

### Categories

• Audio
• Music and Sound FX
• 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

• News

• Audio
• Visual Arts
• Programming
• Writing

### Categories

• GameDev Unboxed

### Categories

• Game Developers Conference
• GDC 2017

### Forums

• Audio
• Music and Sound FX
• Games Career Development
• Production and Management
• 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
• 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

• Members

• 0 Replies

• 0 Reviews

• 0 Views

Found 90 results

1. ## C-Lesh - My Video Game Programming Language

So I wrote a programming language called C-Lesh to program games for my game maker Platformisis. It is a scripting language which tiles into the JavaScript game engine via a memory mapper using memory mapped I/O. Currently, I am porting the language as a standalone interpreter to be able to run on the PC and possibly other devices excluding the phone. The interpreter is being written in C++ so for those of you who are C++ fans you can see the different components implemented. Some background of the language and how to program in C-Lesh can be found here: http://www.codeloader.net/readme.html As I program this thing I will post code from different components and explain.
2. ## DX11 Duplicate Vertices using std::map

I'm trying to duplicate vertices using std::map to be used in a vertex buffer. I don't get the correct index buffer(myInds) or vertex buffer(myVerts). I can get the index array from FBX but it differs from what I get in the following std::map code. Any help is much appreciated. struct FBXVTX { XMFLOAT3 Position; XMFLOAT2 TextureCoord; XMFLOAT3 Normal; }; std::map< FBXVTX, int > myVertsMap; std::vector<FBXVTX> myVerts; std::vector<int> myInds; HRESULT FBXLoader::Open(HWND hWnd, char* Filename, bool UsePositionOnly) { HRESULT hr = S_OK; if (FBXM) { FBXIOS = FbxIOSettings::Create(FBXM, IOSROOT); FBXM->SetIOSettings(FBXIOS); FBXI = FbxImporter::Create(FBXM, ""); if (!(FBXI->Initialize(Filename, -1, FBXIOS))) { hr = E_FAIL; MessageBox(hWnd, (wchar_t*)FBXI->GetStatus().GetErrorString(), TEXT("ALM"), MB_OK); } FBXS = FbxScene::Create(FBXM, "REALMS"); if (!FBXS) { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to create the scene"), TEXT("ALM"), MB_OK); } if (!(FBXI->Import(FBXS))) { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to import fbx file content into the scene"), TEXT("ALM"), MB_OK); } FbxAxisSystem OurAxisSystem = FbxAxisSystem::DirectX; FbxAxisSystem SceneAxisSystem = FBXS->GetGlobalSettings().GetAxisSystem(); if(SceneAxisSystem != OurAxisSystem) { FbxAxisSystem::DirectX.ConvertScene(FBXS); } FbxSystemUnit SceneSystemUnit = FBXS->GetGlobalSettings().GetSystemUnit(); if( SceneSystemUnit.GetScaleFactor() != 1.0 ) { FbxSystemUnit::cm.ConvertScene( FBXS ); } if (FBXI) FBXI->Destroy(); FbxNode* MainNode = FBXS->GetRootNode(); int NumKids = MainNode->GetChildCount(); FbxNode* ChildNode = NULL; for (int i=0; i<NumKids; i++) { ChildNode = MainNode->GetChild(i); FbxNodeAttribute* NodeAttribute = ChildNode->GetNodeAttribute(); if (NodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh) { FbxMesh* Mesh = ChildNode->GetMesh(); if (UsePositionOnly) { NumVertices = Mesh->GetControlPointsCount();//number of vertices MyV = new XMFLOAT3[NumVertices]; for (DWORD j = 0; j < NumVertices; j++) { FbxVector4 Vertex = Mesh->GetControlPointAt(j);//Gets the control point at the specified index. MyV[j] = XMFLOAT3((float)Vertex.mData[0], (float)Vertex.mData[1], (float)Vertex.mData[2]); } NumIndices = Mesh->GetPolygonVertexCount();//number of indices MyI = (DWORD*)Mesh->GetPolygonVertices();//index array } else { FbxLayerElementArrayTemplate<FbxVector2>* uvVertices = NULL; Mesh->GetTextureUV(&uvVertices); int idx = 0; for (int i = 0; i < Mesh->GetPolygonCount(); i++)//polygon(=mostly triangle) count { for (int j = 0; j < Mesh->GetPolygonSize(i); j++)//retrieves number of vertices in a polygon { FBXVTX myVert; int p_index = 3*i+j; int t_index = Mesh->GetTextureUVIndex(i, j); FbxVector4 Vertex = Mesh->GetControlPointAt(p_index);//Gets the control point at the specified index. myVert.Position = XMFLOAT3((float)Vertex.mData[0], (float)Vertex.mData[1], (float)Vertex.mData[2]); FbxVector4 Normal; Mesh->GetPolygonVertexNormal(i, j, Normal); myVert.Normal = XMFLOAT3((float)Normal.mData[0], (float)Normal.mData[1], (float)Normal.mData[2]); FbxVector2 uv = uvVertices->GetAt(t_index); myVert.TextureCoord = XMFLOAT2((float)uv.mData[0], (float)uv.mData[1]); if ( myVertsMap.find( myVert ) != myVertsMap.end() ) myInds.push_back( myVertsMap[ myVert ]); else { myVertsMap.insert( std::pair<FBXVTX, int> (myVert, idx ) ); myVerts.push_back(myVert); myInds.push_back(idx); idx++; } } } } } } } else { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to create the FBX Manager"), TEXT("ALM"), MB_OK); } return hr; } bool operator < ( const FBXVTX &lValue, const FBXVTX &rValue) { if (lValue.Position.x != rValue.Position.x) return(lValue.Position.x < rValue.Position.x); if (lValue.Position.y != rValue.Position.y) return(lValue.Position.y < rValue.Position.y); if (lValue.Position.z != rValue.Position.z) return(lValue.Position.z < rValue.Position.z); if (lValue.TextureCoord.x != rValue.TextureCoord.x) return(lValue.TextureCoord.x < rValue.TextureCoord.x); if (lValue.TextureCoord.y != rValue.TextureCoord.y) return(lValue.TextureCoord.y < rValue.TextureCoord.y); if (lValue.Normal.x != rValue.Normal.x) return(lValue.Normal.x < rValue.Normal.x); if (lValue.Normal.y != rValue.Normal.y) return(lValue.Normal.y < rValue.Normal.y); return(lValue.Normal.z < rValue.Normal.z); }
3. ## Attack of the Demons VS The Lord of the Man of the South - A wild NEW game!

Wow what a wild game by GalaXa Games Entertainment Interactive. Play now... it's really fun but IF you have epilepsy then don't play. It does not feature flashing pictures, but there is lots of animated stuff that might get ya. Anyway, 4 levels, 2 endings, insane action, BY INFERNAL. Please play it, right nao! Also , nice midi music composed by me is in the game. demons.rar
4. ## DX11 Find proper value for sigma in gaussian blur

Hi, I've been trying to implement a basic gaussian blur using the gaussian formula, and here is what it looks like so far: float gaussian(float x, float sigma) { float pi = 3.14159; float sigma_square = sigma * sigma; float a = 1 / sqrt(2 * pi*sigma_square); float b = exp(-((x*x) / (2 * sigma_square))); return a * b; } My problem is that I don't quite know what sigma should be. It seems that if I provide a random value for sigma, weights in my kernel won't add up to 1. So I ended up calling my gaussian function with sigma == 1, which gives me weights adding up to 1, but also a very subtle blur. Here is what my kernel looks like with sigma == 1 [0] 0.0033238872995488885 [1] 0.023804742479357766 [2] 0.09713820127276819 [3] 0.22585307043511713 [4] 0.29920669915475656 [5] 0.22585307043511713 [6] 0.09713820127276819 [7] 0.023804742479357766 [8] 0.0033238872995488885 I would have liked it to be more "rounded" at the top, or a better spread instead of wasting [0], [1], [2] with values bellow 0.1. Based on my experiments, the key to this is to provide a different sigma, but if I do, my kernel values no longer adds up to 1, which results to a darker blur. I've found this post ... which helped me a bit, but I am really confused with this the part where he divide sigma by 3. Can someone please explain how sigma works? How is it related to my kernel size, how can I balance my weights with different sigmas, ect... Thanks :-)

6. ## Voxel Cone Tracing constraints and flexibility

Hi all. I have been looking for a real-time global illumination algorithm to use in my game. I've found voxel cone tracing and I'm debating whether or not it's an algorithm worth investing my time researching and implementing. I have this doubt due to the following reasons: . I see a lot of people say it's really hard to implement. . Apparently this algorithm requires some Nvidia extension to work efficiently according to the original paper (I highly doubt it though) . Barely real-time performance, meaning it's too slow to be implemented in a game So in order to determine if I should invest time in voxel cone tracing, I want to ask the following questions: . Is the algorithm itself flexible enough so that I can increase the performance by tweaking it (probably lowering the GI quality at the same time, but I don't care) . Can I implement it without any driver requirement or special extensions, like the paper claims?
7. ## From OBB-OBB intersection test to Sweep OBB test?

I understand what stationary OBB intersection test is get min/max scalar in 15 axises, when all overlap, then minimum interval overlapping is the axis that used to push away 2 OBBs to "just touch". I have complete this. So in sweep test, how to choose the right axis projecting and how every projection transform? I only need a ratio of current velocity when start intersect from disjoint. I have read Ron Levine's post: http://www.realtimecollisiondetection.net/files/levine_swept_sat.txt And oliii's: I get the code but cannot get it works as expect when port to my project, even I don't clearly know what params refer to. For further optimization, I wish somebody can teach me how velocity part works conceptually instead of just code. My case is DOBB-OBB only(dynamic to stationary).
8. ## Simple Json Lib.

I went looking for Json. But there wasn't a simple Json. I just wanted to change Class to Json and change Class back to Json. So I made it myself. zJson.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 /* code by eekdro@gmail.com */ /* zJson is a simple Json library */ /* Just Class to Json, Json to Class, Haven't Depth*/ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; namespace AliceUtil { /// <summary> /// Json to Class , Class to Json 을 지원하는 Class /// </summary> public class zJson { public static string MakeJson<T>(List<T> jsonClassList, string FileName ) where T : new() { string Result = MakeJson(jsonClassList); zUt.SaveTextFile(FileName, Result); return Result; } /// <summary> /// List를 Json으로 만들어준다. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jsonClassList"></param> /// <returns></returns> public static string MakeJson<T>(List<T> jsonClassList) where T : new() { string ResultStr = "{\n"; Type ClassType = typeof(T); ResultStr += "\t\"" + ClassType.Name + "\":["; foreach (T jsonClass in jsonClassList) { string JsonStr = MakeJson(jsonClass).Replace("\t", "\t\t"); ResultStr += "\t" + JsonStr.Insert(JsonStr.Length - 1, "\t") + ",\n"; } if (ResultStr[ResultStr.Length - 2] == ',') ResultStr = ResultStr.Substring(0, ResultStr.Length - 2); ResultStr += "\t]\n}"; return ResultStr; } public static string MakeJson<T>(T jsonClass, string FileName) where T : new() { string Result = MakeJson(jsonClass); zUt.SaveTextFile(FileName, Result); return Result; } public static string MakeJson<T>(T jsonClass) where T : new() { string ResultStr = "{\n"; Type ClassType = typeof(T); FieldInfo[] fields = ClassType.GetFields(); PropertyInfo[] Pinfo = ClassType.GetProperties(); foreach (FieldInfo f in fields) { if (f.FieldType == typeof(string)) { string value = f.GetValue(jsonClass) == null ? "" : f.GetValue(jsonClass).ToString(); ResultStr += "\t\"" + f.Name + "\":\"" + value + "\",\n"; } else if (f.FieldType == typeof(DateTime)) ResultStr += "\t\"" + f.Name + "\":" + ((DateTime)f.GetValue(jsonClass)).Ticks.ToString() + ",\n"; else if (f.FieldType == typeof(int) || f.FieldType == typeof(long) || f.FieldType == typeof(float) || f.FieldType == typeof(double) || f.FieldType == typeof(bool)) ResultStr += "\t\"" + f.Name + "\":" + f.GetValue(jsonClass).ToString() + ",\n"; else if (f.FieldType == typeof(int[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((int[])f.GetValue(jsonClass)).Select(x => x.ToString()).ToArray()) + "],\n"; else if (f.FieldType == typeof(long[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((long[])f.GetValue(jsonClass)).Select(x => x.ToString()).ToArray()) + "],\n"; else if (f.FieldType == typeof(double[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((double[])f.GetValue(jsonClass)).Select(x => x.ToString()).ToArray()) + "],\n"; else if (f.FieldType == typeof(float[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((float[])f.GetValue(jsonClass)).Select(x => x.ToString()).ToArray()) + "],\n"; else if (f.FieldType == typeof(bool[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((bool[])f.GetValue(jsonClass)).Select(x => x.ToString()).ToArray()) + "],\n"; else if (f.FieldType == typeof(string[])) ResultStr += "\t\"" + f.Name + "\":" + "[" + string.Join(",", ((string[])f.GetValue(jsonClass)).Select(x => "\"" + x + "\"").ToArray()) + "],\n"; } if (ResultStr[ResultStr.Length - 2] == ',') ResultStr = ResultStr.Substring(0, ResultStr.Length - 2); return ResultStr + "\n}"; } static string GetTokenString(string Source, string StartStr, string EndStr) { int Openidx = Source.IndexOf(StartStr); int Closeidx = 0; while (true) { Openidx = Source.IndexOf(StartStr, Openidx + 1); Closeidx = Source.IndexOf(EndStr, Closeidx + 1); if (Closeidx == -1) return ""; // 여기로 온다는 것은 정상적인 Json 이 아니라는 것을 의미한다. if (Openidx == -1 || Openidx > Closeidx) break; } return Source.Substring(1, Closeidx - 1); } public static List<T> PaserListFromFile<T>(string jsonFilename) where T : new() { return PaserList<T>(zUt.LoadTextFile(jsonFilename)); } public static List<T> PaserList<T>(string jsonStr) where T : new() { List<T> ResultList = new List<T>(); int idx = jsonStr.IndexOf("\"" + typeof(T).Name + "\""); if (idx == -1) return ResultList; jsonStr = jsonStr.Substring(idx); idx = jsonStr.IndexOf("["); if (idx == -1) return ResultList; jsonStr = jsonStr.Substring(idx).Trim().Replace("\t", "").Replace("\n", ""); ; jsonStr = GetTokenString(jsonStr, "[", "]"); while (true) { if (jsonStr.Trim() == "") break; string ItemStr = GetTokenString(jsonStr, "{", "}"); if (ItemStr == "") break; ResultList.Add(Paser<T>(ItemStr)); jsonStr = jsonStr.Substring(ItemStr.Length + 2); } Console.WriteLine(jsonStr); return ResultList; } public static T PaserFromFile<T>(string jsonFilename) where T : new() { return Paser<T>(zUt.LoadTextFile(jsonFilename)); } public static T Paser<T>(string jsonStr) where T : new() { T nJsonClass = new T(); Type ClassType = typeof(T); FieldInfo[] fields = ClassType.GetFields(); PropertyInfo[] Pinfo = ClassType.GetProperties(); foreach (FieldInfo f in fields) { int idx = jsonStr.IndexOf("\"" + f.Name + "\""); if (idx == -1) continue; string rs = jsonStr.Substring(idx + ("\"" + f.Name + "\"").Length).Trim().Replace("\t", "").Replace("\n", ""); if (rs[0] != ':') continue; if (f.FieldType == typeof(string)) { int ix = rs.IndexOf("\""); int chix = rs.IndexOf(","); if (chix != -1 && chix > ix && ix != -1) { rs = rs.Substring(rs.IndexOf("\"") + 1); string value = rs.Substring(0, rs.IndexOf("\"")); f.SetValue(nJsonClass, value); } else f.SetValue(nJsonClass, null); } else if (f.FieldType == typeof(int[]) || f.FieldType == typeof(string[])) { int ps = rs.IndexOf("[") + 1; rs = rs.Substring(ps, rs.IndexOf("]") - ps).Trim(); if (rs == "") continue; string[] datas = rs.Split(','); if (f.FieldType == typeof(int[])) { var temp = new int[datas.Length]; for (int n = 0; n < datas.Length; n++) temp[n] = int.Parse(datas[n].Trim()); f.SetValue(nJsonClass, temp); } else if (f.FieldType == typeof(string[])) { var temp = new string[datas.Length]; for (int n = 0; n < datas.Length; n++) temp[n] = datas[n].Trim().Substring(1, datas[n].Trim().Length - 2); f.SetValue(nJsonClass, temp); } } else { // 마지막이 , } ] 중 가까운 문자위치가 마지막이라고 판단해야된다. int[] EndPos = { rs.IndexOf(","), rs.IndexOf("}"), rs.IndexOf("]") }; int ps = 99; foreach (int ix in EndPos) if (ix != -1 && ix < ps) ps = ix; if (ps == -1 || ps == 99) continue; string value = rs.Substring(1, ps - 1).Trim(); if (f.FieldType == typeof(int)) f.SetValue(nJsonClass, int.Parse(value)); else if (f.FieldType == typeof(DateTime)) f.SetValue(nJsonClass, new DateTime(long.Parse(value))); else if (f.FieldType == typeof(double)) f.SetValue(nJsonClass, double.Parse(value)); else if (f.FieldType == typeof(float)) f.SetValue(nJsonClass, float.Parse(value)); else if (f.FieldType == typeof(long)) f.SetValue(nJsonClass, long.Parse(value)); else if (f.FieldType == typeof(bool)) f.SetValue(nJsonClass, bool.Parse(value)); } } return nJsonClass; } } } for coffee 0x4C668AeBB9Facd8ecE8764AaAC48B7186130C411 약간 이해가 안되는 내용이 있다면 나는 Datetime 을 Tick로 보관한다. 이유는 단순하다. 다국적 처리를 할때 Datetime를 String로 바꾸면 문제가 생길 수 있기 때문이다. If there is something special code, I use Tick to keep Datetime. The reason is simple. Because changing Datetime to String can cause problem when dealing with multinational process. Test Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 using System; using System.Collections.Generic; using System.Text; using AliceUtil; namespace JsonTest { class Person { public bool ok; public int Id; public string Name; public DateTime Ddate; public int[] intArray = { 1, 2, 3, 4 }; public string[] strArray = { "1", "2", "3", "4" }; } class Program { static void Main(string[] args) { List<Person> tbPerson = new List<Person>(); for (int n = 0; n < 3; n++) { tbPerson.Add( zJson.Paser<Person>(("{'Id' : " + n + ", 'Name' : 'Alex', 'ok':true}").Replace("'", "\"")) ); } string result = zJson.MakeJson<Person>(tbPerson); Console.WriteLine(result); Console.WriteLine("---------------"); List<Person> PList = zJson.PaserList<Person>(result); foreach( Person ps in PList) { Console.WriteLine(zJson.MakeJson(ps)); } } } }
9. ## Algorithm Generate unique ID per user

I am developing a cross platform game for which I needs to generate unique identifier (User ID) for each user. I known some platform (Android or iOS) specific approaches to get device related identifiers but I am looking for a solution independent of the device identifiers. User ID Requirements: 1. Independent of the device's platform 2. Offline implementation (no communication with any servers) 3. Without sign-up process I have implemented one approach to create User IDs where I store the system time when the game was launched for the first time on the device. I have following questions: 1. Are there any other approaches to generate User IDs (which will meet the above requirements)? 2. What are the common approaches to create unique identifiers with taking any information from the user? 3. Are there any third party plug-ins to implement User IDs? I would appreciate any suggestions and thoughts on this topic. EDIT: There are lot of responses to use UUID/GUID. Generally, this approach looks fine but I am looking for a solution which can generate same User ID even if the user reinstall the game.
10. ## Algorithm ill-regular shaped tiles and their selection

so thinking about a map divided into states and the selection of these states. How I have handled this in the past. I have each state as a separate image. I pre-process each state into an array of transparent/non-transparent flags foreach pixel of the image. As the mouse moves across the map it will be over a N amount of states. I check each of these states and I conclude the selected tile is the one with non-transparent flag. Is there a better approach to this?
11. ## DX11 Shadow Map Details

I think I understand the idea behind Shadow Mapping, however I'm having problems with implementation details. In VS I need light position - but I don't have one! I only have light direction, what light position should I use? I have working camera class, with Projection and View matrices and all - how can I reuse this? I should put camera position, but how to calculate "lookAt" parameter? Is this suppose to be ortographic or perspective camera? And one more thing - when in the 3D piplene is the actual write to the Depth Buffer? In PS or somewhere earlier? Br.,BB
12. ## Separating axis theorem 3D - polygons

I have been working on a collision engine in Java, utilizing the Separating Axis Theorem in 3D space. I have it working successfully in all cases (that I could think of testing) with object-oriented bounding boxes, but I'm finding that SAT isn't super accurate at detecting collisions as immediately with other convex 3D polygons. Corners of rotated polygons may overlap a small amount before any valid collision is found, and the subsequent clipping algorithm I use to calculate contact points will fail. I'll highlight the main points on my current SAT implementation below, and I'd just like to get some feedback to see if I was on the right track with this or if I'm fundamentally missing something in the theory. Trying to refrain from pasting code since its moderately long. Do note that I am using object models imported from Blender in wavefront.obj files, so I'm using the vertex normals in these files to populate my collision bodies in simulation. I'm not sure if that could cause issues with ordering or normal calculations. Input two collision bodies (BodyA, BodyB) Calculate distance between the centers of bodyB and bodyA (the offset) for each face normal (axis) in bodyA: - Project the vertices of both bodyA and bodyB along this axis to get the 2D minimum and maximum projections along that direction - add offset to projection of bodyA - check for overlap along the projections of both bodies, exit the separating axis test if their is no overlap along this projection as this is a separation. Otherwise continue the loop. for each face normal (axis) in bodyB: - Project the vertices of both bodyA and bodyB along this axis to get the 2D minimum and maximum projections along that direction - add offset to projection of bodyA - check for overlap along the projections of both bodies, exit the separating axis test if their is no overlap along this projection as this is a separation. Otherwise continue the loop. for each face normal in bodyA (axisA): - for each face normal in bodyB (axisB): - - get the cross product of axisA and axisB (axis) - - Project the vertices of both bodyA and bodyB along this axis to get the 2D minimum and maximum projections along that direction - - add offset to projection of bodyA - - check for overlap along the projections of both bodies, exit the separating axis test if their is no overlap along this projection as this is a separation. Otherwise continue the loop. Most SAT resources I have read seem to be concerned with AABB or OBB collision and don't care for more complex polygon shapes so any resources you might know of that deal with a more general 3D SAT implementation would be a great help. Thanks.
13. ## Parameters of physically based Material in UE4?

Hi, I'm currently studying physically based shading in UE4 described in Real Shading in Unreal Engine 4. In the notes, the Material has 4 basic properties: BaseColor, Metallic, Roughness and Cavity. Here is their BRDF model in use: The use of roughness is clearly clarified, and I guess BaseColor is referred as $$c_{diff}$$c_diff in the diffuse component. Then anyone knows how Metallic and Cavity is implemented in UE4? Exact fragments in the source code of the engine would be the best. Thanks a lot!!
14. ## Scatter / Gather for server read

I just have a quick question as I've looked around but really haven't gotten a credible answer on the topic. I have a server using TCP sockets and IOCP sending a custom binary protocol / flatbuffers. I just switched to using a scatter/gather approach for writing in order to avoid the memory copies into a large send buffer, as this way I can just burn direct from the packet queue. It worked out great, and I'm happy with the improvement as it's a noticeable gain with a large amount of clients / traffic. What I'm wondering is if people are using scatter / gather on server reads? And if so what are the benefits to doing so? It was very easy to see the benefit for writes, but I'm not really sure what I would actually gain on read. I figured since I'm making changes at this level it might be wise to do so now if there is a benefit that I'm not seeing. EDIT: Also I guess I should mention that incoming packets are variable length, otherwise that would be an easy to see win
15. ## Algorithm Logic in ECS?

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!
16. ## Algorithm Turn based - Line of Effect for AI

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
17. ## 2D how to implement picking for irregular texture, just need scheme.

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?
18. ## Algorithm Tetrahedralization

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!
19. ## Algorithm I need help in the creation of "tree felling"

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!
20. ## Boid's algorithm doesn't work perfectly

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...
21. ## Algorithm Smooth motion - how we did it for a high-latency environment (aka the browser)

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!
22. ## Algorithm Collision detection algorithm for sphere tree (static)

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?
23. ## Practical (robust) vertex-face continuous collision detection?

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..
24. ## Algorithm Room Assignment Algorithm

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.
25. ## Height map terrain + discontinuities

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?