tag:blogger.com,1999:blog-321319712024-03-23T14:56:58.217-03:00Pé de PinicoFrancisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.comBlogger133125tag:blogger.com,1999:blog-32131971.post-20251952710820506582012-08-25T10:16:00.000-03:002012-08-25T10:17:25.877-03:00Compilacao de curtas da semana<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/46578864" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/46578864">Crumbs</a> from <a href="http://vimeo.com/user5777231">eyal lebo</a> on <a href="http://vimeo.com/">Vimeo</a>.
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/43152728" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/43152728">Rain</a> from <a href="http://vimeo.com/user6442807">Christine Chen</a> on <a href="http://vimeo.com/">Vimeo</a>.
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/40178532" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/40178532">Pollen</a> from <a href="http://vimeo.com/user9944633">Jeremy Bondy</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/41816762" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/41816762">Lil' Boy Bunyan</a> from <a href="http://vimeo.com/user7098381">Kyle Couture</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/47303882?portrait=0&color=ffffff" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/47303882">Sick Leave</a> from <a href="http://vimeo.com/jakefried">Jake Fried</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/46613102?portrait=0&color=ffffff" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/46613102">Stitches</a> from <a href="http://vimeo.com/user4274659">Reut Bortz</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="281" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/47096672?portrait=0&color=ffffff" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/47096672">God Is Kidding - English Subs</a> from <a href="http://vimeo.com/user1266183">Boaz Balachsan</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="209" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/47006314?title=0&byline=0&portrait=0&color=ff9933" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/47006314">A fox tale</a> from <a href="http://vimeo.com/user10428482">A Fox Tale</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="322" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/46530945?title=0&byline=0&portrait=0&color=ff9933" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/46530945">Anna Blume</a> from <a href="http://vimeo.com/user2624511">FinFilm</a> on <a href="http://vimeo.com/">Vimeo</a>.Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-26547750488016706322012-08-20T08:54:00.000-03:002012-08-31T15:04:05.106-03:00GSOC 2012: Pencils down<br />
Hi all!<br />
<br />
Today we have the final pencils down for the Google Summer of Code 2012. It was a wonderful experience do this work along with an awesome team such as the Krita developers. So much learning, and yet so much to be learned, that only a summertime it's not enough.<br />
<br />
Along the course of this project, I made some changes in many things, like the integrator, the particle implementation, mouse dynamics calculation and other features, which appeared while the job was advancing in its results. However, the initial functions related with the sand painting style were always the final purpose, so they endured.<br />
<span style="font-size: small;"> </span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">I described some of the implementations we made so far and what is yet to be done. I put a few links to past blog posts that described some of the features developed in more detail.</span><br />
<br />
<br />
<h2>
<span style="font-size: small;">What we have</span></h2>
<h2>
<span style="font-size: small;"></span></h2>
<br />
<br />
The problems concerning the <b>Pouring </b>operation was made in <a href="http://pedepinico.blogspot.com.br/2012/08/performance-improvements.html" target="_blank">this post</a>. There are some things to do, but for now, I believe that the current state will do. The Pouring set some properties related to the grains, such as size, mass and friction, which modifies the way the spread operation work <br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7UeghHfleDgC9TuFeuuP65AAS2D6z1wxFBREnYQlPv5DcgJuqvCRF_QXYOfwHpO6SpM1gaSAtGGByyzL4c4J4FHEqSAIXvlWXymGbpmU5rixz2bw6A_5kV4ujV6kpCKcIlbub/s1600/print_01.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7UeghHfleDgC9TuFeuuP65AAS2D6z1wxFBREnYQlPv5DcgJuqvCRF_QXYOfwHpO6SpM1gaSAtGGByyzL4c4J4FHEqSAIXvlWXymGbpmU5rixz2bw6A_5kV4ujV6kpCKcIlbub/s640/print_01.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The brush settings widget: we have the brush settings and the grains settings. Most of them have a diference in the <b>Pouring</b> operation mode.</td><td class="tr-caption" style="text-align: center;"><br /></td><td class="tr-caption" style="text-align: center;"><br /></td><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<br />
Once we add grains in the canvas, we can <b>Spread</b> them like a regular sand painting technique. Initially we had some numerical errors related with the grains positions and velocities. To fix this problem was really hard but we accomplish good results without compromising performance.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnEDgmeg1U9lwEtDbeWRcPcf4dJXWFCrM5iOuIE3EOvp3xip8X6Qa1ZCqd9iInepPcFlhDXQNjfcV1ts1RLQjLiiU7rnjFg-8yG_8N3iaxT-sfG5r91-7YpoXuMG0Hy_QkcU3L/s1600/sample_1.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnEDgmeg1U9lwEtDbeWRcPcf4dJXWFCrM5iOuIE3EOvp3xip8X6Qa1ZCqd9iInepPcFlhDXQNjfcV1ts1RLQjLiiU7rnjFg-8yG_8N3iaxT-sfG5r91-7YpoXuMG0Hy_QkcU3L/s640/sample_1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
Some errors were due to mouse velocity calculation. In some situations, mostly when we move the mouse very fast, the time interval becames very small, close to zero, resulting in ugly results in the mouse velocity estimative. Fortunately, Krita already had some code with a solution for this, so I just had to understand what was done and adapt in my situation.<br />
<br />
I made a video of an experiment :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='620' height='360' src='https://www.youtube.com/embed/nUFyEbX5GCY?feature=player_embedded' frameborder='0'></iframe></div>
<br />
Note that the particles are not erased while spreading. Taking a closer look we see that the particles are painted in new positions, although some of them act a little out of the expected behaviour.<br />
<br />
From the videos and images some of you could think that the brush works only in grayscale, but it does work in other color models :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmtV2K8TVHHD0m2AZsac-9itqSzGCSBY9tSaDBkPdogQGxHk9kSlstUNjzJxDj_tBTtEwhEDKh_Mn_5dXioHNjRjrmp-F0fG8hH0eXf4UFZhn15v_j9zBBV_HKoizLMdZyMUa_/s1600/sample_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmtV2K8TVHHD0m2AZsac-9itqSzGCSBY9tSaDBkPdogQGxHk9kSlstUNjzJxDj_tBTtEwhEDKh_Mn_5dXioHNjRjrmp-F0fG8hH0eXf4UFZhn15v_j9zBBV_HKoizLMdZyMUa_/s640/sample_2.png" width="640" /></a></div>
<br />
We made strokes of the <b>Pouring</b> operation with different colors in each one.<br />
After that, we did some <b>Spread</b> (the well defined white spaces) to show it working in the color grains. The main drawback in this <b>Spread</b> operation is the grain color handling. When we update the grains positions we repaint them using the current color (when putting a grain in a new position) and background color (when "erasing" the particle previous position). We can improve that by holding the color used in the <b>Pouring</b> operation inside the <i>Particle</i> class and deleting the previous position using a alpha channel painting.<br />
<br />
<br />
<span style="font-size: small;"> </span><br />
<h2>
<span style="font-size: small;"> What is missing</span></h2>
<h2>
<span style="font-size: small;"> </span></h2>
<br />
There are a few more things that were planed to be done, but I didn't have time to do it. Again, to the <b>Spread</b> operation work properly it took a very good effort so it could emulate the sand behaviour while the user painted using it.<br />
<br />
As explained <a href="http://pedepinico.blogspot.com.br/2012/07/particle-persistence-with-krita.html" target="_blank">in this post</a>, we divided the canvas in a number of grid cells so it could apply the <b>Spread</b> only in those which are under the mouse position.<br />
However, the grains which are under the brush radius should have been spread as well. So one of the things to be done is the to extend the grid cell selection under the mouse radius, not only to the mouse position. There is also the posibility of customizing the grid size for user convenience: larger cells for faster computers, smaller cells for slower computers.<br />
<br />
A missing feature is the mouse "particle" customization. The spreading is made by emulating a particle in the mouse position with the same size as the brush radius. However, the mass and friction for the brush are the same as the current configuration of the grain particles, so it's not a very user friendly setting scheme, since the grains settings is only, obviously, for the grains.<br />
<br />
Another problem is when you save a document where you used the sand brush. When you load it, the particle positions are not retrieved, although we can use the created <i>KisAnnotation</i> to do so.<br />
<br />
<br />
<h2>
<span style="font-size: small;">And now?</span></h2>
<br />
<br />
Well, now we wait for the evaluation. I tried to put a good documentation in the code so anyone can understand what is happening in each part of it. Although some things are missing, most of what was proposed was made<br />
and the main features are working well. I need to do some more tweaks to make the brush more user friendly, but for now, the visual results are satisfying.<br />
<br />
I really hope I can continue working in this brush in the next years so it can have a behaviour even more beffiting with the actual behaviour of sand painting. But we will make more plans when we are sure that everything went okay in the evaluation.<br />
<br />
Until next time!Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com2tag:blogger.com,1999:blog-32131971.post-62007220441669629032012-08-04T19:21:00.000-03:002012-08-04T19:21:47.483-03:00Performance improvements :)Hi all! <br />
<br />
For the first time, I accomplished good performance improvement in a code after refactoring and commenting the code. This kind of practice really helps to clarify an implementation. <br />
<br />
My code was very "dirty", almost unreadable, so I rewrote all the comments, hoping that it could help anyone to understand what's going on in the scene. While rewriting, some major errors in the link cell algorithm was corrected. For instance, I had the grid cell operation retrieving the upper-right neighborhood of a cell, instead of the lower-right: this was driving me crazy.<br />
<br />
Anyway, most of the particles retrivement algorithm was slow due to unnecessary I/O operations in the annotations. So, to make things faster, one class is working as a particles manager (KisSandPaintOp), where it takes care of the interaction between the image properties and the particle architeture (grids, neighborhoods and the particles themselves).<br />
The KisSandPaintOp reads and writes all the particles from the annotation ans save them as the SandBrush add new particles.<br />
<br />
<br />
There are some other things that is missing, but is easy to be done:<br />
<ul>
<li><b>brush widget update:</b> have to add the "mouse particle"
settings, mostly the physical properties like mass, friction and
dissipation. The grid customization had to be done again, since I
removed while fixing the grid retrieve in the neighboorhood.</li>
</ul>
<ul>
<li><b>brush default settings:</b> the brush is begins with all its values set to zero, so I need to initialize them in a default value</li>
</ul>
<br />
This was the good news of this week. Along with that, I made a list of the main flaws in the brush behaviour. I have some ideas how to fixing each one,<br />
but, like most of the previous ideas, I'm taking sometime to study the best ones:<br />
<br />
<ul>
<li><b>dynamic pouring fix:</b> the mouse velocity and acceleration are taken as parameters to modify the added particles position. However, when the movement is in one direction only (X or Y) the grains form a line, yielding an undesirable result (see the picture below). I'm applying the mouse velocity and acceleration directly in the particle pixel position, and update them at each call of the <i>paintAt()</i> method of the SandBrush.</li>
</ul>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv5CQgo7YD-T-65Xzt7kRvr6hfQbYv1Qohlaw_pS9YsG3rt4v50GO2lRWWhgDWDuxQJ3fv-6AgX6dWaI9O88WbURj7Q0L2OlIN8sLri6u8mLiQrp55-Uy67nVNxf5nLgrLvLe4/s1600/sand_probs01.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv5CQgo7YD-T-65Xzt7kRvr6hfQbYv1Qohlaw_pS9YsG3rt4v50GO2lRWWhgDWDuxQJ3fv-6AgX6dWaI9O88WbURj7Q0L2OlIN8sLri6u8mLiQrp55-Uy67nVNxf5nLgrLvLe4/s640/sand_probs01.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Note the lines drawn in the X/Y directions. The mouse movement in this type of situation has to act in a more "random" way.</td></tr>
</tbody></table>
<ul>
<li><b>sand depletion operation: </b>the sand depletion (amount of sand for each brush stroke) is decreasing too fast. I need to find a more reasonable asymptotic function to do the depletion, with the brush radius as parameter. As bigger the radius is, more fast the sand should This is not a high priority feature, but it's nice to have a more real feeling of the painting.</li>
</ul>
<ul>
<li><b>particle positions update in the spread operation: </b>I implemented the main step of the spread operation (the final step of the brush function). As the following video shows, the correct grid position is retrieved allong with its particles to do the spread operation. <br /><br /><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='600' height='400' src='https://www.youtube.com/embed/f818Pmxkt08?feature=player_embedded' frameborder='0'></iframe><br /><br /><br />However, for a reason I can't identify, the positions are not updated:
I'm not deleting the previous positions yet, just trying to paint the
new ones, which does not happen. And to make things worse, the selected
particles have their color modified to blue, something that I'm not
doing.</li>
</ul>
<br />
Anyway, just a few more steps and the spread operation will be done. The main properties of the brush is in this spread operation so accomplish the desired behaviour depends on this step. F<span class="short_text" id="result_box" lang="en"><span class="hps">ortunately, most of the necessary functions for this operations are working properly so I'm with good expectations of the results. Let's see how it will go!</span></span><br />
<span class="short_text" id="result_box" lang="en"><span class="hps"><br /></span></span><br />
<span class="short_text" id="result_box" lang="en"><span class="hps">Till next time!</span></span><br />
<ul>
</ul>
<br />
<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-56982963261356982792012-07-22T12:09:00.001-03:002012-07-22T12:09:55.589-03:00Particle persistence with Krita AnnotationsHello there! <br />
<br />
Since we can add grains with physical properties, we can start to work on the hard part: particle selection, collision and animation. However, to do that, we need a way to make the objects created in a stroke to be persistent, since after the paintop is done all objects created during the operation are destroyed.<br />
<br />
To do that, we had to find a way to hold a collection of particles and then spread it after the pouring. Thus, I'm using Krita's Annotations, a feature that make possible to add aditional information to an image, like a comment, or, in my case, the collection of particles.<br />
<br />
With that, we can save the image state after the creation/pouring of the grains and load them in a way that make it possible to start the usual painting operations. <br />
<br />
However, since the number of particles grows really fast, the pouring mode of the brush will just add the particles and save them in a collection that will be converted in an annotation. This annotation will be reloaded when the user start the spread mode, where we only modify the particles positions and don't add any new particle on the canvas.<br />
<br />
Another feature that we made these days is a private grid partition of the image. This is necessary since the number of particles grows really fast (in a common pouring painting we add from 5000 to 100000 grains), so to speed up particle selection and neighborhood detection, we are using two data structures that holds the particle indices associated with a grid and create a neighborhood relation between them, so we have to retrieve only those inside and near that grid cell.<br />
<br />
For instance, given a image, its associated grid is created by taking the canvas width and height and dividing each by the number of rows/columns disired. If the mouse is in the position <i>(gx,gy)</i>, we will search the grid index<br />
by taking its position, multiplying by the number of grids and dividing it by the image size:<br />
<br />
<blockquote class="tr_bq">
grid_x_position = number_of_horizontal_grids * gx / image_width</blockquote>
<br />
doing the same for the grid vertical position. With that, we initialize a neighborhood relation structure where we will seach for particles to select and do collision, if need to be.<br />
<br />
We could search for these particles in the eight neighbors of the cell where the mouse is, but in practice we can reduce it by half, based on commutativity relation between neighbors. Suppose that <i>(gx, gy) </i>are not boundary cells. Them, since a particle <i>i</i> is neighbor of particle <i>j</i>, we only need to search for neighbors in one way only, in our case, the lower-right half of the neighborhood.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyua6COZ98LqsO-YSEUe6-rMLApdpQcr8eNTcTew2rRyYWouT-qdPkUG9BEY8mNzmk5OUAJh1wDSrEWku0Mu2ggtkj2SWMgQNkbhRwQB37c4fA1Lis4oDeBPYXTHiMj7f1ABHc/s1600/grid_search.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="322" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyua6COZ98LqsO-YSEUe6-rMLApdpQcr8eNTcTew2rRyYWouT-qdPkUG9BEY8mNzmk5OUAJh1wDSrEWku0Mu2ggtkj2SWMgQNkbhRwQB37c4fA1Lis4oDeBPYXTHiMj7f1ABHc/s400/grid_search.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Neighborhood search space restriction.</td></tr>
</tbody></table>
<br />
Witha that, when the mouse moves, we can apply the forces on each particle based on the mouse speed and acceleration and after that, we animate them to have the dynamic feel. For now, the grid creation is based on the image size, but I'm doing the grid customization widget so the user can indicate the number of grids that suits his/hers needs better.<br />
<br />
Along with that, I have more few things to fix yet, but I'm enumerating them and soon we will have more details of the situation. Until next time!<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-45830243437069549092012-07-08T20:36:00.002-03:002012-07-08T20:36:12.380-03:00A more dynamic pouringHi again!<br />
<br />
I modified the brush so we can apply velocity and acceleration on the particles based on the mouse movements. In the brush settings, we can set how much sand can drop while pouring it on the canvas, with the sand depletion marked. I will make a better way to control this behaviour in the widget since the values are pretty low for the real amount of sand (when you select the value "50" in the "amount" spinbox, you can add 5000 particles per stroke). The solution I'm thinking is to add a multiplier button, like in the Pixel brush, so the user can add more with low values of the "amount".<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='600' height='400' src='https://www.youtube.com/embed/agvmCqRfG1s?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
Another news is that we can't use the QGraphics Framework due to performance issues. The framework make the selection and collision more easy to handle, but it's really slow for what we had in mind, so I will work on my own code for that.<br />
<br />
For now, I'm thinking in the way to divide the canvas in a grid. Using this division, I can use a faster data structure to retrieve particles close to the mouse position and do some processing on then. I already made something similar in the Granular Particles Simulation and I think it won't be a problem to adapt it to the brush.<br />
<br />
Regards!Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com2tag:blogger.com,1999:blog-32131971.post-37198339849645091442012-07-05T01:36:00.001-03:002012-07-05T01:36:49.136-03:00Some news of the sand brushHi all!<br />
<br />
It's been a long time since my last post. Lots of things happened since then: I got sick, start a chapter in my university project, finished my short experience as teacher, saw family and friends... and kept working on the sand brush (just forgot to blog about it :P).<br />
<br />
The project changed a few things for the sake of simplicity. Since the brush have some similar aspects with games, I'll use the Qt4 <a href="http://doc.qt.nokia.com/4.7/graphicsview.html#graphicsview" target="_blank">Graphics Framework </a>in Krita. Since collision detection, shape modification and object (particle) transformations will be features that the brush has to have, instead of reinventing the wheel, I saw that the Graphics Framework already have these functions.<br />
<br />
I did some tutorials about the QGraphicsView to better understand how the QGraphicsItem, QGraphicsScene and
QGraphicsView interact and how I can modify Krita's nodes and layers to work with it. I modified my previous Particle class to work in a more simple way and now I'm putting some inheritance from QGraphicsItem to proper use the Graphics Framework advantages. For instance, the updated() method of the class will work using the RK4 integration algorithm to redraw the particle new position in a animation step. <br />
<div class="im">
</div>
<div class="im">
</div>
<div class="im">
</div>
<div class="im">
</div>
<div class="im">
<br /></div>
<br />
Meanwhile, I created a new paintop plugin on Krita repository and did some hacking on it so we can have some visual stuff to look at it:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/1RwZHV_U1sM/0.jpg" height="420" width="640"><param name="movie" value="http://www.youtube.com/v/1RwZHV_U1sM?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" /><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><embed width="640" height="420" src="http://www.youtube.com/v/1RwZHV_U1sM?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object></div>
<br />
<br />
I have just loaded and put some filled circles on the canvas with a (slow) depletion. When working with the brush, imagine that you have limited sand on your hand, so every stroke has a sand limit. I'm searching a better assymptotic function than the one I'm using now to do a more smooth depletion. One of the next features to do it's a more dynamic way of spreading these circles, based on the mouse movement properties (velocity, position and acceleration). <br />
<br />
I'm studying the layers and nodes of Krita archtecture in a way that I can add a more interactive canvas to manage these circle grains. Perhaps managing these grains in this architecture will yield a behaviour closer to the expected.<br />
<br />
Till next time!Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com5tag:blogger.com,1999:blog-32131971.post-20824204672668437922012-06-03T09:15:00.001-03:002012-06-03T10:33:23.964-03:00Granular particles at sightHi all! This week was a little rough, since I had some health issues, but nothing that could stop my coding. :)<br />
<br />
The simulation had a huge improvement when I changed the integrator. I was using the fifth order <a href="http://web.mse.uiuc.edu/courses/mse485/projects/2001/team5/node10.html" target="_blank">Gear's predictor and corrector integrator</a>. Since most of the people in real-time applications says that the fourth order Runge Kutta integrator is the most effective, I implemented and saw what they where talking about: it's really fast! From a few minutes using Gear's algorithm with collision detection, it dropped to a few seconds with collision detection. A lot better. :)<br />
<br />
In the first time I was calculating the collisions between particles. To another improvement, I followed the hint given by Bugsbane in a comment of the <a href="http://pedepinico.blogspot.com.br/2012/05/hello-again-ive-been-fooling-around.html#comment-form" target="_blank">last post</a> and decided to remove the particles collisions.Indeed, for our purposes, these collisions must happen only in two specific situations: (1) when the mouse does the spreading of sand already in the canvas and (2) when one particle tries to pass the canvas boundaries.<br />
<br />
<a name='more'></a><br />
<br />
I had some numerical problems too, but that was my fault. In certain initial conditions, one of the particle properties was set to zero, without I even notice that. This propertie was the <a href="http://en.wikipedia.org/wiki/Young's_modulus" target="_blank">Young modulus</a>, which gives us the elastic properties of a material. The value was set to zero, doing a unproper division in the equations and yielding numerical errors.<br />
<br />
When most of the previous errors and drawbacks was removed, I ploted the particles in a QWidget and animated it to see what was really happening:<br />
<br />
<div style="text-align: center;">
<object style="height: 390px; width: 640px;"><param name="movie" value="http://www.youtube.com/v/2N6pHe4q7fE?version=3&feature=player_detailpage">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed src="http://www.youtube.com/v/2N6pHe4q7fE?version=3&feature=player_detailpage" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></object>
</div>
<br />
I took the particles properties from a initialization file (with it's positions, velocities, forces and other properties), instatiated them and draw each one with a drawEllipse method of a QPainter class. After that, for each time step, I applied the integrator and redraw the entire particle set on the canvas.<br />
<span style="color: #204a87; font-size: x-small;"><br /></span><br />
I didn't pushed this part to the repository yet, but as soon as I finish the code comments and refactoring, it will be available. For now, I'm listing my next steps :<br />
<br />
- Forces evaluation : I will modify the normal force method to deal with a big "particle" of the size of the brush, so the particles can move properly in the canvas as the mouse emulates the artist finger. Another thing is that the code is working only with circular particles for now, so the tangencial force do not have any significant role for this simulation. Perhaps in the future when it starts to deal with non-circular elements it will be useful, but until there, it will remain unused.<br />
<br />
- Grid Mouse interaction: I divided the numerical simulation space in a grid to improve the performance. Now I will do the same with the canvas to detect which particles the mouse are touching and apply forces in each of them based on the mouse movements. I believe I will not have much problem with that when I port this code to a Krita paintop, since the canvas is already divided in 64x64 grid cells.<br />
<br />
- Canvas Boundaries: This will be more complicated since the behaviour of the sand in the boundaries depend of the box material. Most of the particles have a little bounce back after colliding with the bounds, so I'm thinking if I set invisible particles at the bounds or if I set a default bounce back force for each particle.<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-30641955369562727132012-05-24T18:49:00.002-03:002012-05-24T18:50:24.304-03:00Granular particles update!Hello again!<br />
<br />
I've been fooling around with my granular particles repository these past days before do a real coding into Krita. I'm trying to optimize my simulation through a series of modifications in the code I wrote last week.<br />
<br />
My first attempt to run this granular particles simulation was quite a big failure, since it was really slow and full of errors. I correct some small things this past weekend and during this week I implemented a neighborhood restriction to the collision detection between particles.<br />
<br />
<a name='more'></a><br />
<br />
One of the reasons the code had a slow response was the fact that each particle was doing a collision detection with every other particle in the simulation. I initialized with 2010 particles, so we had a lot time wasted just doing useless calculations, since we only had to worry about each particle vicinity. So this time I implemented a grid so we could restrict the computation of collision only for neighbors particles. I have yet some other two improvements to test before generate some QImages: try the <a href="http://gafferongames.com/game-physics/integration-basics/" target="_blank">RK4 integrator</a> instead of the <a href="http://web.mse.uiuc.edu/courses/mse485/projects/2001/team5/node10.html" target="_blank">Gear's predictor and corrector</a>, and a more vectorizable grid construction which will be more easily implemented in a GPU.<br />
<br />
I'm already writting a more detailed post with all the theory used behind the scenes. But if you already took a <a href="https://gitorious.org/granular_sphere_particles" target="_blank">look at the code before</a>, <a href="https://gitorious.org/granular_sphere_particles/granular_sphere_particles/commit/859d3d24b51f6c72620e0b6782c164b8d47b9aff/diffs" target="_blank">this update</a> will be easy to understand. Again, the code is well commented and any questions you can contact me here in the comments or sending me a message to <a href="https://gitorious.org/~chicao" target="_blank">my Gitorious account</a>.<br />
<br />
See you all soon! :)<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com2tag:blogger.com,1999:blog-32131971.post-7512846883504886082012-05-17T10:55:00.003-03:002012-05-17T10:57:09.836-03:00Modelos tridimensionais no Inkscape 2: editando e exportando<span style="text-align: left;">Continuando ainda a <a href="http://pedepinico.blogspot.com.br/2012/05/modelos-tridimensionais-no-inkscape-1.html" target="_blank">edição de modelos no Inkscape</a>, as vezes é util editar algumas propriedades do objeto antes de exportar. No Blender é possível importar e exportar para diversos modelos. O formato Wavefront (</span><b style="text-align: left;">.obj</b><span style="text-align: left;">) é o suportado no Inkscape, então vamos nos focar na abordagem com ele.</span><br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Após deletar o cubo inicial, vá em <b>File > Import > Wavefront (obj)</b>. Selecione o arquivo do seu modelo e clique em <b>Import.</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUFVXnrT2A4NjDieVhRYrSKJOD-uj4jzFvFIpPGdii7Ho-wJQcFaBW9H64gMX-kXCeSfcbwMpxLST9Cd1C80OPJbkYMR3hoKKIrzUjPF9FK3K8EAJKmcZB8aKNNZhDhHleNXDm/s1600/tt01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUFVXnrT2A4NjDieVhRYrSKJOD-uj4jzFvFIpPGdii7Ho-wJQcFaBW9H64gMX-kXCeSfcbwMpxLST9Cd1C80OPJbkYMR3hoKKIrzUjPF9FK3K8EAJKmcZB8aKNNZhDhHleNXDm/s400/tt01.png" width="400" /></a> </div>
<br />
<a name='more'></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvopMxxy7slD-p-qSdcauYniKbCn-l24VV0gCcEXB8-GLDYfDRoYK4ipRJfIc6TpyFiXBJgNiEZC_lxQL4hxNCTC74Vdod2048MMOaWqax5t9AlObfeLVPoAVo8Q2k1D-5fDdN/s1600/tt02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvopMxxy7slD-p-qSdcauYniKbCn-l24VV0gCcEXB8-GLDYfDRoYK4ipRJfIc6TpyFiXBJgNiEZC_lxQL4hxNCTC74Vdod2048MMOaWqax5t9AlObfeLVPoAVo8Q2k1D-5fDdN/s400/tt02.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyajyXwiKi3PXpceJCPGFgq06-DxAPNFKMpDQoqClL34SEzWPLBbMKrptuy-7ghpS-wBJHb-KeOpzHMDYNz9J-yFL6mCBdBMKMGmQAGu1PDT4Q9Zy4pcqtHMf4tXc5LdUFzvnA/s1600/tt03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyajyXwiKi3PXpceJCPGFgq06-DxAPNFKMpDQoqClL34SEzWPLBbMKrptuy-7ghpS-wBJHb-KeOpzHMDYNz9J-yFL6mCBdBMKMGmQAGu1PDT4Q9Zy4pcqtHMf4tXc5LdUFzvnA/s400/tt03.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6MEMqQk82vv9VbJ5uBkznOFSIycQLWCZtOX3rltzZIkkhvFEDcn_gMjRqXw3R2UeAxgYWBY2aLnrOATpMSF4XKPKvD953Q4ndOUECo28q5dl3dY5u9vC5f2f_1BR7HZW9XqaF/s1600/tt04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6MEMqQk82vv9VbJ5uBkznOFSIycQLWCZtOX3rltzZIkkhvFEDcn_gMjRqXw3R2UeAxgYWBY2aLnrOATpMSF4XKPKvD953Q4ndOUECo28q5dl3dY5u9vC5f2f_1BR7HZW9XqaF/s400/tt04.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
O arquivo será importado do modelo <b>.obj </b>e poderá ser editado como qualquer modelo do Blender.</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTFHu55pZC4KjMKwxTVLpvQBlfsF8eVY4qY33YDOtP7TdSTBkwqDMpicwVtdUgPF0SjCim7Ee1XEObZIbEFDC_JbctTuwhBCVRHXh9a2TR_TfxyVioKA4T-oy84WMJ91K4qQkT/s1600/tt05.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTFHu55pZC4KjMKwxTVLpvQBlfsF8eVY4qY33YDOtP7TdSTBkwqDMpicwVtdUgPF0SjCim7Ee1XEObZIbEFDC_JbctTuwhBCVRHXh9a2TR_TfxyVioKA4T-oy84WMJ91K4qQkT/s400/tt05.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaXVmhCcmWOoHW0g3f_X3YS4i9YGbuufsHBqvxjDDQdaQjDs7frG5Cgam-WSFdFO6j4mmBLsQG-7wvbXKqMpXKenV12ALD90JmxnorlgEvkP7PJsVdEbbsxm25Fw5yGDr1xN_u/s1600/tt06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaXVmhCcmWOoHW0g3f_X3YS4i9YGbuufsHBqvxjDDQdaQjDs7frG5Cgam-WSFdFO6j4mmBLsQG-7wvbXKqMpXKenV12ALD90JmxnorlgEvkP7PJsVdEbbsxm25Fw5yGDr1xN_u/s400/tt06.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Uma operação interessante aqui é a Subdivisão de faces, então subdivide-se as faces. Depois disso, vá em <b>File > Export > Wavefront (.obj) </b>coloque o novo nome do objeto e clique em <b>Export.</b></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpK8jawtMPTngpXf3ij68rKBaQIV-ColEpphxT5ktblN_SCwwmjvOKsL0AH0KwF1LcmWcronBdUAdUsyBBujjoFiKI0ke3mFIxtsEU1vsJJ6y9azWZyjrDWc17eJQYyGWzqMzo/s1600/tt07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpK8jawtMPTngpXf3ij68rKBaQIV-ColEpphxT5ktblN_SCwwmjvOKsL0AH0KwF1LcmWcronBdUAdUsyBBujjoFiKI0ke3mFIxtsEU1vsJJ6y9azWZyjrDWc17eJQYyGWzqMzo/s400/tt07.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsuN4KZ-bqxzVSY36Tk6mjTEhOVZOBh2PVni__HG7gGajl8wt6e708C9mX4ddjUaMWlkZfu3znXouISElp7zSnR2eiaBjIEAIxe-NdzBCwg07szrqn0Ku9R5ARP8i0yGunfZnx/s1600/tt08.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsuN4KZ-bqxzVSY36Tk6mjTEhOVZOBh2PVni__HG7gGajl8wt6e708C9mX4ddjUaMWlkZfu3znXouISElp7zSnR2eiaBjIEAIxe-NdzBCwg07szrqn0Ku9R5ARP8i0yGunfZnx/s400/tt08.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Depois disso, siga os passos do tutorial de inserção de modelos Wavefront para o Inkscape para importá-lo para o formato vetorial.</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuwN9hk77wyAHN5D6RB-HhYlBeXOpNAr-b69UjnL7uC33O7q9EZ_fe0x97CTZ25iWaYNrNyWSB1oRR_QeO1y3kPNfPdUBGMShYLhP-O0cqwfq640w5Iw5FzxXtBrhjTE4kLMVg/s1600/tt09.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuwN9hk77wyAHN5D6RB-HhYlBeXOpNAr-b69UjnL7uC33O7q9EZ_fe0x97CTZ25iWaYNrNyWSB1oRR_QeO1y3kPNfPdUBGMShYLhP-O0cqwfq640w5Iw5FzxXtBrhjTE4kLMVg/s400/tt09.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgx2EFaEpkYYliuOrDP8IVzfjeMof_GH4_58y2FAcRFsUBYR3XKQZqFuaMO8hqV1DSfs9VxQXPTflun2tSLUxQhTkl-2aTu4T0ghamTfqfRxwzHc0d7wUqwhn3CFpMrh7RlkBDn/s1600/tt10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgx2EFaEpkYYliuOrDP8IVzfjeMof_GH4_58y2FAcRFsUBYR3XKQZqFuaMO8hqV1DSfs9VxQXPTflun2tSLUxQhTkl-2aTu4T0ghamTfqfRxwzHc0d7wUqwhn3CFpMrh7RlkBDn/s400/tt10.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8gaTRhekRiEtvOkjBKF3yycIesPj_MWuyKwgRRwzONsxy_yc2h_1BgqL-IGXVr63kYuNKCoHpyfIyzFbegP5jGxCAzO1xrhlseaqhSUd9vWoZsWsGogq3uQ4ocxcvMdzxqANX/s1600/tt11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8gaTRhekRiEtvOkjBKF3yycIesPj_MWuyKwgRRwzONsxy_yc2h_1BgqL-IGXVr63kYuNKCoHpyfIyzFbegP5jGxCAzO1xrhlseaqhSUd9vWoZsWsGogq3uQ4ocxcvMdzxqANX/s400/tt11.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqTNpPMk1jKw3VbpO6eWHSmC9B-9f5Q0NdVhkNdpwUM-DMR1m0E-EgI4sLbv7z65C-INHXt5itZo4BKwEmT6RouS5hgQ9xYMB7kZozPaI4GIqK4SIibA0NOOmCcarfGmnFN5HJ/s1600/tt12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqTNpPMk1jKw3VbpO6eWHSmC9B-9f5Q0NdVhkNdpwUM-DMR1m0E-EgI4sLbv7z65C-INHXt5itZo4BKwEmT6RouS5hgQ9xYMB7kZozPaI4GIqK4SIibA0NOOmCcarfGmnFN5HJ/s400/tt12.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Terminada a edição e importação do modelo, para gerar uma saída interessante para os arquivos Latex, vá em <b>Arquivo > Salvar Como</b> , selecione o nome do objeto e os formatos desejados na <i>combo box </i>no canto inferior direito da caixa de diálogo. Geralmente as boas pedidas são os EPS ou SVG, formatos vetoriais suportados pelo Latex.</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuPGyXDYXIj2nT7avNoG3-MYmxmjX71_3T2oRayAdimLUil8M5ec36pJ9JcGEsuhBgr9xCSsA_Wiof1UajT1WH-2Ko4EkKs4qKL6yzsGUON9EbzTxlLFvaywoCq1mublaT0jua/s1600/tt13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuPGyXDYXIj2nT7avNoG3-MYmxmjX71_3T2oRayAdimLUil8M5ec36pJ9JcGEsuhBgr9xCSsA_Wiof1UajT1WH-2Ko4EkKs4qKL6yzsGUON9EbzTxlLFvaywoCq1mublaT0jua/s400/tt13.png" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHZZi3lKwXgjH17PmaOw9PBBLMeAmVfXcNFU5MpSl47tzDvRORSAsZdqh7NBrVCzvrvRckDAk9wiIJa2aIXRt-KBiW2YBbC3BZ9yfxbl-qBUyQ3-qsq0t8eZL3nGDVlPOZPGtO/s1600/tt14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHZZi3lKwXgjH17PmaOw9PBBLMeAmVfXcNFU5MpSl47tzDvRORSAsZdqh7NBrVCzvrvRckDAk9wiIJa2aIXRt-KBiW2YBbC3BZ9yfxbl-qBUyQ3-qsq0t8eZL3nGDVlPOZPGtO/s400/tt14.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Com isso é encerrada os tutoriais de importação de modelos tridimensionais. O Inkscape também desenha curvas paramétricas usando a notação das funções definidas no pacote <i>math</i> do Python. Talvez eu acabe tirando um tempo pra explorar essa função também, pois também deve ser muito útil na hora de gerar bons gráficos para os nossos Latex.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Até la!</div>
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-29121736249028220552012-05-17T10:54:00.001-03:002012-05-17T10:56:42.925-03:00Modelos tridimensionais no Inkscape 1: importando e editando<div class="separator" style="clear: both; text-align: left;">
Este tutorial é meio que uma continuação deste meu post sobre como colocar texto <a href="http://pedepinico.blogspot.com.br/2012/05/latex-no-inkscape-com-textext.html" target="_blank">Latex no Inkscape</a>. Como as vezes é preciso exibir modelos tridimensionais em alguns trabalhos, usar um software de edição vetorial ajuda a colocar formatos com melhor resolução em <i>papers</i> e <i>slides. </i>O Inkscape tem por padrão um renderizador vetorial que aceita modelos tridimensionais Wavefront ( <b>.obj</b>). Aqui eu vou mostrar como importá-los e editá-los (primeira parte) e como gerar arquivos de saida Encapsulated Post Script (<b>.eps</b>) e/ou Scalable Vector Graphics (<b>.svg</b>), formatos muito utilizados pra quem quer colocar figuras no Latex (segunda parte).</div>
<div style="text-align: left;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmlj7-dBybOgACRzKSMVkqPnonTupWu7CUgooUayZo2IRq_GGsrkzTUn2VCOPNHy0TCSP1nzEi2AuHsYDYI9g0agH-OWtfq-oTncqmeFW-sWfA8yvHtjTuHqHQYtY9wS8MYIW3/s1600/tt_i00.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmlj7-dBybOgACRzKSMVkqPnonTupWu7CUgooUayZo2IRq_GGsrkzTUn2VCOPNHy0TCSP1nzEi2AuHsYDYI9g0agH-OWtfq-oTncqmeFW-sWfA8yvHtjTuHqHQYtY9wS8MYIW3/s400/tt_i00.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<a name='more'></a><br /><br />
</div>
Com o Inkscape aberto, vá em <b>Extensões > Renderizar > 3D Polyhedron</b>. Essa ação irá abrir uma caixa de diálogo em que você poderar escolher que objetos você quer renderizar. Escolha <b>Load from file, </b>informe o caminho completo do modelo (infelizmente não tem um diálogo que cuide disso, então é no braço mesmo que o modelo deve ser informado) e clique em <b>Aplicar.</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1ewDW33NUG62mAKrOXpz5XYwLJTudc8QARdXg-WkIaVqXJgZ1n8BdYoxE9scWOpPGnQKcYlu3oLFAnACr-MurPSaOnB4jWC0o56UmOynZTey9LKFEZWiOes6fXniLeSDsbZhL/s1600/tt_i01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1ewDW33NUG62mAKrOXpz5XYwLJTudc8QARdXg-WkIaVqXJgZ1n8BdYoxE9scWOpPGnQKcYlu3oLFAnACr-MurPSaOnB4jWC0o56UmOynZTey9LKFEZWiOes6fXniLeSDsbZhL/s400/tt_i01.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEKQ9z76wmJ0LJWgjRKsl_2wi6ePfHakrfI25MO_Ygfe4TiDT3d_ki-T-q46mNduF3gvNsm3bGOR4Rn4vbUL5xRnepRKdHCPzdjH8vYUe2kvmhJNuV9ZfUUNujh9FTz7tIllru/s1600/tt_i02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEKQ9z76wmJ0LJWgjRKsl_2wi6ePfHakrfI25MO_Ygfe4TiDT3d_ki-T-q46mNduF3gvNsm3bGOR4Rn4vbUL5xRnepRKdHCPzdjH8vYUe2kvmhJNuV9ZfUUNujh9FTz7tIllru/s400/tt_i02.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfcWNtcSo0kdqW7Jy4NRRtFKsQQ_YyaUjqj3lN48t9kvcP63FfaCcxd-hzwbJSLcJTsPMuUoBsRMxt_T6CKsQQx8cNPCX3MupoPh6SXB9eOaAHWCiR1XGegf3u361LYEtQcYCN/s1600/tt_i03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfcWNtcSo0kdqW7Jy4NRRtFKsQQ_YyaUjqj3lN48t9kvcP63FfaCcxd-hzwbJSLcJTsPMuUoBsRMxt_T6CKsQQx8cNPCX3MupoPh6SXB9eOaAHWCiR1XGegf3u361LYEtQcYCN/s400/tt_i03.png" width="400" /></a></div>
<br />
Com isso você já renderizou seu modelo tridimensional. Você pode alterar algumas características do objeto que vai ser como por exemplo a posição em que o modelo será visualizado, na aba <b>View</b>. Nela você poderá definir 6 rotações a serem aplicadas no objeto em torno dos eixos X, Y e Z com os valores dos ângulos em graus. Pode-se marcar a caixa <b>Pré-Visualizar, </b>para ver como será exibido o objeto antes de renderizá-lo.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrCy2d60L56VyCubUMFKMUZGnZzutOe3o74cVBHEI1umThhpdmxjEA8F5VLvyfmqfGB86hY2w2ausjy9ZonjSwsiVOxw6Dltsf3NJqAkFXLE1OI53vcYXrbBu94_52MZ2tStlV/s1600/tt_i04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrCy2d60L56VyCubUMFKMUZGnZzutOe3o74cVBHEI1umThhpdmxjEA8F5VLvyfmqfGB86hY2w2ausjy9ZonjSwsiVOxw6Dltsf3NJqAkFXLE1OI53vcYXrbBu94_52MZ2tStlV/s400/tt_i04.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitNMVfIi4li58cRt9-1Yx25EuukauMWkT3XtQdf0hmEY1STENS0t9_CXoo6ddqQuculr27GSL_1Q5cDPLpiKOHn69oed6tb1wRy_Ueh8IG6MgNYx0sPtA9_HEmdScK6kMNM6p4/s1600/tt_i05.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitNMVfIi4li58cRt9-1Yx25EuukauMWkT3XtQdf0hmEY1STENS0t9_CXoo6ddqQuculr27GSL_1Q5cDPLpiKOHn69oed6tb1wRy_Ueh8IG6MgNYx0sPtA9_HEmdScK6kMNM6p4/s400/tt_i05.png" width="400" /></a></div>
<br />
E finalmente, pode-se definir o estilo do objeto a ser renderizado. Tem-se <b>Scaling factor, </b>para definir em que tamanho o objeto será gerado; <b>Fill color, </b>com opções <b>Red, Green e Blue </b>para alterar os valores RGB das faces do modelo tridimensional; <b>Stroke opacity </b>e<b> Stroke width </b>para definir a opacidade e largura das arestas, respectivamente. Pode-se definir a posição da luz em <b>Light X, Y e Z</b>, no caso do sombreamento do objeto ter sido habilitado na caixa <b>Shading.</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSPmNs1ndr-xPP7e5gUEL5qd_fH74wGuuK7_FWqphwsJCNGRtrOPlbmNSyZI2VUeNmxC1UzLkjTq-dCqiG4waHBF2gOPyGlxzdAMz1__IHgxGara-dDEaSjxhCWB4JYJbGWVO/s1600/tt_i06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSPmNs1ndr-xPP7e5gUEL5qd_fH74wGuuK7_FWqphwsJCNGRtrOPlbmNSyZI2VUeNmxC1UzLkjTq-dCqiG4waHBF2gOPyGlxzdAMz1__IHgxGara-dDEaSjxhCWB4JYJbGWVO/s400/tt_i06.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwmlO55fuyzRzqNVMxJ3NU6BLqNILSyH_L8Dv5Q510_fUkUu09ozUsfKclP6_rjhxZj-lbL8JP7xaC6Qp2TfhyRnfNVE5oziDYzimwYqXgDbOAcunkb512rC_C-iEaUvRx_5nI/s1600/tt_i07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwmlO55fuyzRzqNVMxJ3NU6BLqNILSyH_L8Dv5Q510_fUkUu09ozUsfKclP6_rjhxZj-lbL8JP7xaC6Qp2TfhyRnfNVE5oziDYzimwYqXgDbOAcunkb512rC_C-iEaUvRx_5nI/s400/tt_i07.png" width="400" /></a></div>
<br />
Depois disso, se quiser inserir mais informações sobre o objeto, basta seguir o <a href="http://pedepinico.blogspot.com.br/2012/05/latex-no-inkscape-com-textext.html" target="_blank">tutorial de inserção de Latex no Inkscape</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWC5lq9ql1TzgRNIFat_ptv0POMZswgmnuxFF29fqPoh1FzthFVdQCZNGhU9QwwRoQPphSkrIlM627kGnYCNgyoROCHU3Z-5w4VixLDlNo9BQicAtStDyhxlnD7oGztW1VpU8C/s1600/tt_i08.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWC5lq9ql1TzgRNIFat_ptv0POMZswgmnuxFF29fqPoh1FzthFVdQCZNGhU9QwwRoQPphSkrIlM627kGnYCNgyoROCHU3Z-5w4VixLDlNo9BQicAtStDyhxlnD7oGztW1VpU8C/s400/tt_i08.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Este é o fim da primeira parte. Para concluir, <a href="http://pedepinico.blogspot.com.br/2012/05/modelos-tridimensionais-no-inkscape-2.html" target="_blank">veja a segunda parte</a>.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-30654811857437147492012-05-09T21:46:00.000-03:002012-05-09T23:42:53.213-03:00The right tools for the right job<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbLCowTHgzn-h6WfTeUuCU3R1Hj-YMJYRIVKSHpjEths0powJtqVni12JDPmh3C6daGk7FQAv1SyKV9MTOYFx_GQouKieLg8u_hroQyVx8ghyLp42KONehUX0Ivxlb96ryKapc/s1600/09052012095.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbLCowTHgzn-h6WfTeUuCU3R1Hj-YMJYRIVKSHpjEths0powJtqVni12JDPmh3C6daGk7FQAv1SyKV9MTOYFx_GQouKieLg8u_hroQyVx8ghyLp42KONehUX0Ivxlb96ryKapc/s400/09052012095.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Last year I bought a Wacom Bamboo tablet to enjoy my free time studying some digital art with Krita and MyPaint. I lent it to my girlfriend for a few months after 2011 Christmas so she could have some fun too. Angela was here in Natal last week (while the Lakademy was happening in Porto Alegre, south of Brazil ) and she brought it back. I askd her to bring it to me so I could use it while I am working in my GSoC project.<br />
<br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEbO9rQw_366Fq6xEFKLTilE3FhV9B6GEiI81GyThvn7eL6pUQlQ20YddLZllFGIPXkk0Jcnpn-6kxv69vpOnA38QVgocRYbScYNI-B6tAX5ixzYyD3Vc2cJI08T2BO1ZzMX8g/s1600/05052012094.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEbO9rQw_366Fq6xEFKLTilE3FhV9B6GEiI81GyThvn7eL6pUQlQ20YddLZllFGIPXkk0Jcnpn-6kxv69vpOnA38QVgocRYbScYNI-B6tAX5ixzYyD3Vc2cJI08T2BO1ZzMX8g/s400/05052012094.jpg" width="400" /></a></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://d3-04.twitpicproxy.com/photos/large/369685026.png?key=9131030" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://d3-04.twitpicproxy.com/photos/large/369685026.png?key=9131030" width="283" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">just a test i made when Krita 2.4 was still in Alpha 3</td></tr>
</tbody></table>
<br />
It takes some time to get used to this kind of input device but after that it's really fun to do things with it. I really love drawing, but the reason why I bought a tablet was that my painting skills it's quite low. I get jealous very easily from <a href="http://www.davidrevoy.com/2-portfolio.html" target="_blank">other artists works</a>.<br />
Anyway, another point: Angela bought my Qt4 book too, since I had left it in Teresina after I moved to Natal.<br />
<br />
I am not a KDE (not even a Qt ) experienced programmer, so the book will help a lot in some things I am doing. For instance, I corrected some points in my granular particles simulation and now I have some right values in it's output. Although some errors persists, I got some key values right. It's just some numbers in a text file, but as soon I eliminate some Batman lyrics (NaNs are one of my nightmares), the next step it's to pass the generated values to a sequence of QImages and see if the particles got the right pixels and the right movements.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOy2e_ZVZcgYWwYHmZ4VzHVlWZqLSxsgFvq2Z1wah0xWLI8O3RbM9Su7XM6KzekqpORSMrTyottDB8OhQ509TBO6DAhDQj76JBerY32hvujBfxXMn1mrUYSPXsMrlUZKO2dvKr/s1600/mulher+1.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOy2e_ZVZcgYWwYHmZ4VzHVlWZqLSxsgFvq2Z1wah0xWLI8O3RbM9Su7XM6KzekqpORSMrTyottDB8OhQ509TBO6DAhDQj76JBerY32hvujBfxXMn1mrUYSPXsMrlUZKO2dvKr/s400/mulher+1.jpeg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">a speed painting Angela made with my wacom</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
As I said in previous posts, this project it's not a easy one. It requires a real-time approach to a not so common particle type. The simulation I did have some serious performance drawbacks. For just a few particles (200 particles in the data set randomly initialized and distributed in a euclidean plane of size 100x100 units) the simulation takes almost 3 minutes to run 1000 steps, with a few wrong outputs !! It's a really bad result.<br />
<br />
After that, I gathered a handfull of books related to the topic. Physics and engineering are the fundamentals, but a real-time approach it's the more important feature in the project. I got a book with my university advicer about real-time collision detection in the hope that it will help me do a better job in this simulation.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsosnjrFiN-ds6Jar2T8AXblxQieYa4axj9VJNxc3Y698GVfTlLwJSvcExrp7NuvvruRGGiNhErtikXEEm4VUrVWzHiQIBSE0RwHvvvFTJ_2Alz2uTtt6u0LcKa2Nomrv5iMLK/s1600/09052012097.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsosnjrFiN-ds6Jar2T8AXblxQieYa4axj9VJNxc3Y698GVfTlLwJSvcExrp7NuvvruRGGiNhErtikXEEm4VUrVWzHiQIBSE0RwHvvvFTJ_2Alz2uTtt6u0LcKa2Nomrv5iMLK/s400/09052012097.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Real-time collisions, linear algebra, engineering math and Qt/C++ : the tools for the job</td></tr>
</tbody></table>
Another point is that I'm thinking of trying to see the actual state of it using a OpenCL approach. I have access to a relative good computer in the university: a i3 intel processor with 4Gb of RAM with a NVidia graphics board. With that, what need to be done it's some self-training in this tecnology. I never coded in OpenCL before and the talk around here is that it's really hard. I check it out with a few OpenCL tutorials and I have to agree with the guys: it's really tough. A simple hello world pass through all kinds of concepts, from context creation, through devices association to kernel programming. Fortunately, I found a few books about it too.<br />
<br />
Anyway, if you want to check it out the actual state of my simulation, the repository is hosted in my <a href="http://gitorious.org/granular_sphere_particles" target="_blank">gitorious account</a>. I did not allowed merge requests since the code it's quite unstable, but it's well commented and have some references if you want to understand it better. I'm already writting another post with the theory behind the simulation, doing a more extensive and well detailed explanation of the concepts (some few drawings and formulas for our enlightment :)<br />
<br />
Until next round!Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com5tag:blogger.com,1999:blog-32131971.post-86302392408672593882012-05-05T20:12:00.002-03:002012-05-07T16:00:39.051-03:00A little understanding on Krita's structureThis last thursday Boudwewijn schedule a skype chat group to present the main concepts of the Krita development. It was really nice, since a more dynamic interaction was made with the students. It answered some doubts I had and important features was explained. It covered from the KDE and Calligra foundation of Krita to dockers and resource management of the software.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5KYih2iG7ycISUnr7O8BDE6LMSCMTPSpdG5YslMqzMGgvM4pAn2vDw6yPZePHwELinLaT4wW91t9w42fb6ubmnMvID6dqHJ1k1hj34kgKbeZrhctcoJqwChDUODB5XLYzBzNR/s1600/krita_pres.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="229" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5KYih2iG7ycISUnr7O8BDE6LMSCMTPSpdG5YslMqzMGgvM4pAn2vDw6yPZePHwELinLaT4wW91t9w42fb6ubmnMvID6dqHJ1k1hj34kgKbeZrhctcoJqwChDUODB5XLYzBzNR/s400/krita_pres.png" width="400" /></a></div>
<br />
<br />
<br />
I am posting here a few notes about what I got from it and some notes on how I imagine some of these will affect directly in my project. If any concept that I wrote here is wrong, please, leave a comment correcting me. This would be really helpful and more than welcome!<br />
<br />
<a name='more'></a><br />
<h4>
Color Management</h4>
<div>
<br /></div>
I am familiar with color models concept, but not so familiar with <a href="http://en.wikipedia.org/wiki/Color_space" target="_blank">color spaces</a>. This was a good point in the presentation. It clarified to me that I do not have to worry about how to deal with these spaces since the color management libraries take care of it. Although I have some interest to understand how to manage colors, I think I will have to leave that for another time.<br />
<br />
<h4>
Tiles</h4>
<div>
<br /></div>
Krita tiles was a really new concept to me. After you talk about the advantages of divide the pixels in groups, it makes sense and we question ourselves why we didn't though about that before. Dmitry posted in the mail group a nice <a href="http://www.valdyas.org/~boud/krita_tiles_engine.pdf" target="_blank">article</a> about the Krita tiles. I believe I have to take some time to discuss this point with him. In my project I'll deal with a considerable amount of particles so a full understaning on this framework will garantee a better performance of the brush. In one of the books I'm reading, a improvement in the grain interactions performance is done with the division of the space in tiles, although is suggested to divide the 2D region or in uniform <a href="http://en.wikipedia.org/wiki/Voronoi_diagram" target="_blank">Voronoi tiles</a> or in a <a href="http://en.wikipedia.org/wiki/Hexagonal_tiling" target="_blank">hexagonal grid</a>. I think that in a general way, the effects are the same for the application, so the tile form doesn't play a mean role.<br />
<br />
<h4>
Data Structure and Image composition</h4>
<br />
This was one of the trickiest definitions of the presentation. In a program like Krita, which have a big amount of processing and operations done at pixels, it's expected that we should have a not so straightforward data structure.<br />
<br />
The base class of the image components is the KisBaseNode class. It takes care of other nodes, layers and selections of the image. However this class do not have anything to do with its peers. For that, we use a KisNode, which is the parent class for Layers and Masks. Along with that, every node has a representation of it, which we call the <i>Projection</i><b> </b>of that node. It's a rendered result of the layer, with the processed data applied. For the composition of the final image result, a multithread structure is behind each node. Then to produce the result in the parent node, the <i><b>setDirty </b></i>method will pass through all the way up to it.<br />
<br />
I don't know if in the future I will need to modify or create a new layer type since the feeling of live sandpainting would need a lot of updates in the canvas. I asked that in the chat group and probably I will not need to do it. For instance, the closest feature in Krita that deals with this kind of painting is the Deform Brush. It modifies the closest pixels several times and updates the canvas after each mouse movement, so it's more or less what I wanted.<br />
<br />
<h4>
Canvas and Tool Handling</h4>
<br />
The canvas take care of the user interaction through mouse, keyboard and tablet, paints the decorations and the visible image results. It has two implementations: one based on OpenGL and another based on QPainter. I had to look directly on the code to understand this better, but i think the main reason to have two implementations is that if the user have OpenGL on his/her computer, a better perfomance widget can be used. Otherwise, the QPainter based canvas will be used. Both classes inherit from KisAbstractCanvasWidget, so both has to have the same event handling.<br />
<br />
When we modify something with a tool, the canvas have a Tool Proxy, which manages the current tool. So, when we change from some tool to another, the native events are mapped to the newly chosen tool. Then, when the tool does a operation, it requires a canvas update so the user can get the result.<br />
<br />
<h4>
Painting</h4>
<br />
I didn't have much trouble to understand this point. Pentalis helped me a lot in this part. I even made a simple paintop modifying one of the paintops plugins in the source code. The Chalk Brush have a simple implementation and it was easy to understand the code and modify it. Most of my doubts in doing it was in the underlying structure, like how paint devices and layers worked together, but the presentation answered most of it.<br />
<br />
<h4>
Filters, Resources, Imports and Exports</h4>
<br />
These features wasn't so hard to understand. Filters have the usual concept and is applyed in a multi-threaded stateless way. It is implemented as plugins in Krita. Imports and Exports use the KoFilter class as base of the implementation and invokes KoFilterChain to do the sequence of operations to complete the conversions. Resources are managed using KoResourceServer and manages resources of one type at a time. To represent the resource itself we use a KoResource as base class.<br />
<br />
<h4>
That's it</h4>
<br />
This was what I got from the presentation. I have some notes about other questions that came after, but I believe that I have to write it with more visual details to a full undestanding about what I'm working on. My particle simulation didn't work as I was expecting and I have to spend some time debugging it. Pentalis suggested that, after the simulation is working, I write the positions updates in QImages so we could have the visual feel of the particles moving. After that, I have to formulate how I will do this visual feeling in Krita, but I believe that with this brief background I will be able to do it.<br />
<br />
See you later!<br />
<pre class="fragment"></pre>Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com4tag:blogger.com,1999:blog-32131971.post-48695903081785620802012-05-04T11:48:00.002-03:002012-05-04T11:48:29.898-03:00LaTeX no Inkscape com TexTextAno passado fiz uma série de relatórios em LaTeX e a maioria se utilizou de imagens em extensões <i>png </i>ou <i>jpg, </i>que são bastante úteis para mostrar saídas de processamento de imagens do tipo raster em operações de visão computacional.<br />
<br />
Recentemente nas minhas aventuras no LaTeX me deparei com o problema de desenhar ilustrações para os meus textos, mais especificamente com o problema de colocar fórmulas em algumas imagens dos textos. Nunca senti tal necessidade antes. Além disso, vi que a utilização de gráficos vetoriais em textos escritos em LaTeX melhoram a visualização de detalhes da saída de alguns algoritmos.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhX8etH8kp8Jaiofm7uFNK-R1UCY50okb_-fj8DMjWdWpzGSt6E-X_hVWg2AxYCWNuEz7xvvS6nPkaH33CulH5Dr2H267qUYHXY3wMFPku4FHOfMAHfS_xyk0ep6uII59Dx-OW/s1600/textext_blender.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhX8etH8kp8Jaiofm7uFNK-R1UCY50okb_-fj8DMjWdWpzGSt6E-X_hVWg2AxYCWNuEz7xvvS6nPkaH33CulH5Dr2H267qUYHXY3wMFPku4FHOfMAHfS_xyk0ep6uII59Dx-OW/s400/textext_blender.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
Em uma breve pesquisa, achei uma interessante extensão para o Inkscape chamada <a href="http://pav.iki.fi/software/textext/" target="_blank">Textext</a> em que você escreve seu texto usando o padrão do LaTeX de <i>tags </i>de marcação de texto.<br />
<br />
<a name='more'></a><h4>
Usando o Textext para escrever fórmulas </h4>
Supondo que o LaTeX já está instalado, instale também os pacotes <i>pdf2svg </i>e <i>pstoedit. </i>Então<i>, p</i>ara instalar o Textext, <a href="http://pav.iki.fi/software/textext/textext-0.4.4.tar.gz" target="_blank">baixe</a> o pacote e descompacte-a na sua pasta de extensões <i>~/.config/inkscape/extensions.</i><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0qvEoaDLDXqinFVcBeipiPKa5yR27oC986UEBnThCPmbPYPrtP7EmUzQrZNbDWzB51lA25NY6M1M1TQ-bBi-EB62VEisk6dEF6sf44PEL8mqYDjgWLGVVqxW8o6NfsBYJYPeY/s1600/textext0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0qvEoaDLDXqinFVcBeipiPKa5yR27oC986UEBnThCPmbPYPrtP7EmUzQrZNbDWzB51lA25NY6M1M1TQ-bBi-EB62VEisk6dEF6sf44PEL8mqYDjgWLGVVqxW8o6NfsBYJYPeY/s400/textext0.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">O plugin está descompactado na pasta oculta de configurações do Inkscape:<br /><b>~/config/inkscape/extensions</b></td></tr>
</tbody></table>
<br />
Ao iniciar o Inkscape após essa operação o <i>plugin</i> está em <b>Extensões > Textext. </b>Com isso, uma caixa de diálogo será aberta com as opções de escolher o arquivo de pre-ambulo para o LaTeX, o fator de escala do texto e o texto em si:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij-AuYMRtOYzi7LoVVCU801yntxN2-N0V-dS6io_cJh2D7d5ZkUKGTx5Ie8KiFVN-kDtG4yCrRbp7AIbkubdenUsfIngJwm_FkRVv0DVWy-P1mPWGKgUxJ4qJ4Qp_DjeJAOFbX/s1600/textext1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij-AuYMRtOYzi7LoVVCU801yntxN2-N0V-dS6io_cJh2D7d5ZkUKGTx5Ie8KiFVN-kDtG4yCrRbp7AIbkubdenUsfIngJwm_FkRVv0DVWy-P1mPWGKgUxJ4qJ4Qp_DjeJAOFbX/s400/textext1.png" width="400" /></a></div>
<br />
<br />
Após esse passo, basta clicar em <b>OK </b>e,se o texto escrito estiver com a marcação correta, será renderizado.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5rAiFJWvN_va7oY0fxLej5iDluaP2gKn_Rw0qotdf35CpfhsQj843DcVjgKZ-4XVz8Slf8NZfnT2p-z5S086P3spaIy8z4hkjcjmYkgYP2HPnUGQSw_wEzyl5W7BFblFVBJ8X/s1600/textext2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5rAiFJWvN_va7oY0fxLej5iDluaP2gKn_Rw0qotdf35CpfhsQj843DcVjgKZ-4XVz8Slf8NZfnT2p-z5S086P3spaIy8z4hkjcjmYkgYP2HPnUGQSw_wEzyl5W7BFblFVBJ8X/s400/textext2.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
De gancho, estou escrevendo mais um tutorial sobre como usar o Blender para modelar gráficos e exportá-lo para o Inkscape. Assim pode-se usa-los em textos escritos no LaTeX ( que na verdade é a minha intenção) ou mesmo editá-los para trabalhos de design.<br />
<br />
Por enquanto é só. :)<br />
<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com3tag:blogger.com,1999:blog-32131971.post-32755747177393413032012-04-30T17:24:00.000-03:002012-04-30T17:26:12.878-03:00Introdução ao Blender 2.5 : SlidesEste fim de semana eu ministrei um minicurso introdutório de Blender 2.5 no <a href="http://softwarelivre.org/flisol-parnamirim" target="_blank">Flisol-Parnamirim</a>. Deu um público interessante e gente interessada, mas infelizmente não consegui atingir meu principal objetivo no curso que era fazer @s alun@s criarem um modelo completo, desde modelagem, passando por textura e indo para renderização.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBPsFrfg-7QFfavOn4S8YlX50MIE2Lw5yBNNNzOASnCtzNueK83KE_QuBioJpxrOku1J810bA8bXL7yK_XMoC49Yo-h0-bxhGUzkujbJY2P4lY8bKlga1dTAxnz5IeAD1TYIrk/s1600/bl_tu294.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="219" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBPsFrfg-7QFfavOn4S8YlX50MIE2Lw5yBNNNzOASnCtzNueK83KE_QuBioJpxrOku1J810bA8bXL7yK_XMoC49Yo-h0-bxhGUzkujbJY2P4lY8bKlga1dTAxnz5IeAD1TYIrk/s400/bl_tu294.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<a name='more'></a><br /><br />
Em parte a culpa é minha, pois o que era pra ser um minicurso, acabou como algo que precisaria de no minimo dois dias para terminar devidamente. Como se sabe, a curva de aprendizado de softwares de modelagem e animação 3D não é a mesma para os demais softwares gráficos, então foi algo meio sem noção da minha parte colocar algo tão denso para um curso de 4h.<br />
<br />
Mas enfim, estou disponibilizando os slides neste <a href="https://www.dropbox.com/s/bc2putfo9ry4ooj/presentation.pdf" target="_blank">link</a>. Eu irei melhora-los assim que puder, pois precisa-se de instruções e passos mais descritivos de uma etapa para outra. São mais de 300 slides com o passo-a-passo das ações a serem tomadas nos itens da interface. Qualquer duvida poste nos comentários deste post. :)<br />
<br />
Novas versões do tutorial serão postados aqui, então fiquem de olho. :)Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-15668626510321072112012-04-28T10:04:00.000-03:002012-05-07T16:03:22.112-03:00Spread ALL the sand in the GSoC 2012Hello Fellows!<br />
<br />
It's kind of late, since the result came this Monday, but I want to notify that my <a href="http://www.google-melange.com/gsoc/project/google/gsoc2012/chicao/15001" target="_blank">proposal</a> was accepted for this year Google Summer of Code! :D<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCHsXEuuagc65kZpvX8FnKiIFItN-T6UeMJt85arE67f5x0qD8utWU5aae30K7mWxqrt3QvLJo5ZM63dtMJ4tQuhGJ1v5hhsEBRbu0WHoagmgi13wURFoC_fdzQJDbUoKlHsw5/s1600/230527.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCHsXEuuagc65kZpvX8FnKiIFItN-T6UeMJt85arE67f5x0qD8utWU5aae30K7mWxqrt3QvLJo5ZM63dtMJ4tQuhGJ1v5hhsEBRbu0WHoagmgi13wURFoC_fdzQJDbUoKlHsw5/s400/230527.jpg" width="400" /></a></div>
<br />
<br />
<br />
Krita have a lot of awesome brushes, whose is fun to play with (checkout <a href="http://forum.kde.org/viewforum.php?f=138" target="_blank">this</a> KDE forum thread to see the works that artists have done using it), so I wanted to do something that could be a nice new feature. Then, I proposed a sandpainting brush for Krita.<br />
<br />
<br />
<a name='more'></a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/k43xQ7VfmTQ?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
After I saw some videos of this type of art, I was a bit lost of how I could accomplish such a beautiful effect on a canvas. I searched through the web about similar effects and particle system in game engines is the closest concept. However, most particle systems do not deal with the singularities of granular particle system. Sometimes sand acts like fluids and sometimes acts like a deformable solid. So sand simulation it's not very similar to particle systems used to simulate fluids like water.<br />
<br />
But eventually, I found the exact concept that I was looking for : computational granular dynamics, used in the simulations and predictions of avalanches, land slides and general powder technology. So, after some papers and books chapters I got the idea to develop the project: simulate sand particles usind a <a href="http://en.wikipedia.org/wiki/Discrete_element_method" target="_blank">discrete element modelling</a> based particle layer. It's not a easy task, since the real time aspect of the sand spreading movement it's crucial, but I believe that with some problem relaxations I could make this work in the due time. :)<br />
<br />
Soon enough I will show some results in simulations that I've been doing. Not much visual results but it's something.<br />
<br />
Until next time!<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-82198035138287405552012-04-13T17:46:00.001-03:002012-04-13T18:27:11.615-03:00const correctness em C++: Substituição de valorUma das coisas que sempre me pegam quando vou ler um código C++ é pegar uma declaração desse tipo:<br />
<br />
const Classe * point = new Classe();<br />
<br />
No meu entender, a palavra-chave <b>const </b>sempre teve aquela função em C de declarar uma variável sem se utilizar de valores definidos no pré-processador<br />
por exemplo, quando a gente usa um <b>#define CONSTANTE</b>. De fato, o propósito<br />
original de <b>const </b>foi exatamente substituir o <b>#define.</b><br />
<b><br /></b><br />
<b>const </b>é uma palavra que em C++ foi ampliada em diversos usos e quero nos próximos posts ir relatando minha compreensão quanto a ela. Essa primeira parte é relativa a constantes de fato, substituição de valores (mais específicamente <i>constant folding</i>) e tipos de linkagem.<br />
<br />
<br />
<a name='more'></a><br />
<br />
<h4>
const para constantes</h4>
<br />
<b></b>Quando você define um valor no pré-processador, o compilador não tem acesso a tipagem, logo corre-se o risco de ocorrer bugs sutis, muito difíceis de achar.<br />
<br />
<br />
Por exemplo, em<br />
<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 35px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">#define BUFFER 100
</pre>
</div>
<br />
BUFFER vai se comportar na maioria das vezes como uma variável qualquer. No entanto isso não é assegurado, sem falar no problema de tipagem, já que não se sabe o que foi definido, um <i>float, double ou int</i>. Agora, usando const,<br />
<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 35px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">const int buffer = 100;
</pre>
</div>
<br />
pode-se usar <b>buffer </b>em qualquer lugar onde o compilador tem acesso. Com isso o compilador irá guardar o valor na tabela de simbolos e substituir na constante, caracterizando o <i>constant folding.</i> em que o compilador irá reduzir uma expressão de constante complicada para uma mais simples, apenas fazendo alguns cálculos em tempo de compilação.<br />
<h4>
const em cabeçalhos (headers)</h4>
Dar preferência a <b>const </b>em<b> </b>vez de <b>#define</b> nos leva a questionar o seu uso em arquivos de cabeçalho. <b>const </b>em C++ tem linkagem interna, por padrão. Isso significa que uma constante definida por ela é visível apenas no arquivo em que foi definida. Assim, deve-se sempre atribuir um valor a uma variável caracterizada como <b>const, </b>já que em linkagem interna não se pode apenas declarar valores, deve-se defini-las com algum valor.<br />
<b><br /></b><br />
Uma exceção a isso é o uso de <b>extern</b>, em que define explicitamente que uma variável tem linkagem externa e com isso terá um espaço alocado para armazenar o valor (normalmente os compiladores evitam armazenar <b>const</b>s em memória, deixando guardada a definição na tabela de símbolos).<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 35px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">extern const int buffer;
</pre>
</div>
Com esse valor definido como linkagem externa, outros arquivos terão visibilidade da variável <b>const. </b><br />
<b><br /></b><br />
O motivo de <b>const </b>ser definida como linkagem interna por padrão é que o linkador não irá tentar interligar definições de <b>const </b>em vários arquivos, evitando colisões. Se fosse externa, memória seria alocada, gerando conflitos de nomes no linkador.<br />
<br />
<h4>
consts seguros </h4>
<div>
Quando um valor é produzido em tempo de compilação e você sabe que esse valor não irá mudar ao longo do programa, o <b>const </b>para previne possíveis alterações nesse valor. No exemplo a seguir, em que define-se vários tipos de <b>const</b>s<b>, </b>a variável const <i>'c'</i><b> </b>na função <b>main() </b>recebe um valor de entrada em sua definição, onde não será mais possível altera-la ao longo da função, sendo assim caracterizada como uma constante de tempo de execução.</div>
<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 625px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 500px;">#include <iostream>
<iostream>using namespace std;
<iostream>const int i = 100; // constante tipica </iostream>
<iostream>/*
* por ser definida a partir de outra constante, j irá ser
</iostream> * armazenada na tabela de simbolos, como uma constante típica
*/
const int j = i + 10;
<iostream>//essa linha força a alocação de j por requerer seu endereço </iostream>
<iostream>long address = (long) &j; </iostream>
<iostream>//como o compilador reconhece j como const, pode-se utiliza-lo</iostream>
<iostream>//para definir o tamanho de buf </iostream>
<iostream>char buf[j + 10] ; </iostream>
<iostream>int main(){ </iostream>
<iostream> cout << "insira um caractere ";
</iostream>
<iostream>// como o valor da constante 'c' é definida em tempo de execução </iostream>
<iostream>// será necessário alocar valor na memória (como em C), ao invés </iostream>
<iostream>// de armazenar numa tabela de símbolos. </iostream>
<iostream>const char c = cin.get();
</iostream><iostream>const char c2 = c + 'a'; </iostream>
<iostream>cout << c2; </iostream>
<iostream>}</iostream>
</iostream></pre>
</div>
<div>
Na prática, se um valor não deve mudar deve-se declará-lo com um const. Desta forma ocorre melhora de desempenho na prevenção leitura e escrita na memória, precisando apenas fazer o <i>constant folding </i>do compilador.<br />
<br />
<h4>
Diferenças em relação ao C</h4>
</div>
<div>
Em C, <b>const </b>tem linkagem externa por padrão, daí<b> </b>sempre ocupa espaço de memória. Trocando em miúdos, uma declaração <b>const </b>é<b> </b>variável comum que não pode ser modificada ( ao contrário de C++ em que é guardada na tabela de símbolos e ocorre <i>constant folding</i>). Com isso, uma declaração do tipo:<br />
<br />
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 55px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">const int bufsize = 100;
char buffer[bufsize];
</pre>
</div>
<br />
não é permitida em C. Por ser armazenada em algum lugar, <i>bufsize </i>teria que ser tratada como constante de tempo de compilação, o que não ocorre em C. Por isso o compilador não irá saber o valor de bufsize, já que estará em memória e não será acessivel em tempo de compilação. A alternativa seria<br />
<br />
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 55px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">const int bufsize;
</pre>
<br />
Já em C++, a declaração acima é invalida, pois está declarando uma variável <b>const</b><b style="font-style: italic;">, </b>mas não está definindo: toda variável declarada como const deve ser inicializada em C++, devido a linkagem interna. Para apenas declarar esta variável, em C++ deve-se usar <b>extern,</b><br />
<b><br /></b><br />
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 30px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">extern const int bufsize;
</pre>
<br />
indicando ao compilador que a linkagem foi definida como externa.<br />
<br />
Como em C++ não se cria espaço para armazenamento para <b>const</b>, a visibilidade é apenas no arquivo declarado. Por exemplo, se um const é definido fora de qualquer função/método seu escopo é o arquivo declarado. Isso difere de outras variáveis de C++ e de <b>const</b> em C. Assim, se for desejável ter acesso em outros arquivos de uma constante definida, deve-se declará-la como <b>extern,</b><br />
<div>
<br /></div>
<div>
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 35px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">extern const int y = 20;
</pre>
</div>
<br />
isso força alocação de y, mas previne o <i>constant folding</i> de uma constante em C++.Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-48644551089355804942012-04-12T10:15:00.001-03:002012-04-12T18:54:47.013-03:00Krita 2.4 Lançado!Finalmente é lançado o Krita 2.4, primeiro release realmente pronto para uso por artistas profissionais. Ja faz um tempo que acompanho a lista dos desenvolvedores e os caras colocaram muito esforço em cima dessa versão. Estabilidade foi a principal delas, resultando numa aplicação bastante agradável de se produzir.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.plazmazone.com/wordpress/wp-content/uploads/2011/12/Afoutain7201.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://www.plazmazone.com/wordpress/wp-content/uploads/2011/12/Afoutain7201.png" width="271" /></a></div>
<br />
<br />
<a name='more'></a><br /><br />
As principais melhorias foram a integração de novos pincéis, aumento no desempenho do programa, pintura espelhada (gera-se cópias refletidas da pincelada feita em um ou mais eixos definidos no <i>canvas ), </i>melhoria<i> na </i>sensibilidade de pressão via <i>tablet, </i>compartilhamento (usando as funções do desktop semântico Nepomuk ) e <i>Quick access wheel </i>(acessar de maneira mais ágil as ferramentas favoritas do artista).<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZZBDqfGeV6NbhWHcA5FkxnmKxMSC4AdewzVAjJn67flYXilHiyc8Hpe-jzKs1LU-5-QfgPs5YOfOpRbeZ2zDizZdGOVXRS63HcRWX3GYovkerk2dkBwyyH27wFKBov__0d49z/s1600/krita.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZZBDqfGeV6NbhWHcA5FkxnmKxMSC4AdewzVAjJn67flYXilHiyc8Hpe-jzKs1LU-5-QfgPs5YOfOpRbeZ2zDizZdGOVXRS63HcRWX3GYovkerk2dkBwyyH27wFKBov__0d49z/s400/krita.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Quick-access wheel</td></tr>
</tbody></table>
<br />
Também tem um <a href="http://heap.kogmbh.net/downloads/calligra_windows/calligra_2.3.92.5.msi" target="_blank">instalador experimental para Windows</a> do Calligra em que o Krita esta integrado, mas é ainda o RC 2. Caso alguém se aventure por lá, dá um feedback aqui ;).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://fc07.deviantart.net/fs70/f/2011/355/6/0/sketch1_by_artsymptom-d4jsqah.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://fc07.deviantart.net/fs70/f/2011/355/6/0/sketch1_by_artsymptom-d4jsqah.jpg" width="257" /></a></div>
<br />
<br />
Para mais informações, <a href="http://krita.org/about-krita-2-4.pdf" target="_blank">tem este PDF</a> com descrição completa das novas funcionalidades e este <a href="http://forum.kde.org/viewforum.php?f=138" target="_blank">tópico no fórum do KDE</a> com produção artística, pra se<br />
ter ideia do que o programa é capaz.Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-12793307915498558532012-04-12T01:45:00.000-03:002012-04-12T01:45:19.413-03:00"Botões demais", uma ilustração<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPCIqjk4H1KhZ1lrV4-b9_eNmZt1j8fZ4Se6AMFLafJRj571kW67xLknNigt0hxtza-fDE59oZ9c_Si5lVknUZVsa5rsVqlB1VLfapxU8rOn_Zz9sf1X3rzfqUtadV-OKQ9a6h/s1600/12042012081.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPCIqjk4H1KhZ1lrV4-b9_eNmZt1j8fZ4Se6AMFLafJRj571kW67xLknNigt0hxtza-fDE59oZ9c_Si5lVknUZVsa5rsVqlB1VLfapxU8rOn_Zz9sf1X3rzfqUtadV-OKQ9a6h/s640/12042012081.jpg" width="448" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">"Botões demais": como estou sem <i>scanner</i>, tirei uma foto pelo celular.<br />Quando puder escanear, atualizo a imagem.</td></tr>
</tbody></table>
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com2tag:blogger.com,1999:blog-32131971.post-20739647485556306432012-04-07T07:17:00.003-03:002012-04-12T18:56:37.548-03:00Curtas pra santa semana: brazucas<div class="separator" style="clear: both; text-align: left;">
Hoje fiz uma seleção de curtas brasileiros que eu ando assistindo desde o começo do ano. Alguns são muito bons. Outros tem uma boa ideia mas a técnica ainda deixa a desejar. Boa parte está hospedada no Youtube, por isso a qualidade não está das melhores. Mas vale a pena dar uma olhada no que o pessoal está produzindo. Só mostra que a gente tem um potencial enorme pra animação, só ta faltando os canais. :)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/EoiRKsbu3FM?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<a name='more'></a><br /><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/bh5GtyP0PK4?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/38517986?color=ff9933" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/7727630" webkitallowfullscreen="" width="450"></iframe>
</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/2qU1Utp-03Y?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/AhhYfl-ehIk?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/qLTzbfopMmE?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/XsAzz-YG8H8?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/cs5C5MdAIuM?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br /></div>Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-53593974256861080512012-04-06T08:31:00.001-03:002012-04-12T18:56:56.487-03:00Curtas pra santa semana.Fiz uma seleção de curtas que achei por ai na web. Queria colocar só 2D, mas como a safra anda dando preferência maior a 3D, alguns ai escaparam da restrição. Enfim, foram filmes que achei interessantes de maneira geral. Vale a pena tirar um tempim do feriadão pra curtir.<br />
<br />
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/39056960?autoplay=1" webkitallowfullscreen="" width="450"></iframe><br />
<br />
<a name='more'></a><br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/35696200?portrait=0&color=c9161f" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/39659731?title=0&byline=0&portrait=0&color=ff9933" webkitallowfullscreen="" width="450"></iframe><br />
<br />
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/39408892?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/16775883?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/38662605" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/38353167" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/11077331?color=ff0179" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/23354345?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="450"></iframe></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="300" mozallowfullscreen="" src="http://player.vimeo.com/video/38442550" webkitallowfullscreen="" width="450"></iframe></div>Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-58467985740950777272012-04-03T08:43:00.000-03:002012-04-12T18:57:17.170-03:00Dica: Entrada e saida em C++ via bash : cin e coutAs vezes é preciso passar uma quantidade considerável de entradas para um programa e as vezes é moroso passar por funções internas de leitura e escrita de arquivos. Em C++ por exemplo, tem-se a biblioteca <fstream> para lidar com leitura de <i>streams </i>de arquivos.<br />
<br />
<a name='more'></a><br /><br />
Para facilitar a escrita e leitura, o bash pode simplesmente passar e receber saidas através das funções cin e cout. Por exemplo, supondo alguns <b>for</b>'s que possuem a seguinte estrutura de entrada e saida:<br />
<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 520px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;"> cin >> instancias;
for(int i = 0; i < instancias; i++){
cin >> n_reunioes;
for(int j = 0; j < n_reunioes; j++){
cin >> start_t >> stop_t;
reuniao r (start_t, stop_t, j+1);
reunioes.push_back(r);
}
dias.push_back(reunioes_para_ir(reunioes));
reunioes.clear();
}
for ( int i = 0; i < instancias; i++ ) {
for ( int j = 0; j < dias[i].size(); j++ ) {
cout << dias[i][j] ;
if ( j != dias[i].size() - 1 )
cout<< " " ;
}
cout << endl;
}
</pre>
</div>
Supondo um arquivo <b>entrada.in, </b>posso organizar minha entrada nele da seguinte forma:<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 250px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">103
3
08:15 08:45
08:00 08:30
08:30 09:00
5
11:00 12:00
12:20 13:15
10:10 12:15
12:30 13:00
10:30 12:16
</pre>
</div>
<br />
e passa-lo com esses valores como argumento para a entrada e indicar um outro arquivo para a saída :<br />
<div style="margin: 5px 20px 20px;">
<pre class="alt2" dir="ltr" style="border: 1px inset; height: 34px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 450px;">$./programa < entrada.in > saida.out
</pre>
</div>
Com isso, o bash cuida de passar os valores no arquivo de entrada para cada pedido do <b>cin </b>e escrever a saida para o <b>cout </b>sem muito estresse. :)<br />
<br />
Esta dica foi baseada <a href="http://www.alecjacobson.com/weblog/?tag=bash" target="_blank">neste</a> post. La tem mais dicas, como por exemplo, utilizar o pipe ( | ) para passar entrada, já que o pipe é bem mais robusto que '<' ou '>'.Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0tag:blogger.com,1999:blog-32131971.post-22821029678225853762012-04-01T08:00:00.000-03:002012-04-12T18:57:38.978-03:00Códigos de Visão Computacional com C++ e OpenCvSemestre passado paguei uma disciplina de Visão Computacional aqui no mestrado. Disciplina bem interessante, com assuntos variando de conhecimento introdutório de processamento de imagens a interação com elementos robóticos.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://d1-02.twitpicproxy.com/photos/large/444269161.jpg?key=750502" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="266" src="http://d1-02.twitpicproxy.com/photos/large/444269161.jpg?key=750502" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Imagem de uma coruja com os filtros de Frei-Chen aplicados.</td></tr>
</tbody></table>
<br />
<a name='more'></a><br /><br />
Foi uma das disciplinas mais puxadas do mestrado, com trabalhos de implementação semanais exigindo entrega de relatórios justificando teoricamente o que foi feito e os resultados obtidos ao longo dos experimentos. No entanto foi uma das disciplinas mais empolgantes que paguei aqui na UFRN. Os laboratórios de robótica tem vários projetos em andamento, como futebol de robôs, visão estereoscópica e um sistema de voo de quadricópteros. Interagir com o pessoal que estava tocando esses trabalhos foi de um aprendizado sem igual.<br />
<br />
<a href="http://gitorious.org/visaocomputacional" target="_blank">Eu estou disponibilizando os códigos</a> dos trabalhos principais que fiz ao longo da disciplina, já com alguns arquivos de plotagem no meu repositório do <a href="http://gitorious.org/" target="_blank">Gitorious</a>. Não me lembrei de refatorar cada projeto, mas cada um é auto contido, com funções e variáveis mnemônicas, de forma que se o leitor tiver o conhecimento teórico do assunto, a leitura do código fica bem fácil. Foram utilizadas várias referências, mas o principal foi o livro <i><a href="http://www.flazx.us/books/3343-Introductory-Techniques-for-3-D-Computer-Vision/" target="_blank">Introductory Techniques for 3D Computer Vision</a>, </i>do <a href="http://www.computing.dundee.ac.uk/ac_staff/staffdetails.asp?298" target="_blank">Emmanuele Trucco</a>.<br />
<br />
Tenho planos de reescrever os fontes com vários comentários e inserir notações em Doxygen, pra depois gerar uma documentação útil. Quem sabe posso precisar disso em trabalhos futuros. O código está com a <a href="http://opensource.org/licenses/bsd-license.php" target="_blank">licensa BSD</a> (aproveitando a licença do OpenCV) e caso queira contribuir com ele (tipo, adicionando os comentários que eu não fiz :), deixe um comentário neste post que depois entro em contato.<br />
<br />
<br />
<br />
<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-37770160781321028212012-03-24T07:25:00.000-03:002012-04-12T18:58:02.266-03:00Krita 2.4 RC : Em memória a Jean GiraudA equipe do Krita, poderoso software de pintura digital, está liberando o primeiro Release Candidate da versão 2.4, depois de grandes esforços da comunidade.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.krita.org/images/stories/krita-screen_01_davidrevoy.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="241" src="http://www.krita.org/images/stories/krita-screen_01_davidrevoy.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pintura por David Revoy</td></tr>
</tbody></table>
<br />
<a name='more'></a><br /><br />
Esta versão tem várias novas funcionalidades, implementadas ao longo dos ultimos seis meses:<br />
<br />
<br />
<ul>
<li>gerenciamento de cor usando Little Color Management 2</li>
<li>integração com o GIMP Paint Studio</li>
<li>multi-hand tool (multiplica, simetricamente, seus traços no cavalete)</li>
<li>melhoria no curve-brush, com retas aleatórias geradas pela curva</li>
<li>processamento da pintura em background, sendo possível fazer várias ações ao mesmo tempo</li>
<li>pipe mode para o text-painting tool</li>
<li>preset editor, pra salvar as configurações de pincéis usados</li>
</ul>
<br />
Interessante de observar o lento direcionamento para o mundo dos tablets, com interface mais focada em botões e slides. Pra ter mais detalhes do que tem de novo, tem uma review completa na <a href="http://lwn.net/Articles/464495/">LWN.net</a>, abordando desde mudanças na interface até melhorias de desempenho e quem quiser dar uma olhada mais afundo no RC1, <a href="http://community.kde.org/Calligra/Building">a wiki do Calligra</a> tem um passo a passo ensinando como construir o software.<br />
<br />
Um lance legal é que a equipe resolveu dedicar esta versão a memória do artísta Jean Giraud, mais conhecido como Moebius em seus trabalhos em quadrinhos e artes gráficas.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.revistaogrito.com/page/wp-content/uploads/2012/03/silver-surfer-and-galactus-by-moebius-1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="http://www.revistaogrito.com/page/wp-content/uploads/2012/03/silver-surfer-and-galactus-by-moebius-1.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Galactus e o Surfista prateado por Moebius</td></tr>
</tbody></table>
<br />
Eu particularmente sou pouco familiarizado com o trabalho de quadrinhos dele, mas sei que teve grande influência para artístas de quadrinhos e animações, incluindo Hayao Miyazaki, e que trabalhou nos conceitos e designs em filmes pop como Tron, O Quinto Elemento e Alien - O Oitavo Passageiro. Quem quiser conhecer mais sobre o artista, o Omelete fez <a href="http://omelete.uol.com.br/jean-giraud-moebius/">uma página</a> juntando notícias e reviews de trabalhos de Jean Giraud que fizeram ao longo dos anos.<br />
<div style="text-align: -webkit-auto;">
<br /></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.mathcurve.com/surfaces/mobius/MobiusSwans.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="248" src="http://www.mathcurve.com/surfaces/mobius/MobiusSwans.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Möbius Swan , M.C. Escher</td></tr>
</tbody></table>
<br />
Um fato interessante é que o nome Moebius foi usado pelo artista em referência ao matemático alemão August Ferdinand Möbius, que descobriu a superfície de apenas um lado, apenas um bordo e sem orientação, a famosa faixa de Möbius.<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com2tag:blogger.com,1999:blog-32131971.post-1501130525921236702012-03-20T07:56:00.001-03:002012-04-25T15:52:43.863-03:00Dica Blender 2.6: Normal MappingEste fim de semana tive um tempim pra brincar com o Blender e fiz um <a href="http://cgcookie.com/blender/2010/10/30/creating-a-cartoon-skull/">rápido tutorial </a>disponível no Blender Cookie em que o cara faz uma caveira cartunesca. Ta em inglês, mas com paciência da pra sacar o que o cara fala ao longo do vídeo.<br />
O que tirei de mais interessante nem foi a parte de modelagem e sim como se utilizar de uma textura pra modificar o efeito da luz no objeto. Um dos modos é se utilizar de normal mapping, em que uma textura indica modificações nas normais da superfície de maneira a alterar a forma como a luz é refletida. No entanto, normal mapping so altera as normais, de maneira que se for jogado um algorítmo de sombra, a superfície irá projeta a geometria do objeto original (pra modificar a superfície de fato, utiliza-se de bump mapping, mas isso fica pra depois ;).<br />
<br />
No meu caso, com o modelo ja feito, fui no menu <b> Materials</b> (uma bolinha com preto e branco) > <i>New</i> (lado direito)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnFY1z-OwR-C5XFnVdKAbh4UCWj0LBQTVhSmeiuhHKZhjttjFIuYdJ5JzM1jZ7QoTtHG-KW-WrA62m5hllQV1AjubaHJlrRADqxTaQK5P_13xS_hA0GEWcboqBOKGFaU7rE1O2/s1600/normap1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnFY1z-OwR-C5XFnVdKAbh4UCWj0LBQTVhSmeiuhHKZhjttjFIuYdJ5JzM1jZ7QoTtHG-KW-WrA62m5hllQV1AjubaHJlrRADqxTaQK5P_13xS_hA0GEWcboqBOKGFaU7rE1O2/s400/normap1.png" width="400" /></a></div>
<br />
<a name='more'></a><br /><br />
Modifiquei a cor da luz especular pra um marron claro e coloquei a intensidade da luz para 0.228 (aba Specular > Intensity <valor>).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCEZDD_GM-qdBf9ekSfroTCgyRa2g2zb0bxU1qf7hDt5SOiqcC-pa1IqeGkkyaRt5H2s5_hZP4oVHeS7ZfDO_RjxuFEXkycTCqsIlu3PkeedJVv9OqX7YvvoaC9ORORjJ9z7kv/s1600/normap2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCEZDD_GM-qdBf9ekSfroTCgyRa2g2zb0bxU1qf7hDt5SOiqcC-pa1IqeGkkyaRt5H2s5_hZP4oVHeS7ZfDO_RjxuFEXkycTCqsIlu3PkeedJVv9OqX7YvvoaC9ORORjJ9z7kv/s400/normap2.png" width="400" /></a></div>
<br />
<br />
Depois disso vá na aba Texture (menu com o tabuleiro de xadrez ) Em <b>Types</b> coloque <i>Clouds. </i><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6nNlFuuLxfc-hIGoOCHc-CZSgqA7OadYid-Iqvwyn2v0YDH14yVDXXj28yf_QdlvQ9Srq6m-P_7qVmde_bBtByaXhkiWYpOfQjQT5ShkvZV5C0ubX9VCJSBEJZWP41PDQpFHe/s1600/normap6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6nNlFuuLxfc-hIGoOCHc-CZSgqA7OadYid-Iqvwyn2v0YDH14yVDXXj28yf_QdlvQ9Srq6m-P_7qVmde_bBtByaXhkiWYpOfQjQT5ShkvZV5C0ubX9VCJSBEJZWP41PDQpFHe/s400/normap6.png" width="400" /></a></div>
<br />
<br />
Logo após<i>, n</i>a aba <i><b>Colors,</b></i> marque checkbox <b>Ramp</b> e no combobox coloque <i>Linear</i> (ele vai fazer um degrade linear entre as cores na caixa). Ja na aba <b><i>Clouds</i></b> selecione o algoritmo de particionamento de espaço que será o <i>Voronoi F2-F1</i> e coloque o valor de <b>Depth</b> em <i>6</i><br />
<i><br /></i><br />
<i><br /></i><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV9TKjuzrELCdi0nXDZvq2-ZIYs_LC5_CAecBPw-3g38WsZcIUQdOJW_IIZwi1Z2hKmhDBhoZIY-h3QYzKJNxUn-qC6trYHEYXwg1Pqau1GhHGJpsnC7SwgT5P3gdgS5UWI-IB/s1600/normap3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV9TKjuzrELCdi0nXDZvq2-ZIYs_LC5_CAecBPw-3g38WsZcIUQdOJW_IIZwi1Z2hKmhDBhoZIY-h3QYzKJNxUn-qC6trYHEYXwg1Pqau1GhHGJpsnC7SwgT5P3gdgS5UWI-IB/s400/normap3.png" width="400" /></a></div>
Após isso, va na aba <b>Influence, </b>em <b>Geometry </b> e marque a checkbox <i>Normal, </i>abilitando o normal mapping. Coloque algum valor alto, como 4 ou 5, para dar uma aparência mais deteriorada ou um valor próximo de 1 para uma aparência mais lisa.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioQbS6FGF0Zd0eWld7qwc4m5YQ-dJQ3AwQelazQGSvBt9DI6P2QTpwQkdDBROdMo_J6cedDRZVnGeMp63enDILTtDfE_39kqq88YuJPbKel5NDfbSLiCGbU_JCjjO-X9W-C_ZV/s1600/normap4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioQbS6FGF0Zd0eWld7qwc4m5YQ-dJQ3AwQelazQGSvBt9DI6P2QTpwQkdDBROdMo_J6cedDRZVnGeMp63enDILTtDfE_39kqq88YuJPbKel5NDfbSLiCGbU_JCjjO-X9W-C_ZV/s400/normap4.png" width="400" /></a></div>
<br />
<br />
<br />
Terminado, o normal mapping será texturizado no modelo. Va na aba de renderização (a maquina fotográfica no menu direito), clique no botão <i>Image</i> pra renderizar a imagem para ver o resultado.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglplQ3jLuLIlZWFJIxbqV5RNA1QZObQ4xc4pWR9QOUQei6IOWW9cQ9o54mGJajk4glxV4A-pK8gmct6bjFlrys9UHlC6r5qYvJoYCUWG8s5ZHI6k_O2uJDWbLqpesLQdwF8CjL/s1600/normap5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglplQ3jLuLIlZWFJIxbqV5RNA1QZObQ4xc4pWR9QOUQei6IOWW9cQ9o54mGJajk4glxV4A-pK8gmct6bjFlrys9UHlC6r5qYvJoYCUWG8s5ZHI6k_O2uJDWbLqpesLQdwF8CjL/s640/normap5.png" width="640" /></a><br />
<br />
<br />
Com isso, temos nossa caveirinha com um normal mapping :D O arquivo com a modelagem pode ser baixado <a href="https://dl.dropbox.com/s/dsa537feyz5r4b9/cartoon_skull.blend?dl=1">aqui</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh20RCfuz30jySHlRfSYwBsz4_ptj8Ppq8Q9h3DSViCQFlpYoMHg5jIOvZZoQkey6Oq3A7xV_x8IPa8LcschWS4YfipRQUXuKQsl7614ht1ST1XEUk81-ezvFXg-OHf-eP1zOsj/s1600/cartooskull_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh20RCfuz30jySHlRfSYwBsz4_ptj8Ppq8Q9h3DSViCQFlpYoMHg5jIOvZZoQkey6Oq3A7xV_x8IPa8LcschWS4YfipRQUXuKQsl7614ht1ST1XEUk81-ezvFXg-OHf-eP1zOsj/s400/cartooskull_1.png" width="400" /></a></div>
<br />
Até a proxima! :D<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com1tag:blogger.com,1999:blog-32131971.post-42162636229753204552012-03-17T08:48:00.000-03:002012-04-12T18:58:31.466-03:00Mango Open Movie ProjectA Blender Foundation, instituição responsável pelo software livre de modelagem, animação e edição de video 3D Blender, está mais uma vez com um Open Movie Project em andamento.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://peach.blender.org/wp-content/uploads/bird1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="http://peach.blender.org/wp-content/uploads/bird1.jpg" width="400" /></a></div>
<br />
<br />
<a name='more'></a><br /><br />
Há mais de 5 anos que a fundação teve a idéia de financiar o desenvolvimento do Blender através de incentivo a produção artística. Funciona da seguinte maneira: é feita uma chamada de artistas e desenvolvedores da comunidade Blender para trabalharem conjuntamente em um filme. Os artístas cuidam da produção (conceitos, roteiros, storyboard, modelagem, etc...) e vão dando feedback para os programadores na produção de novas funcionalidades.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://orange.blender.org/wp-content/themes/orange/images/media/gallery/s5_proog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="http://orange.blender.org/wp-content/themes/orange/images/media/gallery/s5_proog.jpg" width="400" /></a></div>
<br />
Enquanto o filme é produzido, é feita a pré-venda do DVD com os resultados do projeto e com isso o projeto acaba tendo um suporte financeiro. Claro que tambem existe o suporte direto de outras pessoas e instituições, de maneira que é possível financiar a produção sem necessariamente ter que comprar o DVD. É um modelo bem legal, com resultados para ambos os lados da comunidade. Quem tiver curiosidade, o primeiro projeto foi o Orange, cujo resultado foi o curta <a href="http://orange.blender.org/">Elephant's Dream.</a> Os outros projetos que feitos estão disponíveis aqui, <a href="http://www.yofrankie.org/">aqui</a> e <a href="http://durian.blender.org/">aqui</a>.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.sintel.org/wp-content/uploads/2010/06/05.1b_comp_000156.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="170" src="http://www.sintel.org/wp-content/uploads/2010/06/05.1b_comp_000156.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Sintel: o Open Movie Project mais recente.</td></tr>
</tbody></table>
<br />
<br />
Como a Blender Foundation não tinha intenções de expandirem em um estudio e pelas dificuldades naturais que projetos open source tem de conseguir um bom feedback de usuários, o Open Movie Project é uma maneira de incentivar produções em instituições educacionais, universidades e em empresas de maneira geral. Além de manter as produções independentes, ocorre o incentivo ocacional para pesquisas de como melhorar a maneira que os artistas produzem.<br />
<br />
O projeto atualmente em produção é o Mango Open Movie Project. Já está com a pré-venda de DVDs e tem uma boa quantidade de conceitos feitas:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/brainCloud-and-scientist_mango_concept-art_04_net.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/brainCloud-and-scientist_mango_concept-art_04_net.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/celia-hovering-airship_mango_concept-art_02_net.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/celia-hovering-airship_mango_concept-art_02_net.jpg" width="640" /></a></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/thom-celia-love-affair-_mango_concept-art_02_net.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/thom-celia-love-affair-_mango_concept-art_02_net.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="text-align: -webkit-auto;"><span style="font-size: x-small;">Os conceitos foram feitos usando o Krita, o programa de pintura digital da suite de office do KDE, o Calligra ( e meu programa de desenho favorito ;).</span></span></td></tr>
</tbody></table>
<br />
Tá na cara que a trama desse filme vai ser em um cenário futurístico e pelo jeito vai pirar a cabeça da galera da robótica. Tem até um rig de um braço mecânico em um teste feito pela parte da equipe que está em Amsterdam:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/XwuJo0VqzFE?feature=player_embedded' frameborder='0'></iframe></div>
<br />
Quem quiser ter mais ou menos uma ideia da trama e acompanhar o andamento do projeto, tem o <a href="http://download.blender.org/mango/2012-march_mango-storyboard-1min.pdf">pdf</a> com o <i>storyboard</i> da animação e todos os conceitos no <a href="http://mango.blender.org/development/development-update-cycles-s-curves/#more-1285">blog do projeto</a>.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/genghis-jones-pod-active_mango_concept-art_02_net.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://mango.blender.org/wp-content/gallery/movie-concept-art-01/genghis-jones-pod-active_mango_concept-art_02_net.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Nyan cat rules!</td></tr>
</tbody></table>
<br />
<br />
<br />Francisco Fernandeshttp://www.blogger.com/profile/14976691121453638551noreply@blogger.com0