OCOSMO 3D Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Manuais de software OCOSMO 3D. oCOSMO 3D User's Manual Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 261
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes

Resumo do Conteúdo

Página 1 - Programmer’s Guide

Cosmo 3D™Programmer’s GuideDocument Number 007-3445-002

Página 2

xContents4. Scene Graph Nodes 55What Is a Node 56Node Types 56Leaf Nodes 57csShape 57Group Nodes 58Group Node Types 58Using csSwi

Página 3 - Contents at a Glance

74Chapter 5: Building a Scene GraphLoading a VRML Scene GraphExample 5-2 shows a portion of vrml.cxx. The example illustrates how to load a VRMLscene

Página 4

Saving Scene Graphs75Saving Scene GraphsThe data in the scene graph database is not necessarily static. You might, therefore, needto save scene graph

Página 6

77Chapter 66. Placing Shapes in a SceneWhen you create a geometry, it has a specified size, location, and orientation, as definedin its own space. You p

Página 7

78Chapter 6: Placing Shapes in a SceneOverriding the Default Order of Layering ShapesTo override this layering effect, you can use the csContext::setc

Página 8

Transforming Shapes to New Locations, Sizes, and Orientations79Transforming Shapes to New Locations, Sizes, and OrientationsThe csTransform node• Allo

Página 9

80Chapter 6: Placing Shapes in a SceneSetting the TransformationThe csTransform node allows you to set the location (translation), rotation, and scale

Página 10 - Contents

Transforming Shapes to New Locations, Sizes, and Orientations81Figure 6-2 Scaling in Different OrientationsAll of these methods invisibly set a transf

Página 11

82Chapter 6: Placing Shapes in a SceneWhen you reverse the order of the transformations, the end result is different. Since thecenter of rotation is t

Página 12

83Chapter 77. Traversing the Scene GraphOnce you create a scene graph, you apply an action to the root node to trigger the eventsprescribed in the sce

Página 13

ContentsxiTransforming Shapes to New Locations, Sizes, and Orientations 79Placing Transform Nodes 79Setting the Transformation 80Ordering Tra

Página 14

84Chapter 7: Traversing the Scene GraphThe action-specific responses taken by a node are implemented in the following nodefunctions:• draw()—for csDraw

Página 15

Scene Graph Actions85You invoke an action by creating an instance of an action class and applying it to a node(commonly the root node), for example:cs

Página 16

86Chapter 7: Traversing the Scene GraphPlaying Sound FilescsSoundAction plays sound files. The csSound node indirectly specifies—throughcsAudioClip and

Página 17

The Order In Which Actions Are Passed Between Nodes87Figure 7-1 The Flow of an Action Through A Scene GraphA top-down traversal means that a node can

Página 19 - List of Figures

89Chapter 88. Lighting and FogThis chapter discusses two features implemented by subclasses of csEnvironment,lighting and fog.• Lights illuminate shap

Página 20

90Chapter 8: Lighting and FogcsLightcsLight is an abstract base class for light sources. It provides the following methods forsetting light values:voi

Página 21 - List of Tables

Using Lights in Scenes91csSpotLightcsSpotLight is a directional light source. Because csSpotLight is subclassed fromcsPointLight, csSpotLight can be p

Página 22

92Chapter 8: Lighting and FogLimiting the Scope of LightscsEnvironment defines the scope of environmental effects, such as how far light from acsLight

Página 23 - About This Guide

Using Fog in Scenes93// add the lights to the environment light arraypark->light()->append(3, spot);park->light()->append(4, flood);Using

Página 24

xiiContentscsOrthoCamera 101csPerspCamera 101Setting the Frustum 102Setting the Clip Planes 103Setting the Fields of View 103Offsetting

Página 25 - Who Should Read This Guide

94Chapter 8: Lighting and FogAll types of geometric primitives can be fogged, including points and lines. Using the fogeffect on points and lines is a

Página 26 - Style Conventions

Using Fog in Scenes95In general whoever is OFF has precedence.• If csContext::fogEnable is OFF, no fog is drawn unless there is a csAppearance thathas

Página 28 - Scene Graph Base Classes

97Chapter 99. Viewing the SceneTo view a scene, you must define:• The size of the viewport.• The position and the orientation of the camera.This chapte

Página 29 - The csObject Class

98Chapter 9: Viewing the SceneFigure 9-1 ViewportYou set the size of the viewport using the following csContext method:static void setViewport(csInt x

Página 30 - Runtime Typing

csCamera99csCameracsCamera is an abstract base class from which all other cameras are derived. csCameradefines the viewing volume. The viewing volume i

Página 31 - The csField Class

100Chapter 9: Viewing the SceneFigure 9-3 Changing the Window Without Changing the Image’s AspectIt is important, therefore, to change the aspect of t

Página 32 - The csNode Class

csOrthoCamera101csOrthoCameracsOrthoCamera defines an orthographic projection. An orthographic projection uses aparallelepiped (box) frustum. Unlike th

Página 33

102Chapter 9: Viewing the SceneFigure 9-4 Perspective ExplainedIf you compare the height of an object in the near clipping plane to the height of the

Página 34 - The csGroup Class

csPerspCamera103Setting the Clip PlanesYou use the following fields to set the distance to the near and far clip planes:void setNearClip(csFloat nearCl

Página 35 - The csTransform Class

Contentsxiii11. Sensors 121csTimeSensor 122Enabling csTimeSensor 122Updating csTimeSensor 123Updating with csWindow 123Setting the Star

Página 36 - Transform node

104Chapter 9: Viewing the SceneFigure 9-5 Horizontal and Vertical Fields of View OffsetsThe offset angles are measured starting at the -z axis, follow

Página 37 - The csGeometry Class

csFrustumCamera105csFrustumCameracsFrustumCamera allows you to work directly with a frustum without worrying aboutthe specifics of a camera. You define

Página 39

107Chapter 1010. Scene Graph EnginesThere are classes that work with scene graphs, but are not nodes; they cannot be part ofthe scene graph, but they

Página 40

108Chapter 10: Scene Graph EnginesInput and Output FieldscsEngine has input and output fields. csEngine updates its output fields according to thefuncti

Página 41 - 2. Creating Geometries

Engines109Engine TypesMany engines interpolate between two values at specified increments. For example, arotation interpolator might take the beginning

Página 42 - Using Large Geometries

110Chapter 10: Scene Graph EnginescsInterpolator is the base class for the following engines:• csColorInterpolator• csCoordinateInterpolator• csNormal

Página 43 - Creating csGeoSet Objects

Engines that Interpolate Values111Interpolator nodes are designed for linear, keyframed animation, that is, an interpolatornode defines a piecewise lin

Página 44

112Chapter 10: Scene Graph EnginescsInterpolator FieldsThe fields in csInterpolator include:void setFraction(float fraction);float

Página 45 - Field Default

Engines that Interpolate Values113Keys and Key ValuesIn Figure 10-3, the X axis represents keys, such as time, and the Y axis represents anyattribute

Página 46 - Attribute Bindings

xivContentscsTouchSensor 134Associating csTouchSensor and Geometry 134Scope of csTouchSensor 135csTouchSensor Output 135isOver Event 13

Página 47 - Setting Attribute Bindings

114Chapter 10: Scene Graph EnginescsColorInterpolatorThis node interpolates among a set of key values in a csMFColor to produce a csSFColor(RGB) color

Página 48 - Setting Attributes

Engines that Interpolate Values115When P and Q are pointed in opposite directions, they are on opposite sides of the unitsphere, and therefore all arc

Página 49 - Indexing Attributes

116Chapter 10: Scene Graph EnginescsPositionInterpolatorcsPositionInterpolator linearly interpolates between sets of values in a SFVec3f. This isappro

Página 50 - When to Index Attributes

Engines That Change Shapes117csSelectorEng3F and csSelectorEng4FcsSelectorEng3F and csSelectorEng4F sets the output value to the nth item in the input

Página 51

118Chapter 10: Scene Graph EnginescsMorphEng FieldscsMorphEng contains the following fields:csMFInt* count() const;csMFInt* index

Página 52 - Specifying Attributes

Engines That Change Shapes119Example 10-1 Building a Morph Engine: the Worm// Build morph engine MorphCoords = new csMorphEng3f; // “Neutral” is

Página 53

120Chapter 10: Scene Graph EnginescsTransformEng FieldscsTransformEng has the following fields:void setTransformType(TransformTypeEnum t

Página 54 - Setting Attributes Example

121Chapter 1111. SensorsSensors are used to detect one of the following:• Time passing.• Pointer device events.Sensors are often implemented to perfor

Página 55 - Editing Attribute Arrays

122Chapter 11: SensorscsTimeSensorcsTimeSensor generates timer events either once or repeatedly for a specified interval. AcsTimeSensor is typically us

Página 56 - Using csPointSet

csTimeSensor123Updating csTimeSensorcsTimeSensors are not automatically evaluated. The following method triggers theevaluation of all instantiated csT

Página 57 - Using csTriSet

ContentsxvBack Patch Culling 152Back Patch Culling Advantage 153When to Use Back Patch Culling 154Method of Calculation 154Updating the Vi

Página 58 - Using csTriStripSet

124Chapter 11: SensorsYou can, for example, trigger events based on the time of day usingcsTime::getTimeOfDay(), which returns the current time of day

Página 59 - Using csIndexedFaceSet

csTimeSensor125Continuing Timer EventscsTimeSensor::loop() takes a boolean value. If it is TRUE, the csTimeSensor continuesto generate events after th

Página 60

126Chapter 11: SensorscsSphereSensorcsSphereSensor maps the drag motion of a pointer device into a spherical rotation abouta virtual sphere. The rotat

Página 61

csSphereSensor127csSphereSensor EventsA csSphereSensor begins generating events when both of the following conditions aremet:• The pointer device curs

Página 62 - Inheritance Mask

128Chapter 11: SensorsUpdating csSphereSensorcsSphereSensor is not updated automatically. You customarily update it explicitly whenpointer device even

Página 63 - Accessing States

csSphereSensor129Figure 11-2 Placing csSphereSensor in a Scene GraphA csSphereSensor is activated when the pointer device is depressed over its associ

Página 64 - Traversal Order

130Chapter 11: SensorscsPlaneSensorA csPlaneSensor maps the drag motion of a pointer device’s events into a translation inthe XY plane of the local or

Página 65 - Changing the Context

csPlaneSensor131Figure 11-3 Placing csPlaneSensor in a Scene GraphScope of csPlaneSensorA csPlaneSensor translates all geometries in the scene graph “

Página 66 - Using csAppearance

132Chapter 11: SensorsUpdating csPlaneSensorcsPlaneSensor is not updated automatically. You customarily update it explicitly whenpointer device events

Página 67

csPlaneSensor133TrackPoint events represent unclamped drag positions of the geometry in the XY planeof local or world space, depending on the value se

Página 68 - Texture Map Coordinates

xviContentsSpecifying Audio Files 174Manipulating the Audio Samples Directly 176Example Setting a csAudioSamples Node 176Playing Sound in Imm

Página 69 - Applying a Texture

134Chapter 11: SensorscsTouchSensorcsTouchSensor tracks the location of the pointer device cursor and generates up to fiveoutputs when the cursor is ov

Página 70 - Specifying a Texture Image

csTouchSensor135Scope of csTouchSensorA csTouchSensor monitors all geometries in the scene graph “below” the parent node ofthe csTouchSensor. Not only

Página 71 - Non Perspective Perspective

136Chapter 11: SensorsHit EventscsTouchSensor generates the following three hit events whenever the pointing device isover a geometry associated with

Página 72 - Texture Environment Settings

137Chapter 1212. User Interface MechanismsCosmo 3D applications either appear within a csWindow object or a window object thatyou create using X windo

Página 73 - Color Components

138Chapter 12: User Interface MechanismsTo reposition or reshape the window after its initial display, use the following methods:static void p

Página 74 - Using the Default

Handling User Input139Handling User InputEvents, such as mouse motion, key presses, and window resize, are converted to csEventobjects and queued on t

Página 75

140Chapter 12: User Interface MechanismsWhen csWindow::setFreeRun() is TRUE, callbacks are invoked only when the main loopgoes idle, similar to the CO

Página 76 - Enabling Texture Generation

Selecting Screen Objects141Figure 12-1 Ray Pick ActionThe shape closest to the origin of the csSeg and intersected by the line segment isrecorded in a

Página 77 - Material Settings

142Chapter 12: User Interface MechanismsStoring Selected Screen ObjectscsHit objects hold pointers to objects selected using a variety of mechanisms.

Página 78 - Filling Geometries

Creating Your Own Window143Creating Your Own WindowInstead of using the window provided by Cosmo 3D, csWindow, you can create yourown window using X11

Página 79 - Transparency Settings

ContentsxviiB. Cosmo 3D Sample Application 193Cube.cxx Explained 195Understanding the Different Parts of Cube.cxx 202Scene Graph for Cube.cxx

Página 81 - 4. Scene Graph Nodes

145Chapter 1313. MultiprocessingIf you would like to display two views of the same scene graph, you need to use themultiprocessing capabilities of Cos

Página 82 - What Is a Node

146Chapter 13: MultiprocessingImplementing MultiprocessingOne rule that you must follow when implementing multiprocessing is the scene graphcannot be

Página 83 - Leaf Nodes

Implementing Multiprocessing147To create a thread and bind it appropriately, use the following procedure:1. Create a thread, as follows:csThread* draw

Página 84 - Group Nodes

148Chapter 13: MultiprocessingThread ParametersThread-related parameters include the following csThread methods:• numProcessors()—returns the number o

Página 85

Thread Blocking149Figure 13-2 Blocking Action of Multiple ThreadsThe general order of events displayed in Figure 13-2 is as follows:1. The application

Página 86 - Using csBillboard

150Chapter 13: MultiprocessingCleaning the csContext FieldsBefore rendering, the application thread must call csField::cleanFields() to clean thecsCon

Página 87 - Must specify

151Chapter 1414. Optimizing RenderingOne of the greatest challenges developers face is optimizing application performance.This chapter describes the C

Página 88

152Chapter 14: Optimizing RenderingFace CullingWhen solid, three-dimensional geometry is rendered, the side of it facing away from thecamera is normal

Página 89

Back Patch Culling153Figure 14-1 shows the same geometry before and after back patch culling.Figure 14-1 Before and After Back Patch CullingBack Patch

Página 91 - 5. Building a Scene Graph

154Chapter 14: Optimizing RenderingBack patch culling usually reduces the work done by the graphics hardware but it doesincrease the workload of the h

Página 92 - Creating Scene Graphs

Back Patch Culling155Updating the View VectorAs long as you use csDrawAction::apply() to initiate the back patch culling, you neverneed to calculate t

Página 93

156Chapter 14: Optimizing RenderingFigure 14-4 Direction of NormalsChoosing the Type of NormalThe csGeoSet method, setBPCullVertNormModeEnable(), sets

Página 94 - Creating A Sample Scene Graph

Back Patch Culling157Face normals are used by default with the following primitive types:• csPolySet• csQuadSet• csTriFanSet• csTriSet• csTriStripSetI

Página 95 - Diagramming Scene Graphs

158Chapter 14: Optimizing RenderingBuilding Back Patch Culling Data for a csGeoSetBefore calling a csDrawAction, which triggers back patch culling, yo

Página 96 - Hydrogen

Back Patch Culling159Back Patch Culling CodeNow that you understand all the facets of back patch culling, Example 14-1 presents theseries of calls you

Página 97 - Figure 5-5 Torso Subgraph

160Chapter 14: Optimizing RenderingCulling the View FrustumView frustum culling eliminates from the rendering list all of those shapes not in theviewi

Página 98

Level of Detail Reduced for Performance161csLOD allows you to reach a compromise between performance and the level of detailrendered. For high quality

Página 99 - Altering Scene Graphs

162Chapter 14: Optimizing RenderingThe camera may disregard range values and• Display an already-fetched level of detail while a higher level of detai

Página 100 - Loading a VRML Scene Graph

Performance Programming Techniques163Performance Programming TechniquesThe following sections provide programming tips for improving the performance o

Página 101 - Saving Scene Graphs

xixList of FiguresFigure 1-1 Cube Scene Graph 8Figure 1-2 Two Transformations into World Space 10Figure 2-1 Primitives in a csGeoSet 18Figure

Página 102

164Chapter 14: Optimizing RenderingIndexing csGeoSet AttributesYou can specify the appearance of all the csGeoSet elements making up a geometryeither

Página 103 - 6. Placing Shapes in a Scene

Performance Programming Techniques165Figure 14-6 Arranging Scene Graph NodesWhen an action traverses a scene graph, the more nodes it visits, the long

Página 105 - Placing Transform Nodes

167Chapter 1515. Adding Sounds To Virtual WorldsYou can incorporate sound into your virtual worlds by including at least one csSoundnode in a scene gr

Página 106 - Setting the Transformation

168Chapter 15: Adding Sounds To Virtual WorldsOverviewA csSound node contains the location of a sound file and the parameters used for playingit. To pl

Página 107 - Ordering Transformations

Overview169csSound FieldsThe fields in csSound specify the sound source to play by specifying a csAudioClipobject. csSound can optionally specify the l

Página 108 - Cosmo 3D Matrices

170Chapter 15: Adding Sounds To Virtual WorldsTo choose a starting location in a sound file, pass the starting frame to thesetCurrentFrame() field. A fr

Página 109 - 7. Traversing the Scene Graph

Overview171Figure 15-2 Sound DirectionIn this figure, (1.0, 1.0, 0.0) is passed as the direction vector to setDirection(). The ellipsetips, accordingly

Página 110 - Action Types

172Chapter 15: Adding Sounds To Virtual WorldsOutside of the maximum intensity perimeter, the intensity of the sound attenuates overdistance until it

Página 111 - Rendering the Scene

How to Play a Sound File173How to Play a Sound FileYou use csAudioClip to specify how to play the sound files referenced in thecsAudioSamples node.csAu

Página 112 - Top-Down Traversals

Cosmo 3D™ Programmer’s GuideDocument Number 007-3445-002CONTRIBUTORSWritten by George EckelIllustrated by Dany Galgani and Martha LevineProduction by

Página 113

xxList of FiguresFigure 9-1 Viewport 98Figure 9-2 Aspect Ratio 99Figure 9-3 Changing the Window Without Changing the Image’s Aspect 100Figure

Página 114

174Chapter 15: Adding Sounds To Virtual WorldsExample 15-1 sets all of the fields in a csAudioSamples node.Example 15-1 Setting the Fields in a csAudio

Página 115 - 8. Lighting and Fog

Specifying Audio Files175csAudioSamples has the following fields:void setFileName(const csString& fileName);void setN

Página 116

176Chapter 15: Adding Sounds To Virtual WorldsManipulating the Audio Samples DirectlycsAudioSample::samples() returns the multivalued array field that

Página 117

Playing Sound in Immediate Mode177Playing Sound in Immediate ModeWhen a csSoundAction is invoked on a scene graph, the action traverses the scene grap

Página 119 - Using Fog in Scenes

167Chapter 1515. Adding Sounds To Virtual WorldsYou can incorporate sound into your virtual worlds by including at least one csSoundnode in a scene gr

Página 120 - Enabling Fog

168Chapter 15: Adding Sounds To Virtual WorldsOverviewA csSound node contains the location of a sound file and the parameters used for playingit. To pl

Página 121 - How to Use Fog

Overview169csSound FieldsThe fields in csSound specify the sound source to play by specifying a csAudioClipobject. csSound can optionally specify the l

Página 122

170Chapter 15: Adding Sounds To Virtual WorldsTo choose a starting location in a sound file, pass the starting frame to thesetCurrentFrame() field. A fr

Página 123 - 9. Viewing the Scene

Overview171Figure 15-2 Sound DirectionIn this figure, (1.0, 1.0, 0.0) is passed as the direction vector to setDirection(). The ellipsetips, accordingly

Página 124 - Figure 9-1 Viewport

xxiList of TablesTable 2-1 Geometry Terminology 16Table 2-2 Fields in a csGeoSet 19Table 2-3 Attribute Bindings 21Table 4-1 Examples of Field

Página 125 - Figure 9-2 Aspect Ratio

172Chapter 15: Adding Sounds To Virtual WorldsOutside of the maximum intensity perimeter, the intensity of the sound attenuates overdistance until it

Página 126

How to Play a Sound File173How to Play a Sound FileYou use csAudioClip to specify how to play the sound files referenced in thecsAudioSamples node.csAu

Página 127

174Chapter 15: Adding Sounds To Virtual WorldsExample 15-1 sets all of the fields in a csAudioSamples node.Example 15-1 Setting the Fields in a csAudio

Página 128 - >

Specifying Audio Files175csAudioSamples has the following fields:void setFileName(const csString& fileName);void setN

Página 129 - Offsetting the Fields of View

176Chapter 15: Adding Sounds To Virtual WorldsManipulating the Audio Samples DirectlycsAudioSample::samples() returns the multivalued array field that

Página 130

Playing Sound in Immediate Mode177Playing Sound in Immediate ModeWhen a csSoundAction is invoked on a scene graph, the action traverses the scene grap

Página 132

179Appendix AA. Cosmo Basic TypesThis chapter discusses all of the basic types that are used in other Cosmo 3D classes. Thebasic class types fall into

Página 133 - 10. Scene Graph Engines

180Appendix A: Cosmo Basic TypesArray Storage Class TypesThe array classes store data.• csData—stores raw data.• csArray—is a virtual array class.• Ar

Página 134 - Input and Output Fields

Array Storage Class Types181Array ClassescsArray is a virtual array class from which all other array classes are derived. Arrays areused as storage ve

Página 136 - Key values, attributes

182Appendix A: Cosmo Basic TypesTo fill an array, or to retrieve values from an array, use one of the set() or get() methodsin the class, respectively,

Página 137 - Key values

Vector Classes183• Use the append() method to add a value after the last value in an array.• Use the insert() method to insert a value at a specified i

Página 138 - Attribute

184Appendix A: Cosmo Basic TypesVector MathVectors are used in a variety of ways in Cosmo 3D. Commonly, they are used to defineorientation, rotation, a

Página 139 - Keys and Key Values

Vector Classes185The classes contain the following methods:csBool equal(const csVec4f& v) const;csBool almostEqual(const csVec4f& v

Página 140

186Appendix A: Cosmo Basic TypesThe classes also provide the following write and operator methods:void write(csOutput *out);csVec4f& ope

Página 141

Bounding Volumes187• A csVec3f::xformPt(const csVec3f& v, const csMatrix4f& m) transform vector sets acsVec3f vector, v, to be the first three

Página 142

188Appendix A: Cosmo Basic TypesCosmo 3D provides two bounding shapes as well as an abstract class from which you canderive your own bounding shapes.•

Página 143 - Engines That Change Shapes

Field Classes189csFieldcsField is the abstract class from which all of the other field classes are derived. Becauseit does not have a constructor, you

Página 144

190Appendix A: Cosmo Basic TypesThe editDone() method allows you to signal when you have finished manipulating thecsMField object so that, for example,

Página 145

Other Math Classes191You can fill an array by setting groups of values using the following methods:void setRange(int i, int count, csInt vals[])

Página 146

xxiiiAbout This GuideCosmo 3D is a new toolkit that brings 3D graphics programming to desktop applications.Cosmo 3D is a scene graph API; its concepts

Página 147 - 11. Sensors

192Appendix A: Cosmo Basic TypescsPlanecsPlane represents a half space with a normal and an offset, which together form theparameters of the tradition

Página 148 - Enabling csTimeSensor

193Appendix BB. Cosmo 3D Sample ApplicationThis appendix discusses a simple Cosmo 3D application, called cube.cxx. The files are inthe following locati

Página 149 - Updating csTimeSensor

194Appendix B: Cosmo 3D Sample ApplicationThese are the sections in this chapter:•“Cube.cxx Explained” on page 195.•“Understanding the Different Parts

Página 150 - Setting Cycle Duration

Cube.cxx Explained195Cube.cxx ExplainedExample B-1 shows the cube.cxx application. It also includes embedded comments (notfound in the cube.cxx file) t

Página 151 - Continuing Timer Events

196Appendix B: Cosmo 3D Sample Application//Start the application hereintmain(int argc, char *argv[]){int doOrthoCam = 0, doFullScreen = 0;if(argc >

Página 152 - Virtual Sphere

Cube.cxx Explained197// define render windowif (doFullScreen) {csWindow::initPosition(0, 0);csWindow::initSize(csWindow::get(csWindow::SCREEN_WIDTH),

Página 153

198Appendix B: Cosmo 3D Sample Applicationintframe(void*){static int frame = 0;const csEventArray &elist = csWindow::getCurrent()->getEvents();

Página 154 - Setting Up csSphereSensor

Cube.cxx Explained199// swap bufferscsWindow::swapBuffers();frame++;return csWindow::CONTINUE;}//Create a cube; the cube will be rendered twice.static

Página 155

200Appendix B: Cosmo 3D Sample ApplicationcsQuadSet *gset = new csQuadSet;// cube verticescsCoordSet3f *cset = new csCoordSet3f(numCubeCoords);cset-&g

Página 156 - Setting Up csPlaneSensor

Cube.cxx Explained201highlight = new csAppearance;highlight->setMaterial(hlMaterial);highlight->setLightEnable(1);// red cubecsMaterial *redMate

Página 157 - Scope of csPlaneSensor

xxivAbout This Guidexxiv• Chapter 3, “Specifying the Appearance of Geometries,” describes the appearancefields in csContext and csAppearance.• Chapter

Página 158 - Limiting Translations

202Appendix B: Cosmo 3D Sample Application// environmentcsPointLight *lt = new csPointLight;csEnvironment *environment = new csEnvironment;environment

Página 159 - Local or World Translations

Scene Graph for Cube.cxx203Scene Graph for Cube.cxxScene graphs provide the structure for Cosmo 3D applications. Cosmo 3D applicationsuse scene graphs

Página 160 - Chapter 11: Sensors

204Appendix B: Cosmo 3D Sample ApplicationIn cube.cxx, csGeometry defines a cube and the csAppearance nodes specify the greenand red colors of the cube

Página 161 - Scope of csTouchSensor

Scene Graph for Cube.cxx205Figure B-3 Two Transformations Into World SpaceIn Figure B-3, after the leaf node is transformed twice, it is placed in wor

Página 162 - Hit Events

206Appendix B: Cosmo 3D Sample ApplicationCreating the User InterfacecsWindow encapsulates the user interface: it includes the methods you use to cons

Página 163 - 12. User Interface Mechanisms

Scene Graph for Cube.cxx207SummaryThe following procedure summarizes the steps you take to create and render a verysimple scene graph.1. Create csAppe

Página 165 - Handling User Input

209Appendix CC. Cosmo 3D Class HierarchyThe following list shows the class hierarcy in Cosmo 3D.csActionFunTablecsArraycsByteArraycsFloatArraycsIntArr

Página 166 - Selecting Screen Objects

210Appendix C: Cosmo 3D Class HierarchycsFieldcsMFieldcsMFBytecsMFFloatcsMFIntcsMFMatrix4fcsMFRefcsMFRotationcsMFStringcsMFVec2fcsMFVec3fcsMFVec3scsMF

Página 167 - Using Pick()

211csFieldInfocsMFByteInfocsMFFloatInfocsMFIntInfocsMFMatrix4fInfocsMFRefInfocsMFRotationInfocsMFStringInfocsMFVec2fInfocsMFVec3fInfocsMFVec3sInfocsMF

Página 168

About This GuidexxvRelated ReadingReference pages for Cosmo 3D are obtained by pointing your web browser at:• For IRIX: /usr/share/Optimizer/doc/devel

Página 169 - Creating Your Own Window

212Appendix C: Cosmo 3D Class HierarchycsObjectcsActioncsCompileActioncsTransformActioncsIsectActioncsSoundActioncsVFCullActioncsDrawActioncsContainer

Página 170

213csNodecsEnginecsInterpolatorcsColorInterpolatorcsCoordinateInterpolatorcsNormalInterpolatorcsOrientationInterpolatorcsPositionInterpolatorcsScalarI

Página 171 - 13. Multiprocessing

214Appendix C: Cosmo 3D Class HierarchycsTexCoordSetcsTexCoordSet2fcsTexGencsTexturecsImageTexturecsContextcsDatacsDispatchcsEventcsHitcsOverrideGeoPr

Página 172 - Implementing Multiprocessing

215Aactions, 67, 83addChild(), 66ambient color, 51animate, 121animation, creating, 124application, simple, 193aspect ratio, 99atmospheric effec

Página 173 - Starting Threads

216IndexcsEnvironment, 12, 59, 92csFog, 94csField, 5, 189csFieldInfo, 189csFog, 94fields, 94csFrustum, 105, 192csFrustumCamera, 105csGeoMath.h,

Página 174 - Thread Blocking

217IndexcsThread, 146csTimeSensor, 122csTimeSensor, active or not, 124csTimeSensors, updating, 123csTouchSensor, 134csTouchSensor, scope of, 135

Página 175

218Indexflight simulationfog, use of, 93fog, 93-??, 94example program, 95FOV, 104fractionChanged, 125frustum, 160, 192frustum culling, 160Ggeome

Página 176 - Multithreaded Example

219IndexOOBJECT_LINEAR, 50offset, rotation, 126opBarrier, 146OpenGL, 37OpenGL Optimizer, 1optimize, 151optimize,setCullFace(), 152optimizing pe

Página 177 - 14. Optimizing Rendering

220IndexsetMatrix(), 81setNearClip(), 103setPolyMode(), 52setPosition(), 100setScaleOrientation(), 80setTexGen(), 50setting fields, 61setTransla

Página 178 - Back Patch Culling

221IndexVviewusing camera, 98viewport, 97virtual sphere, 126visual simulationfog, use of, 93VRML, 74Wwait(), 148window, creating your own, 143w

Página 179 - Back Patch Culling Advantage

xxviAbout This GuidexxviStyle ConventionsThese style conventions are used in this guide:• Bold—Functions, class names, node names, data members, and d

Página 181 - Updating the View Vector

Tell Us About This ManualAs a user of Silicon Graphics products, you can help us to better understand your needsand to improve the quality of our docu

Página 182 - Choosing the Type of Normal

1Chapter 11. Getting Started with Cosmo 3DCosmo 3D is a scene graph API that brings 3D graphics programming to desktopapplications. Cosmo 3D speeds up

Página 183 - Using Back Patch Culling

2Chapter 1: Getting Started with Cosmo 3DUnderstanding a Cosmo 3D Scene GraphA scene graph is a directed acyclical graph of nodes that embodies the se

Página 184

Scene Graph Base Classes3The csObject ClassThe csObject class is the base class for all objects in a scene; where an object is an entitythat you can p

Página 185 - Back Patch Culling Code

iiiContents at a GlanceList of Figures xxiList of Tables xxiiiAbout This Guide xxvWhat This Guide Contains xxvRelated Reading xxviiWho

Página 186 - Culling the View Frustum

4Chapter 1: Getting Started with Cosmo 3DExample 1-1 demonstrates how reference counts are incremented and decremented.Example 1-1 Objects and Referen

Página 187

Scene Graph Base Classes5The csContainer ClasscsContainer objects contain data associated with scene graphs. The data in csContainerobjects is grouped

Página 188 - Figure 14-5 csLOD Ranges

6Chapter 1: Getting Started with Cosmo 3DSingle-Item and Multi-Item FieldsEach field contains either a single value of a simple data type, such as a flo

Página 189

Scene Graph Construction Classes7Scene Graph Construction ClassesThis section discusses several essential elements of a scene graph.These elements are

Página 190 - Indexing csGeoSet Attributes

8Chapter 1: Getting Started with Cosmo 3DFigure 1-1 Cube Scene GraphThe csGroup ClassThe csGroup class allows applications to group a list of csNodes.

Página 191

Scene Graph Construction Classes9The csTransform ClassA csTransform is a csGroup that allows applications to apply a transformation to all ofits child

Página 192

10Chapter 1: Getting Started with Cosmo 3DFigure 1-2 Two Transformations into World SpaceGroup nodeLeaf nodeGroup nodeTransform nodeTransform node

Página 193

Scene Graph Construction Classes11The csShape ClasscsShape nodes, derived from csNode, define a textured geometry by associating acsAppearance, which d

Página 194 - Overview

12Chapter 1: Getting Started with Cosmo 3DClasses That Determine How Things Are DrawnThe set of nodes discussed in this section determines how things

Página 195

Classes defining Geometric Objects13Classes defining Geometric ObjectsThe actual geometric objects in a Cosmo 3D scene graph are derived as follows:• A

Página 196 - Playing the Sound File

ivContents at a Glance3. Specifying the Appearance of Geometries 35csContext Overview 35Changing the Context 39Using csAppearance 40Applyi

Página 197 - Sound direction

14Chapter 1: Getting Started with Cosmo 3D5. Add the csTransform node as a child of a csGroup-type node.For more information about adding nodes to sce

Página 198 - Reverse Direction Sound

15Chapter 22. Creating GeometriescsGeometry is an abstract class. All derivations of the class represent one or moregeometric objects, either concrete

Página 199 - How to Play a Sound File

16Chapter 2: Creating GeometriesGeometry TerminologyTable 2-1 briefly summarizes the geometry terminology used in this manual.Understanding the key ter

Página 200 - Specifying Audio Files

Creating csGeoSet Objects17Each class has methods that allow you to set and retrieve the values necessary to definethe geometry, including (where appro

Página 201 - Field Description

18Chapter 2: Creating GeometriesFigure 2-1 Primitives in a csGeoSetThese attributes are captured in csGeoSet fields.StripLengthsPrimCoordsColorBindMorm

Página 202

Creating csGeoSet Objects19csGeoSet FieldsThe fields in a csGeoSet object can be grouped in the following manner:The remainder of this section describe

Página 203

20Chapter 2: Creating GeometriescsGeoSet AttributescsGeoSet is a virtual class from which all geometric primitives are derived. Cosmo3D-supplied csGeo

Página 204

csGeoSet Attributes21For example, a single color can be specified for the entire collection of primitives, forindividual primitives, or per vertex. One

Página 205

22Chapter 2: Creating GeometriesThe enumerated binding values that are valid for each of the attributes coincide with theentries in Table 2-3.enum Nor

Página 206

Setting Attributes23This pattern continues, as shown in Figure 2-2.Figure 2-2 Sequential Specification of Attributes Per PrimitiveIndexing AttributesAn

Página 207

Contents at a Glancev9. Viewing the Scene 97Setting the Screen Display of the Scene 97csCamera 99csOrthoCamera 101csPerspCamera 101csFr

Página 208

24Chapter 2: Creating GeometriesFigure 2-3 Indexed AttributesWhen to Index AttributesFor all primitives in a csGeoSet, you have to decide whether to u

Página 209

Setting Attributes25Figure 2-4 Deciding Whether to Index AttributesIn the triangle strip, each vertex is shared by two adjoining triangles. In the squ

Página 210

26Chapter 2: Creating GeometriesSpecifying AttributesWhether you index your attributes or not, you must use the following set...() methods incsGeoSet

Página 211

Setting Attributes27The first constructor allows you to specify the number of array primitives, n.The second constructor allows you to reference an arr

Página 212

28Chapter 2: Creating GeometriesIndexing AttributesAn indexed csGeoSet object uses a list of unsigned short integers to index an attributearray. Four

Página 213

Setting Attributes29// Set the attribute bindingsgset->setNormalBind(csGeoSet::PER_VERTEX_NORMS);gset->setColorBind(csGeoSet::PER_PRIM_COLORS);/

Página 214

30Chapter 2: Creating GeometriesCosmo 3D-Derived csGeoSet Objects Cosmo 3D provides the following csGeoSet collections. Each is a derivative ofcsGeoSe

Página 215

Cosmo 3D-Derived csGeoSet Objects31Using csLineSetA csLineSet object contains a collection of lines of equal length. The fields allow you toset and ret

Página 216

32Chapter 2: Creating GeometriesUsing csTriFanSetA csTriFanSet is a set of triangles all of which share one common vertex, as shown inFigure 2-6.Figur

Página 217 - A. Cosmo Basic Types

Cosmo 3D-Derived csGeoSet Objects33csTriStripSet contains the following field:csMFInt* stripLength() const;This field allows you to specify and find out

Página 218 - Array Storage Class Types

viContents at a Glance15. Adding Sounds To Virtual Worlds 167Overview 168How to Play a Sound File 173Specifying Audio Files 174Playing Sou

Página 219 - Array Classes

34Chapter 2: Creating Geometriesvoid setCreaseAngle(csFloat creaseAngle);void setColorPerVertex(csBool colorPerVertex);void setNo

Página 220

35Chapter 33. Specifying the Appearance of GeometriesThe geometry and appearance of a shape are independent of one another. Theappearance of a shape i

Página 221 - Vector Classes

36Chapter 3: Specifying the Appearance of GeometriesThere is an inheritance mask in each csAppearance that specifies which appearancevalues are inherit

Página 222 - Vector Methods

csContext Overview37..csAppearance *app = new csAppearance;app->setMaterial(mtl);shape->setAppearance(app);Figure 3-1 Inheritance MaskAll 0 bits

Página 223

38Chapter 3: Specifying the Appearance of GeometriesWarning: It is critical that such a callback not alter the OpenGL state.You can avoid altering the

Página 224 - Transforming csVec3f Vectors

Changing the Context39Overriding Appearances and Geometry Properties with csContextIn general, csAppearance settings override csContext default values

Página 225 - Bounding Volumes

40Chapter 3: Specifying the Appearance of GeometriesIn this example, the second context replaces the first.• display is a pointer to the X window displ

Página 226 - Field Classes

Using csAppearance41The csAppearance class includes a series of set...() methods to define the appearancecharacteristics of a geometry. A series of cor

Página 227

42Chapter 3: Specifying the Appearance of GeometriesApplying Textures to GeometriesOne way to affect the appearance of a geometry is to apply a textur

Página 228

Applying Textures to Geometries43Figure 3-3 Texture CoordinatesTexture coordinates are assigned to each vertex of a geometry either by you or by Cosmo

Página 229 - Other Math Classes

viiContentsList of Figures xixList of Tables xxiAbout This Guide xxiiiWhat This Guide Contains xxiiiRelated Reading xxvWho Should Read

Página 230 - Appendix A: Cosmo Basic Types

44Chapter 3: Specifying the Appearance of GeometriesSpecifying a Texture ImageTo apply a texture to a geometry, supply a csTexture object in the argum

Página 231 - Source Executable

Applying Textures to Geometries45When you choose the NON_PERSP_TEX mode, Cosmo 3D applies the texture to ageometry without proper perspective. For exa

Página 232 - Figure B-1 Cube Application

46Chapter 3: Specifying the Appearance of GeometriesTexture Environment SettingsTexture environment variables specify how texture colors are blended w

Página 233 - Cube.cxx Explained

Applying Textures to Geometries47Color ComponentsA texture image can have up to four components per texture element:• A one-component image consists o

Página 234

48Chapter 3: Specifying the Appearance of GeometriesSpecifying Texture CoordinatesThere are two ways to specify how a texture is applied to a geometry

Página 235

Applying Textures to Geometries49The setTexGen() method specifies• Whether or not the texture plane is repeated across the geometry.• Whether the textu

Página 236

50Chapter 3: Specifying the Appearance of GeometriesSetting the csTexGen ModeIf you think of the texture plane as being projected onto the surface of

Página 237

Material Settings51Material SettingsThe material field in csAppearance defines the surface qualities of a geometry, such ashow well it reflects light, wh

Página 238

52Chapter 3: Specifying the Appearance of GeometriesShininess describes how much of the surroundings are reflected by an object, for example,a mirror w

Página 239

Shade Model Settings53Shade Model SettingsYou set the shading model using the setShadeModel() method with one of the followingcsContext::ShadeModelEnu

Página 240

viiiContentsClasses That Determine How Things Are Drawn 12csContext 12The csEnvironment Classes 12Classes defining Geometric Objects 13Ste

Página 241 - Scene Graph for Cube.cxx

54Chapter 3: Specifying the Appearance of GeometriesTo use the setAlphaFunc() method, you first set the reference value against which youmeasure the al

Página 242

55Chapter 44. Scene Graph NodesA node is an object that can be part of or entirely comprise a scene graph. Typically, a nodeis a collection of one or

Página 243

56Chapter 4: Scene Graph NodesWhat Is a NodeA node is a collection of one or more fields and methods. Each field is a C++ class withdata members and met

Página 244 - Rendering World Space

Leaf Nodes57Leaf NodesLeaf nodes are responsible for defining the visual and aural elements portrayed in ascene. Leaf nodes cannot have child nodes.The

Página 245

58Chapter 4: Scene Graph NodesGroup NodesGroup nodes associate other nodes into a hierarchy known as a scene graph. Only groupnodes can have children.

Página 246

Group Nodes59• csLOD—(level-of-detail) is a switch that selects one of its children based on thedistance between the camera and the shape encapsulated

Página 247 - C. Cosmo 3D Class Hierarchy

60Chapter 4: Scene Graph NodesUsing csBillboardcsBillboard is a subclass of csGroup. It is used to rotate its children to face the viewer atall times.

Página 248

Setting the Values in Scene Graph Nodes61Setting the Values in Scene Graph NodesCosmo 3D allows you to set the values for nodes in two ways: either us

Página 249

62Chapter 4: Scene Graph NodesUsing Tokens to Set and Get Single-Value FieldsTo use tokens to set or get single-value fields, you1. Get a handle to the

Página 250

Setting the Values in Scene Graph Nodes63Using Tokens to Set and Get Multiple-Value FieldsTo use tokens to set or get multiple-value fields, you1. Get

Página 251

Contentsix3. Specifying the Appearance of Geometries 35csContext Overview 35State Machine 36Inheritance Mask 36Accessing States 37What

Página 253

65Chapter 55. Building a Scene GraphA scene graph can be a single node or a hierarchy of nodes, as shown in Figure 5-1.Figure 5-1 Scene GraphThe hiera

Página 254

66Chapter 5: Building a Scene GraphThis chapter includes the following sections:•“Creating Scene Graphs” on page 66.•“Diagramming Scene Graphs” on pag

Página 255

Creating Scene Graphs67Figure 5-2 Multiple Root NodesApplying Actions to Multiple Root NodesIf a scene graph has multiple root nodes, an action applie

Página 256

68Chapter 5: Building a Scene GraphCreating A Sample Scene GraphExample 5-1 is a simple scene graph.Example 5-1 A Simple Scene Graph// create the root

Página 257

Diagramming Scene Graphs69Diagramming Scene GraphsDiagramming a scene graph is helpful in visualizing the structure of a Cosmo 3Dapplication. Figure 5

Página 258

70Chapter 5: Building a Scene GraphFor more information about the order in which nodes are acted upon, see “The Order InWhich Actions Are Passed Betwe

Página 259

Diagramming Scene Graphs71In the subgraph shown in Figure 5-5, you can see that the foot, leg, and torso nodes areparts which, when rendered together,

Página 260

72Chapter 5: Building a Scene GraphFigure 5-6 Showing the Same Geometry in Two LocationsIn this example, the scene graph makes it easy to see that a c

Página 261 - Three Ways to Reach Us

Altering Scene Graphs73Altering Scene GraphsAfter using csGroup::addChild() to create a scene graph, you can use the followingmethods to edit it:void

Comentários a estes Manuais

Sem comentários