Posts
 
Reputation
Joined
Last Seen
Ranked #4K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
8
Posts with Upvotes
7
Upvoting Members
5
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
~23.2K People Reached
Favorite Tags
xml x 5
c++ x 3

55 Posted Topics

Member Avatar for DaveTran

I am moving an object around from one node to another. I need to tell the object to stop moving when it has reached its destination node. I am currently using this algorithm for movement and node checking [CODE] if (!isFinished) { // If the level has arrived at the …

Member Avatar for Chris_33
1
2K
Member Avatar for DaveTran

I have two settings classes one abstract base class from which the second settings class derives public abstract class BaseFooSettings { public int a; public int b; public float c; } public class DerivedBarSettings : BaseFooSettings { public float d; } I then have two classes one base class and …

0
75
Member Avatar for DaveTran

I have two classes. One main Game class and an Entity class that needs to point to the Game class so it can call its various functions # Entity.h # class Game; class Entity { public: Entity(Game *game); ~Entity(void); void Draw(float dt); void Update(float dt); protected: Game *m_game; // Missing …

Member Avatar for JasonHippy
0
409
Member Avatar for DaveTran

Is it better to use structs over classes for serializing class settings? Class settings can have initial default values. [code] [Serializable] public class LevelSettings { // Default level values public int Depth = 3; public int Height = 3; public TileSettings[] TileSettings = new TileSettings[27]; public int[] TriangleIndices = new …

Member Avatar for nick.crane
0
899
Member Avatar for DaveTran

Hi folks, I was wondering how I can differentiate between file types when using OpenFileDialog. I would like to be able to have the option to load different file types (as denoted by the Filter property) and handle each type in a different way. For example [CODE] Stream stream; OpenFileDialog …

Member Avatar for DaveTran
0
229
Member Avatar for DaveTran

I've got a font as a sprite sheet with individual characters arranged in the exactly same way as a .ttf file. How can I get the index of the characters from a string so that I can know the index of the source rectangle to use to grab the correct …

0
68
Member Avatar for DaveTran

If I have a class which has a property that I wish to be serializable [CODE] public string Name { get { return name; } set { name = value; } // How can this be private and be used for XML serialization? } [/CODE] How can I prevent other …

Member Avatar for Momerath
0
109
Member Avatar for DaveTran

I have a Ref class [code] public class Ref<T> { private Func<T> getter; private Action<T> setter; /// <summary> /// For XML Serialization /// </summary> private Ref() { } public Ref(Func<T> getter, Action<T> setter) { this.getter = getter; this.setter = setter; } public Func<T> Getter { get { return getter; } …

Member Avatar for DaveTran
0
163
Member Avatar for DaveTran

I've created a ray distribution method that generates rays over a fixed angle with an even distribution along the xz plane. [CODE] /// <summary> /// Generates rays that are evenly distrbuted in a circular formation around a point but are restricted to an angle /// </summary> /// <param name="point">The point …

Member Avatar for ddanbe
0
137
Member Avatar for DaveTran

I would like to allow only certain keys to be valid for my TextBox control. I have set it up as follows and it works fine. [CODE] private void TextBox_MapInputMin_KeyDown(object sender, KeyEventArgs e) { if (!IsFloatingPointTextBoxValid(e, textBox_MapInputMin)) { // 'Handled' property stops key from being entered into the control e.Handled …

Member Avatar for abelLazm
0
157
Member Avatar for DaveTran

If anyone has used Unity 3D ([URL="http://unity3d.com/"]http://unity3d.com/[/URL]) then they will know that on the right hand side there is a tree view control that allows the user to click on a node and drag it into the environment to create an object. Is there a control in Winforms that allows …

0
70
Member Avatar for DaveTran

I have a class which stores my camera settings [CODE] public class SaveData { public CameraFreeLookSettings CameraSettings; /// <summary> /// Parameterless constructor for XML Serialization/Deserialization /// </summary> private SaveData() { } public SaveData(CameraFreeLookSettings cameraSettings) { CameraSettings = cameraSettings; } } [/CODE] I'm trying to save those settings using a SaveFileDialog …

Member Avatar for DaveTran
0
212
Member Avatar for DaveTran

I'm trying to avoid using a singleton pattern with my finite state machine. My agent is changing states based on enumerated messages: [code] public enum MessageType : byte { PathFollow, AlertStatusStart } [/code] Each state is derived from the following class that has access to a Game1 class: [code] public …

Member Avatar for DaveTran
0
109
Member Avatar for DaveTran

I'm currently using the following for counting forwards and backwards through an array depending on the current index. If the index increments past the end of the array it now decrements and vice versa. [CODE] isReversed = isReversed ? index - 1 != -1 : index + 1 == array.Length; …

Member Avatar for DaveTran
0
100
Member Avatar for DaveTran

I have a 1D array. Each element in the array is arranged to emulate a 3D index: [CODE] for (int x = 0; x < depth; ++x) { for (int y = 0; y < height; ++y) { for (int z = 0; z < width; ++z) { int index …

Member Avatar for Momerath
0
140
Member Avatar for DaveTran

I have a method the finds the nearest cell in a grid using ray traversal. The method may or may not find a cell. I would like to return the cell location value from the method if it is found but null if it isn't. The value is non nullable …

0
63
Member Avatar for DaveTran

I'm after an efficient way of detecting whether a List object has changed from one frame to the next. [CODE] List<int> intList = new List<int>(); [/CODE] I have my list as a member variable and will check to see if it has changed each Update() method call. The only way …

Member Avatar for DaveTran
0
6K
Member Avatar for DaveTran

I have a method that is called each frame that will object a GUI window based on the selected object's properties. [CODE] private void Update_Window_Properties() { if (objectSelected == null) { return; } Entity e = objectSelected.Entity; Vector3 position = e.InternalCenterPosition; textBox_PositionX.Text = position.X.ToString(); textBox_PositionY.Text = position.Y.ToString(); textBox_PositionZ.Text = position.Z.ToString(); …

Member Avatar for DaveTran
0
109
Member Avatar for DaveTran

I'm currently on the look out for algorithms that generate uv coordinates for various primitives, including: - Sphere - Cylinder - Cone - Capsule Can anyone point me in the direction of any books, tutorials or code that could be of interest? Thank you.

0
74
Member Avatar for DaveTran

I would like to sort an array of objects by their distance. The problem is that the distance value is a floating point and IComparer only will accept an integer as a return value. [CODE] class SortDistanceAscending : IComparer<ObjectDistance> { static IComparer<ObjectDistance> comparer = new SortDistanceAscending(); public int Compare(ObjectDistance a, …

Member Avatar for DaveTran
0
2K
Member Avatar for DaveTran

I have a simple class that creates unique ID numbers: [CODE] public static class ID { private static int iD = 0; public static int GetNextID() { return iD++; } } [/CODE] If I want each instance of an abstract class to automatically get a new non changeable ID when …

Member Avatar for Mitja Bonca
0
87
Member Avatar for DaveTran

I'm creating an array of vertex formats which I know will always come in groups of 3 as models are generally made for triangles which have 3 vertices. My loop was originally [CODE] for (int i = 0; i < batchVertices.Length; ++i) { batchVertices[i] = new VertexFormat(vertices[i], normals[i], textureCoordinates[i]); } …

Member Avatar for Momerath
0
142
Member Avatar for DaveTran

Let's say I have 5 boolean values: [CODE] bool a; bool b; bool c; bool d; bool e; [/CODE] If they evaluate as true 'a', 'b', 'c' and 'd' should have their associated code run. If 'e' evaluates as true then only its associated code is run and the values …

Member Avatar for DaveTran
0
161
Member Avatar for DaveTran

I would like to write a class that handles a series of timed events for an object. I would need to deal with class properties not being set, and therefore making no change to the object. I've gone with the "?" nullable operator for my first attempt but I would …

Member Avatar for Ramy Mahrous
0
117
Member Avatar for DaveTran

Here are 3 integers and 1 bool. [CODE] int a; int b; int c; bool bHasChangedValue; [/CODE] The boolean value bHasChangedValue depends on the value of b changing. If I update b each frame [CODE] public void Update() { a = b; b += c; bHasChangedValue = a != b; …

Member Avatar for Geekitygeek
0
126
Member Avatar for DaveTran

I have 3 methods [CODE] MethodA() MethodB() MethodC() [/CODE] All 3 methods [U]must[/U] be run at least once per frame/update. MethodA generates a integer count, let's call it 'intCount'. If the count is 0 then MethodB and MethodC don't need to be called. All 3 methods will continue to be …

Member Avatar for Geekitygeek
0
99
Member Avatar for DaveTran

I've got a simple struct. [CODE] struct Data { public float Size; public Data(float size) { Size = size; } } [/CODE] If I create an array of the struct above, the array does not initialise each element to null. How can I change this?

Member Avatar for Momerath
0
125
Member Avatar for DaveTran

In C++ the ternary operator below will return 1. [CODE] true ? 0 : 1 [/CODE] In C# it will return 0. If the following is written in C++ [CODE] int x = ((a < b) ? 1 : ((a > b) ? -1 : 0)); [/CODE] what the heck …

Member Avatar for DaveTran
0
135
Member Avatar for DaveTran

Here's a simple integer array. [CODE] int[] intArray = new int[5]; [/CODE] Now I make the first element equal to a variable. [CODE] a = 10; intArray[0] = a; [/CODE] How can I change the variable so the array automatically updates without using referring to the array? E.g. [CODE] a …

Member Avatar for Momerath
0
164
Member Avatar for DaveTran

I have 3 classes: Foo, Bar and Jim. [CODE] public class Foo { public float a = float.MaxValue; } public class Bar { public float a = float.MaxValue; } public class Jim { public float a = float.MaxValue; } [/CODE] I create a list that holds pairs of objects (classes …

Member Avatar for DaveTran
0
114
Member Avatar for DaveTran

I've created an algorithm that draws a 2D grid in the most efficient way I could think of. Suggestions to improve it are encouraged though :) [CODE] public void DrawWireGrid(int xDivisions, int yDivisions, int cellSize, Color color) { Vector3 a = new Vector3(); Vector3 b = new Vector3(); for (int …

Member Avatar for DaveTran
0
112
Member Avatar for DaveTran

I have a 1D array and I wish to access it like a 3D array. If I know the values of the 3 dimensions Width (x) Height (y) Depth (z) then I can create the 1D array using array[width * height * depth]. How can I now access the indices …

Member Avatar for DaveTran
0
394
Member Avatar for DaveTran

I'm using a dictionary to store my Foo classes. [CODE] class Foo { int i = 0; public void Update() { i++; } } Dictionary<string, Foo> fooDictionary = new Dictionary<string, Foo>(); [/CODE] The dictionary contains [CODE] fooDictionary.Add("MrFoo", new Foo()); fooDictionary.Add("MrsFoo", new Foo()); fooDictionary.Add("BabyFoo", new Foo()); [/CODE] How can I iterate …

Member Avatar for Teme64
0
116
Member Avatar for DaveTran

I have an array of strings. [CODE] string[] array = new string[] { "0", "1", "2", "3", "4", "5", "6" }; [/CODE] I would like to remove a string from the array above using a variable removeIndex, let's say it is equal to 3. [CODE] int removeIndex = 3; [/CODE] …

Member Avatar for nick.crane
1
3K
Member Avatar for DaveTran

If I have an interface for all poolable objects and I require each poolable object to have two delegated methods. [CODE] public delegate T CreateNewObjectGame(Game1 game); public delegate bool ValidateObject(T obj); [/CODE] How can I make sure they are always required when inheriting from an interface when an interface can't …

Member Avatar for DaveTran
1
295
Member Avatar for DaveTran

If this is against the law, then please accept my apologies and delete this post. I have a BT Homehub v2.0. [URL="http://en.wikipedia.org/wiki/BT_Home_Hub"]http://en.wikipedia.org/wiki/BT_Home_Hub[/URL] Is it possible to change the IP address region on the hub so that any device connecting to the internet wirelessly will show this new address? For example …

0
42
Member Avatar for DaveTran

I have a ResourcePool class that uses generics. [CODE] public class ResourcePool<T> where T : class { bool isWrappable; int wrapIndex; int numberOfInvalidObjects; ValidateObject objectCheck; T[] objects; [/CODE] If I have multiple ResourcePool classes. [CODE] private ResourcePool<PlasmaAmmo> poolPlasmaAmmo; private ResourcePool<LazerAmmo> poolLazerAmmo; private ResourcePool<HappyAmmo> poolHappyAmmo; [/CODE] How can I store these …

Member Avatar for DaveTran
0
135
Member Avatar for DaveTran

I've got a helper class to convert an enum into a list. [CODE] class EnumHelper { public static List<T> EnumToList<T>() { Type enumType = typeof(T); // Can't use type constraints on value types, so have to do check like this if (enumType.BaseType != typeof(Enum)) { throw new ArgumentException("T must be …

Member Avatar for DaveTran
0
103
Member Avatar for DaveTran

If two classes (Bar1 and Bar2) inherit from the same base class (Foo) [CODE] public abstract class Foo { public abstract void Spawn(Settings settings); } public class Bar1 : Foo { float a; int b; public override void Spawn(Bar1Settings settings) { if (settings == null) { settings = new Bar1Settings(); …

Member Avatar for nick.crane
1
201
Member Avatar for DaveTran

I would like to automatically call a base class method for a class that inherits from the base class. From the extent of my limited knowledge, I know I can do this using base.Method(). [CODE] public abstract class Foo { private int a; private float b; public virtual void Init() …

Member Avatar for DaveTran
0
126
Member Avatar for DaveTran

When using OR with an if statement does the computer check both statements if the first statement returns true? [CODE] bool a = true; bool b = LongComplicatedMethod(); if (a || b) { Console.WriteLine("Hello"); } [/CODE] So say the boolean b has its value determined by a long complicated algorithmic …

Member Avatar for DaveTran
2
200
Member Avatar for DaveTran

I would like to extend a method found in C# XNA which will set the length of a vector. I thought I should go with extensions as that seemed like the only option. It appears that this isn't going to work as intended as my original vector value isn't updated …

Member Avatar for DaveTran
0
143
Member Avatar for DaveTran

I would like to display the current value of a class on screen for debugging purposes. For example, if I am dealing with the this class [CODE] public class Foo { public bool isSexy; public Foo() { isSexy = false; } } [/CODE] and I wish to display the boolean …

Member Avatar for apegram
0
167
Member Avatar for DaveTran

Say I have 2 classes that inherit from the same interface. [CODE] class Foo : ISomeInterface { int a; int b; } class Bar : ISomeInterface { float a; float b; } [/CODE] Is there anyway I can create a method that automatically recognises the original class without casting but …

Member Avatar for Antenka
0
79
Member Avatar for DaveTran

Here is my class with integer and string variables [CODE] class foo { int age; string name; } [/CODE] How do I create an IComparer that takes in foo as a class without the need for casting from an object? [CODE] class SortAgeAscendingHelper : IComparer { int IComparer.Compare(object a, object …

Member Avatar for apegram
0
982
Member Avatar for DaveTran

I've written a little method that returns the index of the maximum of 3 numbers (0, 1 or 2): [CODE] public static int Max3Index(float val1, float val2, float val3) { int index = val1 > val2 ? 0 : 1; if (index == 0) { index = val1 > val3 …

Member Avatar for apegram
0
127
Member Avatar for DaveTran

[CODE] for (int i = 0; i < 10; ++i) { i > 5 ? MethodA(i) : MethodB(i); } [/CODE] When trying to do the above I get this error [I]Type of conditional expression cannot be determined because there is no implicit conversion between 'void' and 'void' [/I] Does this …

Member Avatar for DaveTran
1
1K
Member Avatar for DaveTran

I would like to produce a number that increments in equal steps between between 0.0 and 1.0. The equal incremental step value will depend on the divisor. One index "i" is fed into the method and two numbers are produced based on i. At the moment, this is my working …

0
66
Member Avatar for DaveTran

I would like to skip the remainder of a function and call another should a statement prove true. [CODE] public bool A(int i) { if (i > 5) { // Skip the rest of A() and return B() return B(i); } // Do stuff to i } public bool B(int …

Member Avatar for caovan
0
314
Member Avatar for DaveTran

[CODE] if (x <= 22.5f) { } if (x >= 22.5f && x <= 67.5f) { } if (x >= 67.5f && x <= 112.5f) { } if (x >= 112.5f && x <= 157.5f) { } if (x >= 157.5f && x <= 180.0f) { } [/CODE] My code …

Member Avatar for DaveTran
0
117

The End.