
Advertisement
gonssas
Member
Content Count
38 
Joined

Last visited
Content Type
Profiles
Articles and Tutorials
News
Contractors
Columns
Podcasts
Games Industry Event Coverage
Gallery
Forums
Calendar
Blogs
Store
GameDev Links
Projects
Developers
Everything posted by gonssas

Hey, I am working on a program that uses the perceptron algorithm to do pattern recognition and classification. Simply put I use a 2d grid in which each pixel is either on (1) or off (1). using the following rules and algorithm taken from some reference.: w(x) = w(x) + LR * R * v(x) b = b + LR * R w  weigth vector v  value vector LR learning rate r expected result The pseudo code for the algorithm: while (1 ) { updates_made = 0 For each Example in Training Set { /* o is b + SUM( v(x) * w(x) for all x ) */ o = awnser ( Example, w, b ) if ( o != R ) { for x = 0 to v.count { w(x) = w(x) + LR * R * v(x) b = b + LR * R } updates_made = 1 } } if (updates_made==0) { break } Problem: train it to recognize a pattern. Then ask if a pattern where one of the active pixels is unactive comparting to the original pattern, it says its the same. The problem is it keeps saying its the same until all the the pixels of the original have been deleted. The sum is giving very high results and taking out one of the active pixels takes a very small value from the ottal sum. Any ideas? Thanks.

Ouch found a crazy bug for x = 0 to v.count { w(x) = w(x) + LR * R * v(x) b = b + LR * R } this is adding to the bias v.count times, hence the bias was giving crazy values.

Hey, thanks for your comments. Quote: It is important to have examples that do not match the pattern. Classification is about picking which category an input belongs in. Your examples only show things that have some property P. It is also important to show things that do not have property P to allow the classifier to know what should be put in category "not P". Quote: In your case, you can try training the network to recognize things that do not match your pattern by outputting 1, just like you're training it to recognize things that do match your pattern by outputting 1. Thanks, Will try this. Is it better not to use random when generating the noisy patterns? Example of how its generating: 5% random changes (for YES) 95% random changes (for NO) Could use the other characters as NO examples, however I want to have this working for a single character first. Thanks for your comments.

Note that the awnser function returns sum = b + SUM ( v(x) * w (x ) for all x ) if sum > 0 return 1 else return0 Thanks.

Hello, I am trying to code backface culling using only software rendering  No directx, no opengl. So I splitted a cube into triangles. Each face has two triangles. Calculation formula (found online) display = y1*(x3  x2) + y2*(x1  x3) + y3 *(x2  x1); Some screenshots of teh results. screenshot "if display > 0" http://img305.imageshack.us/img305/6893/morethanzeroyo8.jpg screenshot "if display < 0" http://img305.imageshack.us/img305/2664/lessthanzerogj3.jpg Triangules are organized like this Face is square defined by P0, P1 P2 P3. P0P1     P3P2 T = P0 P2 P1 T' = P0 P3 P2 Example Front Face Triangules T = 0 1 2 T' = 0 3 2 Example Back Face Triangules T = 5 7 6 T' = 5 8 7 Where the point data is: P0 = 1, 1, 1 P1 = 1, 1, 1 P2 = 1, 1, 1 P3 = 1, 1, 1 P5 = 1, 1, 1 P6 = 1, 1, 1 P7 = 1, 1, 1 P8 = 1, 1, 1 Thanks for your comments. [Edited by  gonssas on January 10, 2007 10:51:17 AM]

Quote:Original post by TheAdmiral A triangle should be culled iff 'it' faces away from the camera; iff its face normal points away from the camera iff the z component of its face normal is positive (respectively, negative) So we are required only to calculate the sign of the z component of its face normal. This can easily be extracted from the crossproduct of two given edges: n = (v3  v1) ^ (v2  v1) n . ez = (v3.x  v1.x)(v2.y  v1.y)  (v3.y  v1.y)(v2.x  v1.x) Hey, thanks, its working now. I would like to know more about that formula. What's the 'ez'? Thanks.

Resources about 3d solids (coordinates of points)
gonssas posted a topic in General and Gameplay Programming
Hey, does anyone know where to find information about 3d solids. What I'm looking for is point coordinates and edge information of 3d objects (convex). Thanks for your comments. 
Hello, my program has got a rotation object but if we translate the object and then rotate, the rotation is done around the origin and around the object itself. For example here is the code that rotates around the X axis: for ( i=0; i<obj.num_points; i++ ) { temp_y = obj.points.y; temp_z = obj.points.z; obj.points.y = temp_y * cos(angle)  temp_z * sin(angle); obj.points.z = temp_y * sin(angle) + temp_z * cos(angle)); } } SO probably the code needs to translate the object back to the origin before applying the rotation and then translate it back to the point where it was. Correct? Isnt' there another way, maybe a way to change the rotation code so it works anywhere? Thanks for your comments. [Edited by  gonssas on January 15, 2007 6:39:23 PM]

Rotation is scaling down the cube
gonssas replied to gonssas's topic in Graphics and GPU Programming
Fixed. Thanks for your comment. 
Hello, I am trying to rotate a cube but the rotation is scaling down the cube. Here is the function that rotates: void rotate_x ( Object *obj, float angle ) { int i; int j; for ( i=0; i<(*obj).num_points; i++ ) { (*obj).points.x = (*obj).points.x; (*obj).points.y = (*obj).points.y * cos(angle)  (*obj).points.z * sin(angle); (*obj).points.z = (*obj).points.y * sin(angle) + (*obj).points.z * cos(angle)); } } The value for the angle is 0.7. Thanks for your comments.

Question about Triangle vertex ordering in backface culling
gonssas posted a topic in Math and Physics
Hello, the backface culling code on my software renderer isn't working very well. This code is done in C using a simple library. The only library call I'm using besides start and close graphics mode is line and setcolor. Results The initial position is correct, shows only the frontal face of the cube. After a few rotations it gets lost ans starts showing all the faces again. Since it could be the order of the vertex in trhe triangle, I am looking for some info on this. The object at hand is a cube. Front face points 0...1 3...2 Back face points 4...5 7...6 So 0 = 1, 1, 1 1 = 1, 1, 1 4 = 1, 1, 1 5 = 1, 1, 1 And so on. The formula to check the sign of each triangle is display = y1*(x3  x2) + y2*(x1  x3) + y3 *(x2  x1); Then the code checks if display > 0 and draws. The formula is applied after projection and translating to the center. Now the triangle ordering: 0 3 2 Initial Front Face 0 2 1 5 7 4 Initial Back Face 5 6 7 1 6 5 Initial Right Face 1 2 6 4 3 0 Initial Left Face 4 7 3 4 1 5 Initial Top Face 4 0 1 3 6 2 Initial Down Face 3 7 6 Is this ordering correct? Thanks. 
Quote:Original post by TheAdmiral And what's the problem? Doesnt work. Faces are not correctly taken off. Those screen shots are not up to date since I did some changes in the order of vertices. Using perspective projection. Initial value After rotation x After some other rotations x The logic is For Each Triangle X1 = Triangle[0].X / Triangle[0].Z; X2 = Triangle[1].X / Triangle[1].Z; X3 = Triangle[2].X / Triangle[2].Z; Y1 = Triangle[0].Y / Triangle[0].Z; Y2 = Triangle[1].Y / Triangle[1].Z; Y3 = Triangle[2].Y / Triangle[2].Z; display = y1*(x3  x2) + y2*(x1  x3) + y3 *(x2  x1); if ( display > 0 ) { /* draw */ }

Hello, how can we know the z value (depth) of a point in a triangle? After working out a way that gives the Z over a line bewtwen two edges, my problem is now calculating the Z for a Point in the triangle but not in the edges. P0 /\ / \ Px / Pn  P1 That method gives Px knowing P0 and P1. So now the problem is getting Pn that is not in an edge. So read somewhere that it can get worked from a scanline / \ /Pn This implicates calculating the intersection of the scanline where Pn is with the two edges of the triangle. Question 1: Is there another more direct way? Question 2: This method bust follow several calculations to get the Z. In Px case the Z is calculated from two know Z. In the Pn case the Z is calculated from two Z that are calculated from known Z. Isn't this going to give only aproximated results? thanks.

Thanks for your comments. Will that work even after the points are projected from 3d to 2d with perspective projection? Thanks.

Hello, The foolowing code was created to allow for objects with any number of vertex. However the last assignment isn't working. typedef struct { float x; float y; } point; typedef struct { point *point; int count; } object; int main () { object random; random.point = (point *) malloc ( 4 * sizeof ( point ) ); random.point[1].x = 10; random.point[1].y = 100; random.point[0] = {10, 100 }; } The last atribution statement doesn't compile. Parse error in { token. The other 2 work fine. Isn't there a way to assign like the last atribution? Thanks.

Removing lines that are invisible in a wireframe
gonssas replied to gonssas's topic in Graphics and GPU Programming
Hello, Quote:Original post by don So just to be clear, you have an array containing a number of vertices and you connect these by making a number of 2D line drawing calls? Do the vertices even contain a depth (z) coordinate? It's difficult to provide a solution to your problem without knowing the capabilities of the graphics API that you've chosen to use. Yes for both your questions. The system also has a list of triangles (where each triangle is made if 3 INTs that represent the vertices in the vertex array) to facilitate working with faces. As for graphics API, I'm using Borland BGI on Borland C 3. Reference here: http://www.cs.colorado.edu/~main/cs1300/doc/bgi/index.html Thanks. 
Removing lines that are invisible in a wireframe
gonssas posted a topic in Graphics and GPU Programming
Hello, can someone give some points about invisible line removal? What are the best algorithms for this? Example: theres a wireframe of a 3d object. The lines that are on the background are "covered" by the "faces" in front of them. So those covered lines are not drawn as if the object was filled. Thanks. 
Removing lines that are invisible in a wireframe
gonssas replied to gonssas's topic in Graphics and GPU Programming
Hello, after some investigation it seams that calculating if a point is in the edge of a polygon is hard to do exactly due do roundings of numbers. http://www.acm.org/pubs/tog/editors/erich/ptinpoly/ So the above method will probably not work very well and give some weird results for some of the points in the line. Next, I'll try to do it with manual line plotting. While processing each line, checking if each pixel coordinate is the one thats closest. Thanks. 
Removing lines that are invisible in a wireframe
gonssas replied to gonssas's topic in Graphics and GPU Programming
Hello. Quote:Original post by xycsoscyx Ah, I see what you mean that it must be convex, a torus, for example, still has front faces in the center, behind the front faces of the outer edge. Also, yes, you would need to render filled in faces to do the depth buffer method. Ultimately, you can't render only a list of lines; you need a list of faces in order to only render the ones in front. Even though nothing is there, you still need a surface area to clear inside of, which means connecting everything to faces (triangles typically), even if you're only rendering the lines. This lets you know what you're blocking out, so as to not render anything behind it, a line by itself has no area (it's just typically represented by a pixel width when drawn), which means by itself, it doesn't really block anything behind it. Thanks. Another question: Since triangles will be used to make up faces and since faces are not to be drawn (dont get into the COLOR[x][y] array wich is updated everytime a "z closer " point is selected) a way of ignoring those points that do not belong to the wireframe (edges only) is needed. Will the following work? Find if Pn is white colored or not. * Use the two points that make each edge (P1 and P2) * Use the line equation (y = m x + b) to find the 'b' value, and the m equation (m = y2  y1 / x2  x1) to find the 'm' value * Check if Pn is in the line and in between P1 and P2 With that info we can see if any other point is in the edge. If it this we can just set the COLOR[Pn.x][Pn.y] to white WHEN Pn is the "z closest" pixel so far. Thanks for your comments. 
Removing lines that are invisible in a wireframe
gonssas replied to gonssas's topic in Graphics and GPU Programming
Hello and thanks for your comments. Quote:Original post by _swx_ Render the object to only the depth buffer (color writes disabled), then render the wireframe with lessequal z comparison? Question: since the program only draws the wireframe (the lines), there's nothing physically "in front" of the backlines. So that would need the pixels that make up each "face" to get filled in some color in the depth buffer, in order to get something to compare the lines against,, correct? Thanks. 
Removing lines that are invisible in a wireframe
gonssas replied to gonssas's topic in Graphics and GPU Programming
Hello, Thanks for your comments. Quote:Original post by Zymph In OpenGL, its just a matter of doing: glPolygonMode(GL_FRONT, GL_LINE); No idea how to do it in DirectX, though it will be something similar. only using a simpler graphics library (Borland). Rendering is done "manually" with lines connection points that are kept in a matrix. Thanks. 
Hello, I need some examples of using Prolog as the game engine and using C for the graphical interface and also for using input. Does anyone have a small example of something like that? If not in C, Java or Delphi examples are also useful. Thanks for your help. [Edited by  gonssas on June 23, 2006 12:25:27 PM]

Prolog + C for game logic and interface
gonssas replied to gonssas's topic in General and Gameplay Programming
Yes, the point is using Prolog for the AI of the game. Thanks. 
Animations  what are the options to display animations
gonssas posted a topic in For Beginners's Forum
Hello, I would like to know what are the several options techniques to display 3d animations inside games. Thanks. 
Hello, after writing a few simple 2d apps I would like to try and convert one of those to a 3d look. For example a board game. Everything that is in the engine (rules) stays the same (it's still a 2d array for example). Functions that draw to the screen need to change. So let's say I want to convert the board (2d on screen) to a 3d looking board. Now what I'm looking for is some advice regarding what kind of alternatives are there in 3d for doing this conversion and wich would be better for learning purposes. Also pointers for articles are welcome. Thanks. [Edited by  gonssas on April 12, 2006 6:06:02 AM]

Advertisement