  # RegularKid

Member

381

139 Neutral

• Rank
Member

## Recent Profile Visitors

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

1. Hi! I'd like to write a budget app for the iPhone for my own personal use, but I want to be able to download transactions from my actual bank in order to use them within the app. I've searched around and found a few things regarding OFX, but was wondering if anyone has any experience with this? In a perfect world with unicorns, there would be a magical C++ API that could be used like this: void GetTransactions( string OnlineBankURL, string OnlineBankID, string OnlineBankPassword ) { MagicalAPI->ConnectToBank( OnlineBankURL, OnlineBankID, OnlineBankPassword ); MagicalAPI->DownloadTransactions(); for( int i = 0; i < MagicalAPI->NumTransactionsInLastDay(); i++ ) { DoAwesomeBudgetStuff( MagicalAPI->GetTransactionInfo( i ) ); } } Thoughts? Thanks!
2. Ok, I figured it out. I was able to port the OGRE Quatenrion - Vector3 multiplication operator. Everything works great now! Here's the final code I used for anyone who's interested: /// <summary> /// Get a random variant vector from a particular vector given a /// specific variant limit angle. /// </summary> /// <param name="vector">The vector to get a variant from.</param> /// <param name="angle">The variant limit angle.</param> /// <returns></returns> public static Vector3 RandomVectorVariant( Vector3 vector, float angle ) { // Thanks to OGRE engine for this logic: Vector3 workVector = vector; workVector.Normalize(); Vector3 vUp = Vector3.Cross( vector, new Vector3( 0, 1, 0 ) ); vUp.Normalize(); float randAngle = ( float )Random.NextDouble() * MathHelper.TwoPi; Quaternion q = Quaternion.CreateFromAxisAngle( workVector, randAngle ); vUp = Vector3QuaternionMultiplication( vUp, q ); q = Quaternion.CreateFromAxisAngle( vUp, MathHelper.ToRadians( angle ) ); return Vector3QuaternionMultiplication( workVector, q ); } /// <summary> /// Multiplay a Vector3 by a quatenrion. /// </summary> /// <param name="v">The vector.</param> /// <param name="q">The quaternion.</param> /// <returns>The resulting vector.</returns> public static Vector3 Vector3QuaternionMultiplication( Vector3 v, Quaternion q ) { // nVidia SDK implementation Vector3 uv, uuv; Vector3 qvec = new Vector3( q.X, q.Y, q.Z ); uv = Vector3.Cross( qvec, v ); uuv = Vector3.Cross( qvec, uv ); uv *= ( 2.0f * q.W ); uuv *= 2.0f; return v + uv + uuv; }
3. Yea, you're right. The *this pointer won't work in C# land. I should have posted my ported code so far. It doesn't compile because of the Vector3 * Quaternion that I'm trying to do of course: /// <summary> /// Get a random variant vector from a particular vector given a /// specific variant limit angle. /// </summary> /// <param name="vector">The vector to get a variant from.</param> /// <param name="angle">The variant limit angle.</param> /// <returns></returns> public static Vector3 RandomVectorVariant( Vector3 vector, float angle ) { // Thanks to OGRE engine for this logic: Vector3 vUp = Vector3.Cross( vector, new Vector3( 0, 1, 0 ) ); vUp.Normalize(); float randAngle = ( float )Random.NextDouble() * MathHelper.TwoPi; Quaternion q = Quaternion.CreateFromAxisAngle( vector, randAngle ); vUp = vUp * q; q = Quaternion.CreateFromAxisAngle( vUp, MathHelper.ToRadians( angle ) ); return vector * q; } Maybe there is an easier way of doing what I'm trying to do. Instead of using Quaternions, maybe there is a way to get a random vector deviant using regular old linear algebra? Any ideas?
4. Hi! I'm trying to create a random variant vector from another vector given a variant limit angle. ie, I have a vector and want to create a random vector that is offset from the original vector by no more than a certain angle. Luckily, since I'm not very good with the math, I've found that the Orge engine does just that! They have a Vector3 function called "RandomDeviant" that looks like this: inline Vector3 randomDeviant( const Radian& angle, const Vector3& up = Vector3::ZERO ) const { Vector3 newUp; if (up == Vector3::ZERO) { // Generate an up vector newUp = this->perpendicular(); } else { newUp = up; } // Rotate up vector by random amount around this Quaternion q; q.FromAngleAxis( Radian(Math::UnitRandom() * Math::TWO_PI), *this ); newUp = q * newUp; // Finally rotate this by given angle around randomised up q.FromAngleAxis( angle, newUp ); return q * (*this); } So I figured I could use this as a base and implement the same functionality in C# / XNA land. However, I found that I'm unable to multiply Quaternions by Vector3 in C#. It gives me errors on the line: newUp = q * newUp; and return q * (*this );. I'm very unfamiliar with Quaternions, so I was hoping someone might be able to point me in the right direction as to how to port this to C#? Any help would be great! Thanks in advance! PS - I also have posted this in the official XNA forums, but no responses so far... so I'm trying GameDev :)
5. I got another one for you, Alvaro :) Would this same formula work for calculating the texture offset along the wall? Meaning, if P1 has a horizontal texture offset ( ie. the U component of the texture ) of 0.0 and P2 has a texture offset of 1.0, and I plug in these values for x1 and x2 and solve for x3, would that give me the perspective corrected texture offset at P3 ( the blue line )? Or would I need to change this formula in some way to work correctly for texture values? Thanks!
6. Doh! I should have seen that :p My bad. Works now! Thank you very much!
7. Anyone know what I'm doing wrong here with this equation?
8. Ok, the z3 formula is working great! Thank you very much! I now need something a little different. I have x1, z1, x2, z2 and z3 and would like to find x3. I tried to derive that using the original equation: x1*z1*z2 + x3*z3*z1 + x2*z2*z3 - x3*z3*z2 - x2*z2*z1 - z1*z1*z3 = 0 and came up with: x3 = ( -x1*z1*z2 -x2*z2*z3 +x2*z2*z1 +z1*z1*z3 ) / ( z3*z1 - z3*z2 ); by doing the following: x1*z1*z2 + x3*z3*z1 + x2*z2*z3 - x3*z3*z2 - x2*z2*z1 - z1*z1*z3 = 0 x3*z3*z1 - x3*z3*z2 = -x1*z1*z2 -x2*z2*z3 +x2*z2*z1 +z1*z1*z3 x3( z3*z1 - z3*z2 ) = -x1*z1*z2 -x2*z2*z3 +x2*z2*z1 +z1*z1*z3 x3 = ( -x1*z1*z2 -x2*z2*z3 +x2*z2*z1 +z1*z1*z3 ) / ( z3*z1 - z3*z2 ); However, that doesn't seem to be working? I even tried this to make sure: x1 = leftCol; z1 = p1Z; x2 = rightCol; z2 = p2Z; x3 = middleCol; z3 = ( x2 * z2 * z1 - x1 * z1 * z2) / ( ( x3 - x1 ) * z1 + ( x2 - x3 ) * z2 ); // At this point z3 is correctly calculated! Yay! x3 = ( -x1*z1*z2 -x2*z2*z3 +x2*z2*z1 +z1*z1*z3 ) / ( z3*z1 - z3*z2 ); // At this point, x3 doesn't match middleCol :( Why?? I'm assuming there must be something wrong with my equation?
9. Thanks, alvaro...makes more sense now. I'll try it out!
10. Quote:Original post by alvaro If you use coordinates in the XZ plane where the viewer is (0,0) and the center of the screen is (0,1), a point P1 with screen coordinate x1 and z coordinate z1 is represents the point (x1*z1,z1). Similarly P2 will be (x2*z2,z2). If you now have some x3 between x1 and x2 and want to know its z coordinate, you know that (x3*z3,z3) has to be aligned with the other two points. You can express that like this: |x1*z1 z1 1| |x2*z2 z2 1| = 0, where z3 is the only unknown. |x3*z3 z3 1| Expanding that determinant will give you a first-degree equation in z3, which is very easy to solve. The solution is something like this (I might have made mistakes): z3 = (x2*z2*z1 - x1*z1*z2) / ( (x3-x1)*z1 + (x2-x3)*z2 ) Yes! You explained it much better than I did :) Excuse my math incompetence, but how did you arrive at the z3 equation again? Can you explain the jump from: |x1*z1 z1 1| |x2*z2 z2 1| = 0, where z3 is the only unknown. |x3*z3 z3 1| to: z3 = (x2*z2*z1 - x1*z1*z2) / ( (x3-x1)*z1 + (x2-x3)*z2 ) ?? Thanks!
11. Hi! I'm trying to calculate the z-value of a point on a polygon on screen. My world is a very simple Wolfenstein style FPS ( ie. the map is a bunch of 2D line segments and they're just rendered to look 3D ). Like this: What I'm trying to do is take a given screen column and figure out the z-value of the wall at that point. So, here's what I know: 1. The z-value of the wall at P1 ( ie. the left screen column of that wall ). 2. The z-value of the wall at P2 ( ie. the right screen column of that wall ). 3. The screen column at the blue line. So, I'd like to use these givens and figure out the z-value for the wall at the screen column denoted by the blue line. Is that possible? I'm assuming I need some formula that adjusts for perspective since I can't simply do a linear interpolation between the two z-values. I've been reading up on the perspective correction formula for textures ( something to do with u/z, v/z and 1/z )....but I'm not quite sure I understand it or know how to apply it to what I'm trying to do here. Can someone help me figure out what the formula would be for this? Or maybe point me to a good reference for better understanding how perspective correction works so I can apply it here? Thanks!
12. Quote:Original post by AndreTheGiant Why not implement it this way: When the mouse is in the dead center of the Flash window, The player is still. If the mouse is moved slightly to the left, the player slowly turns left. If the mouse is moved even further to the left, the player turns to the left faster. The further the mouse goes to the left, the faster the player turns. To the point where, just before the mouse leaves the left side of the Flash area, the player is spinning to the left at some high speed, say 5 spins per second. If the cursor actually leaves the Flash area, then pause the game. Do the same for Right, Top and Bottom. This way, the player will quickly learn to control the mouse cursor, and not move it too far from the center in any direction. Think about how they implement 3D shooters on the WII. You cant move the pointer off your TV, yet you can still look in all directions by using a method similar to what I described. Great idea! I'll definitely research some Wii shooters. I had thought of that originally ( haven't tried it yet ), but thought that it would feel strange. If the Wii can do it and it feels good, that's great news. Thanks!
13. Fair enough. I've never written a browser plugin before. Anyone know of a good beginners tutorial on the subject ( I don't know where to begin with all the results that came up in Google ). Also, will I need to write a separate plugin for each browser ( IE, Firefox, Safari, etc. )? Or will one plugin work for all? Would setting the mouse position be easy to do in a plugin? Would my Flash app be able to turn this functionality on / off ( ie. be able to talk to the plugin )?
14. Right, I totally agree that it would be bad if all the ads on the web could control your mouse. But it's definitely possible ( not in Flash ) to control the mouse ( see the FPS link in my original post ). I'm looking to do something like that ( even if it requires a seperate plugin or something ). I just can't see controlling an FPS with nothing but the keyboard. Too old-school and people are just too used to using the mouse to look around in an FPS. So the idea would be to maybe have a 1x1 Java app somewhere on the page that does nothing but reposition the mouse each frame in the center of the Flash app. And of course Flash would need to be able to talk to said app in order to turn this functionality off ( for menus and what not ). Is something like this possible?