• Content count

  • Joined

  • Last visited

Community Reputation

154 Neutral

About RubyNL

  • Rank
  1. Space partitioning for flocking

    Well, you could use binary space partitions or quadtree's, which are probably easier for 2d things, or even octrees which are easier to use with 3d things. Or, you can just use a grid, when each cell in the grid has a pointer to the objects in it, the objects only have to check for collisions with objects that are in the same cell.
  2. Help me change my life and career.

    A little tip. If you're gonna make a game, first make some smaller, simpler games in the same genre. By simple I mean especially the graphics. Good graphics are pretty hard to archieve, most game studio's have whole teams of artists for character and level creation, and in my experience, good graphics are one of the hardest things to archieve (together with a general fun game experience: making the whole game not too hard or too easy, not confusing the player, and keep rewarding the player without giving him more of the same every time). The first small game will probably be a mess, maybe you won't even finish it. But, as a result, you will have a better idea of the structure the program needs to have. Sometimes, when you're able to implement a new feature in your old engine, you will think 'OMG, if I redesigned the whole thing it would be so much easier!'. Keep your old projects, and comment everything well, so you have usable source to consult or even use directly if you're having trouble. Also, think about splitting things up in classes, if this doesn't hurt the readability or performance of your game. Also save useful functions in a seperate file. For me, this way of working results in much cleaner and faster code. Please note I didn't ever code a big game, so I don't know how well this way of working scales with the projects, possibly this is too much work for big projects. Last thing. You've probably heard this before or thought of it yourself, but seperate your engine from the levels, graphics, and gameplay as much as possible. It will be easier to make special effects (graphical effects or gameplay-wise, for exception, inversing the gravity will be easier when you have some force vectors instead of a hardcoded "player.y += 5;" each frame (as a figure of speech)). This can cost a little bit of performance, but things like this can usually be done pretty efficient. Else you just have to find a balance, or try both ways and then decide what's the way to go. Good luck
  3. Line intersecting a face

    Hmm, good question. This is the easiest to do with triangles, I think. I done a little raytracing a long while ago, and this question came up when I was trying to build a little engine. I've forgot the specifics of the implementation, but don't worry, there is plenty of information out there. For example [url=""]here[/url] and [url=""]here[/url]. If you want to do this for arbitrary polygons you may want to triangulate them first, but again, I forgot the specifics, so I'll leave it up to you to do some research. A little linear algebra skills may come in handy if you want to understand what's going on (or even try to find a way yourself).
  4. Rope/cloth simulation problems

    Here is the result I got with Verlet Integration (the method I described in my first post): [media][/media] I'm quite happy with it, since it was all done it a hurry (I got my finals this week, so I made this from the rope thing in literally one day). Gouraud shading, nothing fancy (I had no time to do research in OpenGL lighting methods, I had enough trouble with C++ alone, since this is the first thing I code in that language). I have to admit, this is the result in optimal circumstances. I don't have any collision detection, so the cloth/flag often sticks through itseld when I move it.
  5. Rope/cloth simulation problems

    Thanks for your reply! I've fiddled with the variables a bit and I get a much better performance now (I would upload another video right now if that wouldn't take so long). At first I thought that setting my stiffness above 1 would result in instability per se, but it turns out that it works quite well. I've got a cloth simulation running with the method I've described above, and it works fine. I do about 7-50 iterations where I satisfy the constraints. Works quite well, however the strings are still quite elastic when I use a lower number of iterations. Then I came across [url=""]deformation constraints in a mass-spring model to describe rigid cloth behavior[/url]. It seems to be what my lecturer aimed at with his descriptions of a mass spring model, with a maximum length for the rope segments between the nodes. I am trying to implement this model right now. Sadly, I'm kind of stuck with Euler's method of integration. I get only way too elastic strings, which fall straight down to the ground, even if I set the stiffness to 1. Maybe I will have a shot at it in the near future, but since it's for an assignment that I have to hand in in a few days, I will finish the project with the Verlet Integration first.
  6. It works, if you use column vectors and premultiply with that matrix. Do you know how matrix multiplication works? Because if you work the multiplication out, you get the desired result (as I stated in my post earlier). Here is how you should multiply matrices (you can treat a column vector as a 1x4 matrix): [url=""][/url] (Skip to 2:50 for the actual multiplication)
  7. Oh, what I was trying to say is that the matrix given there seems to be correct to me. I don't know what exactly a column-major matrix is, but the matrix seems to do the job for column vectors.
  8. Usually you note vectors as column vectors, in this form: x y z 1 Where the last 1 would be 0 for directional vectors, and 1 for positions. This would work fine with the matrix given there (if you premultiply with the matrix as it's given there, which you usually do). If you work out the multiplication by the vector above, you get a new column vector: scaleX * x + tz scaleY * y + ty scaleZ * z + tx 1 So basically, you scaled the axes by scaleX, scaleY, scaleZ and then translated everything with tx, ty, tz. Was this of any help to you?
  9. Hello, for a course in 3-dimensional modelling, I have to program a rope simulation, and, extending that code, a cloth simulation. I'm having some troubles though. First I had a shot at an Eulerian sping mass-model, like described on [url=""]Hugo Elias' site[/url]. It was either way too elastic, or way too 'jumpy' (numerically instable, everything exploded after a few seconds, especially if I attached a node to the mouse so I could test the reaction on mouse movements). Then I read some more articles about rope simulation, the most important being Advanced Character Physics ([url=""]html[/url] | [url=""]pdf[/url]) by Thomas Jakobsen. He suggested using Verlet Integration. I use a fixed timestep (I use dt = 1 in my code), so the Verlet Integration basically comes down to storing the last position of each node/particle instead of storing it's speed (at least, that's what I think, I could be missing something), so initially this had no effect on the instability. But then I read about constraint relaxation. Constraint relaxation basically means you 'satisfy' each constraint, one at a time, while not caring about the effect this has on the other constraints. Then you repeat this process a few times, and you end up with an approximation of a system where all constraints would be satisfied. I have 75 nodes/particles, and I have set the 'sticks' between them to be of a length of 3 pixels (this is the only constaint I'm using, but since I'm doing this for 75 particles, it are in fact 74 constraints which all invalidate each other to some degree). For example, if you have three nodes on a horizontal line with each 100 pixels between them, we have two constraints (the first being that node 1 and node 2 must be 3 pixels apart, and the second that node 2 and node 3 must be 3 pixels apart). Satisfying the first constraint (node 1 and node 2 must be 3 pixels apart) will move node 1 48.5 (=(100-3)/2) to the right and node 2 48.5 pixels to the left. The distance from node 2 to node 3 will then increase to 148.5, but my code uses the old position (which is in memory because I use Verlet Integration) to calculate the distance between two nodes, so the distance between node 2 and node 3 can be regarded as 100 pixels. Then the [url=""]satisfaction[/url] of the second constraint will increase the horizontal position of the second node with 48.5 pixels again, (basically undo-ing the displacement what we did to satisfy the first constraint) and move the third node 48.5 pixels to the left. In practice, this method should converge to a 'solution', satisfying all the constraints, but I fear it might converge too slow. Here is what I have so far: [media][/media] It looks pretty good (especially when you consider that I don't use any 'flexion' springs, which connect nodes that are separated by another node between them), but in this example I have 75 particles, each attached to 1 or 2 'springs'. I run the part of the code where I satisfy each constraint 500 times, and I'm fairly sure this is way too much to be of practical use in a cloth simulation. Further, I still have some 'springyness', even when I use 500 iterations. I'm afraid this springyness will be a much bigger problem in a cloth simulation (because there are many more points, so the mass is much higher). If I use 100 iterations, the rope is much more elastic already. So, I'm confused about the spring-mass model, I couldn't get it working in a satisfying way. Am I on the right track to go on with cloth simulation or am I doing something structurally wrong? Also, in the practicum description it states that you should use Hooke's law (F=-kx where x is the displacement from the rest length of the spring, and k is some positive spring constant). I am not using this equation explicitly, but the constraint relaxation has the same behaviour, so I guess that's fine. But the description also states that you should use a maximum length for the distance between the nodes, which really confuses me, because this is exactly what I'm doing with the constraint relaxation, but this results in spring-like behaviour where the rope still is elastic (the distance between ). I don't know how to set a 'hard' maximum for the distance between two nodes. Suppose I could get an Eulerian system working nicely, I wouldn't know how this implement such a hard border either... Sorry for the long post, it thought it was kind of hard to explain clearly what I'm doing and what's the problem!
  10. ball-curve intersections

    Wow! Thanks for your reaction. I have to take some time to fully understand it, my math and english are only so-so and the combination makes it worse :P. Quote:Original post by Dave Eberly You might have a fetish, but sadly computers do not. The idea of wanting an "exact solution" is an artifact of a mathematical education system whereby exercises are designed to produce closed-form solutions. In practice, this is not always possible, and even if it were, the closed-form solutions can be problematic when using floating-point arithmetic (computing roots of polynomials, for example). I know that with todays (and probably future's) implemention of fixed and floating point math, it is impossible to calculate most non-integer values exactly since they have a infinite amount of decimals. The problem I have with approximations is that in some cases an approximation would cause problems if you compare two values that are very close to each other. An approximation could wrongly point out one of the values as bigger then the other, while in fact, the other value is bigger. An algorhitm that in theory produces exact results does not suffer from this problems. (In theory, or when you calculate exactly, that is, you don't calculate square roots for example, you don't have this problems at all. however when implemented using floating or fixed point arithmetic the problems might still occur, but I assume you would have less of this problems when you use exact algorhitms). Sorry for the long text(edit: when editing it looks a lot longer ;)), I will soon respond on the actual mathematical stuff in your post (as soon as I understand/have something to reply)
  11. I plan on writing a simple bouncing-ball-engine where multiple balls bounce off the environment and each other. No problem if the environment is made of lines. But I want something smoother. Bezier curves for example. I looked up on bezier curves and found that it isn't possible - or at least not easy enough to implement - to calculate the intersection between a moving ball and a bezier curve. Then I figured out that if I could find intersection between a moving ball and a parabola I could 'add' a coordinate system for each parabola and in that way rotate and scale the parabola. It turned out too hard for me too... Is there any type of curve that is commonly used in this kind of engines? Btw, I have some kind of fetisj for exact calculations so if there is any exact solution I would prefer it. But all help and every comment is welcome of course.
  12. I don't know if this of any help to you, but the method I would use with my current experience (= not that much) would be to simply don't let your engine calculate more then 1 frame ahead. Say you have a global variable isdrawn or something. You set it to 1 when you've drawn the current frame, and set it to 0 when your performing calculating 1 frame ahead. Then you can assure that only calculate 1 frame ahead. If you do more, you will skip a frame so that frame won't be drawn. Like this you would still need to make sure that you can calculate ahead without messing your graphics up. No idea if this is of any help, I'm no expert on multithreading but I just got this idea.
  13. Vector Positions?

    Here is a tutorial on vectors and their applications in 3d graphics: The source is in qasic, but don't worry, you will be able to understand it ;) I hope this helps you, if not, please clarify your problems.
  14. 3d rotations

    Quote:Original post by relsoft Same here stopped coding for more than a year and just getting back to coding in Freebasic and C++. I have been tinkering with Nintendo DS coding these days. Sweet :), I was always interested in coding for other hardware then the computer, but never really coded anything. Cool to see that you have!
  15. 3d rotations

    Hey! Yes, I haven't been programming much the last years. I finished my high school and I'm gonna start studying computer science in a few weeks. I learned a bit of java and I wanna learn c++ somewhere in the near future. Btw, your 3d tutorials are great! I'm gonna try to solve this thing myself using that lookat transform ;).