Skip to main content

Abstract

In this chapter we introduce a quad-tree algorithm for drawing an orthographic view of a scene that is modelled as a list of objects, each of which is stored in OBSERVED position. In our restricted version of the quad-tree algorithm we will in fact only be considering spheres (primitive_type=1), the simplest of all three-dimensional objects. Nevertheless, the approach is valid for many other types of primitive object, provided that the relevant functions have been written and the Analytic_scene class has been extended to contain sufficient parameters. You will see that the algorithm we use has close similarities to the recursive techniques used to draw mathematical functions (listing 10.6) and fractal maps (listings 1.6 and 10.9). The application program that initiates the quad-tree approach is given in listing 14.1, and consists of a simple build_it function that links the quad-tree application to all the other functions in our collection of files; the link with “model.cpp”, “display.cpp” and “window.cpp” will be achieved using the C++ Project mechanism. Function build_it, called from draw_a_picture, takes the description of every sphere from file “quadtree.dat”: this data is given in the order of their integer labels and a sample file is shown in listing 14.1. The data is used to instantiate an Analytic_scene object named scene. The data concerning the material used by the spherical objects in the scene is stored in a file “material.dat”: see listing 11.2c for an example. As usual, function draw_a_picture (listing 13.1b) models the scene (build_it), sets up the observer and light source (look_at_it) and finally displays the scene (draw_it). The data structure that brings all this together to form a complete description of the three-dimensional scene is an implied list of integer labels of all objects in the scene.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Author information

Authors and Affiliations

Authors

Copyright information

© 1992 Ian O. Angell and D. Tsoubelis

About this chapter

Cite this chapter

Angell, I.O., Tsoubelis, D. (1992). A quad-tree algorithm. In: Advanced Graphics on VGA and XGA Cards Using Borland C++. Palgrave, London. https://doi.org/10.1007/978-1-349-22336-7_14

Download citation

  • DOI: https://doi.org/10.1007/978-1-349-22336-7_14

  • Publisher Name: Palgrave, London

  • Print ISBN: 978-1-349-22338-1

  • Online ISBN: 978-1-349-22336-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics