• What Do You Need Help With? V6
    7,544 replies, posted
If I have a rectangle shaped as this (except it's actually a perfect rectangle): [img]http://puu.sh/4eBkb.png[/img] How can I calculate wether or not a certain Point is inside of it? Say the width is 100px, the height of the object itself is 10px, and the difference in height is 20px, and the top left point is (0, 0), how can I know that a certain point is within the rectangle? This is in C# by the way, and I'm completely stumped. I looked at [URL="http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test"]a polygon hit test on stackoverflow[/URL] but I feel that it's way too complex for what I need.
That's not a rectangle, just a parallelogram. Transform the point with y -= x * (20px / 100px) to get a check against an axis-aligned rectangle with it's upper-left point on the origin, then check 0px < x < 100px && 0px < y < 10px to get whether a collision occurred.
[QUOTE=Shotgunz;42014520]what is the incentive to use DirectX over OpenGL?[/QUOTE] Depends if you care about cross-platform capability. I'm sure you already know that OpenGL is far better for doing cross-platform work than DirectX is. On the other hand, the APIs are very different, so if you're just picking one to use for a personal project then it's possible you could prefer the DirectX way of doing things over the OpenGL way. The actual processes are the same, but the way you set up and use things is quite different.
Alright so I fixed my issue. Since I am new to 3d physics and physics libraries in general, I didn't have the idea to check the samples. Once there, I looked into how they did jumping for the characters. They had a can jump method. What did it do? It the state of the controller, and from there it got the collision flags. You can check if the state that the controller is in is colliding up, down, and on the sides. What a simple solution: [cpp]if(state.collisionFlags & PxControllerFlag::eCOLLISION_DOWN)[/cpp]
I'm trying to import a source engine model into Unity 3D, I've decompiled it, and imported it into Blender using the SMD importer tools, but when I get it into unity, there doesn't seem to be any animations. And since I'm a total noob at Blender, I haven't a clue what to do. Anyone got any ideas or tutorials to check if the problem is Blenders importer end, or Unitys end?
Assembler / Pe-Format related question: In a function we have push offset 0x1234 It's a offset into .rdata Now I did not relocate or map or "load"(execute) the file in any way. I just loaded the file into a bytearray using the raw bytes. Ok, so in order to actually use the offset I should first subtract the suggested image base (as usual my binary suggests 0x400000). Next I want to convert the offset from a virtual offset to a file offset. So what I've done now is to find the section header of .rdata. I calculate my new offset like this: (rdata virtual address) - (rdata raw file offset) + (myOffset) Where "myOffset" is the value from above with the image base already subtracted as I said. After those steps I nearly got the right result. My address is still 0xf0 bytes from the correct offset. Can anyone explain why? And whats the correct way to find out the fileoffset from an virtual offset? [editline]30th August 2013[/editline] Clarification: I don't want to load / map the binary myself to solve this problem. I only want to parse some data. I know it could be easier to just call load library and work from there but I don't want that.
How is Haskell performance for games? And are there any good physics libraries for it? I can't get the bullet port to work.
Hi, I have a problem where I have a int that contains a number let's say 16382. I need to divide that number over atleast 2 octets of a possible 3. This depends on the subnet mask. That last octet needs to count up to a maximum of 255. When the last octet fills to 255 the third becomes a 1 and the fourth starts over towards 255 again and over and over. It also needs to take in to account the subnet ID and broadcast addresses of each subnet. In this case is 1024 maximum subnets.. 16382 is the number of hosts per subnet. The first subnet is 10.0.0.1 - 10.0.63.254 accordingly to [url]http://www.subnet-calculator.com/subnet.php?net_class=A[/url] This is what I have done so far. Thanks. [CODE]int IP::HostLoop(int HostPerSub, int AmountSub){ int FixMask[5] = {10, 0, 0, 0}; int ArrayCount = 0; float a = 0; for(int i=0;HostPerSub < i;i++){ FixMask[4] += 1; if (FixMask[4] == 255) FixMask[4] = 0; if (a != 0){ if(i < a) { a += 255; ArrayCount++; } if (a == 0) a = 127.5 * 2; if(i == a){ FixMask[3] += ArrayCount; if ( FixMask[3] == 255) FixMask[3] = 0; } } } cout << FixMask[2] << endl << FixMask[3] << endl << FixMask[4]; return 0; }[/CODE]
[QUOTE=eternalflamez;42018655]If I have a rectangle shaped as this (except it's actually a perfect rectangle): [img]http://puu.sh/4eBkb.png[/img] How can I calculate wether or not a certain Point is inside of it? Say the width is 100px, the height of the object itself is 10px, and the difference in height is 20px, and the top left point is (0, 0), how can I know that a certain point is within the rectangle? This is in C# by the way, and I'm completely stumped. I looked at [URL="http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test"]a polygon hit test on stackoverflow[/URL] but I feel that it's way too complex for what I need.[/QUOTE] Hey, as you probably know, any convex polygon can be defined by a system of inequalities your example shown here; [img]https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash4/1003233_669420423077473_1659230621_n.jpg[/img] these equalities lend themselves nicely to some if statements! NB; if a point satisfies all 4 inequalities, then it is within or on the bounds of the polygon.
[QUOTE=ZeekyHBomb;42018535]You're checking a 12-digit isbn, while you probably want a 13-digit one.[/QUOTE] 0-12 should be 13 items though right? And I'm adding 12 digits because the last digit isn't added. Unless I'm looking at this wrong somehow
I'm trying to create a 3d RTS game that uses multiple levels and tiles, does anyone know a good way on creating a mesh that doesn't use a trillion tiny quads? I'm trying to achieve a look like warcraft 3 and starcraft 2. I'm currently using a quadtree and it's great for 1 level, other than that continuing to use it is a pain, does anyone have any suggestions on any algorithms to try.
I feel like I should know this. Here are two sprites at 100% scaling. [t]http://puu.sh/4fmA1.png[/t] Here are the same sprites at 200% scaling. [t]http://puu.sh/4fmyX.png[/t] How do I scale all of the sprites whilst keeping the distances between them relative to the scale?
[QUOTE=177cheese;42025859]0-12 should be 13 items though right? And I'm adding 12 digits because the last digit isn't added. Unless I'm looking at this wrong somehow[/QUOTE] The upper bound in range(...) is exclusive, you're only casting twelve elements. I'd replace the constants with a loop depending on the length though, as the specification doesn't seem to explicitly mention a 13 digit ISBN. The lower bound of 0 is implicit in range(upper_bound). [editline]31st August 2013[/editline] [QUOTE=reevezy67;42028895] How do I scale all of the sprites whilst keeping the distances between them relative to the scale?[/QUOTE] Scale their positions and the camera position by the same factor.
[QUOTE=ECrownofFire;42015052]I hear it's faster on a few GPUs.[/QUOTE] Maybe, but that is really subjective. That depends on the driver being used and also how the graphics engine is coded. Personally I can't think of any objective way to compare the speed of OpenGL and DirectX since it depends so much on implementation.
I want to add some networking to my game/engine does anyone have any articles/whatever they would recommend? I know how to do networking outside of games, so one that just explains networking in games would be nice. [editline]1st September 2013[/editline] A book even.
I'm trying to learn Haskell. Can someone tell me why my Union function isn't working?? [CODE]union :: Eq a => [a] -> [a] -> [a] union [] [] = [] union [] ys = ys union (x:xs) (ys) | x `elem` ys = union (xs) (ys) | otherwise = x : (union (xs) (ys))[/CODE]
[QUOTE=sarge997;42022144]I'm trying to import a source engine model into Unity 3D, I've decompiled it, and imported it into Blender using the SMD importer tools, but when I get it into unity, there doesn't seem to be any animations. And since I'm a total noob at Blender, I haven't a clue what to do. Anyone got any ideas or tutorials to check if the problem is Blenders importer end, or Unitys end?[/QUOTE] Load the models first (e.g. sven_model.dmx.smd, sven_belt_model.dmx.smd and so on). After you've finished importing the models, proceed to import animation files (e.g. attack01.smd). Export them as FBX (remember to correct the Up axis, Blender uses Z as up while Unity uses Y). Also: Importing a new animation (e.g. attack02.smd) after you've imported one (e.g. attack01.smd) [b]does not overwrite[/b] the old one. It'll still be there when you export them as fbx, you can access them via Source Take in Unity's model inspector: [img]https://dl.dropboxusercontent.com/u/7422512/Unity3D/sourcetakes.png[/img] It works fine as you can see here: [t]https://dl.dropboxusercontent.com/u/7422512/Unity3D/image.png[/t]
[QUOTE=Mr_Razzums;42038374]I'm trying to learn Haskell. Can someone tell me why my Union function isn't working?? [CODE]union :: Eq a => [a] -> [a] -> [a] union [] [] = [] union [] ys = ys union (x:xs) (ys) | x `elem` ys = union (xs) (ys) | otherwise = x : (union (xs) (ys))[/CODE][/QUOTE] Not working how? Looks fine to me.
[QUOTE=reevezy67;42037916]I want to add some networking to my game/engine does anyone have any articles/whatever they would recommend? I know how to do networking outside of games, so one that just explains networking in games would be nice. [editline]1st September 2013[/editline] A book even.[/QUOTE] [url]https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking[/url]
[QUOTE=ZeekyHBomb;42040796]Not working how? Looks fine to me.[/QUOTE] I guess I forgot to reload or something, works now. Embarrassing.
Doing this feels dirty, is there any other way to clean it up? Pref using the most complicated way possible. [IMG]http://puu.sh/4gwGb.png[/IMG]
[QUOTE=Dorkslayz;42043832]Doing this feels dirty, is there any other way to clean it up? Pref using the most complicated way possible. [IMG]http://puu.sh/4gwGb.png[/IMG][/QUOTE] Does PHP have closures? You could put a number of them catching the variables into a dictionary together with the strings and iterate that, but it would be hardly efficient. [editline]1st September 2013[/editline] You [i]could[/i] do this with strings and eval, but the question is whether you'd want that. [editline]1st September 2013[/editline] With PHPs "variable types" you could also dump the variable values and error messages into a dictionary and then iterate it, but again that would be quite a bit less efficient than the ifs. Probably actually less to write though, unlike the closures which are mostly implicit in C#.
[QUOTE=Tamschi;42044154]Does PHP have closures? You could put a number of them catching the variables into a dictionary together with the strings and iterate that, but it would be hardly efficient. [editline]1st September 2013[/editline] You [i]could[/i] do this with strings and eval, but the question is whether you'd want that. [editline]1st September 2013[/editline] With PHPs "variable types" you could also dump the variable values and error messages into a dictionary and then iterate it, but again that would be quite a bit less efficient than the ifs. Probably actually less to write though.[/QUOTE] Thanks for the input, but I'm looking for more of an efficient solution rather than less code.
Alright. After many extensive google-search filled hours I give in. I have an interface as such; [code] public interface IObjectVisible { String Image { get; set; } int Depth { get; set; } } [/code] and a few classes that implement it, and ISerializable [code] [Serializable] public class OBJVisible_1 : OBJVisible { public OBJVisible_1(String image, int depth, String field_1) : base(image, depth) { Field_1 = field_1; } protected OBJVisible_1(SerializationInfo info, StreamingContext context) : base(info, context) { Field_1 = (String)info.GetValue("Field_1", Type.GetType("System.String")); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("Field_1", Field_1); } public String Field_1; } [Serializable] public class OBJVisible : IObjectVisible, ISerializable { public OBJVisible(String image, int depth) { Image = image; Depth = depth; } protected OBJVisible(SerializationInfo info, StreamingContext context) { Image = (String)info.GetValue("Image", Type.GetType("System.String")); Depth = (int)info.GetValue("Depth", Type.GetType("System.Int32")); } public String Image { get; set; } public int Depth { get; set; } public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("Image", Image); info.AddValue("Depth", Depth); } } [/code] I have a List<IObjectVisible> and I want to binary-serialize it, to 'save' the map. My idea was, iterate over the list and get the type of each object. Then serialize that type, and serialize the object and output them both to file. Then when reading in, de-serialize the type, and use it to dynamically create the object. Only problem is, I get the type back out, but can't find anywhere how to create the object dynamically (And no, straight up Activator.CreateInstance() doesn't work) this is the manager class; [code] public sealed class MapDaemon { public static void Save(List<IObjectVisible> objectsToSave, String path) { BinaryFormatter f = new BinaryFormatter(); using (Stream stream = new FileStream(path, FileMode.Create)) { foreach (IObjectVisible obj in objectsToSave) { Type objType = obj.GetType(); f.Serialize(stream, objType); } } } public static void Load(String path) { BinaryFormatter f = new BinaryFormatter(); using (Stream stream = new FileStream(path, FileMode.Open)) { while (stream.Position != stream.Length) { Type T = (Type)f.Deserialize(stream); // Something like: IObjectVisible x = (T)f.Deserialize(stream); } } } } [/code] Is this possible? if not...how do you store a list of interface, thanks!
[QUOTE=Dorkslayz;42044233]Thanks for the input, but I'm looking for more of an efficient solution rather than less code.[/QUOTE] You already found the fastest, unless PHP has a StringBuilder equivalent.
Plus how often do web-apps have performance issues in this realm? In PHP you can probably get away with some pretty gross inefficiencies because the network is almost always the bottleneck anyway.
[QUOTE=Lemmingz95;42045788]Only problem is, I get the type back out, but can't find anywhere how to create the object dynamically (And no, straight up Activator.CreateInstance() doesn't work)[/QUOTE] It's possible you need a parameterless constructor to create it like that without parameters, maybe it's needed for the built-in serialization too. A much easier solution would be to use protobuf-net (v2) though (available via NuGet). I don't know if it works as root element, but if your serialized object has a list of the interface type as member it should automatically serialize and restore your whole list with a few lines of code. It only needs a (possibly private) parameterless constructor, no interfaces. You can also mark the properties and fields with attributes instead of serialization methods for more efficient storage and better forwards compatibility. If there's a reference loop somewhere you have to change the format to use references, but that's just a single parameter iirc. [editline]1st September 2013[/editline] [QUOTE=Rayjingstorm;42045894]Plus how often do web-apps have performance issues in this realm? In PHP you can probably get away with some pretty gross inefficiencies because the network is almost always the bottleneck anyway.[/QUOTE] Only if the page is really large or the connection really slow, otherwise the delay just adds up because it can't send before it's constructed.
I was trying to avoid many dependencies, But there's no point re-inventing the wheel I guess. Thanks for the recommendation! [editline]1st September 2013[/editline] Found a temporary fix, oh dear :s [code] if (t is IObjectVisible) { IObjectVisible q = t as IObjectVisible; Console.WriteLine(q.Image); } [/code] produces the correct result. however nasty :P
[QUOTE=Lemmingz95;42046104]I was trying to avoid many dependencies, But there's no point re-inventing the wheel I guess. Thanks for the recommendation! [editline]1st September 2013[/editline] Found a temporary fix, oh dear :s [code] if (t is IObjectVisible) { IObjectVisible q = t as IObjectVisible; Console.WriteLine(q.Image); } [/code] produces the correct result. however nasty :P[/QUOTE] [code] var q = t as IObjectVisible; if (q != null) { Console.WriteLine(q.Image); } [/code] would be slightly better, or just a direct cast if you're sure about the type. [editline]edit[/editline] Also, it seems you're currently using the built-in serialization. Never use that for persistent storage, it doesn't have a specification and is backwards incompatible to the point where very small changes can make your data unreadable. With protobuf-net you can theoretically serialize an object and deserialize it as a different type with matching fields, it's much more tolerant against minor changes (especially with the attributes) and in some cases even forward compatible.
I know this has come up in the past, but can someone help me understand Bezier curves? Every document I find about them confuses me. I just need to know how to implement them.
Sorry, you need to Log In to post a reply to this thread.