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

7019 Articles
article-image-scribus-importing-images
Packt
06 Apr 2011
13 min read
Save for later

Scribus: Importing Images

Packt
06 Apr 2011
13 min read
  Scribus 1.3.5: Beginner's Guide Create optimum page layouts for your documents using productive tools of Scribus.  Importing and exporting: The concepts To begin with, remember that there are two kinds of graphics you can add to your layout. You can have photos, generally taken from a digital camera, downloaded, or bought on some website. Photos will generally be stored in JPEG files, but you can also find PNG, TIFF, or many other file formats. The second kind of graphics is vector drawings such as logos and maps. They are computer-made drawings and are stored as EPS or SVG files. You will certainly need to work with both in most of your documents. The previous image shows the comparison between a photo on the left-hand side, and the same photo traced in vectors on the right-hand side. In the middle, see how the details of the photo are made up of square pixels that are sometimes difficult to handle to get good printing results. The first difference is that with photos, you will need to place them in a frame. There are some tips to automatically add the frame, but anyway, a frame will be needed. Vector drawings are imported as shapes and can be manipulated in Scribus like any other Scribus object. The second difference is that when working with photos, you will have to import them within Scribus. The term "import" is precise here. Most text processors don't import but insert images. In the case of "insert", the images are definitely stored in your document. So you can send this document to anyone via e-mail or can store it on any external storage device without caring about whether these images will still be present later. Scribus does it differently: it adds to the frame a reference to the imported file's own storage position. Scribus will look for the file each time it needs it, and if the file is not where it should be, problems may arise. Basically, the steps you go through while performing a DTP import and while performing a text processor insert are the same, but the global workflows are different because the professional needs to which they refer to are different. All the communication software, layout programs, website building software, as well as video editing software perform the same steps. Once you're used to it, it's really handy: it results in lighter and more adaptable files. However, while teaching Scribus, I have many times received mails from students who have trouble with the images in their documents, just because they didn't take enough care of this little difference. Remembering it will really help you to work peacefully. DTP versus text processors again Here we are talking about the default behavior of the software. As text processors can now work with frames, they often import the image as a link. Scribus itself should be able to embed pictures in its next release. Will the difference between these two pieces software one day disappear? The next difference is about the color space of the pictures. Cameras use RAW or JPEG (which are RGB documents). Offset printers, which everyone usually refers to, are based on the CMYK (Cyan, Magenta, Yellow, and Black) model. Traditionally, most proprietary packages ask the users to convert RGB files into CMYK. With Scribus there is no need to do so. You can import your graphics as RGB and Scribus will export them all as desired at the end of the process (which most of the time is exporting to PDF). So, if you use GIMP, you shouldn't be embarrassed by its default lack of CMYK support. CMYK in GIMP If you really want to import CMYK photos into Scribus, you can use the GIMP Separate plugin to convert an RGB document to a CMYK. Batch converting can be easily done using the convert utility of ImageMagick. Consider using the new CMYKTool software too, which gives some nice color test tools and options, including ink coverage. That said, we now have to see how it really works in Scribus. Importing photos To import photos, you simply have to: Create an Image Frame with the Insert Image Frame tool (I) or with a shape or polygon converted to an Image Frame. Go to File | Import | Get Image or use Ctrl + D. This is the most common way to do it. On some systems, you can even drag the picture from your folder into the frame. The thing that you should never do is copy the photo (wherever it is) and paste it into your frame. When doing this, Scribus has no knowledge of the initial picture's storage location (because the copied image is placed in a special buffer shared among the applications), and that's what it needs. There are other ways to import an image. You can use: The DirectImageImport script The Picture Browser on some very new and experimental Scribus versions The DirectImageImport script is placed in the Script | Scribus Scripts menu. It will display a window waiting for you to specify which image to import. Once you validate, Scribus automatically creates the frame and places the image within. Some people find it useful because it seems that you can save one step this way. But, in fact, the frame size is a default based on the page width, so you will have to customize it. You might have to draw it directly with a good size and it should be as easy. But anyway, you'll choose the one you prefer. Always remember that each image needs a frame. The image might be smaller or bigger than the frame. In the first case it won't fill it, and in the second case it will appear cropped. You can adapt the frame size as you want; the photo won't change at all. However, one thing you will certainly want to do is move the picture within the frame to select a better area. To do this, double-click on the frame to go into the Content Editing mode; you can now drag the picture inside to place it more precisely. The contextual menu of the Image Frame will give you two menus that will help to make the size of the image the same as that of the frame: Adjust Image to Frame will extend or reduce the photo so that it fills the frame but keeps the photo's height to width ratio Adjust Frame to Image will modify the frame size so that it fits the image In both cases, once applied, you can change the size of the frame as you need to and the photo will automatically be scaled to fit the frame size. Using such options is really interesting because it is fast and easy, but it is not without some risk. When a frame shape is changed after the image is imported, the image itself doesn't change. For example, if you use any of the skew buttons in the Node window (Edit button of the Shape tab of PP) you'll see that the frame will be skewed but not the picture itself. Image changes have to be made in an image manipulation program. Relinking photos Once your photos have been imported and they fit perfectly in your page content, you may wish to stop for a day or show this to some other people. It's always a good idea to make your decisions later, as you'll see more weaknesses a few days later. It is generally at this point that problems appear. If you send your Scribus .sla document for proofreading, the photos won't be displayed on the proofreader's screen as they are not embedded into the file. The same issue arises if you decide to move or rename some folders or photos on your own computer. Since Scribus just saves the location of your files and loads them when necessary, it won't be able to find them anymore. In this case, don't worry at all. Nothing is lost; it is just that Scribus has no idea of what you have done to your file—you will just need to tell it. At this point, you have two possibilities: Import the photos that have disappeared, again, so that Scribus can save their new location. Go to Extra | Manage Images. Show where the photos have gone by choosing the missing photo (shown with red diagonals crossing the image display area) and clicking on the Search button just below it. When relinking, you can link to another image if you wish; these images just need to have the same name to make Scribus guess it's the good one. So it will be very important that you give unique names to your photos. You can define some naming rules, or keep the camera automatic numbering. If you need to send your document to someone, you can either send a PDF that can't be modified, just annotated, or the whole Scribus document along with the photos. The best thing for this is not to compress the photo folder. It won't make the link into Scribus for they are absolute and the folder path name will differ on your reader's computer. They would need to relink every picture and that might take long for some documents. The best technique is to use the built-in File } Collect for Output window. It will ask you to create a new directory in which all the files needed for that document will be copied with relative paths, so that it will work everywhere. Compress this folder and send it. Time for action – creating a postcard As an example, let's create a postcard. It's an easy document that won't need many features and, therefore, we can concentrate on our image issues. We'll go through the dos and don'ts to let you experiment with the problems that you might have with a bad workflow. Let's create a two page, A6 landscape document with a small margin guide of 6mm. After creating the page, use Page | Manage Guides and add one vertical guide with a gap of 5mm and one horizontal guide with a gap of 20mm. In the first frame, import (File | Import | Get Image) the pict8-1.psd file. Notice that it is in a folder called Photos, with some other files that we will use in this document. When you're in the file selector, Scribus shows some file information: you can see the size in pixels (1552x2592), the resolution (72x72), and the colorspace (RGB). This image will look very big in the frame. Right-click and choose Adjust Image to Frame. It fits the height but not the width. Also we'd want the bottom of the flower image to be at the bottom of the frame. Open the Properties Palette and in the Image tab, select the Free Scaling option and change the X-scale and Y-scale up to 12 or a value close to it. Now it might be better. In the top right-hand side frame, import pict8-2.jpg and set it in the best way you can using the same procedure. Double-click on the frame and drag the picture to find the best placement. Then in the last frame of the first page, import the pict8-3.png file. You can add frame text and type something inside it, such as "Utopia through centuries", and set it nicely. On the second page we'll use one horizontal column without gap and one vertical column with a 5mm gap. On the right-hand part of the horizontal guide (use Page | Snap to Guides if you want to be sure) draw an horizontal line from one vertical to another bordering that one. Keep this line selected and go to Item | Multiple Duplicate. In the window, choose 4 copies, leave the next option selected, and define a 0.4 inch vertical gap. Here it is necessary to write the address. At the bottom left-hand corner of the same page, draw a new Image Frame in which you can import the pict8-4.tif file. In the Image properties, scale the image to the frame size and deselect Proportional so that the image fills the frame perfectly, even if it is distorted. Then in the XYZ tab of the PP, click on the Flip Horizontally button (the blue double arrow icon). We have now set our pages and the photos are placed correctly. Let's create some errors voluntarily. First, let's say we rename the Photos folder to PostcardPhotos. This must be done in your file browser; you cannot do it from Scribus. Go back to Scribus. Things might not have changed for now, but if you right-click on an image and choose Update Image you will see that it won't be displayed anymore. If you want everything to go well again, you can rename your folder again or go to Extras | Manage Images. You see there that each Image Frame of the document is listed and that they contain nothing because the photos are not found anymore. For each image selected in this window, you'll have to click on the Search button and specify which directory it has been moved into in the next window. Scribus will display the image found (image with a similar name only). Select one of the listed images and click on Select. Everything should go well now. (Move the mouse over the image to enlarge.) What just happened? After having created our page, we placed our photos inside the frames. By renaming the folder we broke the link between Scribus and the image files. The Manage Images window lets us see what happened. The full paths to the pictures are displayed here. In our example, all the pictures are in the same folder, but you could have imported pictures from several directories. In this case, only those being included in the renamed folder would have disappeared from the Scribus frames. By clicking on Search, we told Scribus what happened to those pictures and that those pictures still exist but somewhere else. Notice that if you deleted the photos they will be lost forever. The best advice would be to keep a copy of everything: the original as well as the modified photos. Notice that if your images are stored on an external device, it should be plugged and mounted. In fact, renaming the folder is not the only reason why an image might disappear. It happens when: We rename the image folder We rename any parent folder of the image folder We rename the picture We delete the picture We delete the whole folder containing the picture Giving the documents and the pictures to someone else by an e-mail or an USB-key will certainly be similar to the second case. In the first three cases, using the Manage Images window will help you find the images (it's better to know where they are). In the last two cases, you should be ready to look for new pictures and import them into the frames.  
Read more
  • 0
  • 1
  • 25097

article-image-creating-quick-logo-company-gimp-26
Packt
06 Apr 2011
3 min read
Save for later

Creating a quick logo for a company with GIMP 2.6

Packt
06 Apr 2011
3 min read
How to do it... We can go about creating our logo by carrying out the following steps: In a new file, using the Text Tool, write the name of the company. Pick a font, its size, and place it a little above the middle of the canvas. Lock the layer by selecting it and clicking in the Lock checkbox to avoid accidentally making changes to it: Create a new gradient by clicking on the + button at the bottom of the Gradients dialog. If it is not enabled, call it by using Ctrl + G, or go to Windows | Dockable Dialogs | Gradients: To pick the colors for the gradient, position the mouse over the the orange bar (blue in Windows) and right-click: Select the Left Endpoint's Color: And/or the Right Endpoint's Color: Here are the colors I have chosen: Using the Blend Tool, apply the gradient: Right-click inside the text layer name in the Layers dialog, and select the Alpha to Selection option: Then, go to Select | Grow, and make it bigger by 3 pixels: Create a new layer and name it border. Fill it using the Bucket Fill Tool (I used a dark color), and place it underneath the text layer (drag and drop the border layer): Duplicate the border layer by clicking on the Duplicate button at the bottom of the layers dialog, or going to Layer | Duplicate Layer. Repeat this operation with the text layer. Move this last duplicated layer on top of the border copy layer. Merge these duplicated layers by going to Layer | Merge Down, and change its name to reflection: Choose Select | none from the menu to be sure there's no selection present. Using the Move Tool, place the reflection layer below the "text" layer and flip it with the Flip Tool. Use the Move Tool to adjust the position of the flipped text, and separate them vertically by just a few pixels. Right-click in the reflection layer inside the Layers dialog, and select the Add Layer Mask option. Choose the Black (Full Transparency) and click Add. Using the Blend Tool, pick the FG to BG gradient from the Gradients Dialog, and apply it from bottom to the top to create a semitransparent reflection of the text: Select the original text layer. Right-click on it in the Layers dialog, and choose Alpha to Selection. Then with the Ellipse Select Tool in subtract mode (check the following image): Draw an ellipse, as in the following image: Create a new layer and name it glass. Then, fill it with a white color using the Bucket Fill Tool: Change its opacity to something around 30 and you are done! Here's the final logo: How it works... Just by using a font you like and a few tools you quickly created a logo. See how we only used default paint/blend tools and masks to create it? GIMP has powerful extensions but you can also create professional pieces without using complex filters or even using much time. Summary This article showed us how to use a few filters to create a company logo. Further resources on this subject: Photo Manipulation with GIMP 2.6 [Article] How To Create Amazing Text and Font Effects in Gimp 2.6 [Article] Creating Pseudo-3D Imagery with GIMP [Article] Blender 2.5: Creating a UV Texture [Article] Python Graphics: Combining Raster and Vector Pictures [Article] Open Source Awards 2010: Gimp [Article]
Read more
  • 0
  • 0
  • 16015

article-image-squid-proxy-server-3-getting-started
Packt
06 Apr 2011
12 min read
Save for later

Squid Proxy Server 3: getting started

Packt
06 Apr 2011
12 min read
What is a proxy server? A proxy server is a computer system sitting between the client requesting a web document and the target server (another computer system) serving the document. In its simplest form, a proxy server facilitates communication between client and target server without modifying requests or replies. When we initiate a request for a resource from the target server, the proxy server hijacks our connection and represents itself as a client to the target server, requesting the resource on our behalf. If a reply is received, the proxy server returns it to us, giving a feel that we have communicated with the target server. In advanced forms, a proxy server can filter requests based on various rules and may allow communication only when requests can be validated against the available rules. The rules are generally based on an IP address of a client or target server, protocol, content type of web documents, web content type, and so on. As seen in the preceding image, clients can't make direct requests to the web servers. To facilitate communication between clients and web servers, we have connected them using a proxy server which is acting as a medium of communication for clients and web servers. Sometimes, a proxy server can modify requests or replies, or can even store the replies from the target server locally for fulfilling the same request from the same or other clients at a later stage. Storing the replies locally for use at a later time is known as caching. Caching is a popular technique used by proxy servers to save bandwidth, empowering web servers, and improving the end user's browsing experience. Proxy servers are mostly deployed to perform the following: Reduce bandwidth usage Enhance the user's browsing experience by reducing page load time which, in turn, is achieved by caching web documents Enforce network access policies Monitoring user traffic or reporting Internet usage for individual users or groups Enhance user privacy by not exposing a user's machine directly to Internet Distribute load among different web servers to reduce load on a single server Empower a poorly performing web server Filter requests or replies using an integrated virus/malware detection system Load balance network traffic across multiple Internet connections Relay traffic around within a local area network In simple terms, a proxy server is an agent between a client and target server that has a list of rules against which it validates every request or reply, and then allows or denies access accordingly. What is a reverse proxy? Reverse proxying is a technique of storing the replies or resources from a web server locally so that the subsequent requests to the same resource can be satisfied from the local copy on the proxy server, sometimes without even actually contacting the web server. The proxy server or web cache checks if the locally stored copy of the web document is still valid before serving the cached copy. The life of the locally stored web document is calculated from the additional HTTP headers received from the web server. Using HTTP headers, web servers can control whether a given document/response should be cached by a proxy server or not. Web caching is mostly used: To reduce bandwidth usage. A large number of static web documents like CSS and JavaScript files, images, videos, and so on can be cached as they don't change frequently and constitutes the major part of a response from a web server. By ISPs to reduce average page load time to enhance browsing experience for their customers on Dial-Up or broadband. To take a load off a very busy web server by serving static pages/documents from a proxy server's cache. How to download Squid Squid is available in several forms (compressed source archives, source code from a version control system, binary packages such as RPM, DEB, and so on) from Squid's official website, various Squid mirrors worldwide, and software repositories of almost all the popular operating systems. Squid is also shipped with many Linux/Unix distributions. There are various versions and releases of Squid available for download from Squid's official website. To get the most out of a Squid installation its best to check out the latest source code from a Version Control System (VCS) so that we get the latest features and fixes. But be warned, the latest source code from a VCS is generally leading edge and may not be stable or may not even work properly. Though code from a VCS is good for learning or testing Squid's new features, you are strongly advised not to use code from a VCS for production deployments. If we want to play safe, we should probably download the latest stable version or stable version from the older releases. Stable versions are generally tested before they are released and are supposed to work out of the box. Stable versions can directly be used in production deployments. Time for action – identifying the right version A list of available versions of Squid is maintained here. For production environments, we should use versions listed under the Stable Versions section only. If we want to test new Squid features in our environment or if we intend to provide feedback to the Squid community about the new version, then we should be using one of the Beta Versions. As we can see in the preceding screenshot, the website contains the First Production Release Date and Latest Release Date for the stable versions. If we click on any of the versions, we are directed to a page containing a list of all the releases in that particular version. Let's have a look at the page for version 3.1: For every release, along with a release date, there are links for downloading compressed source archives. Different versions of Squid may have different features. For example, all the features available in Squid version 2.7 may or may not be available in newer versions such as Squid 3.x. Some features may have been deprecated or have become redundant over time and they are generally removed. On the other hand, Squid 3.x may have several new features or existing features in an improved and revised manner. Therefore, we should always aim for the latest version, but depending on the environment, we may go for stable or beta version. Also, if we need specific features that are not available in the latest version, we may choose from the available releases in a different branch. What just happened? We had a brief look at the pages containing the different versions and releases of Squid, on Squid's official website. We also learned which versions and releases that we should download and use for different types of usage. Methods of obtaining Squid After identifying the version of Squid that we should be using for compiling and installation, let's have a look at the ways in which we can obtain Squid release 3.1.10. Using source archives Compressed source archives are the most popular way of getting Squid. To download the source archive, please visit Squid download page, http://www.squid-cache.org/Download/. This web page has links for downloading the different versions and releases of Squid, either from the official website or available mirrors worldwide. We can use either HTTP or FTP for getting the Squid source archive. Time for action – downloading Squid Now we are going to download Squid 3.1.10 from Squid's official website: Let's go to the web page. Now we need to click on the link to Version 3.1, as shown in the following screenshot: We'll be taken to a page displaying the various releases in version 3.1. The link with the display text tar.gz in the Download column is a link to the compressed source archive for Squid release 3.1.10, as shown in the following screenshot: To download Squid 3.1.10 using the web browser, just click on the link. Alternatively, we can use wget to download the source archive from the command line as follows: wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.10.tar.gz What just happened? We successfully retrieved Squid version 3.1.10 from Squid's official website. The process of retrieving other stable or beta versions is very similar. Obtaining the latest source code from Bazaar VCS Advanced users may be interested in getting the very latest source code from the Squid code repository, using Bazaar. We can safely skip this section if we are not familiar with VCS in general. Bazaar is a popular version control system used to track project history and facilitate collaboration. From version 3.x onwards, Squid source code has been migrated to Bazaar. Therefore, we should ensure that we have Bazaar installed on our system in order to checkout the source code from repository. To find out more about Bazaar or for Bazaar installation and configuration manuals, please visit Bazaar's official website. Once we have setup Bazaar, we should head to the Squid code repository mirrored on Launchpad. From here we can browse all the versions and branches of Squid. Let's get ourselves familiar with the page layout: In the previous screenshot, Series: trunk represents the development branch, which contains code that is still in development and is not ready for production use. The branches with the status Mature are stable and can be used right away in production environments. Time for action – using Bazaar to obtain source code Now that we are familiar with the various branches, versions, and releases. Let's proceed to checking out the source code with Bazaar. To download code from any branch, the syntax for the command is as follows: bzr branch lp:squid[/branch[/version]] branch and version are optional parameters in the previous code. So, if we want to get branch 3.1, then the command will be as follows: bzr branch lp:squid/3.1 The previous command will fetch source code from Launchpad and may take a considerable amount of time, depending on the Internet connection. If we are willing to download source code for Squid version 3.1.10, then the command will be as follows: bzr branch lp:squid/3.1/3.1.10 In the previous code, 3.1 is the branch name and 3.1.10 is the specific version of Squid that we want to checkout. What just happened? We learned to fetch the source code for any Squid branch or release using Bazaar from Squid's source code hosted on Launchpad. Have a go hero – fetching the source code Using the command syntax that we learned in the previous section, fetch the source code for Squid version 3.0.stable25 from Launchpad. Solution: bzr branch lp:squid/3.0/3.0.stable25 Explanation: If we browse to the particular version on Launchpad, the version number used in the command becomes obvious. Using binary packages Squid binary packages are pre-compiled and ready to install software bundles. Binary packages are available in the software repositories of almost all Linux/Unix-based operating systems. Depending on the operating system, only stable and sometimes well tested beta versions make it to the software repositories, so they are ready for production use. Installing Squid Squid can be installed using the source code we obtained in the previous section, using a package manager which, in turn, uses the binary package available for our operating system. Let's have a detailed look at the ways in which we can install Squid. Installing Squid from source code Installing Squid from source code is a three step process: Select the features and operating system-specific settings. Compile the source code to generate the executables. Place the generated executables and other required files in their designated locations for Squid to function properly. We can perform some of the above steps using automated tools that make the compilation and installation process relatively easy. Compiling Squid Compiling Squid is a process of compiling several files containing C/C++ source code and generating executables. Compiling Squid is really easy and can be done in a few steps. For compiling Squid, we need an ANSI C/C++ compliant compiler. If we already have a GNU C/C++ Compiler (GNU Compiler Collection (GCC) and g++, which are available on almost every Linux/Unix-based operating system by default), we are ready to begin the actual compilation. Why compile? Compiling Squid is a bit of a painful task compared to installing Squid from the binary package. However, we recommend compiling Squid from the source instead of using pre-compiled binaries. Let's walk through a few advantages of compiling Squid from the source: While compiling we can enable extra features, which may not be enabled in the pre-compiled binary package. When compiling, we can also disable extra features that are not needed for a particular environment. For example, we may not need Authentication helpers or ICMP support. configure probes the system for several features and enables or disables them accordingly, while pre-compiled binary packages will have the features detected for the system the source was compiled on. Using configure, we can specify an alternate location for installing Squid. We can even install Squid without root or super user privileges, which may not be possible with pre-compiled binary package. Though compiling Squid from source has a lot of advantages over installing from the binary package, the binary package has its own advantages. For example, when we are in damage control mode or a crisis situation and we need to get the proxy server up and running really quickly, using a binary package for installation will provide a quicker installation. Uncompressing the source archive If we obtained the Squid in a compressed archive format, we must extract it before we can proceed any further. If we obtained Squid from Launchpad using Bazaar, we don't need to perform this step. tar -xvzf squid-3.1.10.tar.gz tar is a popular command which is used to extract compressed archives of various types. On the other hand, it can also be used to compress many files into a single archive. The preceding command will extract the archive to a directory named squid-3.1.10.
Read more
  • 0
  • 0
  • 9481

article-image-zbrush-4-modeling-creature-zsketch
Packt
06 Apr 2011
4 min read
Save for later

ZBrush 4: how to model a creature with ZSketch

Packt
06 Apr 2011
4 min read
What the creature looks like The Brute is a crossbreed between a harmless emu and a wild forest bear. It is a roaming rogue living in the deepest forests. Only a few people have seen it and survived, so it's said to be between three and eight meters high. Despite its size, it combines strength and agility in a dangerous way. It is said that it hides his rather cute-looking head with trophies of its victims. ZSketching a character In this workflow, we can think of our ZSpheres as a skeleton we can place our virtual clay onto. So we try to build the armature, not as thick as the whole arm, but as thick as the underlying bone would be. With that in mind, let's get started. Time for action – creating the basic armature with ZSpheres Let's say the art director comes to your desk and shows you a concept of a monster to be created for the game project that you're working on. As always, there's little to no time for this task. Don't panic; just sketch it with ZSketch in no time. Let's see how this works: Pick a new ZSphere and align its rotation by holding Shift. Set your draw size down to 1. Activate Symmetry on the X-axis. The root ZSphere can't be deleted without deleting everything else, so the best place for this would be in the pelvis area. Placing the cursor on the line of symmetry will create a single ZSphere—this is indicated by the cursor turning green. Start out to create the armature or skeleton from the root ZSphere, commencing from the pelvis to the head, as shown in the next screenshot. Similar to the human spine, it roughly follows an S-curve: Continue by adding the shoulders. A little trick is to start the clavicle bone a bit lower at the spine, which gives a more natural motion in the shoulder area. Add the arms with the fingers as one ZSphere plus the thumbs, we'll refine it later. The arms should be lowered and bent so that we're able to judge the overall proportions better, as the next image shows: This "skeleton" will also be used for moving or posing our model, so we'll try to place ZSpheres where our virtual joints would be, for example, at the elbow joint. Add the hips, stretching out from the pelvis and continue with the legs. Try to bend the legs a bit (which looks more natural) as shown in the next screenshot. Finally, add the foot as one ZSphere for the creature to stand on: Now we have all the basic features of the armature ready. Let's check the concept again to get our character's proportions right. Because our character is more of a compact, bulky build, we have to shorten his legs and neck a bit. Make sure to check the perspective view, too. Inside any game engine, characters will be viewed in perspective. We can also set the focal angle under Draw FocalAngle|. The default value is 50. Switching perspective off helps comparing lengths. Add another ZSphere in the belly area to better control its mass, even if it looks embarrassing. To make him look less like Anubis, you may want to lower the top-most ZSphere a bit, so it will fit the horns. Our revised armature could now look like this with perspective enabled: With the overall proportions done, let's move on with details, starting with the toes. Insert another ZSphere next to the heels and continue by adding the toes, including the tiny fourth toe, as shown in the next screenshot: With larger ZSpheres, we can better judge the mass of the foot. But because we need a thinner bone-like structure, let's scale them down once we're done. Be careful to scale the ZSpheres, and not the Link spheres in-between them. This keeps them in place while scaling, as shown in the next image:
Read more
  • 0
  • 0
  • 3641

article-image-apache-wicket-displaying-data-using-datatable
Packt
01 Apr 2011
6 min read
Save for later

Apache Wicket: displaying data using DataTable

Packt
01 Apr 2011
6 min read
It's hard to find a web application that does not have a single table that presents the user with some data. Building these DataTables, although not very difficult, can be a daunting task because each of these tables must often support paging, sorting, filtering, and so on. Wicket ships with a very powerful component called the DataTable that makes implementing all these features simple and elegant. Because Wicket is component-oriented, once implemented, these features can be easily reused across multiple DataTable deployments. In this article, we will see how to implement the features mentioned previously using the DataTable and the infrastructure it provides. Sorting A common requirement, when displaying tabular data, is to allow users to sort it by clicking the table headers. Click a header once and the data is sorted on that column in ascending order; click it again, and the data is sorted in the descending order. In this recipe, we will see how to implement such a behavior when displaying data using a DataTable component. We will build a simple table that will look much like a phone book and will allow the sorting of data on the name and e-mail columns: Getting ready Begin by creating a page that will list contacts using the DataTable, but without sorting: Create Contact bean: Contact.java public class Contact implements Serializable { public String name, email, phone; // getters, setters, constructors2. Create the page that will list the contacts: HomePage.html <html> <body> <table wicket_id="contacts" class="contacts"></table> </body> </html> HomePage.java public class HomePage extends WebPage { private static List<Contact> contacts = Arrays.asList( new Contact("Homer Simpson", "homer@fox.com", "555-1211"), new Contact("Charles Burns", "cmb@fox.com", "555-5322"), new Contact("Ned Flanders", "green@fox.com", "555-9732")); public HomePage(final PageParameters parameters) { // sample code adds a DataTable and a data providert hat uses the contacts list created above } } How to do it... Enable sorting by letting DataTable columns know they can be sorted by using a constructor that takes the sort data parameter: HomePage.java List<IColumn<Contact>> columns = new ArrayList<IColumn<Contact>>(); columns.add(new PropertyColumn<Contact>(Model.of("Name"), "name","name")); columns.add(new PropertyColumn<Contact>(Model.of("Email"), "email", "email")); columns.add(new PropertyColumn<Contact>(Model.of("Phone"), "phone")); Implement sorting by modifying the data provider: private static class ContactsProvider extends SortableDataProvider<Contact> { public ContactsProvider() { setSort("name", true); } public Iterator<? extends Contact> iterator(int first, int count) { List<Contact> data = new ArrayList<Contact>(contacts); Collections.sort(data, new Comparator<Contact>() { public int compare(Contact o1, Contact o2) { int dir = getSort().isAscending() ? 1 : -1; if ("name".equals(getSort().getProperty())) { return dir * (o1.name.compareTo(o2.name)); } else { return dir * (o1.email.compareTo(o2.email)); } } }); return data.subList(first, Math.min(first + count, data.size())).iterator(); } public int size() { return contacts.size(); } public IModel<Contact> model(Contact object) { return Model.of(object); } } How it works... DataTable supports sorting out of the box. Any column with the IColumn#getSortProperty() method that returns a non-null value is treated as a sortable column and Wicket makes its header clickable. When a header of a sortable column is clicked Wicket will pass the value of IColumn#getSortProperty to the data provider which should use this value to sort the data. In order to know about the sorting information the data provider must implement the ISortableDataProvider interface; Wicket provides the default SortableDataProvider implementation which is commonly used to implement sort-capable data providers. DataTable will take care of details such as multiple clicks to the same column resulting in change of sorting direction, so on. Let's examine how to implement sorting in practice. In step 1 and 2, we have implemented a basic DataTable that cannot yet sort data. Even though the data provider we have implemented already extends a SortableDataProvider, it does not yet take advantage of any sort information that may be passed to it. We start building support for sorting by enabling it on the columns, in our case the name and the email columns: List<IColumn<Contact>> columns = new ArrayList<IColumn<Contact>>(); columns.add(new PropertyColumn<Contact>(Model.of("Name"), "name", "name")); columns.add(new PropertyColumn<Contact>(Model.of("Email"), "email", "email")); columns.add(new PropertyColumn<Contact>(Model.of("Phone"), "phone")); We enable sorting on the columns by using the three-argument constructor of the PropertyColumn, with the second argument being the "sort data". Whenever a DataTable column with sorting enabled is clicked, the data provider will be given the value of the "sort data". In the example, only the name and e-mail columns have sorting enabled with the sort data defined as a string with values "name" and "e-mail" respectively. Now, let's implement sorting by making our data provider implementation sort-aware. Since our data provider already extends a provider that implements ISortableDataProvider we only need to take advantage of the sort information: public Iterator<? extends Contact> iterator(int first, int count) { List<Contact> data = new ArrayList<Contact>(contacts); Collections.sort(data, new Comparator<Contact>() { public int compare(Contact o1, Contact o2) { int dir = getSort().isAscending() ? 1 : -1; if ("name".equals(getSort().getProperty())) { return dir * (o1.name.compareTo(o2.name)); } else { return dir * (o1.email.compareTo(o2.email)); } } }); return data.subList(first, Math.min(first + count, data.size())).iterator(); } First we copy the data into a new list which we can sort as needed and then we sort based on the sort data and direction provided. The value returned by getSort().getProperty() is the same sort data values we have defined previously when creating columns. The only remaining task is to define a default sort which will be used when the table is rendered before the user clicks any header of a sortable column. We do this in the constructor of our data provider: public ContactsProvider() { setSort("name", true); } There's more... DataTable gives us a lot out of the box; in this section we see how to add some usability enhancements. Adding sort direction indicators via CSS DataTable is nice enough to decorate sortable <th> elements with sort-related CSS classes out of the box. This makes it trivial to implement sort direction indicators as shown in the following screenshot: A possible CSS style definition can look like this: table tr th { background-position: right; background-repeat:no-repeat; } table tr th.wicket_orderDown { background-image: url(images/arrow_down.png); } table tr th.wicket_orderUp { background-image: url(images/arrow_up.png); } table tr th.wicket_orderNone { background-image: url(images/arrow_off.png);
Read more
  • 0
  • 1
  • 9181

article-image-moodle-20-science-monitoring-your-students-progress
Packt
01 Apr 2011
7 min read
Save for later

Moodle 2.0 Science: Monitoring Your Students' Progress

Packt
01 Apr 2011
7 min read
Moodle is a really useful tool for helping teachers to monitor the progress of their students. As any teacher knows, this can be a challenge, so having everything in one place is very useful. We'll look at how you can monitor progress with an example. Checking usage and completion of tasks For you to be able to help your users learn, it goes without saying that they have to complete the tasks you set! Quite a common question is "how do I know if my users are looking at the content I make for them?" There are a variety of ways to monitor this, which vary depending on whether you are looking at a resource or an activity. Tracking usage of course materials Quite often you might set your students a task to go on to your Moodle course and read a resource that you have uploaded or follow a link to another website. While you can't know for sure that they have read the material, it is possible to check that they have displayed it on their screen. To check if users had viewed a resource, we have completion tracking. To use this feature, your administrator must enable it for your whole site and you need to turn it on in the student progress section of the course settings. This means that now you can easily see a list of users who have looked at the resource. On the pupil view, there are boxes next to items that require completion. If a teacher has specified certain conditions that need to be met, the box will automatically fill with a tick once they have been met. Users can also use this to manually track their progress towards completion if there are no criteria set for a particular task by ticking a shaded box themselves. This is shown in the following screenshot: Preparation for course completion reports The course completion report will show you which activities or resources your learners have used. To demonstrate this first you need to change some of the settings on your resources and activities, and ask your administrator to enable it in the site settings. Completion settings for resources Let's go back to a resource we uploaded in the first topic "Manufacture of magnesium sulfate" and edit it. Click on Turn editing on, which has the icon of the hand holding the pen. When the updating file dialog comes up, scroll right down to the bottom where it says Activity completion. Here you have a number of settings, as shown in the next screenshot: We're going to use the setting Show activity as complete when conditions are met. If you're happy letting your users decide to declare when they have completed an activity, you can use the setting Students can manually mark the activity as completed. This would be useful for a self review, towards pupils building a portfolio, or just to get them to take more responsibility over their learning. Once you've done this choose the conditions that need to be met. As this is a resource check the box next to Require view. These conditions vary depending on the nature of the activity. If you want to you can set a date when you expect the activity to be completed. This is just to help organize your completion report and is not shared with the users. Completion settings for activities Different activities have their own settings that you can set to decide when an activity is completed by your users. We'll go through each of these below. Forum activity completion settings You can set up activity completion for forums. In the introduction to this forum, our learners were asked to answer the most recent unanswered question and then post a question of their own. Let's use activity completion to make sure that they do this. In the same way, go to update the forum and scroll down to the activity completion settings at the bottom. You'll notice that there are a lot more options than for a resource. The activity completion settings that we'll choose are Required discussions and Require replies. Both of these will be set to one. This means that your students will need to start at least one discussion and provide at least one reply. Don't forget to set the completion tracking setting in the top drop-down box. This is what the settings will look like: Quiz activity completion For quizzes (assignments and lessons), there are two options for activity completion. You can either require your users to view the quiz or require a grade. Let's go back to the motion quiz we set up and let that require students to receive a grade to complete this activity. Here are the settings: Chat activity completion For a chat activity, the only completion option is for users to manually check the boxes completed. Once you've gone through and set the activity completion settings you will be able to see which of your activities your users have completed. Completion tracking for your whole course Now that you have set up your activities and resources to be tracked, you need to define at a course level, which activities need to be finished for course completion. From the settings block on the left-hand side, click on the link Completion tracking. This is where you decide on the criteria for course completion. We want our users to complete all of the activities chosen, so in the first box choose All for the aggregation method. If there are prerequisites for your course, you can set them here. In the activities completed box, check all of the activities you want your users to complete and specify the completion dates, if any, and passing grades. All the settings can be changed to a later date, if you wish. Course completion reports You can now set up the course completion reports. The link can be found in the navigation block on the left-hand side: Once you click on the course completion reports link, you should see something like the following: The grayed out boxes with ticks are for activities that users can manually choose completion for. So as you can see, it would be quite easy to identify which users haven't completed particular tasks. From here, you can click a user's name and send them a reminder via a message. You can also export this data if you wish. Course reports There are three different types of course reports—activity report, view course logs, and participation report. You can use them to monitor your users in slightly different ways. Activity report For the activity report, you can see a simple overview of the number of views for each activity. This could be useful if you want to see if one activity is more popular than another or if an activity is not being viewed a lot. View course logs This report shows detailed usage across the whole course. Now that we are using completion reports, you would only need to use this type of log if you wanted to check when a particular user accessed a task. Participation report This report gives you a customizable overview for each activity listed by a user. You could use this type of report to see if the users have viewed or posted to an activity or resource and then send messages directly to multiple users.
Read more
  • 0
  • 0
  • 2178
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-getting-started-sphinx-search
Packt
31 Mar 2011
6 min read
Save for later

Getting Started with Sphinx Search

Packt
31 Mar 2011
6 min read
Sphinx is a full-text search engine. So, before going any further, we need to understand what full-text search is and how it excels over the traditional searching. What is full-text search? Full-text search is one of the techniques for searching a document or database stored on a computer. While searching, the search engine goes through and examines all of the words stored in the document and tries to match the search query against those words. A complete examination of all the words (text) stored in the document is undertaken and hence it is called a full-text search. Full-text search excels in searching large volumes of unstructured text quickly and effectively. It returns pages based on how well they match the user's query. Traditional search To understand the difference between a normal search and full-text search, let's take an example of a MySQL database table and perform searches on it. It is assumed that MySQL Server and phpMyAdmin are already installed on your system. Time for action – normal search in MySQL Open phpMyAdmin in your browser and create a new database called myblog. Select the myblog database: Create a table by executing the following query: CREATE TABLE `posts` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 255 ) NOT NULL , `description` TEXT NOT NULL , `created` DATETIME NOT NULL , `modified` DATETIME NOT NULL ) ENGINE = MYISAM; Queries can be executed from the SQL page in phpMyAdmin. You can find the link to that page in the top menu. Populate the table with some records: INSERT INTO `posts`(`id`, `title`, `description`, `created`, `modified`) VALUES (1, 'PHP scripting language', 'PHP is a web scripting language originally created by Rasmus Lerdorf', NOW(), NOW()), (2, 'Programming Languages', 'There are many languages available to cater any kind of programming need', NOW(), NOW()), (3, 'My Life', 'This post is about my life which in a sense is beautiful', NOW(), NOW()), (4, 'Life on Mars', 'Is there any life on mars?', NOW(), NOW()); Next, run the following queries against the table: SELECT * FROM posts WHERE title LIKE 'programming%'; The above query returns row 2. SELECT * FROM posts WHERE description LIKE '%life%'; The above query return rows 3 and 4. SELECT * FROM posts WHERE description LIKE '%scripting language%'; The above query returns row 1. SELECT * FROM posts WHERE description LIKE '%beautiful%' OR description LIKE '%programming%'; The above query returns rows 2 and 3. phpMyAdmin To administer MySQL database, I highly recommend using a GUI interface tool like phpMyAdmin (http://www.phpmyadmin.net). All the above mentioned queries can easily be executed What just happened? We first created a table posts to hold some data. Each post has a title and a description. We then populated the table with some records. With the first SELECT query we tried to find all posts where the title starts with the word programming. This correctly gave us the row number 2. But what if you want to search for the word anywhere in the field and not just at that start? For this we fired the second query, wherein we searched for the word life anywhere in the description of the post. Again this worked pretty well for us and as expected we got the result in the form of row numbers 3 and 4. Now what if we wanted to search for multiple words? For this we fired the third query where we searched for the words scripting language. As row 1 has those words in its description, it was returned correctly. Until now everything looked fine and we were able to perform searches without any hassle. The query gets complex when we want to search for multiple words and those words are not necessarily placed consecutively in a field, that is, side by side. One such example is shown in the form of our fourth query where we tried to search for the words programming and beautiful in the description of the posts. Since the number of words we need to search for increases, this query gets complicated, and moreover, slow in execution, since it needs to match each word individually. The previous SELECT queries and their output also don't give us any information about the relevance of the search terms with the results found. Relevance can be defined as a measure of how closely the returned database records match the user's search query. In other words, how pertinent the result set is to the search query. Relevance is very important in the search world because users want to see the items with highest relevance at the top of their search results. One of the major reasons for the success of Google is that their search results are always sorted by relevance. MySQL full-text search This is where full-text search comes to the rescue. MySQL has inbuilt support for full-text search and you only need to add FULLTEXT INDEX to the field against which you want to perform your search. Continuing the earlier example of the posts table, let's add a full-text index to the description field of the table. Run the following query: ALTER TABLE `posts` ADD FULLTEXT ( `description` ); The query will add an INDEX of type FULLTEXT to the description field of the posts table. Only MyISAM Engine in MySQL supports the full-text indexes. Now to search for all the records which contain the words programming or beautiful anywhere in their description, the query would be: SELECT * FROM posts WHERE MATCH (description) AGAINST ('beautiful programming'); This query will return rows 2 and 3, and the returned results are sorted by relevance. One more thing to note is that this query takes less time than the earlier query, which used LIKE for matching. By default, the MATCH() function performs a natural language search, it attempts to use natural language processing to understand the nature of the query and then search accordingly. Full-text search in MySQL is a big topic in itself and we have only seen the tip of the iceberg. For a complete reference, please refer to the MySQL manual at http://dev.mysql.com/doc/. Advantages of full-text search The following points are some of the major advantages of full-text search: It is quicker than traditional searches as it benefits from an index of words that is used to look up records instead of doing a full table scan It gives results that can be sorted by relevance to the searched phrase or term, with sophisticated ranking capabilities to find the best documents or records It performs very well on huge databases with millions of records It skips the common words such as the, an, for, and so on When to use a full-text search? When there is a high volume of free-form text data to be searched When there is a need for highly optimized search results When there is a demand for flexible search querying
Read more
  • 0
  • 0
  • 2017

article-image-creating-tables-latex
Packt
31 Mar 2011
4 min read
Save for later

How to create tables in LaTeX

Packt
31 Mar 2011
4 min read
LaTeX is a high-quality open source typesetting software that produces professional prints and PDF files. In this LaTeX tutorial, taken from by LaTeX Beginner's Guide, you'll learn how to line up text and data in columns and typeset complex tables. (For more resources on this subject, see here.) How to align text in columns in LaTeX Remember the time of the typewriter and early word processing software? When we needed to line up some text in columns, we could use tab stops. LaTeX provides a similar way to easily align text in columns, namely, the tabbing environment. Time for action – lining up information using the tabbing environment We would like to present a quick overview regarding LaTeX. We shall present one point on each line, aligned at words and double colons: Begin a new document and open a tabbing environment: documentclass{article} begin{document} begin{tabbing} Write the text, set tab stops by =, and end the line by \: emph{Info:} = Software = : = LaTeX \ Add further lines, move to the next tab stop by >, and again end lines by \: > Author > : > Leslie Lamport \ > Website > : > www.latex-project.org Close the tabbing environment and end the document: end{tabbing} end{document} Typeset to get the output: What just happened? The tabbing environment that we used begins a new line. We used three simple tags for markup: = sets a tab stop. We could put several tab stops on a line. If we use = later, the next awaited tab stop would be reset to this position. \ ends a row. > goes to the next tab stop. This could also mean to go backwards. This way, we can quickly produce columns containing left-aligned text. If the rows of the tabbing environment would reach the end of a page, it could continue on the next page. What if a column is too long, running over the tab stop? Let's see how to solve that. Time for action – lining up font commands Now we shall create a table: Begin a new document, like the one in step 1 of our previous example, but define a command for setting the font of our header: documentclass{article} newcommand{head}[1]{textbf{#1}} begin{document} begin{tabbing} Write the first row set tab stops by = and use > to move to the tab stops. Use the command verb…|| to typeset the LaTeX commands: begin{tabbing} Family = verb|textrm{...}| = head{Declaration} = kill > head{Command} > head{Declaration} > head{Example}\ Family > verb|textrm{...}| > verb|rmfamily| > rmfamily Example text\ > verb|textsf{...}| > verb|sffamily| > sffamily Example text\ > verb|texttt{...}| > verb|ttfamily| > ttfamily Example text end{tabbing} Typeset and examine: As we can see, the tab stops are too narrow. We shall correct it. Create a new head row containing the tab stops; this time, we will mark the line by kill to hide that line. Use filler text to specify the width between the tab stops. Complete it with further font commands: begin{tabbing} Family = verb|textrm{...}| = head{Declaration} = kill > head{Command} > head{Declaration} > head{Example}\ Family > verb|textrm{...}| > verb|rmfamily| > rmfamily Example text\ > verb|textsf{...}| > verb|sffamily| > sffamily Example text\ > verb|texttt{...}| > verb|ttfamily| > ttfamily Example text end{tabbing} Typeset to get the result: What just happened? After we noticed that our tab stops have been set too narrow, we constructed a new first row containing the tab stops. It consists of words representing the widest entries of each column. To hide this auxiliary row, we used the command kill right at the end of the line; kill at the end of a line causes this line to have no output. Like in this example, the command verb|code| typesets code "as it is", without interpreting commands within. Instead of |, any character may be chosen as the delimiter. verb cannot be used in arguments of commands including section and footnote, and not in table heads. For longer, verbatim text, use the environment with the same name: verbatim. There are further useful commands: + at the end of a line causes each subsequent line to start at the first tab. Use it twice ++ to start at the second tab and so on. - cancels a preceding +; also using multiply has cumulative effect. < at the beginning of a line cancels the effect of one previous + command for that line. The mentioned commands already allow a good use of the tabbing environment. Even more commands can be found in the reference manual: http://texblog.net/help/latex/ tabbing.html. Inside tabbing environments, declarations are local to the current item. A following =, >, \, or kill command would stop the effect. Tabbing environments cannot be nested.
Read more
  • 0
  • 0
  • 10771

article-image-how-set-basic-workshop-moodle
Packt
31 Mar 2011
9 min read
Save for later

How to Set Up a Basic Workshop in Moodle

Packt
31 Mar 2011
9 min read
  Moodle 1.9 Testing and Assessment Develop and evaluate quizzes and tests using Moodle modules         Read more about this book       (For more resources on Moodle, see here.) Workshop is an important part of our look at testing and assessing with Moodle. Here we will look at Workshop, which offers a way to interact and assess students through their submitted work as well as offering the option of self-assessment, peer assessment, and teacher assessment. The first thing we need to do is name the Workshop and give it a description. We will call ours Paragraph Writing Workshop. In the description, we will write a brief summary of what is expected. We are going to test our students on their ability to write a paragraph on a topic of their choosing, with the requirements being that they have a main idea, supporting sentences, and a conclusion. Now, we need to choose our settings. For our first Workshop, we're going to leave most of the settings at the default. The first settings we are going to change are the Grade for Submission and Grade for Assessments. We want our Workshop to be worth 100 points, with each aspect, the teacher and peer assessment, of the Workshop making up half the grade, 50 percent and 50 percent respectively. The other setting we're going to change is Number of Comments, Assessment Elements, Grade Bands, which we will move from one to three. We are moving it to three because our paragraph has three elements we are going to evaluate: main idea, support, and conclusion. Once we've made that change in the Workshop, we will save it. The first thing we see after saving the Workshop is Editing Assessment Elements, since we decided to stay with the default Accumulative grading technique. We have three Elements to complete here, and for Element 1 we are going to enter 'Has a main idea.' For Element 2 we are going to enter 'Has supporting sentences.' For Element 3 we are going to enter 'Has a conclusion.' For each Type of Scale menu, we are going to leave it set to the two point Yes or No scale, since we are simply going to be checking whether or not the paragraph has met the requirements set. We are also going to leave the Element Weight set at 1, since we want each Element to be equal. Once we have entered everything and confirmed the spelling, we click on Save changes. Once the page has been saved, we are taken to the Paragraph Writing Workshop page. Workshop page—Teacher's view This page has all the information you need regarding the Workshop. It has three sections, which give us all the details about the Workshop. The top section is shown in the next screenshot: Here, we have the information about the phase the Workshop is in. The phases are Set up Assignment, Allow Submissions, Allow Submissions and Assessments, Allow Assessments, Calculation of Final Grades, and Show Final Grades. The phases let us know where we are in the Workshop. As you can see, we are in the Allow Submissions and Assessments phase. We also see the start and end of submissions and assessments. The final information contained in this section is the Maximum grade. Here, we see that our maximum grade is 100. This is because we changed the settings from default and the Grade for Assessments and Grade for Submission were both set to 50. Next to the Maximum grade, we see the Specimen Assessment Form link. Clicking on this link will bring us to a sample of the Assessment Sheet we created. This is shown in the next screenshot: I have only shown the first Element here, and the others follow the same pattern. At the top we see the date and time. Under that, we see the criterion we are assessing in the submitted work. Following this, we see the Grade. We have chosen to use a simple 2 Point Scale, Yes or No, so we are presented with just that. Under this we see an area for comments regarding Element 1. Underneath all of the Elements of the Assessment sheet, there is a box for general feedback or comments, which is not graded. At the very bottom of the page, you will see a continue button. Clicking on this will bring you back to the Workshop page. The final thing to mention here is that next to the Specimen Assessment Form link, there is an Edit icon. This can come in handy if you missed something or want to change something in one of the Elements. The second section of the Workshop page is shown here: (Move the mouse over the image to enlarge.) In the previous screenshot, we see the Show Workshop Description link. Clicking on this link will show the description entered when the Workshop was created. Once review of the Workshop description is done, click on the continue button to return to the Workshop page. Under this, we see information about submitted assignments. There are five columns, First Name / Surname, Submission Title, Date, Teacher Assessment, and Total Grade. Under this, in the small letters, we see information about how to interpret the grades as well as the total possible points. Each of these columns will display the appropriate information, and we will look at this again once we submit an assignment. The final section we see on the Workshop page is called Grading Grade Analysis and is shown in the next screenshot: We can see the Count, Mean, Standard Deviation, Maximum, and Minimum in the previous screenshot. Again, we have not submitted any work or assessed anything yet, so there is nothing here. However, once scores are entered into the Workshop, these numbers will be automatically calculated and updated. Now, all we need to do is have our students log into Moodle and they will see the Workshop and they will be able to enter and begin using it. Workshop page—Student's view When the students enter the Workshop, they will see a page that looks a bit different than the one we have just looked at. This is shown in the next screenshot: As you can see, at the top of the page, they see the same thing as the instructor. The student can see the Current phase, which has now moved to the third phase, Allow Submissions and Assessments. It moved to the third Phase because we set the opening for Submissions and Assessments at the same time. We would have seen the second Phase if we had set the Submission and Assessment times to be different. Students will also see the Workshop submission's and assessment's open and close dates and the Maximum grade possible for the Workshop. They are also able to preview the Assessment Form that will be used. This preview is identical to the one the instructor sees. Under this, the students will see the description of the Workshop with the instructions on how they should complete it. Under the Workshop description, we see the Assignment Submission Form. Here is where the students enter their work. There are three things that are done with this form. First, the student will need to create a title in the Submission Title box. Submission Titles Since Workshop is mostly about peer assessments, you may want to control the way titles are handled. While we can hide the student's name from the peer assessor, the title will always be visible. You may want to have students to use an anonymous system, numbers or some other form of code, so that there is no bias in grading. The second thing the students will do is enter their work in the Submission rich text editor. If there were any attachments included as part of the assignment, they would be seen directly below the textbox. When the students have finished with their submission, they click on the Submit Assignment button and the work will be uploaded to a new area called Your Submissions. What a student sees after clicking on the Submit Assignment button is shown in the next screenshot: This newly created section has four pieces of information for the student to see. The first is the Submission Title. Clicking on the title link will bring the student to a new page where they can view their work. The second section is the Action link. If the student is not satisfied with their work, they have the option to either edit or delete it. Clicking on the Edit link will bring the student to the submission screen where they can change whatever they would like, including uploading additional files, should this feature be enabled. The Delete link will permanently erase the file, but as a safeguard, Workshop will offer the student one chance to change their mind before completely erasing the file. The third is the column that shows the date the assignment was submitted. If the assignment is edited, the time of the editing will be reflected in the Submitted column. This can cause a problem for instructors if the deadline for submissions is not set properly. For example, say a student submits the work on time and as they are reviewing the work later in the week, they notice a misspelling, which they edit. The submitted time will be changed to reflect the last edit completed. The final column is Assessments. This is where the student can see how many times they have been assessed. We have no assessments yet, but we do now have a newly submitted piece of work, so we will switch back to our Teacher profile and look at the changes that have taken place.  
Read more
  • 0
  • 0
  • 1768

article-image-processing-and-managing-participants-civicrm
Packt
31 Mar 2011
9 min read
Save for later

Processing and Managing Participants in CiviCRM

Packt
31 Mar 2011
9 min read
Using CiviCRM Develop and implement a fully functional, systematic CRM plan for your organization Using CiviCRM Processing and managing participants You've configured your event, tested it, and publicly promoted the online information page and registration form. Before you know it, event registrations start rolling in. Now what? As with so many other areas of CiviCRM, these records may be viewed collectively through search tools or on an individual-contact basis. In this section, we'll walk through the event registration as it is viewed through the contact's record and then briefly review importing participant records. Working with event registrations A contact's history of event attendance will appear in their Events tab. From this tab, you can view, edit, or delete an existing registration, or create a new registration for the contact. Notice that there are two buttons above the event history listing, namely, Add Event Registration and Submit Credit Card Event Registration. The first is used for registrations that do not involve real time credit card processing through the system. This may include free events, payments by check, cash, EFT, or a credit card that was processed outside of the system. The second button should be used if you will be processing a credit card directly through CiviCRM. If you have not configured a payment processor, or your payment processor does not handle integrated payments (for example, PayPal Standard or Google Checkout, which redirect you to an external site to process the payment), then that button will not be visible. The new registration form allows you to select the event you wish to register the individual for, the fees and fields specific to the event, payment options, and receipting options. The following screenshot shows the top half of the form: There are several things to note about this form: The event drop-down list will only show current and future events. If you wish to register someone for an event in the past, you must click the Include past event(s) in this select list link, which will reload the form with the full list of events. This is done to reduce any confusion and simplify the event selection process. If you have created any custom data fields attached to participants, they will appear and be available only when the selections match their "used for" criteria. For example, if you have created custom fields for the participant role Guest, they will only appear when you change the role on this form. If you have custom fields attached to the event type Conference, they will only appear if the event selected is associated with that event type. If you are expecting, but not seeing a certain custom field, make sure your selections match how that field is configured to be used. Directly below the event fee block is an option to record a payment with this registration. Checking the box reveals a series of contribution-related fields, as shown in the following screenshot: It is important to understand that an event registration in which fees are collected involves both an event participant record and an associated contribution record. While you could process these separately, we strongly advise that you manage them through this single interface. In addition to being easier than entering them separately (since you may handle both records at once), doing so creates a link between the two records. If you return at a later date to view this event registration, you will see the related contribution record summarized below it. Likewise, if you enter the associated contribution record, you will see the event record summarized below it. Revenue totals for the event in reports will also reflect the linked records. Entering them separately will not build that connection. Handling expected payments Inevitably, you will receive event registrations by mail, fax, or phone, in which payment has not been submitted with the event registration. Though you have not actually received the payment, there is an expected payment and consequently, the best practice is to enter the payment as a pending contribution. Use the Record Payment option to log the contribution, but do not complete the Paid By field, and change the Payment Status field to Pending. Why is this recommended? For two reasons: first, it captures the reality of the data better. You have received a registration that implies a commitment to pay. This is different from a registration for a guest, speaker, or other VIP attendee for whom you do not plan to charge a fee. Secondly, it provides better tools for tracking payments due. If each registrant in the above scenario has a pending contribution payment, you can easily run a search to find out the total due and process invoices or follow- up communication accordingly. In essence, it gives you a better overview of your actual financial position, and a clear data path to those who owe you payment. Registrations received through your public-facing event registration page will also have both an event and contribution record created. Pay later registrations will have contribution records with a status of Pending, indicating that a payment has not yet been received. When you receive payment, first record the details in the contribution record and change the status to Completed. Doing so will automatically change the status of the associated event registration record to reflect that the payment has been received. Note that the reverse action does not have the same effect: changing the status of a registration to completed does not likewise change the status of its associated contribution record. This supports situations where you want to allow people to attend the event (marked completed) even though they will pay after the event (marked pending). Before leaving the event record displayed within the contact record, we want to point out one additional feature. From the event tab, click on View to see the registration details. From this screen, you'll notice a button to create a name badge. Clicking on this option will direct you to a form where you select the template to be used and trigger the creation of a PDF file with the name badge. In the following Tracking, searching, and reporting section, we will review how to create name badges for all event participants in bulk. For now, it's useful to see how an individual name badge can be created. Importing participant records As with other areas of CiviCRM, the event functions include a tool for importing event registrations. This is particularly useful when you are initially migrating data from an external database such as MS Access or MS SQL Server. It may come in handy at times depending on your organization structure and how CiviCRM is being used. Let's say your organization consists of five chapters geographically oriented to cover the entire state. Each chapter hosts local events and handles all onsite management through volunteers. The registration process is centralized through the state-wide organization using CiviCRM, so the contact participant list is generated and e-mailed to the chapter coordinator the day before the event. Suppose some of these events allow walk-in registrations and others include continuing education credits that must have verified attendance in order to be earned. In other words, the organization must not only track if people have registered, but must also track whether they actually attended. You choose to handle this by sending a .csv (comma-separated) export file the evening before the event to the chapter coordinator. The coordinator welcomes people as they arrive at the event and uses spreadsheet software to mark each person who attends in the .csv file. They add new rows for walk-ins. That file is sent back to the main office at the conclusion of the event and is imported into CiviCRM in two steps: existing registrants are imported using the Update option, where the participant status value reflects who attended; and the new registrants are imported using the Insert option, and then are matched with existing records using their name and e-mail. The import tool is very similar to what we saw in other areas. The four-step wizard consists of loading a file and configuring the import settings, mapping the file's fields to CiviCRM fields, previewing the results, and completing the import. An error file will be generated and will be available for download if any problems are discovered with any records. To access the import tool, visit Events | Import Participants. There are a few things to note that are specific to importing events: Participant import only accepts .csv files. You cannot connect to a MySQL database as with the contact import. The most significant difference between importing participants and importing contacts is the behavior of the Update option for handling duplicates. The Update option requires the presence of an existing participant record, which must be identified using the unique participant ID value. Consequently, you will only use it in scenarios similar to the one we just discussed, where the participant list is exported from the system, changes are made, and it is then imported back into the system. If the Update option is used, CiviCRM will not process new registration records. In this way, it differs from the contact import that matches and updates existing records and creates new records for those that do not match. As one might expect, the field mapping options available for the participant import include a number of registration-related fields. Take note of those in red, as they are required in order to successfully import these records. They include the Event ID and Participant Status. The former can be obtained from the Manage Events page. Several of the fields highlighted in red are used for matching to the contact record. Not all of these are required; only ones sufficient for making a valid match are required. For example, you do not need the internal contact ID and the first/last name. Either of these is sufficient for making a match.
Read more
  • 0
  • 0
  • 2597
article-image-behind-book-oracle-database-11g-r2-performance-tuning-cookbook
Packt
30 Mar 2011
7 min read
Save for later

Behind the Book: Oracle Database 11g R2 Performance Tuning Cookbook

Packt
30 Mar 2011
7 min read
 The Idea The intial idea for the book is created by the Acquisition Editor, Dhwani Devater: "For this book things started the other way round (instead of sourcing an idea and then finding an author) - Ciro our author was interested in writing a book, and discussed this with me while reviewing a previous book for us - and that is how the ball was set rolling!  The book had to be about Oracle Database Performance Tuning, as Ciro has extensive experience around this topic, and with immense hands-on experience I was certain he woud write an expert level book." Dhwani, Acquisition Editor __________________________________________________________________________________ "The choice of writing something on Oracle database performance was obvious because I have worked on Oracle databases since 1998, and since then I am the guy who solves performance problems.  The Cookbook* format (suggested by Dhwani) also makes the book accessible to DBAs and developers without a deep understanding of the Oracle database architecture." Ciro Fiorillo, Author *Cookbook - a collection of IT technology recipes  The Proposal Following the creation of the idea Dhwani then worked with Ciro to outline their idea in the form of a Book Proposal, which would need to be approved by the AE Team* before the book can go into development: "It was a really quick process, and we had the proposal ready in no time - I did my research and Ciro advised me on technical details such as the book's aim and the nature of competing titles" Dhwani *The AE Team - the other Acquisition Editors working with Enterprise books  The First Chapters Following approval by the rest of the Packt Enterprise AE Team, based on her proposal, Dhwani starts working on the initial chapters of the book with the author: "I sent some sample cookbooks to Ciro for reference so that the writing process would be smooth.  Having worked on so many Cookbooks I have observed that authors find it difficult at first to get into the flow of the Cookbook format, but Ciro has a clear view about what he is doing and is very communicative, when he started writing he enquired about the Cookbook protocals and raised his concerns, this will save time later" Dhwani __________________________________________________________________________________ "When I saw the first chapter I was sure Ciro was on the right track.  As usual, the first chapter required a few necessary modifications (which I fedback to Ciro), but for a first chapter it was a very good write up and Ciro had put in alot of effort to make it perfect" Dhwani "The most difficult chapter to write was the first because I needed to find a way to transfer my ideas into a recipe format, but after the first two or three chapters, thanks to  editorial's comments, the writing process became much faster, and the recipes ran smoothly" Ciro Fiorillo  The Book Cover The image for the book cover has now been chosen by James Lumsden, the Enterprise Publisher, from Packt's Image Bank.  It's an image of Pennyback Bridge in Austin, Texas, from photographer Stanford Moore - who also provided the cover image for Oracle Identity Access Manager 11g for Administrators. The image has been passed to Geetanjali Sawant from the Products Team who will create the RAW book cover image, ahead of the book entering the RAW Programme. Click here for further information on RAW  RAW With the first few chapters written, and passing Dhwani's strict standards, the book is now ready to be entered into the RAW Programme*.  To enter the book into the programme, Dhwani and the author work together to create a Title Information Sheet (TIS) detailing the content to be included in the Book page on the PacktPub website. "Writing the TIS was easy, as a lot of detail had gone into the proposal and outline.  The TIS however needs to be more detailed and SEO friendly, Ciro gave some good content, I structured the information into relevant sections and edited some bits - then it was ready to roll" Dhwani *RAW books allow customers to read books as they're written, with the downloaded eBook updating as new chapters are submitted so when the book is completed you receive the full finished book  The Book Page Now Dhwani has created the TIS - Archana Manjrekar, from the Products Team can use this as a basis to create the Book Page on the PacktPub website. She will also correspond with Dhwani to upload the book's chapters to the website as they're completed - so customers will receive updates to their downloaded RAW eBook - reading as its written. "The announcement of this book and the creation of the Book Page went smoothly, with everyone working to ensure that the RAW book came out on target.  The chapters for this book have been on time so far and are published on the site as soon as they're received" Archana, Product Executive __________________________________________________________________________________ The Book Page is now complete and the Oracle Database 11g R2 Performance Tuning Cookbook is now available for sale in RAW format - click here to view the book page  Letting People Know The Marketing Team now set to work letting people know the book is available in RAW Format "Now the book is available for sale, the Direct Marketing team immediately announced it on our Facebook and Twitter pages.  Following this we advertised the RAW book on our homepage - giving the book some much needed visibility" Damayanti, Direct Marketing Team Leader "We've just published a blog post on the Packt site announcing the book's availability in RAW format.  Plus in order to announce the arrival of this, and nine other new RAW books, Packt is celebrating a RAW Fortnight - providing people with further information on the RAW books via newsletters etc. and entering everyone who purchases a RAW book (during these two weeks) into a prize draw to win a PacktLib subscription" Suzanne, Marketing Executive  Enter the Development Editor Now the first chapters have been written and Dhwani is happy with the book's progress it's passed to a Development Editor who will oversee the book's progress from here on in. "As soon as I got the list to select books entering development, without wasting any time I chose the Oracle Database 11g Performance Tuning Cookbook as I have always been fascinated by the Performance Tuning aspect of the Oracle Database with it being one of the most important topics" Kartikey Pandey, Development Editor __________________________________________________________________________________ "My job as a Development Editor involves working with the author Ciro - checking and accepting the drafted chapters, sending them to the reviewers and preparing the rewrites.  The Technical Reviewers - Asif and Advait - are really helping us improve the content.  They are experts in the Oracle Database field and their feedback is invaluable, their reviews not only help Ciro improve the quality during rewrites, but  provide options and consistency to the content, be it technical or not technical" Kartikey __________________________________________________________________________________ News Update: As a star performer Kartikey has just been promoted to Acquisition Editor, and Pallavi Iyenger has now taken over the role of Development Editor for the book  The First Orders The first few orders for the book in RAW format have started coming in! The first official customer for this book is Kathy Lenon from Tempe, Arizona who purchased it citing "the level of detail and clarity of explanations will definately be an advantage to me" Have you purchased this book?  Let us know what you think  Stay Tuned! The next installment in the story Behind the Book will be uploaded shortly...
Read more
  • 0
  • 0
  • 1513

article-image-collision-detection-and-physics-panda3d-game-development
Packt
30 Mar 2011
12 min read
Save for later

Collision Detection and Physics in Panda3D Game Development

Packt
30 Mar 2011
12 min read
Panda3D 1.7 Game Developer's Cookbook Over 80 recipes for developing 3D games with Panda3D, a full-scale 3D game engine In a video game, the game world or level defines the boundaries within which the player is allowed to interact with the game environment. But how do we enforce these boundaries? How do we keep the player from running through walls? This is where collision detection and response come into play. Collision detection and response not only allow us to keep players from passing through the level boundaries, but also are the basis for many forms of interaction. For example, lots of actions in games are started when the player hits an invisible collision mesh, called a trigger, which initiates a scripted sequence as a response to the player entering its boundaries. Simple collision detection and response form the basis for nearly all forms of interaction in video games. It’s responsible for keeping the player within the level, for crates being pushable, for telling if and where a bullet hit the enemy. What if we could add some extra magic to the mix to make our games even more believable, immersive, and entertaining? Let’s think again about pushing crates around: What happens if the player pushes a stack of crates? Do they just move like they have been glued together, or will they start to tumble and eventually topple over? This is where we add physics to the mix to make things more interesting, realistic, and dynamic. In this article, we will take a look at the various collision detection and physics libraries that the Panda3D engine allows us to work with. Putting in some extra effort, we will also see that it is not very hard to integrate a physics engine that is not part of the Panda3D SDK. Using the built-in collision detection system Not all problems concerning world and player interaction need to be handled by a fully fledged physics API—sometimes a much more basic and lightweight system is just enough for our purposes. This is why in this recipe we dive into the collision handling system that is built into the Panda3D engine. Getting ready This recipe relies upon the project structure created in Setting up the game structure (code download-Ch:1), Setting Up Panda3D and Configuring Development Tools. How to do it... Let’s go through this recipe’s tasks: Open Application.py and add the include statements as well as the constructor of the Application class: from direct.showbase.ShowBase import ShowBase from panda3d.core import * import random class Application(ShowBase): def __init__(self): ShowBase.__init__(self) self.cam.setPos(0, -50, 10) self.setupCD() self.addSmiley() self.addFloor() taskMgr.add(self.updateSmiley, "UpdateSmiley") Next, add the method that initializes the collision detection system: def setupCD(self): base.cTrav = CollisionTraverser() base.cTrav.showCollisions(render) self.notifier = CollisionHandlerEvent() self.notifier.addInPattern("%fn-in-%in") self.accept("frowney-in-floor", self.onCollision) Next, implement the method for adding the frowney model to the scene: def addSmiley(self): self.frowney = loader.loadModel("frowney") self.frowney.reparentTo(render) self.frowney.setPos(0, 0, 10) self.frowney.setPythonTag("velocity", 0) col = self.frowney.attachNewNode(CollisionNode("frowney")) col.node().addSolid(CollisionSphere(0, 0, 0, 1.1)) col.show() base.cTrav.addCollider(col, self.notifier) The following methods will add a floor plane to the scene and handle the collision response: def addFloor(self): floor = render.attachNewNode(CollisionNode("floor")) floor.node().addSolid(CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0)))) floor.show() def onCollision(self, entry): vel = random.uniform(0.01, 0.2) self.frowney.setPythonTag("velocity", vel) Add this last piece of code. This will make the frowney model bounce up and down: def updateSmiley(self, task): vel = self.frowney.getPythonTag("velocity") z = self.frowney.getZ() self.frowney.setZ(z + vel) vel -= 0.001 self.frowney.setPythonTag("velocity", vel) return task.cont Hit the F6 key to launch the program: How it works... We start off by adding some setup code that calls the other initialization routines. We also add the task that will update the smiley’s position. In the setupCD() method, we initialize the collision detection system. To be able to find out which scene objects collided and issue the appropriate responses, we create an instance of the CollisionTraverser class and assign it to base.cTrav. The variable name is important, because this way, Panda3D will automatically update the CollisionTraverser every frame. The engine checks if a CollisionTraverser was assigned to that variable and will automatically add the required tasks to Panda3D’s update loop. Additionally, we enable debug drawing, so collisions are being visualized at runtime. This will overlay a visualization of the collision meshes the collision detection system uses internally. In the last lines of setupCD(), we instantiate a collision handler that sends a message using Panda3D’s event system whenever a collision is detected. The method call addInPattern(“%fn-in-%in”) defines the pattern for the name of the event that is created when a collision is encountered the first time. %fn will be replaced by the name of the object that bumps into another object that goes by the name that will be inserted in the place of %in. Take a look at the event handler that is added below to get an idea of what these events will look like. After the code for setting up the collision detection system is ready, we add the addSmiley() method, where we first load the model and then create a new collision node, which we attach to the model’s node so it is moved around together with the model. We also add a sphere collision shape, defined by its local center coordinates and radius. This is the shape that defines the boundaries; the collision system will test against it to determine whether two objects have touched. To complete this step, we register our new collision node with the collision traverser and configure it to use the collision handler that sends events as a collision response. Next, we add an infinite floor plane and add the event handling method for reacting on collision notifications. Although the debug visualization shows us a limited rectangular area, this plane actually has an unlimited width and height. In our case, this means that at any given x- and y-coordinate, objects will register a collision when any point on their bounding volume reaches a z-coordinate of 0. It’s also important to note that the floor is not registered as a collider here. This is contrary to what we did for the frowney model and guarantees that the model will act as the collider, and the floor will be treated as the collidee when a contact between the two is encountered. While the onCollision() method makes the smiley model go up again, the code in updateSmiley() constantly drags it downwards. Setting the velocity tag on the frowney model to a positive or negative value, respectively, does this in these two methods. We can think of that as forces being applied. Whenever we encounter a collision with the ground plane, we add a one-shot bounce to our model. But what goes up must come down, eventually. Therefore, we continuously add a gravity force by decreasing the model’s velocity every frame. There’s more... This sample only touched a few of the features of Panda3D’s collision system. The following sections are meant as an overview to give you an impression of what else is possible. For more details, take a look into Panda3D’s API reference. Collision Shapes In the sample code, we used CollisionPlane and CollisionSphere, but there are several more shapes available: CollisionBox: A simple rectangular shape. Crates, boxes, and walls are example usages for this kind of collision shape. CollisionTube: A cylinder with rounded ends. This type of collision mesh is often used as a bounding volume for first and third person game characters. CollisionInvSphere: This shape can be thought of as a bubble that contains objects, like a fish bowl. Everything that is outside the bubble is reported to be colliding. A CollisionInvSphere may be used to delimit the boundaries of a game world, for example. CollisionPolygon: This collision shape is formed from a set of vertices, and allows for the creating of freeform collision meshes. This kind of shape is the most complex to test for collisions, but also the most accurate one. Whenever polygon-level collision detection is important, when doing hit detection in a shooter for example, this collision mesh comes in handy. CollisionRay: This is a line that, starting from one point, extends to infinity in a given direction. Rays are usually shot into a scene to determine whether one or more objects intersect with them. This can be used for various tasks like finding out if a bullet shot in the given direction hit a target, or simple AI tasks like finding out whether a bot is approaching a wall. CollisionLine: Like CollisionRay, but stretches to infinity in both directions. CollisionSegment: This is a special form of ray that is limited by two end points. CollisionParabola: Another special type of ray that is bent. The flying curves of ballistic objects are commonly described as parabolas. Naturally, we would use this kind of ray to find collisions for bullets, for example. Collision Handlers Just like it is the case with collision shapes for this recipe, we only used CollisionHandlerEvent for our sample program, even though there are several more collision handler classes available: CollisionHandlerPusher: This collision handler automatically keeps the collider out of intersecting vertical geometry, like walls. CollisionHandlerFloor: Like CollisionHandlerPusher, but works in the horizontal plane. CollisionHandlerQueue: A very simple handler. All it does is add any intersecting objects to a list. PhysicsCollisionHandler: This collision handler should be used in connection with Panda3D’s built-in physics engine. Whenever a collision is found by this collision handler, the appropriate response is calculated by the simple physics engine that is built into the engine. Using the built-in physics system Panda3D has a built-in physics system that treats its entities as simple particles with masses to which forces may be applied. This physics system is a great amount simpler than a fully featured rigid body one. But it still is enough for cheaply, quickly, and easily creating some nice and simple physics effects. Getting ready To be prepared for this recipe, please first follow the steps found in Setting up the game structure (code download-Ch:1). Also, the collision detection system of Panda3D will be used, so reading up on it in Using the built-in collision detection system might be a good idea! How to do it... The following steps are required to work with Panda3D’s built-in physics system: Edit Application.py and add the required import statements as well as the constructor of the Application class: from direct.showbase.ShowBase import ShowBase from panda3d.core import * from panda3d.physics import * class Application(ShowBase): def __init__(self): ShowBase.__init__(self) self.cam.setPos(0, -50, 10) self.setupCD() self.setupPhysics() self.addSmiley() self.addFloor() Next, add the methods for initializing the collision detection and physics systems to the Application class: def setupCD(self): base.cTrav = CollisionTraverser() base.cTrav.showCollisions(render) self.notifier = CollisionHandlerEvent() self.notifier.addInPattern("%fn-in-%in") self.notifier.addOutPattern("%fn-out-%in") self.accept("smiley-in-floor", self.onCollisionStart) self.accept("smiley-out-floor", self.onCollisionEnd) def setupPhysics(self): base.enableParticles() gravNode = ForceNode("gravity") render.attachNewNode(gravNode) gravityForce = LinearVectorForce(0, 0, -9.81) gravNode.addForce(gravityForce) base.physicsMgr.addLinearForce(gravityForce) Next, implement the method for adding a model and physics actor to the scene: def addSmiley(self): actor = ActorNode("physics") actor.getPhysicsObject().setMass(10) self.phys = render.attachNewNode(actor) base.physicsMgr.attachPhysicalNode(actor) self.smiley = loader.loadModel("smiley") self.smiley.reparentTo(self.phys) self.phys.setPos(0, 0, 10) thrustNode = ForceNode("thrust") self.phys.attachNewNode(thrustNode) self.thrustForce = LinearVectorForce(0, 0, 400) self.thrustForce.setMassDependent(1) thrustNode.addForce(self.thrustForce) col = self.smiley.attachNewNode(CollisionNode("smiley")) col.node().addSolid(CollisionSphere(0, 0, 0, 1.1)) col.show() base.cTrav.addCollider(col, self.notifier) Add this last piece of source code that adds the floor plane to the scene to Application.py: Application.py: def addFloor(self): floor = render.attachNewNode(CollisionNode("floor")) floor.node().addSolid(CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0)))) floor.show() def onCollisionStart(self, entry): base.physicsMgr.addLinearForce(self.thrustForce) def onCollisionEnd(self, entry): base.physicsMgr.removeLinearForce(self.thrustForce) Start the program by pressing F6: How it works... After adding the mandatory libraries and initialization code, we proceed to the code that sets up the collision detection system. Here we register event handlers for when the smiley starts or stops colliding with the floor. The calls involved in setupCD() are very similar to the ones used in Using the built-in collision detection system. Instead of moving the smiley model in our own update task, we use the built-in physics system to calculate new object positions based on the forces applied to them. In setupPhysics(), we call base.enableParticles() to fire up the physics system. We also attach a new ForceNode to the scene graph, so all physics objects will be affected by the gravity force. We also register the force with base.physicsMgr, which is automatically defined when the physics engine is initialized and ready. In the first couple of lines in addSmiley(), we create a new ActorNode, give it a mass, attach it to the scene graph and register it with the physics manager class. The graphical representation, which is the smiley model in this case, is then added to the physics node as a child so it will be moved automatically as the physics system updates. We also add a ForceNode to the physics actor. This acts as a thruster that applies a force that pushes the smiley upwards whenever it intersects the floor. As opposed to the gravity force, the thruster force is set to be mass dependant. This means that no matter how heavy we set the smiley to be, it will always be accelerated at the same rate by the gravity force. The thruster force, on the other hand, would need to be more powerful if we increased the mass of the smiley. The last step when adding a smiley is adding its collision node and shape, which leads us to the last methods added in this recipe, where we add the floor plane and define that the thruster should be enabled when the collision starts, and disabled when the objects’ contact phase ends.
Read more
  • 0
  • 0
  • 11173

article-image-ibm-lotus-domino-adding-style-form-and-page-elements
Packt
29 Mar 2011
6 min read
Save for later

IBM Lotus Domino: Adding Style to Form and Page Elements

Packt
29 Mar 2011
6 min read
  IBM Lotus Domino: Classic Web Application Development Techniques A step-by-step guide for web application development and quick tips to enhance applications using Lotus Domino Most of the CSS rules you write for an application relate to design elements on forms and pages. Suggestions and examples in this section just scratch the surface of CSS possibilities. Browse the Web for additional ideas. Here we focus on the mechanics of how elements are styled, rather than on specific recommendations about what looks good, which is largely a matter of taste. Use color effectively Use pleasing, complementary colors. If your organization requires a specific set of colors, then, of course, find out what that palette is and conform to it as much as possible. Color tastes change over the years, primary colors dominating at times and lighter pastels in vogue at others. Here are a few generalities to consider: Use white or very light colors for backgrounds Use stronger colors such as dark red to make important elements stand out Use no more than three or four colors on a form Use black or dark gray text on a light background for lengthy text passages If you have paid little attention to the matter of color in your applications, do some web work on the subject. Once you select a color scheme, provide some samples to your customers for their opinions and suggestions. Style text Typography is a complex topic with a rich history and strong opinions. For web application design purposes, consider using web-safe fonts which are likely to be available on most or all personal computers. If you use a font that is not available to a browser, then text is rendered with a default font. Fonts with serifs are usually considered easier to read on paper, and less so as web page text. Experiment with the following fonts: Bookman Old Style Cambria Garamond Georgia Times New Roman Common fonts without serifs (sans serif) are considered easier to read on the Web. Some examples include: Arial Calibri Helvetica MS Sans Serif Tahoma Trebuchet MS Verdana Mono-spaced fonts are useful when you want text to line up—columns of numbers in a table, perhaps: Courier New Courier Establish a common font style with CSS rules applied to the body type selector or to a main division using a type selector, a class selector, or an ID selector: body { color: #555555; font-family: Verdana; font-size: 8pt; } Style headings and labels If headings and labels are bracketed with HTML heading tags (for example, <h1> or <h2gt;), they can be styled with type selectors: h1 { color: Blue; font-family: Arial; font-size: 18pt; font-weight: bold; } If headings and labels are bracketed with <span> tags, use CSS classes: <span class="highlight1">October News</span> Underline links in text but not in menus When browsers and the Web first appeared in the early 1990's, hyperlinks were a novelty. To distinguish a link from normal text, the convention developed to underscore the text containing the link, and often the link text was colored blue. There is no magic associated with underscoring and making text blue—it was just the convention adopted at the time. Today links in text passages are usually distinguished from adjacent text with color, weight or underscoring. In a menu, however, each item is understood to be a hotspot link. Underscores and blue text are not required. So if you feel like underscoring a link, do so if the link appears within some text, but don't underscore links in menus. At the same time, refrain from highlighting important text with underscoring, which implies that that text is a hyperlink. Use another highlighting technique; italics, bold, or an alternate color work well for this purpose. Style fields Fields can be styled with CSS either with the Style attribute in Field Properties or with CSS rules. The key to understanding how CSS rules can be applied to fields is to understand that fields are translated to the Web using <input> tags. Here is how a simple text field translates into HTML: <input name="FirstName" value=""> Here is how a radio button field translates: <input name="%%Surrogate_Gender" type="hidden" value="1"> <label><input type="radio" name="Gender" value="M">M</label><br> <label><input type="radio" name="Gender" value="F">F</label><br> CSS rules can be defined for the <input> tag, an ID, or a class. For example, assume that a CSS class named requiredtext is defined. If that class name is entered in the Class attribute of Field Properties, the resulting HTML might look like this: <input name="FirstName" value="" class="requiredtext"> CSS style rules coded for the requiredtext class are applied to the field. Highlight required fields Required fields are validated, most likely with JavaScript code, so that complete and good data is saved into the database when a document is submitted. If entered values fail validation, the user is presented with a message of some sort that identifies the problem and requests correction. Web forms typically identify which fields are required. Any of several techniques can be used. Required field labels can be styled with a more prominent color or a special marker such as an asterisk or a checkmark can be positioned near the field. Required fields also can be co-located and set apart using the <fieldset> and <legend> tags. If a field value fails validation, it is common practice to provide an error message and then to set the focus into the field; the cursor is positioned in the field to facilitate an immediate correction. As the cursor can be difficult to spot on a busy form, it is also possible to change the background color of the incorrect field as a way of drawing the user's attention to the field. In this illustration, the background color of the field has been changed to yellow: Implementing this technique requires writing a small JavaScript function that changes the background color of the field, and then calling that function when field validation fails.
Read more
  • 0
  • 0
  • 4550
article-image-opencart-layout-structure
Packt
29 Mar 2011
7 min read
Save for later

OpenCart: layout structure

Packt
29 Mar 2011
7 min read
In this article, we will see the default layout structure of OpenCart. We'll discuss the cascading stylesheet file from it and modify it according to our needs. First of all, we'll use the reset style properties to eliminate cross-browser problems. We will discuss every property here. We'll also see the corresponding effects on our site. Then, we'll do some basic styling for the site. For each change in style, we will see why we did that. Folder structure In our main OpenCart folder, we have the admin and catalog sections. These are two separate subsystems. As the name says, admin has the files and folders for administration operation. Catalog contains the store files and folders. Each admin and catalog section has a separate model, view, and controller. Under this admin and catalog folder, we will see the model, view, and controller folders. You will see different subfolders within those folders. So, let's discuss this MVC structure in the following paragraph. OpenCart is built with the MVC design pattern. So, it has model, view, and controller. A user requests the OpenCart controller to process the request. Then, the controller gets the data using the model and processes the fetched data to show the response with the view file. The following figure shows the above operation of MVC: For theme modification, we will focus only on the View folder of the catalog in this article. It has javascript and theme folders. We place our themes under the theme folder and the necessary JavaScript files in the JavaScript folder. Each theme has an image, stylesheet, and template folder. We will see how we can create a new theme later in this article. Theme file style As we stated earlier, OpenCart uses the MVC design pattern. So, the view files remain separated from the core code. These files are .tpl files. And, they are placed under catalogviewthemedefaulttemplate. These .tpl files are basically HTML files. They have PHP code within them to display the necessary data. OpenCart doesn't use the smarty template engine. Rather, it uses embedded PHP codes that are easy to use. We assign the PHP variables in the controller with necessary data. Then, we call the variable in the .tpl view file. We can also use the global class reference variable. In the controller, we will assign the value like this: $this->data['shop_name'] = 'store'; Here, we assigned store value to the shop_name variable. In the .tpl view file, we will display the value like this: <?php echo $shop_name; ?> Creating a new theme In this recipe, we will see the steps to create a new theme for OpenCart. There are some rules to create OpenCart themes. Getting started Let's get started with the steps to create a new theme with OpenCart. How to do it Following are the steps for creating a new theme for OpenCart: First of all, we need to create a new folder under catalogviewtheme. For example, we will name it shop for this project. Now, we need to copy some files from the default theme folder to our new theme folder. The files are the following: catalogviewthemedefaultstylesheet*.* catalogviewthemedefaultimage*.* catalogviewthemedefaulttemplatecommonheader.tpl We have to edit some values in the header.tpl file for our new theme. We will replace all default keywords with our new theme name shop. Actually, there are six places where we need to replace the new theme name. The lines are the following: <link rel="stylesheet" type="text/css" href="catalog/view/theme/shop/stylesheet/stylesheet.css" /> // other lines ... <link rel="stylesheet" type="text/css" href="catalog/view/theme/shop/stylesheet/ie6.css" /> //other lines ... <div class="div3"> <a href="<?php echo str_replace('&', '&amp;', $special); ?>" style="background-image: url('catalog/view/theme/shop/image/special.png');"> <?php echo $text_special; ?></a> <a onclick="bookmark(document.location, '<?php echo addslashes($title); ?>');" style="background-image: url('catalog/view/theme/shop/image/bookmark.png');"> <?php echo $text_bookmark; ?></a><a href="<?php echo str_replace('&', '&amp;', $contact); ?>" style="background-image: url('catalog/view/theme/shop/image/contact.png');"><?php echo $text_contact; ?></a><a href="<?php echo str_replace('&', '&amp;', $sitemap); ?>" style="background-image: url('catalog/view/theme/shop/image/sitemap.png');"><?php echo $text_sitemap; ?></a></div> //other lines ... And now, save it. Now, we will go to the admin area. First log in with our stored admin credentials. Go to System | Settings in the admin panel: We will go to the Store tab. We will change the theme from default to shop, our new theme from a select list. You can make changes on your theme's CSS file. Resetting layout styles Before beginning our theme styling work, we must first reset all the styles. This will help us with cross-browser problems. Getting started We need to modify the stylesheet.css file of our new theme first. We will go to catalogviewthemeshopstylesheet. And open up stylesheet.css in our favourite editor. How to do it Now, we will add reset styles to our stylesheet.css file. First, we need to change the browser's margin, padding, and border properties. We will set styles for several different HTML tags. We can add extra style properties into it: html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } We will see the effect of our code in our store. The product images will come closer now. We adjust the line height of body tag. So, put the following code in the CSS file. body { line-height: 1; } This also squeezes the lines in the body element. The following image depicts this: By applying the above style, the line height of these tabs becomes shortened. We need to reset the style for ordered/unordered list elements. Hence, we use the following reset value: ol, ul { list-style: none; } It shows all the ul, ol tags without the default bullet properties. Now, we will reset the blockquote element styles. We will find the changes if we use blockquotes in our HTML code: blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } For all the elements, we are going to change the focus-styling attributes. We change the outline properties to 0. We set the styles like the following: :focus { outline: 0; } There could be some styling for insert and deletion in some browsers. So, we will use this styling for the purpose: ins { text-decoration: none; } del { text-decoration: line-through; } We will control the styling of our tables also. We set the border and spacing qualities like the following: table { border-collapse: collapse; border-spacing: 0; } We still need to set the attribute cell-spacing to 0. So, our reset styling becomes the following: html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } :focus { outline: 0; } ins { text-decoration: none; } del { text-decoration: line-through; } table { border-collapse: collapse; border-spacing: 0; } We can place it at the start of our site's style file stylesheet.css, or we can create a new file and put the content there also. To do that, just create a new CSS file within the catalogviewthemeshopstylesheet folder. For example, we can name the new style file as reset.css. If we use a new style file, then we need to add the style file in the controller.  
Read more
  • 0
  • 0
  • 4419

article-image-introduction-editing-operators-blender-sequel
Packt
29 Mar 2011
3 min read
Save for later

Introduction to the Editing Operators in Blender: A Sequel

Packt
29 Mar 2011
3 min read
  Blender 2.5 Materials and Textures Cookbook Over 80 great recipes to create life-like Blender objects         Read more about this book       (For more resources on Blender, see here.) Well, ready to go with a simple mouth structure, right? Then select the two lower vertex as in picture below. We'll extrude them in Z axis and then again in Y axis to finish scaling. First, just select the two lower vertices. (See illustration 12) Illustration 12: Modeling Stage After all past actions you should have something similar to this picture. Use the known select commands to select the two lower vertices. For manipulating the 3D View and checking your model at any perspective you want, use MMB (Middle Mouse Button). This will show you your model at any perspective allowing you to move around it. Also, you can probably notice that in the latest picture I have disabled the Transform Manipulator (those green, red and blue arrows). In the modeling stage they are not primordial to use if you get used to commands, but they will help you in other areas such as animation. Transform Manipulator function is to help in the Location, Rotation and Scale procedure while manipulating data (objects, meshes, vertex, edges, etc). You can disable/enable Transform Manipulator from the buttons close the Orientations (Global by default). Other way to do that is with Ctrl + Space bar Key. (See illustration 13) Illustration 13: Transform Manipulator Buttons You can manage the transformation mode with different manipulators. From left to side buttons are: Enable/Disable manipulators view, Translate manipulator mode, Rotate manipulator mode, and Scale manipulator mode. Extrude now the selected bit of mesh in the Z Axis. Then go to E Key and Z Axis after that to just extrude in the right axis. Make it small because this will be the start point to extrude the lower side of the mouth and the jaw. When you do that, extrude again two times in the Y Axis in negative normals, in other words pointing to the direction we started modeling. So, E Key and Y Axis (negative normals) and repeat it again. Make those extrudes to coincide with upper edges. After that, just scale a little bit with S Key. (See illustration 14) Illustration 14: Modeling Stage After all past actions you should have something similar to this picture. After some steps, we have something similar (more or less) to our model nose and mouth and you have learned all basics commands for successful and creative modeling. Just all you need to know at this point to develop interesting characters in your projects. Let's go to complete the jaw now. Select vertices as they are in the illustration below (See illustration 15). Go to Right View by pressing 3 Key in Numpad and extrude them to Z Axis, so press E Key to extrude and Z to tell Blender the right direction to extrude (doing so is useful to extrude in straight line according with axis, but is not required always, that just depends on the model). After that you should rotate the selected elements, so press R Key to rotate and you should have something similar to the illustration 18. (See illustration 18) Illustration 15: Modeling Stage After all past actions you should have something similar to this picture. Select these four vertices to extrude the mouth and the jaw. Illustration 16: Modeling Stage After all past actions you should have something similar to this picture. Previous selection after the rotation action.
Read more
  • 0
  • 0
  • 1840
Modal Close icon
Modal Close icon