Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-photo-manipulation-gimp-26
Packt
21 Mar 2011
5 min read
Save for later

Photo Manipulation with GIMP 2.6

Packt
21 Mar 2011
5 min read
Introduction When working with photos we need to be sure that colors always look the way we want. Monitors, LCDs, and laptop screens, all render colors differently, and they don't look the same. There's no way you can control how people see their own screen, but you can calibrate your own using some kind of color profiling. The problem extends to different devices like scanners, printers, and cellphones, among others, because each device has its own color characteristics. Also, each device can handle different ranges of color. To avoid these problems, color profiles were implemented. It's a table that matches a specific color of a device to a device-independent color. Color profiles are created by each manufacturer, but the ICC (International Color Consortium) created its own standard. Calibration, image modes, and colour profiles This is one of the first things to do before working with photos. The Color Management menu (Edit | Preferences | Color Management) enables you to load any preset for your monitor. The presets can be created using any hardware calibration and measurement tool. For Linux, you can use LPROF and ARGYLL. For more information on color management in Linux, check the Linux color management page on Wikipedia. Apart from the color profile in use, you should set up your monitor and video card to render colors as close as possible to the standard. For Linux you can use XCALIB or DISPWIN. You can also simulate how an image will look when printed by selecting Print Simulation from the Mode of Operation in the Color Management menu. Scaling an image Image scaling is one of the easiest tasks, and also one of the most useful. In just a few seconds you can reduce an image's size, making e-mail transfers quicker. How to do it... To scale an image follow these steps: Open a file, go to Image | Scale Image. Change the size to whatever you want: As you change one value, you can see the other changing too. That's to keep the original file aspect ratio. If you click on any of the chain icons you can change any value independently. How it works... Image scaling works by changing the number of pixels of an image. The way pixels are created/deleted can be changed by choosing a different interpolation method in the Quality section of the Scale Image window. The best (but slowest) method is the Cubic interpolation, which calculates the color of each pixel by estimating an average of the eight closest ones. On the opposite corner, if you choose None as the interpolation method, each pixel gets its own color from its closest neighbor. This is the fastest method, but it also generates unwanted aliasing that can give you headaches if you are working with transparencies and highcontrasts. The resolution fields are useful when printing the image, they say how many pixels are per inch. If your image is too big and the resolution too low, the printed image can look pixelated. You can change the print size of an image without changing its resolution or size by going to Image | Print Size. Cropping an image There's another quick way to rescale your image and select just a section of it. Use the Crop Tool. How to do it... The following steps will show you how to crop an existing image: Open an image, and select the Crop Tool: Quickly click and drag around the area you want. Then, just press Return (Enter in Windows), and anything around the selection area will be cropped. Flipping or rotating an image Sometimes you scan and old photo or take a picture with the camera tilted. Following is how to quickly rotate or flip them. How to do it... To rotate or flip an image easily, carry out the following steps: Open an image, for example the following: Select the Flip Tool from the Toolbox: Use the left-mouse button along with the Ctrl key to change between horizontal and vertical flipping. Now, to rotate the image, select the Rotate Tool from the Toolbox: Click and drag your image to rotate it. Use the Ctrl key to constrain rotation to 15 degrees steps. Press the Return key when you've finished: How it works... Flip and rotate are basic tools. You can use the mouse to perform the operations after selecting any of them, but using their respective tool options gives you a lot more control. In both cases, you can control what to rotate (a layer, a selection, or a path). Also, in the Rotate tool, you can change the middle point around which the image rotates. This allows you to rotate the image with more freedom. To change it, select the Rotate Tool, and click and drag the small circle that appears in the center of the image: You can also set its coordinates from the Rotate window: You can also flip and rotate an image by using the menu items in Image | transform.
Read more
  • 0
  • 0
  • 2432

article-image-tips-and-tricks-away3d-36
Packt
18 Mar 2011
7 min read
Save for later

Tips and Tricks on Away3D 3.6

Packt
18 Mar 2011
7 min read
  Away3D 3.6 Essentials Take Flash to the next dimension by creating detailed, animated, and interactive 3D worlds with Away3D Determining the current frame rate When we talk about the performance of an Away3D application, almost always we are referring to the number of frames per second (FPS) that are being rendered. This is also referred to as the frame rate. Higher frame rates result in a more fluid and visually-appealing experience for the end user. Although it is possible to visually determine if an application has an acceptable frame rate, it can also be useful to get a more objective measurement. Fortunately, Away3D has this functionality built in. By default, when it is constructed, the View3D class will create an instance of the Stats class, which is in the away3d.core.stats package. This Stats object can be accessed via the statsPanel property from the View3D class. You can display the output of the Stats object on the screen using the Away3D project stats option in the context (or right-click) menu of an Away3D application. To see the Away3D Project stats option in the context menu you will need to click on a visible 3D object. If you click on the empty space around the 3D objects in the scene, you will see the standard Flash context menu. This will display a window similar to the following screenshot: This window provides a number of useful measurements: FPS, which measures the current frames per second AFPS, which measures the average number of frames per second Max, which measures the maximum peak value of the frames per second MS, which measures the time it took to render the last frame in milliseconds RAM, which measures how much memory the application is using MESHES, which measures the number of 3D objects in the scene SWF FR, which measures the maximum frame rate of the Flash application T ELEMENTS, which measures the total number of individual elements that make up the 3D objects in the scene R ELEMENTS, which measures the number of individual elements that make up the 3D objects that are being rendered to the screen These values come in very handy when trying to quantify the performance of an Away3D application. Setting the maximum frame rate Recent versions of Flash default to a maximum frame rate of 24 frames per second. This is usually fine for animations, but changing the maximum frame rate for a game may allow you to achieve a more fluid end result. The easiest way to do this is to use the SWF frameRate meta tag, which is a line of code added before the Away3DTemplate class. [SWF(frameRate=100)] public class Away3DTemplate extends Sprite { // class definition goes here } The SWF FR measurement displayed by the Away3D Stats object reflects the maximum frame rate defined by the frameRate meta tag. Note that setting the maximum frame rate using the frameRate meta tag does not mean that your application will always run at a higher frame rate, just that it can run at a higher frame rate. A slow PC will still run an Away3D application at a low frame rate even if the maximum frame rate has been set to a high value. You also need to be aware that any calculations performed in the onEnterFrame() function, such as transforming a 3D object, can be dependent on the frame rate of the application. In the following code, we rotate a 3D object by 1 degree around the X-axis every frame. override protected function onEnterFrame(event:Event):void { super.onEnterFrame(event); shipModel.rotationX += 1; } If the frame rate is 30 FPS, the 3D object will rotate around the X-axis by 30 degrees every second. If the frame rate is 90 FPS, the 3D object will rotate around the X-axis by 90 degrees every second. If your application requires these kinds of transformations to be performed consistently regardless of the frame rate, you can use a tweening library. Setting Flash quality to low You may have noticed that Flash offers a number of quality settings in its context menu. This quality setting can be set to one of the four options, which are defined in the StageQuality class from the flash.display package. As described by the Flash API documentation, these settings are: StageQuality.LOW: Low rendering quality. Graphics are not anti-aliased, and bitmaps are not smoothed, but runtime still use mip-mapping. StageQuality.MEDIUM: Medium rendering quality. Graphics are anti-aliased using a 2 x 2 pixel grid, bitmap smoothing is dependent on the Bitmap.smoothing setting. Runtimes use mip-mapping. This setting is suitable for movies that do not contain text. StageQuality.HIGH: High rendering quality. Graphics are anti-aliased using a 4 x 4 pixel grid, and bitmap smoothing is dependent on the Bitmap.smoothing setting. Runtimes use mip-mapping. This is the default rendering quality setting that Flash Player uses. StageQuality.BEST: Very high rendering quality. Graphics are anti-aliased using a 4 x 4 pixel grid. If Bitmap.smoothing is true the runtime uses a high-quality downscale algorithm that produces fewer artifacts. Mip-mapping refers to the use of mip-maps, which are precomputed smaller versions of an original bitmap. They are used instead of the original bitmap when the original is scaled down by more than 50 %. This bitmap scaling may occur when a 3D object with a bitmap material is itself scaled down, or off in the distance within the scene. The quality setting is defined by assigning one of these values to the quality property on the stage object: stage.quality = StageQuality.LOW; A number of demos that are supplied with Away3D set the stage quality by using the SWF quality metatag, like so: [SWF(quality="LOW")] The Flex compiler does not support setting the stage quality in this way. Although this code will not raise any errors during compilation, the stage quality will remain at the default value of StageQuality.HIGH. You can find more information on the metatags supported by the Flex compiler at http://livedocs.adobe.com/flex/3/html/help.html?content=metadata_3.html. Setting the stage quality to low will improve the performance of your Away3D application. The increase is felt most in applications that display a large number of 3D objects. The downside to setting the stage quality to low is that it affects all the objects on the stage, not just those drawn by Away3D. The low stage quality is particularly noticeable when rendering text, so the visual quality of controls like textfields and buttons can be significantly degraded. Using the medium-quality setting offers a good compromise between speed and visual quality. Reducing the size of the viewport The fewer pixels that are drawn to the screen, the faster the rendering process will be. The area that the view will draw into can be defined by assigning a ClippingRectangle object to the clipping property on the View3D class. To use the RectangleClipping class you first need to import it from the away3d.core.clip package. You can then define the area that Away3D will draw into by supplying the minx, maxX, minY, and maxY init object parameters to the RectangleClipping constructor like so: view.clipping = new RectangleClipping( { minX: -100, maxX: 100, minY: -100, maxY: 100 } ); The preceding code will limit the output of the view to an area 200 x 200 units in size. The ViewportClippingDemo application, which can be found on the Packt website as code bundle, allows you to modify the size of the clipping rectangle at runtime using the arrow up and arrow down keys. You can see the difference that the clipping rectangle makes in the following image. On the left, the clipping rectangle is set to the full area of the stage. On the right, the clipping rectangle has been reduced.
Read more
  • 0
  • 0
  • 5267

article-image-joomla-16-managing-site-users-access-control
Packt
17 Mar 2011
9 min read
Save for later

Joomla! 1.6: Managing Site Users with Access Control

Packt
17 Mar 2011
9 min read
Joomla! 1.6 First Look A concise guide to everything that's new in Joomla! 1.6.     What's new about the Access Control Levels system? In Joomla! 1.5, a fixed set of user groups was available, ranging from "Public" users (anyone with access to the frontend of the site) to "Super Administrators", allowed to log in to the backend and do anything. The ACL system in Joomla! 1.6 is much more flexible: Instead of fixed user groups with fixed sets of permissions, you can create as many groups as you want and grant the people in those groups any combination of permissions. ACL enables you to control anything users can do on the site: log in, create, edit, delete, publish, unpublish, trash, archive, manage, or administer things. Users are no longer limited to only one group: a user can belong to different groups at the same time. This allows you to give particular users both the set of permissions for one group and another group without having to create a third, combined set of permissions from the ground up. Permissions no longer apply to the whole site as they did in Joomla! 1.5. You can now set permissions for specific parts of the site. Permissions apply to either the whole site, or to specific components, categories, or items (such as a single article). What are the default user groups and permissions? The flexibility of the new ACL system has a downside: it can also get quite complex. The power to create as many user groups as you like, each with very fine-grained sets of permissions assigned to them, means you can easily get entangled in a web of user groups, Joomla! Objects, and permissions. You should carefully plan the combinations of permissions you need to assign to different user groups. Before you change anything in Joomla!, sketch an outline or use mind mapping tools (such as http://bubbl.us) to get an overview of what you want to accomplish through Joomla! ACL: who (which users) should be able to see or do what in which parts of the site? In many cases, you might not need to go beyond the default setup and just use the default users groups and permissions that are already present when you install Joomla! 1.6. So, before we go and find out how you can craft custom user groups and their distinctive sets of permissions, let's have a look at the default Joomla! 1.6 ACL setup. The default site-wide settings In broad terms, the default groups and permissions present in Joomla! 1.6 are much like the ACL system that was available in Joomla! 1.5. To view the default groups and their permissions, go to Site | Global Configuration | Permissions. The Permission Settings screen is displayed, showing a list of User Groups. A user group is a collection of users sharing the same permissions, such as Public, Manager, or Administrator. By default the permission settings of the Public user group are shown; clicking any of the other user group names reveals the settings for that particular group. On the right-hand side of the Permission Settings screen, the generic (site-wide) action permissions for this group are displayed: Site Login, Admin Login, and so on. Actions are the things users are allowed do on the site. For the sample user groups, these action permissions have already been set. Default user groups Let's find out what these default user groups are about. We'll discuss the user groups from the most basic level (Public) to the most powerful (Super Users). Public – the guest group This is the most basic level; anyone visiting your site is considered part of the Public group. Members of the Public group can view the frontend of the site, but they don't have any special permissions. Registered – the user group that can log in Registered users are regular site visitors, except for the fact that they are allowed to log in to the frontend of the site. After they have logged in with their account details, they can view content that may be hidden from ordinary site visitors because the Access level of that content has been set to Registered. This way, Registered users can be presented all kinds of content ordinary (Public) users can't see. Registered users, however, can't contribute content. They're part of the user community, not web team. Author, Editor, Publisher – the frontend content team Authors, Editors, and Publishers are allowed to log in to the frontend, to edit or add articles. There are three types of frontend content contributors, each with their specific permission levels: Authors can create new content for approval by a Publisher or someone higher in rank. They can edit their own articles, but can't edit existing articles created by others. Editors can create new articles and edit existing articles. A Publisher or higher must approve their submissions. Publishers can create, edit, and publish, unpublish, or trash articles in the frontend. They cannot delete content. Manager, Administrator, Super User – the backend administrators Managers, Administrators and Super Users are allowed to log in to the backend to add and manage content and to perform administrative tasks. Managers can do all that Publishers can, but they are also allowed to log in to the backend of the site to create, edit, or delete articles. They can also create and manage categories. They have limited access to administration functions. Administrators can do all that Managers can and have access to more administration functions. They can manage users, edit, or configure extensions and change the site template. They can use manager screens (User Manager, Article Manager, and so on) and can create, delete, edit, and change the state of users, articles, and so on. Super Users can do everything possible in the backend. (In Joomla! 1.5, this user group type was called Super Administrator). When Joomla! is installed, there's always one Super User account created. That's usually the person who builds and customizes the website. In the current example website, you're the Super User. Shop Suppliers and Customers – two sample user groups You'll notice two groups in the Permission Settings screen that we haven't covered yet: Shop Suppliers and Customer. These are added when you install the Joomla! 1.6 sample data. These aren't default user groups; they are used in the sample Fruit Shop site to show how you can create customized groups. Are there also sample users available? As there are user groups present in the sample data, you might expect there are also sample users. This is not the case. There are no (sample) users assigned to the sample user groups. There's just one user available after you've installed Joomla!— you. You can view your details by navigating to Users | User Manager. You're taken to the User Manager: Users screen: Here you can see that your name is Super User, your user name is admin (unless you've changed this yourself when setting up your account), and you're part of the user group called Super Users. There's also a shortcut available to take you to your own basic user settings: click on Site | My Profile or—even faster—just click on the Edit Profile shortcut in the Control Panel. However, you can't manage user permissions here; the purpose of the My Profile screen is only to manage basic user settings. Action Permissions: what users can do We've now seen what types of users are present in the default setup of Joomla! 1.6. The action permissions that you can grant these user groups—things they can do on the site—are shown per user group in the Site | Global Configuration | Permissions screen. Click on any of the user group names to see the permission settings for that group: You'll also find these permissions (such as Site Login, Create, Delete, Edit) on other places in the Joomla! interface: after all, you don't just apply permissions on a site-wide basis (as you could in previous versions of Joomla!), but also on the level of components, categories, or individual items. To allow or deny users to do things, each of the available actions can be set to Allowed or Denied for a specific user group. If the permission for an action isn't explicitly allowed or denied, it is Not Set. Permissions are inherited You don't have to set each and every permission on every level manually: permissions are inherited between groups. That is, a child user group automatically gets the permissions set for its parent. Wait a minute—parents, children, inheritance ... how does that work? To understand these relationships, let's have a look at the overview of user groups in the Permission Settings screen. This shows all available user groups (I've edited this screen image a little to be able to show all the user groups in one column): You'll notice that all user group names are displayed indented, apart from Public. This indicates the permissions hierarchy: Public is the parent group, Manager (indented one position) is a child of Public, Administrator (indented two positions) is a child of Manager. Permissions for a parent group are automatically inherited by all child groups (unless these permissions are explicitly set to Allowed or Denied to "break" the inheritance relationship). In other words: a child group can do anything a parent group can do—and more, as it is a child and therefore has its own specific permissions set. For example, as Authors are children of the Registered group, they inherit the permissions of the Registered group (that is, the permission to log in to the frontend of the site). Apart from that, Authors have their own specific permissions added to the permissions of the Registered group. Setting an action to Denied is very powerful: you can't allow an action for a lower level in the permission hierarchy if it is set to Denied higher up in the hierarchy. So, if an action is set to Denied for a higher group, this action will be inherited all the way down the permissions "tree" and will always be denied for all lower levels—even if you explicitly set the lower level to Allowed.  
Read more
  • 0
  • 0
  • 2741

article-image-zbrush-4-sculpting-preparing-creature-games
Packt
17 Mar 2011
4 min read
Save for later

ZBrush 4 Sculpting: Preparing the Creature for Games

Packt
17 Mar 2011
4 min read
ZBrush 4 Sculpting for Games: Beginner's Guide Sculpt machines, environments, and creatures for your game development projects         Read more about this book       (For more resources on the subject, see here.) You can download the finished creature by clicking here. Retopologizing for games Okay, we've got our high-poly mesh ready. But in order to bring it into a game engine, we need to build a low-polygon mesh from it. Because we used ZSketch in the beginning, we now create the low-poly mesh at the end of the process. This step is called retopologizing, or in most cases just retopo, because it creates a mesh with a new topology and projects the details from the high-poly onto it. In this way, we end up with a mesh with a clean and optimized topology and all of the high resolution details that we sculpted in earlier. This process can also be done in other major 3D applications such as Blender, 3ds Max, and so on. Honestly, I would prefer the retopologizing in Blender over that of ZBrush, as I find it a bit more robust. Nonetheless, the results are the same. So let's see how we can do this in ZBrush Before retopologizing, we should be clear about these points: Polycount: Think of how many polygons the character should have; this always seems tricky, but after some time you get used to it. Ask yourself how many polygons your platform and engine can handle for a character and how big will it be seen onscreen. Let's say our Brute will be used on a PC and console title, he's a few meters high and is visible fullscreen. So we're heading roughly for something around 5000 polygons. This is a very rough estimate and if we need less polygons for it, that's fine too. The fewer the better. Animation: How will the character be animated? If there's elaborate facial animation going on, the character should have enough polygons in his face, so the animator can move something. Ideally, the polygon-flow supports the animation. Quads: Always try to establish as many quads as possible. Sometimes, we just need to add triangles, but try to go for quads wherever you can. With these three points in mind, let's start retopologizing Time for action – creating an in-game mesh with retopologize First, lower the subdivision levels of all the subtools to get increased performance. Append a ZSphere as a subtool and make it the active one. Name it something meaningful like Retopo. Activate Transparency and place the ZSphere inside the mesh so that it is hidden, as shown in the next screenshot. Appending a ZSphere to the model gives us the advantage to easily hide subtools or adjust their subdivision level as we need it: Deactivate Transparency and go to Tool Topology| and click on Edit Topology. Activate Symmetry. Pick the SkinShade4 material and choose a darker color, so that we can see the orange lines of the retopologizing better. The SkinShade4 material offers very low contrast, which is what we need here. Begin drawing edges by left-clicking on the mesh. They will automatically snap to the underlying high-poly surface. Start out by laying in two circles around the eyes, as explained in the next image Retopologize commands When in retopologize mode, left-clicking adds a new vertex and an edge connecting it to the last selected vertex. If we want to start out from a different vertex, we can select a new starting point by Ctrl + left-clicking. Deleting points can be done by Alt + left-clicking. When you miss the point you wanted to delete, the last selected one gets deleted instead, so be careful about that.
Read more
  • 0
  • 0
  • 3135

article-image-sphinx-index-searching
Packt
16 Mar 2011
9 min read
Save for later

Sphinx: Index Searching

Packt
16 Mar 2011
9 min read
Client API implementations for Sphinx Sphinx comes with a number of native searchd client API implementations. Some third-party open source implementations for Perl, Ruby, and C++ are also available. All APIs provide the same set of methods and they implement the same network protocol. As a result, they more or less all work in a similar fashion, they all work in a similar fashion. All examples in this article are for PHP implementation of the Sphinx API. However, you can just as easily use other programming languages. Sphinx is used with PHP more widely than any other language. Search using client API Let's see how we can use native PHP implementation of Sphinx API to search. We will add a configuration related to searchd and then create a PHP file to search the index using the Sphinx client API implementation for PHP. Time for action – creating a basic search script Add the searchd config section to /usr/local/sphinx/etc/sphinx-blog.conf: source blog { # source options } index posts { # index options } indexer { # indexer options } # searchd options (used by search daemon) searchd { listen = 9312 log = /usr/local/sphinx/var/log/searchd.log query_log = /usr/local/sphinx/var/log/query.log max_children = 30 pid_file = /usr/local/sphinx/var/log/searchd.pid } Start the searchd daemon (as root user): $ sudo /usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/ sphinx-blog.conf Copy the sphinxapi.php file (the class with PHP implementation of Sphinx API) from the sphinx source directory to your working directory: $ mkdir /path/to/your/webroot/sphinx $ cd /path/to/your/webroot/sphinx $ cp /path/to/sphinx-0.9.9/api/sphinxapi.php ./ Create a simple_search.php script that uses the PHP client API class to search the Sphinx-blog index, and execute it in the browser: <?php require_once('sphinxapi.php'); // Instantiate the sphinx client $client = new SphinxClient(); // Set search options $client->SetServer('localhost', 9312); $client->SetConnectTimeout(1); $client->SetArrayResult(true); // Query the index $results = $client->Query('php'); // Output the matched results in raw format print_r($results['matches']); The output of the given code, as seen in a browser, will be similar to what's shown in the following screenshot: What just happened? Firstly, we added the searchd configuration section to our sphinx-blog.conf file. The following options were added to searchd section: listen: This options specifies the IP address and port that searchd will listen on. It can also specify the Unix-domain socket path. This options was introduced in v0.9.9 and should be used instead of the port (deprecated) option. If the port part is omitted, then the default port used is 9312.Examples: listen = localhost listen = 9312 listen = localhost:9898 listen = 192.168.1.25:4000 listen = /var/run/sphinx.s log: Name of the file where all searchd runtime events will be logged. This is an optional setting and the default value is "searchd.log". query_log: Name of the file where all search queries will be logged. This is an optional setting and the default value is empty, that is, do not log queries. max_children: The maximum number of concurrent searches to run in parallel. This is an optional setting and the default value is 0 (unlimited). pid_file: Filename of the searchd process ID. This is a mandatory setting. The file is created on startup and it contains the head daemon process ID while the daemon is running. The pid_file becomes unlinked when the daemon is stopped. Once we were done with adding searchd configuration options, we started the searchd daemon with root user. We passed the path of the configuration file as an argument to searchd. The default configuration file used is /usr/local/sphinx/etc/sphinx.conf. After a successful startup, searchd listens on all network interfaces, including all the configured network cards on the server, at port 9312. If we want searchd to listen on a specific interface then we can specify the hostname or IP address in the value of the listen option: listen = 192.168.1.25:9312 The listen setting defined in the configuration file can be overridden in the command line while starting searchd by using the -l command line argument. There are other (optional) arguments that can be passed to searchd as seen in the following screenshot: searchd needs to be running all the time when we are using the client API. The first thing you should always check is whether searchd is running or not, and start it if it is not running. We then created a PHP script to search the sphinx-blog index. To search the Sphinx index, we need to use the Sphinx client API. As we are working with a PHP script, we copied the PHP client implementation class, (sphinxapi.php) which comes along with Sphinx source, to our working directory so that we can include it in our script. However, you can keep this file anywhere on the file system as long as you can include it in your PHP script. Throughout this article we will be using /path/to/webroot/sphinx as the working directory and we will create all PHP scripts in that directory. We will refer to this directory simply as webroot. We initialized the SphinxClient class and then used the following class methods to set upthe Sphinx client API: SphinxClient::SetServer($host, $port)—This method sets the searchd hostname and port. All subsequent requests use these settings unless this method is called again with some different parameters. The default host is localhost and port is 9312. SphinxClient::SetConnectTimeout($timeout)—This is the maximum time allowed to spend trying to connect to the server before giving up. SphinxClient::SetArrayResult($arrayresult)—This is a PHP client APIspecific method. It specifies whether the matches should be returned as an array or a hash. The Default value is false, which means that matches will be returned in a PHP hash format, where document IDs will be the keys, and other information (attributes, weight) will be the values. If $arrayresult is true, then the matches will be returned in plain arrays with complete per-match information. After that, the actual querying of index was pretty straightforward using the SphinxClient::Query($query) method. It returned an array with matched results, as well as other information such as error, fields in index, attributes in index, total records found, time taken for search, and so on. The actual results are in the $results['matches'] variable. We can run a loop on the results, and it is a straightforward job to get the actual document's content from the document ID and display it. Matching modes When a full-text search is performed on the Sphinx index, different matching modes can be used by Sphinx to find the results. The following matching modes are supported by Sphinx: SPH_MATCH_ALL—This is the default mode and it matches all query words, that is, only records that match all of the queried words will be returned. SPH_MATCH_ANY—This matches any of the query words. SPH_MATCH_PHRASE—This matches query as a phrase and requires a perfect match. SPH_MATCH_BOOLEAN—This matches query as a Boolean expression. SPH_MATCH_EXTENDED—This matches query as an expression in Sphinx internal query language. SPH_MATCH_EXTENDED2—This matches query using the second version of Extended matching mode. This supersedes SPH_MATCH_EXTENDED as of v0.9.9. SPH_MATCH_FULLSCAN—In this mode the query terms are ignored and no text-matching is done, but filters and grouping are still applied. Time for action – searching with different matching modes Create a PHP script display_results.php in your webroot with the following code: <?php // Database connection credentials $dsn ='mysql:dbname=myblog;host=localhost'; $user = 'root'; $pass = ''; // Instantiate the PDO (PHP 5 specific) class try { $dbh = new PDO($dsn, $user, $pass); } catch (PDOException $e){ echo'Connection failed: '.$e->getMessage(); } // PDO statement to fetch the post data $query = "SELECT p.*, a.name FROM posts AS p " . "LEFT JOIN authors AS a ON p.author_id = a.id " . "WHERE p.id = :post_id"; $post_stmt = $dbh->prepare($query); // PDO statement to fetch the post's categories $query = "SELECT c.name FROM posts_categories AS pc ". "LEFT JOIN categories AS c ON pc.category_id = c.id " . "WHERE pc.post_id = :post_id"; $cat_stmt = $dbh->prepare($query); // Function to display the results in a nice format function display_results($results, $message = null) { global $post_stmt, $cat_stmt; if ($message) { print "<h3>$message</h3>"; } if (!isset($results['matches'])) { print "No results found<hr />"; return; } foreach ($results['matches'] as $result) { // Get the data for this document (post) from db $post_stmt->bindParam(':post_id', $result['id'], PDO::PARAM_INT); $post_stmt->execute(); $post = $post_stmt->fetch(PDO::FETCH_ASSOC); // Get the categories of this post $cat_stmt->bindParam(':post_id', $result['id'], PDO::PARAM_INT); $cat_stmt->execute(); $categories = $cat_stmt->fetchAll(PDO::FETCH_ASSOC); // Output title, author and categories print "Id: {$posmt['id']}<br />" . "Title: {$post['title']}<br />" . "Author: {$post['name']}"; $cats = array(); foreach ($categories as $category) { $cats[] = $category['name']; } if (count($cats)) { print "<br />Categories: " . implode(', ', $cats); } print "<hr />"; } } Create a PHP script search_matching_modes.php in your webroot with the following code: <?php // Include the api class Require('sphinxapi.php'); // Include the file which contains the function to display results require_once('display_results.php'); $client = new SphinxClient(); // Set search options $client->SetServer('localhost', 9312); $client->SetConnectTimeout(1); $client->SetArrayResult(true); // SPH_MATCH_ALL mode will be used by default // and we need not set it explicitly display_results( $client->Query('php'), '"php" with SPH_MATCH_ALL'); display_results( $client->Query('programming'), '"programming" with SPH_MATCH_ALL'); display_results( $client->Query('php programming'), '"php programming" with SPH_MATCH_ALL'); // Set the mode to SPH_MATCH_ANY $client->SetMatchMode(SPH_MATCH_ANY); display_results( $client->Query('php programming'), '"php programming" with SPH_MATCH_ANY'); // Set the mode to SPH_MATCH_PHRASE $client->SetMatchMode(SPH_MATCH_PHRASE); display_results( $client->Query('php programming'), '"php programming" with SPH_MATCH_PHRASE'); display_results( $client->Query('scripting language'), '"scripting language" with SPH_MATCH_PHRASE'); // Set the mode to SPH_MATCH_FULLSCAN $client->SetMatchMode(SPH_MATCH_FULLSCAN); display_results( $client->Query('php'), '"php programming" with SPH_MATCH_FULLSCAN'); Execute search_matching_modes.php in a browser (http://localhost/sphinx/search_matching_modes.php).
Read more
  • 0
  • 0
  • 3137

article-image-cacti-using-graphs-monitor-networks-and-devices
Packt
16 Mar 2011
10 min read
Save for later

Cacti: Using Graphs to Monitor Networks and Devices

Packt
16 Mar 2011
10 min read
Cacti 0.8 Beginner's Guide Learn Cacti and design a robust Network Operations Center     Introduction to Cacti graphs and the RRDtool You'll be looking into the actual graph creation process and what features Cacti supports. Creating graphs with the RRDtool Cacti uses the RRDtool to store the polled data. In addition to just storing the data, the RRDtool is also used to create the actual performance graphs. If you now expect to see a fully-featured charting application, you will be disappointed. The RRDtool graph functionality offers only a very limited range of chart types. They can either be line charts, area charts, or a combination of both. There is no 3D option available, nor are there any other types of charts such as Pie or Scatter charts. This may be a disadvantage for some at first, but concentrating on only a few basic chart types makes it a fast specialized rendering engine for these. Being fast in displaying the raw RRD data is the main focus of the RRDtool graphing engine. There are several graphing features available for plotting the data. The most commonly used types are: LINE: The data is drawn as a line which can be formatted by width and type (for example, dashed line) VRULE: A fixed vertical line is drawn at a defined value HRULE: A fixed horizontal line is drawn at a predefined value (for example, threshold limits) AREA: A solid filled area chart is drawn. Several area charts can be stacked together Each of these graph types can be combined together to build the final chart image. Let us dive into the graph creation process here to get a better understanding of the RRDtool graphing capabilities. You need to have the RRDtool in your path for the following commands to work. Basic RRDtool graph creation Let's begin with the RRD example and use that RRD file as the basis for our graphs. A note for Windows users The following examples also work for Windows. Simply replace the RRDtool command with the full path to the RRDtool binary, for example, use C:rrdtoolrrdtool.exe instead of rrdtool. You will also have to copy the DejaVu font from the RRDtool directory to your Windows fonts directory. I have created a Perl script which will help in the creation of the RRD file and its automatic update with random data. In order to create the test RRD file, use the following command: perl create_rrdfile_linux.pl test.rrd If you have installed the RRDtool to C:rrdtool you can use the following command for Windows: perl create_rrdfile_windows.pl test.rrd Having created the test data, you can now start to generate your first RRDtool-based graph. It is going to be a very simple graph displaying only the pure data. Execute the following code at the command line interface (CLI): rrdtool graph data_image.png --start 1282413600 --end 1282468500 DEF:intspeed=test.rrd:data:AVERAGE LINE2:intspeed#FF0000 This will create the following graph: So what does this command actually do? Using the command, you defined a start and end time in the Unix time format and defined the RRD file and data set you wanted to plot. You also told RRDtool to draw a two-pixel line (LINE2) using this data set and stored the resulting graph as data_image.png. The RRDtool automatically creates the X- and Y-axis for you and also inserts the time and value description. This is the most basic way of creating an RRDtool-based graph. Advanced RRDtool graph creation Although this basic graph image already has a lot of information in it, it is still missing some important features. It neither describes what is being graphed, nor does it provide additional information such as threshold breaches or MAX/MIN values. So, let's go back to this basic graph and look at how you can enhance it step-by-step using some of the advanced RRDtool features. Adding a label and title to the graph The first enhancement to our graph will be the addition of a label and a graph title. For this you can use the --vertical-label and --title parameters: rrdtool graph data_image.png --start 1282413600 --end 1282468500 --vertical-label bps --title "Interface Speed" DEF:intspeed=test.rrd:data:AVERAGE LINE2:intspeed#FF0000 The resulting graph now has a title at the top and a description to the left as can be seen in the following image: As you can see, the RRDtool command added a rotated description to the Y-axis and also added the title at the top of the graph. The graph is now bigger in dimensions than the first one. The RRDtool uses only the width and height information to set the actual chart size. Everything else must be added to the graph separately. You can see more about how this works in the following examples. Adding a legend to the graph Now that you have added some description to the graph, you can also add a legend to it. For this, you are going to use the LAST, AVERAGE, and MAX poller values. The function of the GPRINT item is to add additional graph information to the legend. You are also going to add a description field to the LINE2 item. Adding a description to the LINE or AREA items will automatically create a legend entry for you. The LAST, AVERAGE, and MAX values are always calculated using the data limited by the start and end time. Therefore they directly relate to the chart being displayed. Let's look at the following command: rrdtool graph data_image.png --start 1282413600 --end 1282468500 --vertical-label bps --title "Interface Speed" DEF:intspeed=test.rrd:data:AVERAGE LINE2:intspeed#FF0000:"Interface eth0" GPRINT:intspeed:LAST:"Current:%8.0lf" GPRINT:intspeed:AVERAGE:"Average:%8.0lf" GPRINT:intspeed:MAX:"Maximum:%8.0lfn" The resulting image now also contains a small legend at the bottom: As you can see, the legend was added to the bottom of the graph, expanding its height. By adding a description to the LINE2 line (Interface eth0) the description was automatically placed at the bottom along with the color being used to draw that line. The GPRINT text and values have then been added right after the description. If you want to add some more text to the next line, you need to make sure that the last GPRINT value contains a n (newline) string at the end. In this example, you can also see that the RRDtool did not increase the width of the graph to fit the legend in it. The Maximum value has been silently dropped. GPRINT statements do not automatically increase the graph width, so you will need to increase the width yourself. This can be done by using the –width parameter. Adding a threshold line to the graph Now let's also set a threshold and display a line on the graph marking the threshold. This can be achieved by using the HRULE item. You are going to set a threshold at 50 and use a light grey color to display it on the graph. The following command creates this line and also adds an additional entry to the legend. In addition, you are also going to change the LINE2 item to an AREA item, so the data being displayed is shown as a filled area: rrdtool graph data_image.png --start 1282413600 --end 1282468500 --vertical-label bps --title "Interface Speed" DEF:intspeed=test.rrd:data:AVERAGE HRULE:50#C0C0C0FF:"Threshold ( 50 )n" AREA:intspeed#FF0000:"Interface eth0" GPRINT:intspeed:LAST:"Current:%8.0lf" GPRINT:intspeed:AVERAGE:"Average:%8.0lf" GPRINT:intspeed:MAX:"Maximum:%8.0lfn" You can see the light gray line being printed horizontally in the image, providing a good overview of when the data exceeds the threshold: Note the usage of the newline string n in the description string for the HRULE item. As you can see in the graph, the following text items are added to the next line. Adding threshold breaches to the graph You have now seen how you can add a threshold line to the graph, but you probably also want to change the color of the data every time the threshold is breached. Let us assume that you want to have the color go red at or above the threshold and go green once it is below. This can be achieved by using a Computed DEFinition (CDEF) and the LIMIT statement. You define a CDEF named isGreen which returns a number as long as the value of intspeed is between 0 and 50, otherwise no value is returned. You are going to use this CDEF to change the color of the displayed area. Instead of using the intspeed value you assign this new CDEF isGreen to the AREA item and change the color of the AREA to green (RGB: 00FF00). You also create a new AREA entry, to which you now assign the intspeed value, set the color to red, and give it a description Over Thresholdn. For this to work correctly, you need to place this new AREA above the old AREA statement. Why are there two AREA statements? In fact, changing the color of one AREA as it is displayed is not possible, so you need to do a little trick here. The first AREA statement will graph all values in red, also the ones which are below the threshold, as you have seen in the preceding example. With the second AREA statement a green area will be drawn at all data values which are below the threshold. As the color is not transparent, the red area will disappear. You can see the total red area when you remove the second AREA statement. The complete code now looks like the following: rrdtool graph data_image.png --start 1282413600 --end 1282468500 --vertical-label bps --title "Interface Speed" DEF:intspeed=test.rrd:data:AVERAGE CDEF:isGreen=intspeed,0,50,LIMIT HRULE:50#C0C0C0FF:"Threshold ( 50 )n" AREA:intspeed#FF0000:"Over Thresholdn" AREA:isGreen#00FF00:"Interface eth0" GPRINT:intspeed:LAST:"Current:%8.0lf" GPRINT:intspeed:AVERAGE:"Average:%8.0lf" GPRINT:intspeed:MAX:"Maximum:%8.0lfn" Run this code from the command line and you will see the resulting graph: All of the graphs you have just created can be created in Cacti using the Cacti web interface. This section provides a small and very limited overview of the capabilities of the RRDtool graphing functions, but should give you enough ideas to start playing around with it to create your own graphs. Adding devices to Cacti A device in Cacti can be anything which can be monitored remotely or locally. This can include storage devices, Windows or UNIX servers, and of course network devices. For Cacti to be able to monitor a device, it needs to be reachable by ping or SNMP, but the actual data retrieval can also be done using scripts and commands, or a set of SNMP queries. Creating a device Creating a device in Cacti can be achieved by using the Cacti web interface. You are going to add your first device here. While looking at the different steps it takes to add a device, you are not going too much into the details of every field, as most of the user interface is self-explanatory and provides a detailed description of each field. Before you start: Create a naming standard If you have not already done so, you should now think about a naming standard for your devices. Creating and keeping to a naming standard is the first step to automation.  
Read more
  • 0
  • 0
  • 15703
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-squid-proxy-server-tips-and-tricks
Packt
16 Mar 2011
6 min read
Save for later

Squid Proxy Server: Tips and Tricks

Packt
16 Mar 2011
6 min read
Rotating log files frequently Tip: For better performance, it is good practice to rotate log files frequently instead of going with large files. --sysconfdir=/etc/squid/ option Tip: It's a good idea to use the --sysconfdir=/etc/squid/ option with configure, so that you can share the configuration across different Squid installations while testing. tproxy mode Tip: We should note that enabling intercept or tproxy mode disables any configured authentication mechanism. Also, IPv6 is supported for tproxy but requires very recent kernel versions. IPv6 is not supported in the intercept mode. Securing the port Tip: We should set the HTTP port carefully as the standard ports like 3128 or 8080 can pose a security risk if we don't secure the port properly. If we don't want to spend time on securing the port, we can use any arbitrary port number above 10000. ACL naming Tip: We should carefully note that one ACL name can't be used with more than one ACL type. acl destination dstdomain example.com acl destination dst 192.0.2.24 The above code is invalid as it uses ACL name destination across two different ACL types. HTTP access control Tip: The default behavior of HTTP access control is a bit tricky if access for a client can't be identified by any of the access rules. In such cases, the default behavior is to do the opposite of the last access rule. If last access rule is deny, then the action will be to allow access and vice-versa. Therefore, to avoid any confusion or undesired behavior, it's a good practice to add a deny all line after the access rules. Using the http_reply_access directive Tip: We should be really careful while using the http_reply_access directive. When a request is allowed by http_access, Squid will contact the original server, even if a rule with the http_reply_access directive denies the response. This may lead to serious security issues. For example, consider a client receiving a malicious URL, which can submit a client's critical private information using the HTTP POST method. If the client's request passes through http_access rules but the response is denied by an http_reply_access rule, then the client will be under the impression that nothing happened but a hacker will have cleverly stolen our client's private information. refresh_pattern directive Tip: Using refresh_pattern to cache the non-cacheable responses or to alter the lifetime of the cached objects, may lead to unexpected behavior or responses from the web servers. We should use this directive very carefully. Expires HTTP header Tip: We should note that the Expires HTTP header overrides min and max values. Overriding directives Tip: Please note that the directive never_direct overrides hierarchy_stoplist. Path of the PID file Tip: Setting the path of the PID file to none will prevent regular management operations like automatic log rotation or restarting Squid. The operating system will not be able to stop Squid at the time of a shutdown or restart. Parsing the configuration file Tip: It's good practice to parse the configuration file for any errors or warning using the -k parse option before issuing the reconfigure signal. Squid signals Tip: Please note that shutdown, interrupt, and kill are Squid signals and not the system kill signals which are emulated. Squid process in debug mode Tip: The Squid process running in debug mode may write a log of debugging output to the cache.log file and may quickly consume a lot of disk space. Access Control List (ACL) elements with dst Tip: ACL elements configured with dst as a ACL type works slower compared to ACLs with the src ACL type, as Squid will have to resolve the destination domain name before evaluating the ACL, which will involve a DNS query. ACL elements with srcdomain Tip: ACL elements with srcdomain as ACL types works slower, compared to ACLs with the dstdomain ACL type because Squid will have to perform a reverse DNS lookup before evaluating ACL. This will introduce significant latency. Moreover, the reverse DNS lookup may not work properly with local IP addresses. Adding port numbers Tip: We should note that the port numbers we add to the SSL ports list should be added to the safe ports list as well. Take care while using the ident protocol Tip: The ident protocol is not really secure and it's very easy to spoof an ident server. So, it should be used carefully. ident lookups Tip: Please note that the ident lookups are blocking calls and Squid will wait for the reply before it can proceed with processing the request, and that may increase the delays by a significant margin. Denied access by the http_access Tip: If a client is denied access by the http_access rule, it'll never match an http_reply_access rule. This is because, if a client's request is denied then Squid will not fetch a reply. Authentication helpers Tip: Configuring authentication helpers is of no use unless we use the proxy_auth ACL type to control access. basic_pop3_auth helper Tip: The basic_pop3_auth helper uses the Net::POP3 Perl package. So, we should make sure that we have this package installed before using the authentication helper.   --enable-ssl option Tip: : Please note that we should use the --enable-ssl option with the configure program before compiling, if we want Squid to accept HTTPS requests. Also note that several operating systems don't provide packages capable of HTTPS reverse-proxy due to GPL and policy constraints.   URL redirector programs Tip: We should be careful while using URL redirector programs because Squid passes the entire URL along with query parameters to the URL redirector program. This may lead to leakage of sensitive client information as some websites use HTTP GET methods for passing clients' private information.   Using the url_rewrite_access directive to block request types Tip: Please note that certain request types such as POST and CONNECT must not be rewritten as they may lead to errors and unexpected behavior. It's a good idea to block them using the url_rewrite_access directive. In this article we saw some tips and tricks on Squid Proxy server to enhance the performance of your network. Further resources on this subject: Configuring Apache and Nginx [Article] Different Ways of Running Squid Proxy Server [Article] Lighttpd [Book] VirtualBox 3.1: Beginner's Guide [Book] Squid Proxy Server 3.1: Beginner's Guide [Book]
Read more
  • 0
  • 2
  • 14792

article-image-new-python-books-packt
Packt
15 Mar 2011
1 min read
Save for later

New Python Books from Packt

Packt
15 Mar 2011
1 min read
Python 3 Web Development Beginner's Guide Use Python to create, theme, and de ploy unique we b applications. To add print book to your cart   Python Testing Cookbook A practical guide, this cookbook will ensure you fully utilize Python testing tools to write tests efficiently        To add print book to your cart    Interesting spread and combination of toolsets. I can’t but recommend this book! -Tim Golden, Python developer, London.       To see the full range of Packt Python Books click here
Read more
  • 0
  • 0
  • 1414

article-image-faq-celtx
Packt
14 Mar 2011
3 min read
Save for later

FAQ on Celtx

Packt
14 Mar 2011
3 min read
Celtx: Open Source Screenwriting Beginner's Guide Write and market Hollywood-perfect movie scripts the free way! Q: What is Celtx? A: Celtx developers describe this software package as "the world's first all-in-one media pre-production system." (http://celtx.com/overview. html) We are told that Celtx: Can be used for the complete production process Lets you write scripts, storyboard scenes, and sketch setups Develop characters, breakdown, and tag elements Schedule productions plus generate useful reports Celtx is powerful software yet simple to use. It can be used in writing the various types of scripts already mentioned, including everything independent filmmakers and media creators of all types need. This includes writing, planning, scheduling, and generating reports during the various stages of all sorts of productions. The following screenshot is an example of a Celtx report screen: Q: What does the acronym, Celtx, stand for? A: The name Celtx is an acronym for Crew, Equipment, Location, Talent, and XML. Q: How far-reaching is the impact of Celtx? A: The Celtx website says that more than 500,000 media creators in 160 countries use Celtx in 33 different languages. Independent filmmakers and studio professionals, and students in over 1,800 universities and film schools have adopted Celtx for teaching and class work submission. Celtx is supported by the Celtx community of volunteer developers and a Canadian company, Greyfirst Corp. in St. John's, Newfoundland. A major reason Celtx can be an open source program is that it is built on non-proprietary standards, such as HTML and XML (basic web mark-up languages) and uses other open source programs (specifically Mozilla's engine, the same used in the Firefox browser) for basic operations. Q: What sets Celtx apart from other free screenwriting software that is available? A: An important concept of Celtx's power is that it's a client-server application. This means only part of Celtx is in that download installed on your computer. The rest is out there in the cloud (the latest buzz term for servers on the Internet). Cloud computing (using remote servers to do part of the work) allows Celtx to have much more sophisticated features, in formatting and collaboration especially, than is normally found in a relatively small free piece of software. It's rather awesome actually. Celtx, by the way, has you covered for PC, Mac, all kinds of Linux, and even eeePC Netbooks. Q: Does Celtx qualify as a web application? A: Celtx is really a web application. We have the advantage of big computers on the web doing stuff for us instead of having to depend on the much more limited resources of our local machine. This also means that improvements in script formats (as final formatting is done out on the web somewhere for you) are yours even if you haven't updated your local software. Q: Can we write movies with Celtx? A: With Celtx we can outline and write an entertainment industry standard feature movie script, short film, or animation—all properly formatted and ready to market. Q: Can we do other audio-visual projects with Celtx? A: Celtx's integral Audio-Visual editor is perfect for documentaries, commercials, public service spots, video tutorials, slide shows, light shows, or just about any other combination of visual and other content (not just sound). Q: Is Celtx equipped for audio plays and podcast? A: Celtx's Audio Play editor makes writing radio or other audio plays a breeze. It's perfect also for radio commercials or spots, and absolutely more than perfect for podcasts. Podcasts are easy to write, require minimal knowledge to produce, and are a snap to put on the Internet.
Read more
  • 0
  • 0
  • 2995

article-image-article-test-article2
Packt
14 Mar 2011
1 min read
Save for later

Test: Article 2

Packt
14 Mar 2011
1 min read
Test: Book Page 3  
Read more
  • 0
  • 0
  • 1820
article-image-article-test-article3
Packt
14 Mar 2011
1 min read
Save for later

Test: Article 3

Packt
14 Mar 2011
1 min read
Test: Book Page 5
Read more
  • 0
  • 0
  • 1220

article-image-questions-answers-inkscapes-alexandre-prokoudine
Packt
14 Mar 2011
5 min read
Save for later

Questions & Answers with Inkscape's Alexandre Prokoudine

Packt
14 Mar 2011
5 min read
1. Packt: Firstly, I would like to congratulate you and Inkscape on your success in the 2010 Open Source Awards - Open Source Graphics Software Category. You were supported quite vociferously by your passionate community. How important do you think the various communities of Open Source projects are to the progression and growth of its software? Alexandre Prokoudine: Thank you! Well, we really wouldn't go far without community; it gives us the drive to continuously improve Inkscape and community gives the drive and shapes development.   2. Packt: For those that do not know, how long has Inkscape been around? How did the creation of Inkscape come about? Alexandre Prokoudine: We've been around since 2003, and much of our project was initially built on top of Sodipodi — a free vector graphics editor by Lauris Kaplinski who had different goals and different vision for his project. Sodipodi itself was based on Gill — an even earlier project by Raph Levien. We positioned Inkscape as SVG (a W3C standard for vector graphics) authoring software, as well as generic vector graphics editor.   3. Packt: How would you describe the Inkscape community? Alexandre Prokoudine: We have a rather diverse community. All the time we stumble upon unique uses of the application. For example, there is a strong interest raising in the manufacturing community lately: CNC, laser cutting, embroidering etc. We're trying to meet this demand by shipping GCode extension with the next version of Inkscape. However in most cases, people use Inkscape for graphic design, branding, web design, illustrating, diagramming, and technical drawing. Inkscape is also the standard de-facto tool for icon design on Linux.   4. Packt: What would you describe as the current strengths and weaknesses of the Inkscape community? Alexandre Prokoudine: We are blessed to have brilliant artists in the community who use Inkscape for their day jobs, which is very motivating to both continuously developing the application and trying to draw something yourself. However we don't know of many uses of Inkscape, because sometimes people don't feel like wanting to be part of communities, so they simply take Inkscape and use it as means to end, and sometimes they just don't know that we'd like them to tell us about all the great work they do using Inkscape.   5. Packt: How many code contributors does the Inkscape project receive on a monthly basis? Alexandre Prokoudine: We have 5 to 10 developers a month (from a team of about 50) who commit their own code, but apart from them a varying amount of people send one-time patches, from small fixes to actual new features.   6. Packt: How has Inkscape encouraged its community to evangelize the software? Alexandre Prokoudine: There are several ways we go about that. From time to time we do deviant art-based design contests: a contest of About screen for every new release and, most recently, a website redesign contest. Since users post submissions in their accounts, everyone can see what they can do, and it broadens the user base. Some of our active community members like Máirín Duffy, Donna Benjamin, and Cedric Gemy organize classes for users in USA, Australia and France respectively, so really we rely on each other.   7. Packt: 2010 was a big year for the Inkscape community, how does the project expect to improve in 2011 and build on the growth experienced? Alexandre Prokoudine: There are several things happening all at once or at least expected to happen. To begin with, we are currently working on a whole new website that will help new users to get accustomed with Inkscape faster, and for new developers it will provide better introductory information. Another thing that will hopefully happen is participation in Google Summer of Code (GSoC) 2011. Thus far GSoC has been great in helping to grow our developer community and bringing our code closer to state of the art technologies. We also expect to fully switch to Cairo based rendering which will significantly improve performance — one of the acknowledged Inkscape's weaknesses.   8. Packt: As you may know, we’ve recently announced that Packt has hit the landmark of donating over $300,000 to Open Source projects, how important are donations of this kind to the Inkscape community? Alexandre Prokoudine: We mostly spend donations on trips of developers to various conferences like Libre Graphics Meeting, where they can meet fellow developers of other free applications and work together to bring consistent user experience to our communities. In many respects donations are a way for users to get better software in the end.   9. Packt: We specialize in refining and distilling advice provided by the community around Open Source projects, into easy to follow specialist information. How important is the sharing of information for the Inkscape community? How do you plan to improve on your role as the hub of distributing information for the Inkscape community in 2011? Alexandre Prokoudine: Sharing information is another definition of community :) In the past our communication channels were somewhat fragmented. This year we intend to fix this, even though it's never possible to consolidate all community-driven projects.   10. Packt: Thanks for your time Alexandre, lastly what projects, if any, are you/Inkscape working on at the moment? Alexandre Prokoudine: The big plan is to release a new 0.49 version later this year. This version is supposed to give a lot of polish to the existing feature set, as well as improve usability and performance. We consider addressing some of existing issues as important as new spiffy features, so there will be a fair share of work on both. We are also working on better SVG compliance and expect to have better support for CSS which is one of most popular user requests. For more information on Inkscape, go to http://inkscape.org/
Read more
  • 0
  • 0
  • 1788

article-image-ogre-3d-faqs
Packt
14 Mar 2011
8 min read
Save for later

Ogre 3D FAQs

Packt
14 Mar 2011
8 min read
  OGRE 3D 1.7 Beginner's Guide Create real time 3D applications using OGRE 3D from scratch         Read more about this book       (For more resources on OGRE 3D, see here.) Q: What is Ogre3D? A: Creating 3D scenes and worlds is an interesting and challenging problem, but the results are hugely rewarding and the process to get there can be a lot of fun. Ogre 3D helps you create your own scenes and worlds. Ogre 3D is one of the biggest open source 3D render engines and enables its users to create and interact freely with their scenes.   Q: What are the system requirements for Ogre 3D? A: You need a compiler to compile the applications. Your computer should have a graphic card with 3D capabilities. It would be best if the graphic card supports DirectX 9.0.   Q: From where can I download the Ogre 3D software? A: Ogre 3D is a cross-platform render engine, so there are a lot of different packages for these different platforms. The following are the steps to download and install Ogre 3D SDK: Go to http://www.ogre3d.org/download/sdk Download the appropriate package. Copy the installer to a directory you would like your OgreSDK to be placed in. Double-click on the Installer; this will start a self extractor. You should now have a new folder in your directory with a name similar to OgreSDK_vc9_v1-7-1. Open this folder. It should look similar to the following screenshot:     Q: Which are the different versions of the Ogre 3D SDK? A: Ogre supports many different platforms, and because of this, there are a lot of different packages we can download. Ogre 3D has several builds for Windows, one for MacOSX, and one Ubuntu package. There is also a package for MinGW and for the iPhone. If you like, you can download the source code and build Ogre 3D by yourself. If you want to use another operating system, you can look at the Ogre 3D Wiki, which can be found at http://www.ogre3d.org/wiki. The wiki contains detailed tutorials on how to set up your development environment for many different platforms.   Q: What do you mean by a scene graph? A: A scene graph is one of the most used concepts in graphics programming. Simply put, it's a way to store information about a scene. A scene graph has a root and is organized like a tree. The important thing about a scene graph is that the transformation is relative to the parent of the node. If we modify the orientation of the parent, the children will also be affected by this change.   Q: What are Spotlights? A: Spotlights are just like flashlights in their effect. They have a position where they are and a direction in which they illuminate the scene. This direction was the first thing we set after creating the light. The direction simply defines in which direction the spotlight is pointed. The next two parameters we set were the inner and the outer angles of the spotlight. The inner part of the spotlight illuminates the area with the complete power of the light source's color. The outer part of the cone uses less power to light the illuminated objects. This is done to emulate the effects of a real flashlight.   Q: What is the difference between frame-based and time-based movement? A: When using frame-based movement, the entity is moved the same distance each frame, by time passed movement, the entity is moved the same distance each second.   Q: What is a window handle and how is it used by our application and the operating system? A: A window handle is simply a number that is used as an identifier for a certain window. This number is created by the operating system and each window has a unique handle. The input system needs this handle because without it, it couldn't get the input events. Ogre 3D creates a window for us. So to get the window handle, we need to ask it the following line: win->getCustomAttribute("WINDOW", &windowHnd);   Q: What does a scene manager do? A: A scene manager does a lot of things, which will be obvious when we take a look at the documentation. There are lots of functions which start with create, destroy, get, set, and has. One important task the scene manager fulfills is the management of objects. This can be scene nodes, entities, lights, or a lot of other object types that Ogre 3D has. The scene manager acts as a factory for these objects and also destroys them. Ogre 3D works with the principle—he who creates an object, also destroys it. Every time we want an entity or scene node deleted, we must use the scene manager; otherwise, Ogre 3D might try to free the same memory later, which might result in an ugly application crash. Besides object management, it manages a scene, like its name suggests. This can include optimizing the scene and calculating positions of each object in the scene for rendering. It also implements efficient culling algorithms.   Q: Which three functions offer the FrameListener interface and at which point is each of these functions called? A: A FrameListener is based on the observer pattern. We can add a class instance which inherits from the Ogre::FrameListener interface to our Ogre 3D root instance using the addFrameListener() method of Ogre::Root. When this class instance is added, our class gets notified when certain events happen. The following are the three functions that offer the FrameListener interface: frameStarted which gets called before the frame is rendered frameRenderingQueued which is called after the frame is rendered but before the buffers are swapped and frameEnded which is called after the current frame has been rendered and displayed.   Q: What is a particle system? A: A particle system consists of two to three different constructs—an emitter, a particle, and an affector (optional). The most important of these three is the particle itself, as the name particle system suggests. A particle displays a color or textures using a quad or the point render capability of the graphics cards. When the particle uses a quad, this quad is always rotated to face the camera. Each particle has a set of parameters, including a time to live, direction, and velocity. There are a lot of different parameters, but these three are the most important for the concept of particle systems. The time to live parameter controls the life and death of a particle. Normally, a particle doesn't live for more than a few seconds before it gets destroyed. This effect can be seen in the demo when we look up at the smoke cone. There will be a point where the smoke vanishes. For these particles, the time to live counter reached zero and they got destroyed. An emitter creates a predefined number of particles per second and can be seen as the source of the particles. Affectors, on the other hand, don't create particles but change some of their parameters. An affector could change the direction, velocity, or color of the particles created by the emitter.     Q: Which add-ons are available for Ogre 3D? Where can I get them? A: The following are some of the add-ons available to Ogre 3D: Hydrax Hydrax is an add-on that adds the capability of rendering pretty water scenes to Ogre 3D. With this add-on, water can be added to a scene and a lot of different settings are available, such as setting the depth of the water, adding foam effects, underwater light rays, and so on. The add-on can be found at http://www.ogre3d.org/tikiwiki/Hydrax. Caelum Caelum is another add-on, which introduces sky rendering with day and night cycles to Ogre 3D. It renders the sun and moon correctly using a date and time. It also renders weather effects like snow or rain and a complex cloud simulation to make the sky look as real as possible. The wiki site for this add-on is http://www.ogre3d.org/tikiwiki/Caelum. Particle Universe Another commercial add-on is Particle Universe. Particle Universe adds a new particle system to Ogre 3D, which allows many more different effects than the normal Ogre 3D particle system allows. Also, it comes with a Particle Editor, allowing artists to create particles in a separate application and the programmer can load the created particle script later. This plugin can be found at http://www.ogre3d.org/tikiwiki/Particle+Universe+plugin.   Summary In this article we took a look at some of the most frequently asked questions on Ogre 3D. The article, Common Mistakes : Ogre Wiki, would be helpful for further queries pertaining to Ogre 3D. Further resources on this subject: Starting Ogre 3D [Article] Installation of Ogre 3D [Article] Materials with Ogre 3D [Article] The Ogre Scene Graph [Article] OGRE 3D 1.7 Beginner's Guide [Book]
Read more
  • 0
  • 0
  • 7516
article-image-article-test-article4
Packt
14 Mar 2011
1 min read
Save for later

Test: Article 4

Packt
14 Mar 2011
1 min read
Test: Book Page 1
Read more
  • 0
  • 0
  • 934

article-image-article-test-article1
Packt
14 Mar 2011
1 min read
Save for later

Test: Article 1

Packt
14 Mar 2011
1 min read
Test: Book Page 1  
Read more
  • 0
  • 0
  • 887
Modal Close icon
Modal Close icon