Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

354 Neutral

About CelticSir

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

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

  1. CelticSir

    Quadratic bezier curve how to find bounding box?

    Well i am unsure which one is the anchor point in the stack overflow answer which was the main confusing. I assumed p1 was the anchor/handle point.
  2. CelticSir

    Quadratic bezier curve how to find bounding box?

    Yeah the red and green points represent the bounds. I did add the range check but it made no difference: var extrema = Vector3.zero; var tx = (p0.x - p1.x) / (p0.x - 2 * p1.x + p2.x); if (tx >= 0 && tx <= 1) { extrema.x = QuadraticBezier.Position(tx, waypointA.Position, waypointB.Position, anchorPoint).x; min.x = Mathf.Min(min.x, extrema.x); max.x = Mathf.Max(max.x, extrema.x); } var tz = (p0.z - p1.z) / (p0.z - 2 * p1.z + p2.z); if (tz >= 0 && tz <= 1) { extrema.z = QuadraticBezier.Position(tz, waypointA.Position, waypointB.Position, anchorPoint).z; min.z = Mathf.Min(min.z, extrema.z); max.z = Mathf.Max(max.z, extrema.z); } I am a little bit out of my depth as i am not good with maths. From what i can gather by the step by step info in my first post, i would need to find the equation of my bezier curve, not sure how i work that out, then find the derivative (theres only one derivative for a quadratic) then find the roots which will give me the stationary point on the curve. But my maths knowledge does not come close to even figuring out how to do that sadly.
  3. CelticSir

    Quadratic bezier curve how to find bounding box?

    I don't think the extrema is correct because if you draw a dashed line from the visual extrema, it doesn't seem to be in the correct place even if it wasn't reflected: And you're right it is mirror'd but i don't know why - i can't see my mistake.
  4. Hi I have this function which draws a quadratic bezier curve: public static Vector3 Position(float t, Vector3 a, Vector3 b, Vector3 anchor) { var oneMinusT = 1 - t; var sumA = oneMinusT * oneMinusT * a; var sumB = 2 * oneMinusT * t * anchor; var sumC = t * t * b; return sumA + sumB + sumC; } And i want to now find the bounding box for it. But i can't seem to get it to work. I used this equation: https://stackoverflow.com/a/1099291/5736835 But i don't get the correct result. This is my code for it: var p0 = waypointA.Position; var p1 = waypointB.Position; var p2 = anchorPoint; var extrema = Vector3.zero; var tx = (p0.x - p1.x) / (p0.x - 2 * p1.x + p2.x); extrema.x = QuadraticBezier.Position(tx, waypointA.Position, waypointB.Position, anchorPoint).x; var tz = (p0.z - p1.z) / (p0.z - 2 * p1.z + p2.z); extrema.z = QuadraticBezier.Position(tz, waypointA.Position, waypointB.Position, anchorPoint).z; Extrema = extrema; min = Vector3.Min(waypointA.Position, waypointB.Position); max = Vector3.Max(waypointA.Position, waypointB.Position); min = Vector3.Min(min, Extrema); max = Vector3.Max(max, Extrema); var center = (min + max) / 2f; var size = max - min; Bounds = new Bounds(center,size); This was the visual end result of it: Definitely not correct. The extrema point is the yellow sphere at the bottom. which is clearly not in the correct place, since its not even on the curve let alone the furthest point. Am hoping some one knows how to solve this - i am not the best at maths so am trying to figure this out but its quite a challenge. I also found this as a guide on how to calculate it but i don't know how i would do that mathematically: If any one is able to help with this i would be very grateful, have been stuck on this for some time now. Edit: Just to note i use the X:Z plane so my Vector3's all have Y position equal to zero.
  5. thank you, quad tree seems like the ideal solution
  6. Hi Say i have like 5000 quads all over the game map. And i want to place another one and check to see if it overlaps another quad. The quad can be any orientation, i was wondering what is fast way to find any quads that it might overlap. I can do a quad overlap check easily, but finding which ones to test against how ever is not so easy. And i am looking for a really performant way to do it. Any suggestions on the most efficient way to do it ?
  7. Hi I have a basic shader that has an applied texture, and a normal map. Now i want to make it "glisten" with like sparkling dots of light, based on the changes between camera and the ground. I am wondering what would the general logical approach be to do this ? I am still learning shaders and am trying to do this to learn more with them. But i've not mastered the way to think in terms of shaders yet so i am struggling to think of the logical approach to make the effect. Any suggestions ?
  8. Thanks for the links everyone. Very helpful
  9. Hi I've been wanting to learn shaders for a while. I use Unity3D and have always wanted to write my own shaders like water or my own PBR shader for example. But information on these topics seem quite sparse. I am not sure where to look to learn to program these things. The syntax is different to C# aswell (obviously). I really want to become an advanced shader programmer and make cool things. I'm pretty good at maths in general (first year in physics degree), but translating them into shaders and having understanding of them sufficiently is lacking. Google isn't really finding me much on it at all. What advice would you recommend ? Any books i should consider? Hope you can help
  10. Hi Sorry about the vagueness with units. Unity3D refers to everything by a unit which is equal to 1m. Just a habit i have picked up. I do have path finding, i use a navmesh, it has found the path. But i don't want it to follow the sequence of nodes so rigidly as it looks a bit unnatural. So i wanted it to accelerate up and down as well as take smooth curving paths. The units i use are: acceleration : 3 m/s^2 (this is also for slowing down) max speed : 15 m/s turn speed : 45 degrees/s The current issue is, if the turn is quite sharp and the object is going near its max speed. Then it will over steer the corner since its turn speed is too low for it. So i need to calculate what speed he needs to be going in order to take the corner giving his limited turn speed. If he has to stop completely to turn for very sharp corners (like a tank) thats fine.
  11. Hello I am a bit noobish with this but am trying to work out how to calculate the correct velocity of an object to have for an approaching corner. So the object has the following stats: acceleration : 3 units/s (this is also for slowing down) max speed : 15 turn speed : 45 degs/s I want to find the correct velocity to approach a corner so that, it will take the corner without over steering. If the object literally has to stop entirely and rotate thats also fine (kind've like a tank). I don't know the right formula to do this. Most google results include complicated aspects like drag and friction, mass etc and stuff that is too complex for my needs and then i don't know how to simplify it for my own needs. If it helps, i calculate the angle in degrees not radians (since i use Unity's Vector3.Angle). Hope some one can help, don't need code, just the math logic for it i can translate to code from that.
  12. Hi I have a basic setup currently where i create a quadratic bezier curve, and then i do 100 steps across the curve to calculate its distance. And from that i do distance / 3 to give me the total number of segments. Its pretty quick but its not a good solution for very large distances (too many segments) and then for very small distances (too few segments). Here is a visual issue of the problem: 7 looks reasonable (though i actually think it computed 6 my mistake), but for something much shorter 2 simply doesn't cut it neither would 3 or 4 to be honest. So i am wondering what is a common way to balance this so they are smooth regardless of length and sharpness of the angle ? I use C# but I'm just looking for a logical approach here not how to implement it in code since i'm sure i can handle that myself Thanks in advance.
  13. Hi I have set up my TcpClient to connect to my server and that works fine. But i am a bit confused how i read messages from the network stream with it continuously running via async, without ever closing the connection ? My TcpClient Manager class has: public async Task<bool> Connect(string address, int port) { try { await _tcpClient.ConnectAsync(address, port); IsConnected = true; return true; } catch(Exception e) { Debug.Log(e); return false; } } public async Task<int> Read(byte[] readBuffer) { if (!IsConnected) return -1; using (var networkStream = _tcpClient.GetStream()) { try { var bytesRead = await networkStream.ReadAsync(readBuffer, 0, readBuffer.Length); return bytesRead; } catch (Exception e) { Debug.Log(e); IsConnected = false; return -1; } } } So i thought to just run a co-routine and call Read constantly to get the most recent message, but that doesn't make much sense to me since a co-routine would be blocked with the await. How is this actually done? The MS Docs don't have very good Async examples with the TcpClient class so i don't know fully get how to keep calling Read correctly.
  14. Hi I have a very basic prototype in unity of a game where by I fire a projectile with a obstacle in the environment that moves blocking its trajectory. Due to the fact that time between events is obviously not instant between clients i have a slight issue where one user shoots the projectile and hits the target, but the other player sees it miss the target entirely. Picture to explain better: The main problem is that the position of the moving obstacle is not in the same position "now" upon the firing event received for client B as it was for client A.This is not an FPS or something like that, the moving obstacle is part of the environment rather than another player. So i am thinking i should be able to get this moving obstacle sync'd far better than i could with player positions. Now i know this is not 100% solvable due to the nature of networks but am wondering what solutions i can implement to reduce the amount of error for this.
  15. Hello I am learning networking at the moment and just in the middle of sending client positions to the server every x amount of milliseconds. But this is a fair bit of bytes to send quite a lot. So i wondered about sending just keyboard and mouse inputs to the server instead of the position updates, since this would be a lot less bytes. Yet it seems most games don't use this method, they tend to send position updates instead. I am curious what pros and cons there are between these 2 options? I feel like i might be over looking something here because sending the keyboard and mouse inputs seem to be at first glance a simpler approach and less bandwidth too. The game is an FPS so it needs to be real time aswell. So is there some issue with just sending keyboard/mouse inputs rather than positions that i am not fully grasping due to lack of experience with this?
  • 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!