Jump to content
  • Advertisement

andrew111

Member
  • Content count

    93
  • Joined

  • Last visited

Community Reputation

310 Neutral

About andrew111

  • Rank
    Member
  1. andrew111

    Question about creating a replay system

    You might find these interesting:   Game Developer Dec 2012 p36 - recording unity - Building a replay system in Unity http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_December_2012.pdf    Game Developer May 2008 p46 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_May_2008.pdf   Game Developer Jun-Jul 2008 p47 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS PART 2 http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_JuneJuly_2008.pdf
  2. If the implementation language doesn't matter, there is a library for Scala called Kiama at https://bitbucket.org/inkytonik/kiama   I don't remember all the details since it has been a while since I used it, but it uses a "packrat parser". Which you basically write the grammar directly in Scala, and specify the classes/params to be used to build the syntax tree.   Attributes are declared in recursive tree-like  expressions. We used the attributes for things like calculating scope and constant expressions, I forget what else, but I remember it being really easy at the time.   Another option is to use Ragel for lexing and Lemon for parsing. These can be used to generate parsers in C.   http://www.colm.net/open-source/ragel/ http://www.hwaci.com/sw/lemon/  
  3. andrew111

    X11 Client Events

    Try this: Display *display; Window win; Atom wmDelete; void onInit() { wmDelete=XInternAtom(display, "WM_DELETE_WINDOW", True); XSetWMProtocols(display, win, &wmDelete, 1); } void onUpdate() { XEvent ev; while(XPending(display)) { XNextEvent(display,&ev); if(ev.type==DestroyNotify) { //on exit } if(ev.type==ClientMessage && (Atom)ev.xclient.data.l[0] == wmDelete) { //on close window } XFreeEventData(display, &ev.xcookie); } }
  4. Looks like a cut down version of stencil shadow volumes. Where it draws the shadows quads to the stencil buffer, and then the lit things are drawn except for the pixels marked by the stencil buffer. Pretty neat idea, looks like it would work for any N sided polygon.   You can't do it in a vertex shader since you can only access one vertex at a time, where as that algorithm needs access to two. Also I think vertex shaders can spit out only one vertex at a time, where that spits out 4. If you had geometry shaders you could do it there but that's opengl 3.3+.   Edit: Actually you could pass more than one vertex to the shader by doing something like for verts in quad or triangle {   glVertex4f(cur.x,cur.y,next.x,next.y); }   But I don't know if you are able to emit more than 1 vertex from the shader. If you could, it might be possible...     Edit2: Actually I just realised another idea, where you send a quad for each edge, e.g. for each edge {   glBegin(GL_QUAD);     glNormal(edgeNor.x,edgeNor.y,0);    glVertex3f(cur.x,cur.y,0);//0 represents the vertex on the edge to not extrude     glNormal(edgeNor.x,edgeNor.y,0);   glVertex3f(next.x,next.y,0); //0 represents the vertex on the edge to not extrude     glNormal(edgeNor.x,edgeNor.y,0);   glVertex3f(cur.x,cur.y,1); //1 represents the extruded vertex     glNormal(edgeNor.x,edgeNor.y,0);   glVertex3f(next.x,next.y,1);//1 represents the extruded vertex   glEnd(); }   Basically in the vertex shader you: 1. redundently do the dot product check to see if a shadow should be extruded. Pass a varying float to there fragment shader, where if shadow pass 1, else pass 0 2. If the vertex.z ==1, extrude the vertex along the light direction.   Fragment shader: 1. Check the varying float passed from the vertex shader, if == 0 then call discard to abort drawing the shadow   Kind of convoluted, but it should/could work.
  5. andrew111

    Font Rendering

    This library really needs some kind of docs or at least example code, I wasn't able to figure it out.
  6. Thanks, I'll give it a try when I get time.
  7. Okay, after Álvaro's question I realised I was confusing the problem. for two triangles sharing an edge I want to find out whether they are facing away from each other, facing towards each other or laying flat (same normal).   So a slight change from  C0lumbo's method, I dot product the normal from the first triangle to the non shared edge of the second triangle, where dotproduct=0 is both triangles laying flat, dotproduct<0 facing away (convex), dotproduct>0 facing towards (concave).   Seems like it should work.
  8.   Yes this was the problem I ran into, I'll give your suggestion a try.     The triangles are part of a 3D mesh, so I'm trying to tell if they are concave or convex, so >= PI is convex and < PI is concave.   The vertices are winded clockwise so the triangle normals always on the outer surface of the mesh.   EDIT:   Ah I just realised what you meant, I've been looking at the problem a bit wrong. I'll have think about this a bit more and get back to you.
  9. Hi I have two triangles sharing an edge and I have their normal vectors. Na          Nb  \    F   /   \  /|\  /   \/ | \/    /\ | /\    \  | /     \ | /     \|/       G (Na and Nb are the triangle normals, F and G are their shared edge) I want to check if the angle between the normals is: = 0, < PI, = PI or > PI.   I'm a bit rusty on 3d related math, but I looked at dot product and I don't think that works since I believe it can only be used to find the angle between 0 and PI, where as I  want between 0 and 2*PI.   I think maybe something could be done with cross product, e.g. since normals are unit length I have: Na * Nb = sinX*V (V being the cross product, X being the angle).   But I don't know where to go from there.       I've looked at this post from a similar/same question: http://www.gamedev.net/topic/112385-detecting-if-2-triangles-are-concave-or-convex/?view=findpost&p=1604381     But in this I don't understand what the a1 and a2 is (I'm guessing something like sinX), or what he means on the second step, compute the components?   Thanks.
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!