virtual forest - plant designs

12
Virtual Forest Plant Designs CMPE 460 Project #2 Specification Document

Upload: isik-baris-fidaner

Post on 12-Mar-2016

224 views

Category:

Documents


6 download

DESCRIPTION

What is our purpose of creating virtual plants? Firstly, it is because we are responsible to do it. Secondly, we must somehow make practice to learn using OpenGL to create 3D computer graphics. And thirdly, plants remind people peace and relief, and in computer graphics, there has been too much 3D war and violence so far.

TRANSCRIPT

Page 1: Virtual Forest - Plant Designs

Virtual Forest

Plant Designs

CMPE 460Project #2

Specification Document

Page 2: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Contents

1. Introductiona. Purposeb. Development tools

2. Describing Plantsa. Layers of plant description

i. Skeleton layerii. Primitive layeriii.OpenGL layer

b. PD classesi. PD classii. Skeleton class

c. PD file format

3. Describing Scenesa. Layers of scene description

i. Scene layerii. Plant description layer

b. SD classc. SD file format

4. Interface Designa. Flowchartsb. Design constraintsc. Design tools

i. Plant modelling tool1. Adding and modifying parts2. Traversing on the plant

ii. Scene modelling tool1. Setting background and ground texture2. Adding and setting up modelled plants3. Setting up animations

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Page 3: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Introduction

Purpose of this projectWhat is our purpose of creating virtual plants?Firstly, it is because we are responsible to do it. Secondly, we must somehow make practice to

learn using OpenGL to create 3D computer graphics.And thirdly, plants remind people peace and relief, and in computer graphics, there has been

too much 3D war and violence so far.

Development environment and toolsWe used following tools in our development:• Hardware

o CPU: Pentium 4o Memory: 256 MBo Video card: GeForce2.

• Softwareo Operating system: Windows 98o 3D graphics framework: OpenGL and GLUTo Programming language: Microsoft Visual C++

Describing Plants

A plant is described as some primitive parts located geometrically on a skeleton. Thus, properties of a plant is parametrized in three layers.

OpenGL layerAt the bottom, is the OpenGL, receiving commands for creating triangles and quads, texturing,

viewing and lighting them. This layer is used by its higher layers to visualize certain geometrical objects in 3d world.

Example of using OpenGL layer:glBegin(GL_QUADS);

glNormal3f( 0.0f, 0.0f, 1.0f);glTexCoord2f(0.448f, 0.721f); glVertex3f( 0.005f, 0.279f, 0.0f); //24glTexCoord2f(0.729f, 0.525f); glVertex3f( 0.286f, 0.475f, 0.0f); //19glTexCoord2f(0.595f, 0.307f); glVertex3f( 0.152f, 0.693f, 0.0f); //15glTexCoord2f(0.438f, 0.713f); glVertex3f(-0.005f, 0.287f, 0.0f); //2

glEnd();

Primitive layerOn top of OpenGL is the primitive layer, which contains hard-coded display lists of certain plant

parts such as leaf, branch or fruit. This layer is for keeping certain polyhedra shapes characterizing the plant types. All primitives are in the same layer, but every primitive can be only used by its corresponding type of plant. For example, an imaginary plant cannot have a realistic leaf, vica versa.

Example of using primitive layer:

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Skeleton layer

Primitive layer

OpenGL layerDrawing primitive parts in the 3D world

Locating primitive parts hierarchically

Page 4: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

putprimitive(yaprak1lo);

Skeleton layerThen comes the skeleton layer, which contains geometrical information of the plant. Its duty is

to put primitives in the right coordinates in the right time. Modelling and animations are made on the skeleton layer.

Example of using skeleton layer:branch->add(dal1,0,58,0,30,90,0,0.8);branch->add(dal1,0,58,0,30,-90,0,0.8);branch = branch->subbranches[0];branch->add(yaprak1lo,0,58,0,70,0,0);branch->add(yaprak1lo,0,58,0,80,120,0);branch->add(yaprak1lo,0,58,0,60,240,0);

PD classesIn describing plants, object-oriented programming is used. Every plant description is an instance

of PD class. This class contains general information about the plant, as well as the layer descriptions.

In OpenGL layer, no classes are needed to be created, because OpenGL uses global variables. In primitive layer, there is also no need for a class, because primitives are hard-coded global shapes. But in the skeleton layer, there must be some kind of class to contain geometrical information.

Skeleton classSkeleton class contains all information regarding geometrical placement of primitives. This

information is kept in a hierarchical tree structure. Every branch of this tree (including the root) contains following information:

• The primitive to be located on this branch

• Scaling relative to its parent branch.

• Position in 3 dimensions, relative to its parent branch.

• Orientation in 3 angular dimensions, relative to its parent branch.

• Velocity in 3 dimensions, relative to its parent branch.

• Angular velocity in 3 angular dimensions, relative to its parent branch.

• Acceleration in 3 dimensions, relative to its parent branch.

• Angular acceleration in 3 angular dimensions, relative to its parent branch.• Subbranches of this branch

PD classPD class is the class of a plant. This contains two things: Type of the plant, and its skeleton in a

separate class structure. Also, this class is capable of:• Saving into a PD file• Loading from a PD file• Displaying the plant in the 3d world• Running an animation using the plant skeleton

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Skeleton branchPrimitivePosition-orientationVelocity dataAcceleration dataChild branches

Page 5: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

PD file formatPlant descriptions can be saved in PD files in text format. A PD file starts with the "plant type".

Then it continues as a list of skeleton branches where every line corresponds to a skeleton element.

Example PD file:plant type 1

childs 2 3 4 5primitive dal2 position 0 0 0 orientation 30 0 0 childs 6 7primitive dal2 position 0 0 0 with relative orientation 30 80 0 childs 8 9primitive dal2 position 0 0 0 with relative orientation 30 200 0 childs 10 11primitive dal2 position 0 0 0 with relative orientation 30 280 0 childs 12 13primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 14 15 16 17primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 18 19 20 21primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 22 23 24 25primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 26 27 28 29primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 30 31 32 33primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 34 35 36 37primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 38 39 40 41primitive dal2 position 0 19 0 with relative orientation 12 25 0 child 42 43 44 45primitive dal2 position 0 19 0 with relative orientation 13 0 0 child 46 47 48 49primitive yaprak2 position 0 0 0 with relative orientation 70 130 0primitive yaprak2 position 0 0 0 with relative orientation 80 250 0primitive yaprak2 position 0 0 0 with relative orientation 60 10 0primitive dal2 position 0 19 0 with relative orientation 13 0 0 child 50 51 52 53primitive yaprak2 position 0 0 0 with relative orientation 70 130 0primitive yaprak2 position 0 0 0 with relative orientation 80 250 0...

Describing Scenes

A scene, is a group of plants put in a scenery. To describe the scene, we must be able to describe every single plant in that scene, and its placement in the picture. In addition, we must know the general scenery of the place. Maybe it is dawn, or morning light comes from the sky. There may be grass or rocks on the ground. A scene has a background image and a ground texture.

Layers of scene descriptionA scene description includes two layers. First is the plant description layer, describing the plants

involved in the scene. Second layer is the scene layer, which contains information about placement and orientation of the plants described. Also, it includes information about the background image and the ground texture.

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Plant DescriptionSkeleton stemSave(file)Load(file)Display()RunFor(time)

Skeleton branchPrimitivePosition-orientationVelocity dataAcceleration dataChild branches

Page 6: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Plant description layerThe plants that are in the scenery, are described in the plant description layer of scene

description. This layer contains PD information and it is connected to other layers, skeleton, primitives and OpenGL.

Scene layerScene layer is on top of plant description layer. This layer uses the modelled descriptions for

viewing and animating them in a scene. Operations involving changes in the scene, and changes regarding plant positions, orientations and animations can be done in this layer.

SD classIn the scene description class, background image and ground texture locations are kept as tga

files. First, there is a list of plant descriptions. Then there is another list of plant samples containing following information for each plant:

• Plant position• Plant orientation• Plant animation• Plant description index

SD file format

Example SD file:background bg.tgaground texture grass.tga

3 plant descriptionsfirst.pdsecond.pdthird.pd

plant 1 position 0 0 -10 orientation 0 0 0plant 1 position 0 0 -50 orientation 0 30 0plant 2 position -10 0 -40 orientation 0 70 0plant 3 position -10 0 -10 orientation 0 20 0

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Scene layerViewing and animating plants in the scene

Scene DescriptionPlant descriptionsArray of plants

• Description index

• Position• Orientation

Plant DescriptionSkeleton stemSave(file)Load(file)Display()RunFor(time)

Skeleton branchPrimitivePosition-orientationVelocity dataAcceleration dataChild branches

Skeleton layer

Primitive layer

OpenGL layerDrawing primitive parts in the 3D world

Locating primitive parts hierarchically

Page 7: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Interface Design

In the program, there are two types of descriptive data, plants and scenes. These are kept in the memory as class instances, and saved on the HDD as PD and SD files. These descriptions can be created by a user interface. User interface involves two things, designing and viewing. These can be combined in the same interface, because you must view what you design, and you must design in order to view something.

Interfaces will be implemented by "masking" idea. There will be a foreground interaction window for the user to construct the plant, scene etc.

The interaction window is not yet implemented, but the details are thought of. Buttons (in the context as we are used to them) will be put and they will exactly be like normal window system buttons, so the user won't lose his/her interest with extraordinary interaction images. Other "hidden" interaction tools will either be prompted on the screen, or not be so complex and written in the manual. These are like camera control keys or mouse buttons (which are, at the moment, available at the program.).

Flowcharts

Design constraintsDesign constraint issue depends on the plant types that we have specified at the beginning. For

example, a 'branch' may consist of;• Leaves and a fruit of its species, • Leaves and a flower of its species,• Leaves and subbranches of its species,• Leaves only,• Subbranches only.

Design toolsThere must be one tool for each data type: Plant modelling tool and scene modelling tool.

These self-explanatory named tools are used to edit plant description files and scene description files respectively. These tools must be considered in both ways, as a designing environment and as

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Plant Modelling Tool Scene Modelling Tool

Choose scene type

Generate new scene

Add/Remove plants

Animate scene

Save scene

Choose plant type

Generate new plant

Add/Remove plant parts

Animate plant

Save plant

Page 8: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

an animation engine-viewing tool. The interface should allow at least two modes in these tools: design mode and viewing. User can toggle between these nodes when designing plants and scenes.

Plant modelling toolPlants were described as three layers, with the skeleton at the top, primitives in the middle,

and the OpenGL at the bottom. Plant modelling tool allows user to design plants on the skeleton layer-the most abstract level. It must even allow the user to design the plant in a more abstract way, because skeleton layer is very low level as it involves with angles and positions of every single polyhedron on the plant. User can see top-front-right-perspective views of the plant.

Traversing on the plantIn the interface, a plant is considered as a tree structure where every branch (except the root)

has a parent and some child branches. User can traverse through the plant, jumping branch to branch. At every moment, interface is focused on a certain branch ("current" branch) on plant's skel-eton. Either the user makes a modification on that branch, or jumps to another branch which is either current branch's parent or its child.

Adding and modifying partsViewing is oriented and focused on the current branch, but the user can rotate the whole plant

around it by using the mouse. Then he/she can add-remove-modify a leaf, add a fruit, or any poly-hedra that is allowed by plant design constraints. Modifications are either changing its position or orientation, all by simple mouse drags.

The plants are simple, but somehow complex 3D objects. That is, there are so many "leaf" prim-itives, and therefore many vertices at one tree for instance. And usually, no user wants to deal with every other leaf in a tree. Of course, users will have the option to do that, but there is also options for simplifying the plant construction process, like "put some leaves" or "fill with leaves".

Scene modelling toolScenes are modelled in a simpler tool, because it only involves combining prepared plants in a

prepared scenery. Scenery can be defined as a background image, and a ground texture. Plants re-quire more complex definitions. Each plant has a position and an orientation in the scenery. There are also animations that can be assigned to plants.

Setting background and ground textureCreating a scene description first involves the user to select a background image, and a ground

texture. There are certain images and textures the user can choose from. User can also set the am-bient and diffuse light colors from the scene modelling tool.

Adding and setting up modelled plantsFor scene construction, only the perspective view is shown, and mouse buttons determine the

position and the orientation of the plant that is put. The interface makes it easy to select and put plants in the scenery in a few mouse clicks and dragging.

Setting up animationsAnimations are properties assigned to plants. Plants are capable of making the required motion.

For example, "winding" animation is defined as regular harmonic angular movement of every branch

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Plant design modeUser can toggle between two modes

Plant view mode

Scene design modeUser can toggle between two modes

Scene animation mode

Page 9: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

in the plant's skeleton with some periodic phase difference between parent and child branches. An-imation requires calculation of every frame, which involves creation of new skeletons for different time instances. This is a built-in function of PD class.

Example Screens

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Page 10: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Our first type of plantin the morning

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Page 11: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Our second type of plantin the morning

Our first type of plantat dawn

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner

Page 12: Virtual Forest - Plant Designs

CMPE 460 Introduction to Computer Graphics

Our second type of plantat dawn

2001100940 Başar Uğur 2001102110 Işık Barış Fidaner