Jump to content

  • Log In with Google      Sign In   
  • Create Account


Matthewj234

Member Since 30 Dec 2011
Offline Last Active Aug 20 2014 12:21 PM

Posts I've Made

In Topic: VBO is Rendering an extra triangle

06 June 2013 - 07:28 AM

Thanks for the responses guys!

 

I will check the indexCount and test it with more triangles.  

 

As for the usage of glDrawElements, I am using this system to render 3D mesh's, I was just using the 3 triangles to test the setup.


In Topic: Looking for 2d iso designer

12 September 2012 - 05:37 PM

Wrong area. You should post this in the classifieds.

In Topic: Terrain Generation

04 August 2012 - 12:13 PM

It's not about whether they are integers, but how many samples you take between integers. The way Perlin noise is calculated, the values at integer co-ordinates are pseudo-random. If you only sampled at integer values (e.g. (1.0, 2.0)) the values would look totally random. If you went by steps of 0.5, the values in between would be a combination of the values from the integer co-ordinates (e.g. the value at (1.5, 2.0) would be part way between the value at (1.0, 2.0) and (2.0, 2.0)). The smaller the steps you take, the smoother the values will look. I would suggest finer steps, e.g. 0.1 instead of 0.4.


Thanks, I am now using 0.01 steps and the results are AMAZING! So thank you very much!



Thanks everyone, you helped alot!

In Topic: Terrain Generation

03 August 2012 - 06:00 PM

I would highly recommend using LibNoise over rolling your own noise algorithm. You'll get more consistent results and you'll have access to many other extremely useful features.


Thanks but Im using java. I had looked at this, and im trying to find a java port. However, I believe that the perlin code is correct, it is from J3D, however my method of implementation is whats causing the issues.

One common error wit Perlin noise is that it looks random if you sample it at integer values. The smoothing occurs between integers, so I would suggest effectively zooming in.


I sample at 1-16*0.4, so I believe all of my samples are doubles.

In Topic: Pathfinding algorithm

11 July 2012 - 03:57 AM

Hello,
My teacher( we're studing programming in the engineering school ) said its really hard to find a way without recursion so I wrote this in C when I was 9th grade; I hope it will help you, its console app:
1. You enter your starting and ending position; X >= 0, X <= 24, Y >=0, Y < 25. Yeah I know its fixed but I was too lazy that day xD
2. FIll in the closed boxes; Places where you can't use to reach the final destination
3. It will print you a 25x25 grid where 5 is your start position, 6 is your destination, 1 is the generated way, 2 are the "locked" boxes, and 0 is the free space where you could walk but u actually didn't

Please don't jungle me for not using const and references ;/

[source lang="cpp"]#include <stdio.h>#include <math.h>typedef struct _COORD{ int x, y;}COORD;typedef struct _BOX{int info, list;float g, h;COORD parent;}BOX;COORD bestNode();void CheckNeighbours(COORD cp);float magnitute(COORD a, COORD b);//global varsBOX grid[25][25]; // main mazeCOORD ep; // end postion. ( where u must reach )void printmaze(int clear){ //clear flag -> if 1 then it will clear the grid and set it to 0 //else -> jsut print its current state int i, z; for(i = 0; i < 25; i++) { for(z = 0; z < 25; z++) { if(clear == 1) { grid[i][z].info = 0; } printf("%i", grid[i][z].info); } printf("\n"); } printf("\n");}int main(){ COORD cp, sp; int e; COORD ctemp; e = 0; printf("Start point. X: / 0-24 / "); scanf("%i", &sp.y); printf("Start point. Y: / 0-24 / "); scanf("%i", &sp.x); printf("End point. X: / 0-24 / "); scanf("%i", &ep.y); printf("End point. Y: / 0-24 / "); scanf("%i", &ep.x); printmaze(1); //add closed printf("Add a closed block? Yes = 1, No = everything else: "); scanf("%i", &e); while(e == 1) { printf("Closed Block. X: / 0-24 / "); scanf("%i", &cp.y); printf("Closed Block. Y: / 0-24 / "); scanf("%i", &cp.x); grid[cp.x][cp.y].list = 2; grid[cp.x][cp.y].info = 2; // with 2 I've marked the closed postions where u can't go printf("Add a closed block? Yes = 1, No = everything else: "); scanf("%i", &e); } grid[sp.x][sp.y].info = 5; // start point on the grid grid[ep.x][ep.y].info = 6; // end point on the grid printf("\n"); // find best way cp.x = sp.x; cp.y = sp.y; //add to open list; grid[cp.x][cp.y].list = 1; grid[cp.x][cp.y].g = 0; grid[cp.x][cp.y].h = magnitute(cp, ep); while(!(cp.x == ep.x && cp.y == ep.y)) // while we have not reached the target {// current postion.x == end postion.x ... //check best node from open list; cp = bestNode(); printf("checking %i-%i \n", cp.x, cp.y); //check out neighbours; if(cp.x == -25000 || cp.y == -25000) // my grid is fix sized from 0-24 so I use -25000 as a flag { printf("There is no way."); cp.x = ep.x; cp.y = ep.y; }else{ CheckNeighbours(cp); grid[cp.x][cp.y].list = 2; // closed list } } while(!(cp.x == sp.x && cp.y == sp.y)) { cp = grid[cp.x][cp.y].parent; grid[cp.x][cp.y].info = 1; if(cp.x == sp.x && cp.y == sp.y) grid[cp.x][cp.y].info = 5; } printf("\n"); printmaze(2); printf("End. \n"); scanf("%i", &e); return 0;}void CheckNeighbours(COORD cp){ int i, z; COORD ctemp; for(i = -1; i < 2; i++) { for(z = -1; z < 2; z++) { //check if alive; if(cp.x + i >= 0 && cp.x + i < 25 && cp.y + z >= 0 && cp.y + z < 25) { if(!(i == 0 && z == 0)) { if(grid[cp.x + i][cp.y + z].list != 1 && grid[cp.x + i][cp.y + z].list != 2) { //if open list or closed grid[cp.x + i][cp.y + z].list = 1; grid[cp.x + i][cp.y + z].parent.x = cp.x; grid[cp.x + i][cp.y + z].parent.y = cp.y; //record h value ctemp.x = cp.x + i; ctemp.y = cp.y + z; grid[cp.x + i][cp.y + z].h = magnitute(ctemp, ep); grid[cp.x + i][cp.y + z].g = magnitute(ctemp, cp) + grid[cp.x][cp.y].g; printf("new neighbour: %i - %i \n", cp.x + i, cp.y + z); }else if(grid[cp.x + i][cp.y + z].list == 1) { ctemp.x = cp.x + i; ctemp.y = cp.y + z; if( grid[cp.x + i][cp.y + z].g > grid[cp.x][cp.y].g + magnitute(cp, ctemp)) { grid[cp.x + i][cp.y + z].parent = cp; grid[cp.x + i][cp.y + z].g = magnitute(ctemp, cp) + grid[cp.x][cp.y].g; } } } // end if mid } // end if alive } // end for z } return;}COORD bestNode(){ int i, z; int bestf = -25000; int a = 0; COORD bestNode; for(i = 0; i < 25; i++) { for(z = 0; z < 25; z++) { if(grid[i][z].list == 1) { if(a == 0) { a = 1; bestf = grid[i][z].g + grid[i][z].h; bestNode.x = i; bestNode.y = z; } else { if(bestf > grid[i][z].g + grid[i][z].h) { bestf = grid[i][z].g + grid[i][z].h; bestNode.x = i; bestNode.y = z; } } } } } if(a == 0) { bestNode.x = -25000; bestNode.y = -25000; } return bestNode;}float magnitute(COORD a, COORD b){ COORD toret; float ab; if(a.x > b.x) { toret.x = a.x - b.x; }else { toret.x = b.x - a.x; } if(a.y > b.y) { toret.y = a.y - b.y; }else { toret.y = b.y - a.y; } ab = toret.x * toret.x + toret.y * toret.y; ab = sqrt(ab); return ab;}[/source]


Thanks, this was really helpful, showing different ways of achieving the same thing. :)

PARTNERS