Jump to content
  • Advertisement

Gon

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

101 Neutral

About Gon

  • Rank
    Newbie

Personal Information

  • Interests
    Education
    Programming

Social

  • Github
    https://github.com/g-amador

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, A detailled explanation of SAT, which might help. http://www.dyn4j.org/2010/01/sat/ Best regards
  2. Hi, You have two main ways to go: 1-Multi-Agent Pathfinding There are other articles, but I recommend https://www.aaai.org/ocs/index.php/WS/AAAIW12/paper/viewFile/5233/5640 2-Influence fields\maps (scalar values) or Potencial field (vectors) https://forum.unity.com/threads/ai-influence-maps.145368/ http://archive.gamedev.net/archive/reference/programming/features/motionplanning/index.html http://www.thequest03.de/Tutorial - Pathfinding(english).htm https://gameschoolgems.blogspot.com/2009/12/influence-maps-i.html Best regards
  3. Gon

    GJK warm starting

    Hi, I wrote an engine in Java a few years ago. It includes this algorithm. https://github.com/g-amador/JOT/blob/master/engine/Core-Toolkit-Components/src/main/java/jot/math/GJK.java Back then I followed mainly these two articles: http://www.dyn4j.org/2010/04/gjk-gilbert-johnson-keerthi/ http://lewisresearchgroup.wikidot.com/gjk-algorithm Best regards
  4. Gon

    Overengeneering Modularity

    Hi, I wrote an engine in Java a few years ago regarding this same topic. The resulting code and article its free: http://vj2016.di.ubi.pt/Amador_JOT_57-62.pdf https://github.com/g-amador/JOT Best regards
  5. Gon

    Native Android Studio Game Engine?

    Hi Jordan, No sure if you have a native android Studio engine. I know JMonkey aside the ones priorly mentioned but the SDK is Netbeans. Regarding algorithms I made an engine in Java during my studies https://github.com/g-amador/JOT If you find any code useful integrate it. Best regards
  6. First the general idea If you use color normals etc more binding. [color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Create[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]object[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glGenBuffers[/font][font="Arial, sans-serif"])[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]W[/font][font="Arial, sans-serif"]hile[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]graphics[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]application[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]requires[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]rendering[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]do[/font][/font] Store all vertexes (depending on the primitive to render in a temp array[color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Bind[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]the[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]object[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glBindBuffer[/font][font="Arial, sans-serif"])[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Upload[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]data[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]from[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]the[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]client[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]to[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]the[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glBufferData[/font][font="Arial, sans-serif"])[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Point[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]to[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]the[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]data[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]to[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]draw[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glVertexPointer[/font][font="Arial, sans-serif"])[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Draw[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]data[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]in[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]the[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glEnableClientState[/font][font="Arial, sans-serif"],[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]glDrawArrays[/font][font="Arial, sans-serif"],[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]and[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]glDisableClientState[/font][font="Arial, sans-serif"])[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]E[/font][font="Arial, sans-serif"]nd[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]while[/font][/font][color="#000000"][font="Times New Roman, serif"][font="Arial, sans-serif"]Delete[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]buffer[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]object[/font][font="Arial, sans-serif"] [/font][font="Arial, sans-serif"]([/font][font="Arial, sans-serif"]glDeleteBuffers()[/font][font="Arial, sans-serif"]).[/font][/font] Now your doubts (gonna try to explain them as best as I can). First you gain performance just by the simple fact that you communicate lots of data at once an not small amount to the GPU, for large amounts of data. You must somehow know which is the number of elements you need to draw and how many to create the arrays to send to the VBO in the GPU. Having done this (which is the complicated tricky part). No great issue with glDrawArrays, but try just to communicate stuff you want to draw not also stuff you don't want to draw or that you put outside the view area. The memory in the GPU might be a problem. Second try to communicate the most possible data at once in as less VBOs as possible. The main gain is to communicate less and to better use the graphics card memory. Look for CUDA work on that that issue was more than addressed by now. All I can say on this is that trees (just simple binary ones are stored in 1D arrays very imaginatively) by hoping root left right and some marker when null for example.
  7. To anyone reading this ahoy there, Now back to serious mode, I'm working in my old stable fluids code and I was trying to implement the Multigrid method (not full MG) I wanted to implement the V-cycle and latter the W-cycle. However after some searching on the internet (a lot of searching) I managed to program something which is not giving the expected results (code will follow briefly). I know this because I have Jacobi, Gauss-Seidel, SOR, and simple Conjugate Gradient working all giving the same results yet MG V-cycle is not. So anyone familiar with this that can find any issue in the code some help would be most welcomed. I'm just testing for a simple 8x8x8 matrix. Also I perform 13 iters each smooth (Using Jacobi solver). And Jacobi alone gets there for the test case in less than the 13. #define _LEVELS 2 float CLINEAR_SOLVERS::laplacian(long i,long j,long k,float *x,float a,float iter) { return((x[_IX(i,j,k)]*iter)-a*( x[_IX(i-1,j,k)]+x[_IX(i+1,j,k)]+ x[_IX(i,j-1,k)]+x[_IX(i,j+1,k)]+ x[_IX(i,j,k-1)]+x[_IX(i,j,k+1)])); } void CLINEAR_SOLVERS::_mg(CGRID *g,float *x,float *x0,float a,float iter,long iters) { long lvl; float *r=(float*) calloc(g->T_cells, sizeof(float)); if(r!=NULL) { for(lvl=0;lvl<(_LEVELS-1);lvl++){ smoth(g,x,x0,a,iter,iters,lvl*2); update_r(g,r,x,x0,a,iter,lvl*2); restrict(g,r,x,x0,lvl*2); } smoth(g,x,x0,a,iter,iters,(_LEVELS-1)*2); //^-1 ?????? for(lvl=(_LEVELS-2);lvl>=0;lvl--){ prolong(g,x,lvl*2); smoth(g,x,x0,a,iter,iters,lvl*2); } free(r); } } void CLINEAR_SOLVERS::smoth(CGRID *g,float *x,float *x0,float a,float iter, long iters,long inc) { long i,j,k,it; float *aux=(float*) calloc(g->T_cells, sizeof(float)); if(inc==0) inc++; if(aux) { for(it=0;it<iters;it++) { FOR_EACH_CELL1 aux[_IX(i,j,k)]=(x0[_IX(i,j,k)]+a*( x[_IX(i-1,j,k)]+x[_IX(i+1,j,k)]+ x[_IX(i,j-1,k)]+x[_IX(i,j+1,k)]+ x[_IX(i,j,k-1)]+x[_IX(i,j,k+1)]))/iter; END_FOR_EACH_CELL FOR_EACH_CELL1 #ifdef _SOR x[_IX(i,j,k)]=(1-_W)*x[_IX(i,j,k)]+_W*aux[_IX(i,j,k)]; #else x[_IX(i,j,k)]=aux[_IX(i,j,k)]; #endif END_FOR_EACH_CELL } free(aux); } } void CLINEAR_SOLVERS::update_r(CGRID *g,float *r,float *x,float *x0,float a,float iter,long inc) { long i,j,k; if(inc==0) inc++; FOR_EACH_CELL1 r[_IX(i,j,k)]=x0[_IX(i,j,k)]-laplacian(i,j,k,x,a,iter); END_FOR_EACH_CELL } void CLINEAR_SOLVERS::restrict(CGRID *g,float *r,float *x,float *x0,long inc) { long i,j,k; if(inc==0) inc++; // 64 points stencil full weighted // | | // ||1 2 1||2 4 2||1 2 1|| //1/64||2 4 2||4 8 4||2 4 2|| // ||1 2 1||2 4 2||1 2 1|| // | | // 32 points stencil half weighted // | | // ||0 1 0||1 2 1||0 1 0|| //1/32||1 2 1||2 8 2||1 2 1|| // ||0 1 0||1 2 1||0 1 0|| // | | // 16 points stencil // | | // ||0 0 0||0 1 0||0 0 0|| //1/16||0 2 0||1 8 1||0 2 0|| // ||0 0 0||0 1 0||0 0 0|| // | | FOR_EACH_CELL1 x0[_IX(i,j,k)]=((0.5*( r[_IX(i-1,j,k)]+r[_IX(i+1,j,k)]+ r[_IX(i,j-1,k)]+r[_IX(i,j+1,k)]+ r[_IX(i,j,k-1)]+r[_IX(i,j,k+1)]))+(0.25*( r[_IX(i-1,j,k-1)]+r[_IX(i+1,j,k-1)]+ r[_IX(i,j-1,k-1)]+r[_IX(i,j+1,k-1)]+ r[_IX(i-1,j,k+1)]+r[_IX(i+1,j,k+1)]+ r[_IX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r[_IX(i,j-1,k-1)]+r[_IX(i,j+1,k-1)]+ // r[_IX(i-1,j,k+1)]+r[_IX(i+1,j,k+1)]+ // r[_IX(i,j-1,k+1)]+r[_IX(i,j+1,k+1)]+ // r[_IX(i-1,j-1,k)]+r[_IX(i-1,j+1,k)]+ // r[_IX(i+1,j-1,k)]+r[_IX(i+1,j+1,k)]+ // (8*(r[_IX(i,j,k)]))); //performing 16 point stencil //x0[_IX(i,j,k)]=1/16*( // r[_IX(i-1,j,k)]+r[_IX(i+1,j,k)]+ // r[_IX(i,j-1,k)]+r[_IX(i,j+1,k)]+ // (2*(r[_IX(i,j,k-1)]+r[_IX(i,j,k+1)]))+8*(r[_IX(i,j,k)])); x[_IX(i,j,k)]=0; END_FOR_EACH_CELL } void CLINEAR_SOLVERS::prolong(CGRID *g,float *x,long inc) { long i,j,k; if(inc==0) inc++; FOR_EACH_CELL1 x[_IX(i,j,k)]+=x[_IX(i,j,k)]; x[_IX(i-1,j,k)]+=(0.5f*x[_IX(i,j,k)]); x[_IX(i+1,j,k)]+=(0.5f*x[_IX(i,j,k)]); x[_IX(i,j-1,k)]+=(0.5f*x[_IX(i,j,k)]); x[_IX(i,j+1,k)]+=(0.5f*x[_IX(i,j,k)]); x[_IX(i,j,k-1)]+=(0.5f*x[_IX(i,j,k)]); x[_IX(i,j,k+1)]+=(0.5f*x[_IX(i,j,k)]); if((k!=1)&&(k!=((g->NZ)-2))){ x[_IX(i-1,j,k-1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i+1,j,k-1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i,j-1,k-1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i,j+1,k-1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i-1,j,k+1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i+1,j,k+1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i,j-1,k+1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i,j+1,k+1)]+=(0.25f*x[_IX(i,j,k)]); x[_IX(i-1,j-1,k-1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i-1,j+1,k-1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i+1,j-1,k-1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i+1,j+1,k-1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i-1,j-1,k+1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i-1,j+1,k+1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i+1,j-1,k+1)]+=(0.125f*x[_IX(i,j,k)]); x[_IX(i+1,j+1,k+1)]+=(0.125f*x[_IX(i,j,k)]); } END_FOR_EACH_CELL }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!