Programming Pimpage Thread

Grab your favourite IDE and tinker with the innards of game engines

Re: Programming Pimpage Thread

Postby vcool on Fri Apr 02, 2010 2:21 am

I think the reason why most people think anything larger than 3 dimensions is weird shit is because they try to think up Cartesian axes with 4, well, axes.

A vector doesn't have to specify "position". I can draw a 4 dimensional object in 3 dimensions where the first three specify coordinates and the fourth specifies colour. So a rainbow coloured sphere is a sphere in 4 dimensions if I say that the fourth dimension corresponds to colour.

Also n-dimensional math is well developed so it's not a big deal to work with it. Practically it's nothing difficult, just tedious. Of course the more theoretical aspects are much harder to grasp.
Image

Neighborhood Forum Elitist
User avatar
vcool
Veteran
Veteran
 
Joined: Fri Jun 23, 2006 1:03 am
Location: USSR

Re: Programming Pimpage Thread

Postby coder0xff on Fri Apr 02, 2010 4:52 am

You can visualize 4D "in a way" by understanding that each dimension is orthogonal - though this is not possible in reality (I made a proof once ;-) ). Not really visualizing I suppose, but you can come to understand the topography, where a 4D cube has 6 faces that are 3D solids, and each edge has three faces. Yeah, weird. :lol:

Back to the topic of programming, I expanded on my SSE implementation of the vector normalization, and now how a library of optimized float and vector operations that work on entire arrays as a batch. Some of you may have seen the screen shot I posted in random thread for my little 2D spring-physics app. Well, I rewrote the physics portion in C++ and C++/CLI using the array style SSE functions (by performing each operation across the entire collection one at a time).

To make a long story short (I suggest watching it in 480p) :
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Programming Pimpage Thread

Postby coder0xff on Mon Apr 05, 2010 4:31 am

MOAR PIMPAGE!
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Programming Pimpage Thread

Postby theCommie on Mon Apr 05, 2010 7:49 am

Coder, please tell me you have a job doing this kind of stuff (Granted, I don't know how complex/easy/hard it is to code that - or to code at all); seems like you should with your prowess.
User avatar
theCommie
Pheropod
Pheropod
 
Joined: Thu Oct 20, 2005 12:11 am

Re: Programming Pimpage Thread

Postby Hollow on Mon Apr 05, 2010 9:57 am

you're nothing short of a friggin' genius Brent!
User avatar
Hollow
Ubisoft/Monothetic
 
Joined: Thu Aug 14, 2008 12:38 pm
Location: London, UK

Re: Programming Pimpage Thread

Postby Terr on Mon Apr 05, 2010 5:55 pm

Some people think they can outsmart me. <sniff> Maybe.... Maybe...

... I have yet to meet one who can outsmart boolet!
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: Programming Pimpage Thread

Postby coder0xff on Thu Apr 08, 2010 5:45 pm

theCommie wrote:Coder, please tell me you have a job doing this kind of stuff (Granted, I don't know how complex/easy/hard it is to code that - or to code at all); seems like you should with your prowess.


I wish I did. Though, admittedly, I probably don't put myself out there enough. I usually give up when the application form asks what degree I hold. Which is none. An internship would be really nice right now. Keep me afloat while I wait to begin skewl.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Programming Pimpage Thread

Postby coder0xff on Thu Apr 15, 2010 10:15 pm

Come on guys, moar pimpage.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Programming Pimpage Thread

Postby zombie@computer on Thu Apr 15, 2010 10:23 pm

System.Reflection is soo awesome. Look at this nifty bit of code that turns an xml-based collection of controls into a form!

Code: Select all
        private Form ParseXMLtoForm(string text)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(new System.IO.StringReader(text));
            XmlNodeList xnl = doc.GetElementsByTagName("form");
            if (xnl.Count != 1) throw new Exception("xml specification of form must have a single root element with the 'form' tag");           
            Form f = new Form();
            foreach (XmlAttribute attr in xnl[0].Attributes)
                SetProperty(f, attr.Name, attr.Value);
            FlowLayoutPanel flp = new FlowLayoutPanel();
            flp.FlowDirection = FlowDirection.LeftToRight;
            flp.Dock = DockStyle.Fill;
            f.Controls.Add(flp);
            Queue<KeyValuePair<XmlNode, Control>> todo = new Queue<KeyValuePair<XmlNode, Control>>();
            string controlfilter = typeof(Control).AssemblyQualifiedName.Replace("Control", "{0}");
            foreach (XmlNode x in xnl[0].ChildNodes)
                todo.Enqueue(new KeyValuePair<XmlNode, Control>(x, flp));
            while (todo.Count > 0)
            {
                KeyValuePair<XmlNode, Control> p = todo.Dequeue();
                if (Type.GetType(string.Format(controlfilter,p.Key.Name), false, true) == null) continue;
                Type t = Type.GetType(string.Format(controlfilter, p.Key.Name), true, true);
                if (!t.IsSubclassOf(typeof(Control))) continue;
                Control newControl = (Control) Activator.CreateInstance(t);
                (p.Value as Control).Controls.Add(newControl);               
                foreach (XmlAttribute attr in p.Key.Attributes)
                    SetProperty(newControl, attr.Name, attr.Value);
                if (t == typeof(Panel) || t == typeof(GroupBox) || t == typeof(FlowLayoutPanel))
                {
                    if (t != typeof(FlowLayoutPanel))
                    {
                        FlowLayoutPanel pan = new FlowLayoutPanel();
                        pan.FlowDirection = FlowDirection.LeftToRight;
                        pan.Dock = DockStyle.Fill;
                        newControl.Controls.Add(pan);
                        newControl = pan;
                    }
                    foreach(XmlNode node in p.Key.ChildNodes)
                        todo.Enqueue(new KeyValuePair<XmlNode,Control>(node,newControl));
                }
            }
            return f;
        }

        private void SetProperty(object subject, string property, string value)
        {
            Type t = subject.GetType();
            try
            {
                object o = 0;
                PropertyInfo pi = t.GetProperty(property, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.Public);
                if (pi.PropertyType == typeof(string))
                    o = value;
                else if (pi.PropertyType == typeof(decimal))
                {
                    decimal d = 0;
                    decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
                    o = d;
                }
                else if (pi.PropertyType == typeof(int))
                {
                    int i = 0;
                    int.TryParse(value, out i);
                    o = i;
                }
                else if (pi.PropertyType == typeof(bool))
                    o = !(value == "0" || value == "" || value == "false");
                else if (pi.PropertyType == typeof(Color))
                    o = ColorTranslator.FromHtml(value);
                else if (pi.PropertyType == typeof(Icon))
                    o = Icon.FromHandle((new Bitmap(value)).GetHicon());
                pi.SetValue(subject, o, null);
            }
            catch
            {
                try
                {
                    EventInfo ei = t.GetEvent(property, BindingFlags.IgnoreCase);
                    //TODO: ei.AddEventHandler(w, new delegate()); //todo: add delegate here
                }
                catch { }
            }
        }
    }
still not finished, but atleast i can use it to create whatever type of form i want, eg

<form name="test" text="water" icon="D:\My Pictures\images\attach.png" width="200" height="300">
<groupbox text="groupbox1">
<button text="button01" />
<textbox text="example input" />
</groupbox>
<progressbar maximum="200" value="150" />
<label text="hello, this is a label" />

<button text="Ok" />
<button text="Cancel" enabled="false" />

<picturebox sizemode="4" width="128" height="128" image="D:\My Pictures\icons\drwho.ico" />
</form>

results in this form:
Image

i'm only going to need to find a good way to universally change enumerable properties and i'm all set!

Tis a lot easier than i thought to create a scriptable form!
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Programming Pimpage Thread

Postby Terr on Thu Apr 15, 2010 10:26 pm

Makes me think of Zend_Form in PHP. Except in reverse, since it goes FROM commands TO markup...
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: Programming Pimpage Thread

Postby source-maps on Thu Apr 15, 2010 10:29 pm

Image
User avatar
source-maps
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Feb 09, 2007 7:50 pm
Location: The Netherlands

Re: Programming Pimpage Thread

Postby Corewarp on Thu Apr 15, 2010 10:55 pm

source-maps wrote:Image


Hah, at first i was like 10?

But then i binaried.
User avatar
Corewarp
Been Here A While
Been Here A While
 
Joined: Thu Mar 13, 2008 6:29 pm

Re: Programming Pimpage Thread

Postby Terr on Fri Apr 16, 2010 12:41 am

Which one you call yourself depends on whether you're a big-endian or a little-endian.
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: Programming Pimpage Thread

Postby vcool on Fri Apr 16, 2010 1:22 am

You have to remember that the proper way to write it is:

bool IsCoder(bool BinaryUnderstand)
{
if(!BinaryUnderstand)
{
return false;
}

return true;
}
Image

Neighborhood Forum Elitist
User avatar
vcool
Veteran
Veteran
 
Joined: Fri Jun 23, 2006 1:03 am
Location: USSR

Re: Programming Pimpage Thread

Postby coder0xff on Fri Apr 16, 2010 1:41 am

optimized:
Code: Select all
bool IsCoder(bool understandsBinary)
{
    return understandsBinary;
}


Lemme try to jump start the pimpage. I invite you to do something clever with this. I'm gonna share with you guys my XML/HTML/XHTML parser. It has some extra facilities for doing web requests and for saving/loading form data for convenience. it's written in C# and can be used from any .Net language. I'd paste it here, but I'd exceed the 60000 character limit. (It has in code XML documentation, so...) http://pastebin.com/itVJg2di (don't forget to put "using XmlHtmlParser" at the beginning if you use this)

For example, let's say we wanted to get the URLs for Google search results. Our search query is "interlopers.net" as set by the first line:
Code: Select all
String searchQuery = "interlopers.net";
DL and parse google search results:
Code: Select all
XHTMLDocument searchResultsPage =
    XHTMLDocument.LoadPageFromURL("http://www.google.com/search?hl=en&q=" + searchQuery);
get all the <h3 class=r> - these are the results
Code: Select all
List<XMLElement> allResults = searchResultsPage.FindElements("h3", "class", "r");
take the first result out of the list - use other numbers than zero for other results
Code: Select all
XMLElement firstResult = allResults[0];
find the <a> tags - the first one is what we want
Code: Select all
XMLElement anchorTagOfFirstResult = firstResult.FindElements("a", null)[0];
get the href attribute from the anchor.
Code: Select all
String firstResultURL = anchorTagOfFirstResult.GetAttribute("href");

Fortunately, firstResultURL is http://www.interlopers.net
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am
PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users