
Advertisement
HypnotiC
Member
Content Count
18 
Joined

Last visited
Community Reputation
162 NeutralAbout HypnotiC

Rank
Member
Personal Information

Interests
Programming

Predicting Collision time of CircleLine segment
HypnotiC replied to Blackperl's topic in Math and Physics
Add some details to cadjunkie's answer: Assume the path of center is C(t) = (x(t), y(t)), line equation is L: ax+by=0, and the current time is t0. "Translate" the line to find the intersection at t0, say it's P1(x1,y1). Then at any time t, position of P1 would be P1(t) = C(t) + (x1x(t0), y1y(t0)) = (x1(t), y1(t)) Now solve the equation for t1: a * x1(t1) + b * y1(t1) = 0 And t1  t0 is the answer Note we need special handling if line equation is y=0 
How would I read/write bit by bit from/to a file?
HypnotiC replied to Komal Shashank's topic in General and Gameplay Programming
Do you really have a need to work on the generated "binary" file at all, e.g. somehow modify or inspect the file through your Hex editor? If no then why not just store the binaries as std::uint8_t and later read them back as std::uint8_t and convert to 0s and 1s as needed? 
how to get unit vector perpendicular to normal surface
HypnotiC replied to anders211's topic in Math and Physics
slope being close to 90 degree means almost all gravity is applied to y direction, in which case you should directly use Fz = (0,1,0) 
How do you differentiate spaces from coordinate systems? I feel they are not 2 distinct entities but rather one is based on the other. When I see people talking about spaces, I always think of those spaces being backed by some coordinate systems and this is essentially how we construct the matrices to transform something from one space to another.

Collision: rotating line & moving point
HypnotiC replied to eascrDVFUgklH's topic in Math and Physics
First I think you need to handle the case where there is not collision between the point and the rotating line... Back to your question. Here is one naïve way (some what similar to what you are doing though):  Since the line is rotating around a fixed point, you should be able to precompute the closed area by this rotation (maybe approximated by a circle).  If the point is not in this area then no need to test collision. Once the point is in the area, compute the time when it enters the area and when it leaves the area. Call them T0 and T1.  We know equation of the rotating line and the trajectory of the point (also a line).  Divide interval [T0, T1] into N sub intervals that are small enough according to your desired precision. Call Ti = T0 + i*N;  For each Ti, compute the point position, if it's "on" equation of the rotating line at Ti then done. 
Should I use the gradient to get the Normal of a Sin wave?
HypnotiC replied to jakovo's topic in Graphics and GPU Programming
Should you also change "y^2" in your partial direvative to "z^2"? 
I think the vector r in your gradient equation needs to be normalized

Shouldn't either U or V be sampled from y component of height? You are sampling both of them from x component: float hL = height.Sample(pointSampler, texCoord  float2(recTexDimensions.x, 0.0f)).x; float hR = height.Sample(pointSampler, texCoord).x; float hB = height.Sample(pointSampler, texCoord  float2(0.0f, recTexDimensions.y)).x; // change to .y? float hT = height.Sample(pointSampler, texCoord).x; // change to .y?

[Solved] Transform 3D Cross Vec to 2D Cross Vec
HypnotiC replied to Finalspace's topic in Math and Physics
I don't know what vorticity is so I can not really understand your equation (e.g. in what space is your problem defined? what does pi mean? Does wi stand for weight?...). I am wondering does it ever make sense to translate this into 2D?  Does Vorticity make sense in 2D?  In 3D, a cross product produces another vector while in 2D a cross product produces a scaler. However, if wi means some kind of weight in a direction, then in 2D you should be able to do something similar with tangent. 
Collision Detection Problem with Scale,Rotate,Fast Object
HypnotiC replied to Stephen Ho's topic in Math and Physics
I think I should take my previous answer back... That check is indeed quick but doesn't cover all possible collision cases, e.g. your triangle and rectangle can still collide when none of the triangle vertices are inside the rectangle. Maybe it's only useful as a fast firstround check and if the test fails you then want to fallback to the normal lineline intersection test. 
Collision Detection Problem with Scale,Rotate,Fast Object
HypnotiC replied to Stephen Ho's topic in Math and Physics
For rectangle and triangle collision detection, I think you don't really need to calculate the edges. You can simply check whether or not any of the 3 vertices of the triangle is in the rectangle. If yes, then it's a collision. This method is simpler and faster, which may also solve your problem no.3 maybe? 
Converting my program to smart pointer and a bit confused
HypnotiC replied to brulogaz's topic in General and Gameplay Programming
I think smart pointers are meant to help manage (longlive) heap objects. If the variables are on stack why bother with smart pointer? Would reference be a better choice? In your case, maybe you can reference to the vector that contains the scenes. 
Boost c++ How to Deserialize Element of Container
HypnotiC replied to Kjansen92's topic in General and Gameplay Programming
I have not used Boost serialization library yet. But I know you can specify the input/output file to store your archive. Can you group your objects or containers before you serialize them? Then when you desterilize you can simply choose the archive you need instead of loading everything from a giant archive. 
Codebase with multiple backends
HypnotiC replied to Laval B's topic in General and Gameplay Programming
I think a simple but somehow less manageable approach is just to use template and typedef: template<class GraphicBackEnd, class VideoBackEnd> class MyGameEngine { public: MyGameEngine() : graphic(new GraphicBackEnd), video(new VideoBackEnd) {} private: GraphicBackEnd* graphic; VideoBackEnd* video; }; And somewhere you do a typedef: #ifdef _MSC_VER typedef DXGraphicBackEnd MyGraphicBackEnd; typedef WindowVideoBackEnd MyVideoBackEnd; #elseif __GNUG__ typedef GNUGraphicBackEnd MyGraphicBackEnd; typedef GNUVideoBackEnd MyVideoBackEnd; # else typedef OSXGraphicBackEnd MyGraphicBackEnd; typedef OSXVideoBackEnd MyVideoBackEnd; #endif Finally in you game.cpp: int main() { MyGameEngine<MyGraphicBackEnd, MyVideoBackEnd> gameEngine; ... } 
Basic Jumping and Gravity Implementation
HypnotiC replied to Endemoniada's topic in Math and Physics
I don't quite understand why you were bothered... 1) when user hit jump button, you can simply give velocity a positive y value, and everything else remains the same. 2) I think you don't need to clamp velocity.y, but need to check for position.y so if you hit ground then velocity.y should be set to zero. Do I understand your question correctly or completely wrong?

Advertisement