Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Volte
Oct 4, 2004

woosh woosh
My first WPF project and I'm kind of diving in the deep end. It'll be a Visual Studio style docking control for WPF. Layout, resizing, window content and tabbing all work now, floating/dragging and pinning are next.

code:
<dock:DockManager>
  <dock:SplitPanel dock:DockManager.CellSize="250" dock:DockManager.Dock="Right">
    <dock:DockWindowGroup>
      <dock:DockWindow Title="Window 1">
        <TextBox />
      </dock:DockWindow>
      <dock:DockWindow Title="Window 2">
        <TextBox />
      </dock:DockWindow>
    </dock:DockWindowGroup>
    ...
  </dock:SplitPanel>
  <dock:SplitPanel dock:DockManager.CellSize="250" dock:DockManager.Dock="Bottom">
    <dock:SplitPanel>
      <dock:DockWindowGroup>
        <dock:DockWindow Title="Window 6">
          <TextBox />
        </dock:DockWindow>
        <dock:DockWindow Title="Window 7">
          <TextBox />
        </dock:DockWindow>
        ...
=


(The window tabs will looks cooler when it's done)

Adbot
ADBOT LOVES YOU

Volte
Oct 4, 2004

woosh woosh

UraniumAnchor posted:

Yeah, yeah, babby's first raytracer, but I wrote the core in python and then turned the matrix math into a C module (making it about 10x faster), so it's a learning experience for multiple reasons.



What's up, baby's first raytracer buddy? This one is written in C++:



Finally got the k-d tree working yesterday, so I implemented triangle meshes today. Total render time, about 20 seconds (with 8 cores) with the k-d tree on and (judging by how slow it is when I run it) about 2 hours with them off. It also uses an embedded Lua interpreter with bindings to my scene objects instead of parsing scene files so I can do things like generate geometry on the fly (see: the ring of spheres).

Volte
Oct 4, 2004

woosh woosh
I love this book, but if you just want to write a simple raytracer, it might not be the place to start. This book is about physically based rendering, meaning modeling the light transport equations with numerical integration methods to make photorealistic images. If you just want to make a toy raytracer (i.e. don't worry about global illumination) that does very rough approximations of real light transport, there are lots of nice resources for that.

I wrote a raytracer for a graphics class last year, using Lua to define scenes. I used the Physically Based Rendering book for inspiration (and I adapted their kd-tree implementation) but most of the ray tracing algorithms are the usual simplistic ones found online.

Volte
Oct 4, 2004

woosh woosh
My raytracer doesn't read normal info from the obj file (in fact it will break if the obj file has anything other than vertex and face info), and calculates the normal for each face itself. I believe the reason for the seam in my render at least is that there are actually two sets of overlapping vertices at that point, rather than the adjoining faces sharing the same vertices. Thus, the vertex normals along the seam only take into account the face normals of one side of the seam and not the other.

Volte
Oct 4, 2004

woosh woosh

Pseudo-God posted:

I have slowly been working on a chess game for Windows 8 Metro; I am close to finishing the game logic. Some artwork has also been finished. I am proud of the chess pieces I designed, they are modern but recognizable:

All I need to do now is choose a color for the background, some decorative elements and I believe I will be ready for the 26th Oct launch.

I don't think the king and queen are distinguishable enough from each other. The defining characteristic of the king is usually the cross on top and the queen's is the spiky crown. They both look like queens to me.

Volte
Oct 4, 2004

woosh woosh
The only way I can even function in a game of computer chess is with the standard 2D pictograms. I can't play on a 3D rendering of a chess board, and I can't play with weirdo reinterpretations of the pieces. It affects the way I perceive the board. The standard chess icons have been around since the 19th century at least, so why change them?

Volte
Oct 4, 2004

woosh woosh

steckles posted:

More ray tracer images hooray!

No major bugs cropped up while rendering any of these images, which is nice. It's almost robust enough to release. Now all it needs is a non-insane file format.
This is really awesome. As far as the file format issue goes, I wrote a (simplistic, non-physically-based) raytracer for a course last year and rather than messing around with trying to come up with a sane file format (actually I did that and then gave up), I ended up embedding Lua in the renderer and writing a Lua library/DSL for generating the scene. The main benefit of this is obviously the ability to generate parts of the scene programmatically without having to write a programming language like POV-Ray, while the scene files still resemble something domain-specific. The .obj loader was also part of the Lua support library. Plus Lua is super-simple to embed, and since I was already using C++, I used LuaBind to simplify the bridge between C++ classes and Lua classes.

For example, the spheres in this scene were added with a simple loop inside the scene file.



It was a pretty rudimentary implementation because I was under severe time pressure, but I think that embedding a proper scripting language is a pretty good way to solve the file format problem and also make the language much more powerful than it would be otherwise.

A simple scene might look like this:
Lua code:
function scene()
    local s = Scene() {
        background_color = Color(0, 0, 0),
        camera = Perspective(45) {
            transform = Translate(1*y + 3*z)
                        * Rotate(x, -math.pi / 8)
        } 
    }
    
    s:add_lights({
        Light() { 
            color = white,
            transform = Translate(4*y + 1*z + 4*x),
            area = true,
            rows = 8,
            cols = 8
        }
    })
    
    local tex = Texture() {
        pigment = ColorPigment() { color = Color(1.0, 0.2, 0.2) },
        finish = Finish() {
            ambient = Color(0.1, 0.1, 0.1),
            diffuse = 1.0,
            specular = 0.9,
            exponent = 170,
            reflection = 0.3
        }
    }
    
    for i = 1,15 do
        local v = Vector(math.sin(i/15*2*math.pi), .2, 5 + math.cos(i/15*2*math.pi))
        local tf = Translate(v) * Scale(.2, .2, .2)
        s:add_entity(Sphere() {
           transform = tf,
            texture = tex
        })
    end

    return s
end

Volte
Oct 4, 2004

woosh woosh

SlightlyMadman posted:

Just disable paste so you make those little shits type it in because that's the only way you'll learn.
If this isn't a joke then I agree with tef completely.

Volte
Oct 4, 2004

woosh woosh
I think I'd like the 3D speech box better if it wasn't for the big fat wedge on it. What about having the speech bubble attached to the character doing the talking by a thin spline curve (like a balloon attached by a string)?

Volte
Oct 4, 2004

woosh woosh
Is it really necessary to have more than two levels of granularity? Why not just have a second bar of the same size pop out of the side when it's activated, like a fine tuning knob on a radio. It doesn't look like any of those values have significant enough precision to justify such complicated input methods.

Volte
Oct 4, 2004

woosh woosh

duck pond posted:

I set up the arbitrary-precision dial like I was talking about.


I think it would actually make more sense to have the fine control close to the dial and the large steps further away. I think most of the time you're going to be making small changes often and vast changes rarely.

edit: Although it's hard to translate to the physical model but still having to move half a screen away from the dial to make fine steps is going to be a hassle, plus it makes it easy to wildly mess up your settings by accidentally moving the dial slightly.

Volte
Oct 4, 2004

woosh woosh
Another obvious problem -- what happens when the knob is on the left edge of the screen and turned down all the way? You won't be able to use it properly.

Volte
Oct 4, 2004

woosh woosh

Bahama.Llama posted:

I discovered LaTeX in this thread thanks to the beaglesnes, and holy poo poo... it is awesome. I've found myself making documents for projects at work and they are in a much nicer format even without using the fancy templates. If you haven't taken a stab, don't be afraid of the initial work - It really is easier than MS Word.
Just for the love of god get some kind of non-standard template, or at least change the default font to Palatino. A bog-standard LaTeX document looks even more amateurish (at least in my eyes) than a default Times New Roman Word document.

Volte
Oct 4, 2004

woosh woosh
Not a screenshot since it's just a library, but I found myself needing to test fairly complex JSON responses in a Python web application, and drilling down into a tree that may contain lists of trees or whatever gets hairy, so I made a little structural matching library. I have no idea if something like this already exists but I couldn't find it. It can be used to match any kind of object but the most interesting part is the Tree pattern which lets me match dict-like objects against tree strutures.

For example:

code:
testdict = {
    'key1': 'hello',
    'key2': 123,
    'key3': {
        'nested': [1, 2, 3, 4],
        'list': [
            { 'boo': 'poo' },
            { 'doo': 'koo' }
        ]
    }
}

pattern = Tree(
    Tree.KeyValue('key1', 'hello'),
    Tree.KeyValue(Regex(r'key\d', name='matched_key'), Tree(
        Tree.KeyValue('list', Predicate(lambda x: x[1]['doo'] == 'koo', name='foo'))
    )),
    Tree.KeyValue(Any(name='123_key'), 123)
)

print pattern.match(testdict)
code:
Match({
    '_self': {'key3': {'list': [{'boo': 'poo'}, {'doo': 'koo'}], 'nested': [1, 2, 3, 4]}, 'key2': 123, 'key1': 'hello'},
    '123_key': 'key2',
    'foo': [{'boo': 'poo'}, {'doo': 'koo'}],
    'matched_key': 'key3'
})
Still very rudimentary (only a couple of hours old) but I thought it was pretty cool since it's barely 150 lines of Python and I can't think of any structure it wouldn't be able to match. You can compose patterns into a single pattern (with either alternation or concatenation) using Concat(a1, a2, ...) and Alternate(a1, a2, ...) higher-order patterns too so you basically get short circuiting && and || as well.

I'm thinking of cleaning it up and making it into a real package if it seems useful.

Volte
Oct 4, 2004

woosh woosh
I've actually integrated the above into my unit tests now and it works really well.

code:
    @app_context
    def testFetchUnowned(self):
        json_data = _fetch(self, datetime.datetime.fromtimestamp(0), headers=AUTH_TOKEN(self.user))
        self.assertIsNotNone(
            tree(
                kv('objects', sequence(
                    exclude(tree(kv('_id', str(self.unowned_object.id))))
                ))
            ).match(json_data)
        )
This says "ensure that the JSON data is a dictionary that contains an 'objects' key which is a sequence, but that the sequence does not have any elements with the id of the unowned object". I'll throw it up on github at some point.

Volte fucked around with this message at 00:19 on Nov 12, 2014

Volte
Oct 4, 2004

woosh woosh
I am writing my master's thesis in LaTeX and I need to typeset both Haskell and Scala code inline in the document, literate style. Normally Haskell is handled by lhs2tex, but it's extremely old and kind of lovely, and is a bitch to integrate into your main document if you only need a few pages typeset. So I spent two days porting the useful functionality of lhs2tex (which is only a very small part of it, turns out) to Python and integrating it with pygments to make it handle any language rather than just Haskell. It also simply processes text so you can process two paragraphs out of your whole document, rather than producing a full separate TeX document. The desirability of non-monospaced typesetting of code may be controversial but I thought it was an interesting pursuit anyway and I'm pretty happy with the result.



The important feature is the column-based alignment from lhs2tex. It's not as fine-tuned as lhs2tex but I'm just going to tweak it ad-hoc to fit my needs as I write my thesis.
The Scala part mostly works but I haven't written a token spacing algorithm for it yet so everything is all mushed togther (other than the column-based alignment).


I dunno why that object keyword is not highlighted, pygments knows about it---I checked.

Volte fucked around with this message at 13:37 on Aug 24, 2015

Adbot
ADBOT LOVES YOU

Volte
Oct 4, 2004

woosh woosh
Well that's satisfying.


Still have to tweak some of the symbol replacements and spacing and stuff, but now I can get back to writing. :coal:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply