translating your cad model to a vrml model your cad model to a vrml model ... facsimile, but in...

20
Translating your CAD Model to a VRML Model While students' CAD models will be the basis of all visual materials displayed by the 3D Virtual Buildings Project, the models themselves will not be displayed in the repository. Given the bandwidth constraints which currently govern data transmission over the Internet, two formats will be employed to portray the project's urban landscapes. The first is QuickTime VR, which will be used to generate highly textured, detailed renditions of the cities on site. While the graphic quality of QuickTime VR is impressive, it nevertheless fails to provide full mobility to users. Viewers frame of reference is limited to the panorama or object in their screen. VRML, Virtual Reality Modeling Language, by contrast, provides full mobility, enabling viewers to move in any direction within the model. The shortcomings of this modeling format are twofold. Most VRML scenes offer only rudimentary portrayals of the objects they are meant to represent. This limitation is necessary since detailed models such as those produced by CAD software produce files too large for rapid transmission over the Internet. Such files would also preclude smooth navigation through the model once it has been downloaded into the computer. Second, the visual quality of VRML models compared to their QuickTime VR counterparts is poor. It is for this reason that both formats have been incorporated into the 3D Virtual Buildings Project. The shortcomings of one format will be compensated by resort to the strengths of its counterpart. The object of this tutorial is to take the user through the steps necessary to generate a VRML equivalent of an existing CAD model such as the Hope building. Like the regular tutorial, this lesson will be based on Diehl Graphsoft's VectorWorks to generate the model. Unlike the previous tutorial, this lesson assumes the reader has already completed the regular tutorial and has a working knowledge of VectorWorks. After the model is constructed, the reader will be expected to use AccuTrans, or an equivalent translation package, to translate his or her model into VRML format. As the reader progresses through this tutorial it is important that he or she realizes that: The purpose of constructing a VRML model is to produce a model that can be viably added to an urban landscape that will be transmitted via the Internet. This means that the memory size of your present CAD model, which likely is between 5 to 35 M of memory, must be reduced to a figure between 10 and 100K of memory. Only abstract the basic shapes necessary to produce a simple rendering of the building. Stated another way, stay away from complex shapes. As you can see in Figure 1, curved surfaces such as the canister above require the software to generate large numbers of polygons, and the more polygons you have, the more memory you use. You will also need to avoid producing objects of ornamentation, such as tiles, and polygon heady objects such as window frames, chimneys, and gables. Instead of reproducing an entire window unit, simply draw a plane to represent the window. Remember, the important task here is to produce a rudimentary facsimile of the model, if the user wants to see a detailed rendition, he or she can consult the QuickTime VR representation of the structure.

Upload: lydiep

Post on 08-May-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

Translating your CAD Modelto a VRML Model

While students' CAD models will be the basis of all visual materials displayed by the 3D Virtual Buildings Project,the models themselves will not be displayed in the repository. Given the bandwidth constraints which currentlygovern data transmission over the Internet, two formats will be employed to portray the project's urban landscapes.

The first is QuickTime VR, which will be used to generate highly textured, detailed renditions of the cities on site.While the graphic quality of QuickTime VR is impressive, it nevertheless fails to provide full mobility to users.Viewers frame of reference is limited to the panorama or object in their screen.

VRML, Virtual Reality Modeling Language, by contrast, provides full mobility, enabling viewers to move in anydirection within the model. The shortcomings of this modeling format are twofold. Most VRML scenes offer onlyrudimentary portrayals of the objects they are meant to represent. This limitation is necessary since detailed modelssuch as those produced by CAD software produce files too large for rapid transmission over the Internet. Such fileswould also preclude smooth navigation through the model once it has been downloaded into the computer. Second,the visual quality of VRML models compared to their QuickTime VR counterparts is poor. It is for this reason thatboth formats have been incorporated into the 3D Virtual Buildings Project. The shortcomings of one format will becompensated by resort to the strengths of its counterpart.

The object of this tutorial is to take the user through the steps necessary to generate a VRML equivalent of anexisting CAD model such as the Hope building. Like the regular tutorial, this lesson will be based on DiehlGraphsoft's VectorWorks to generate the model. Unlike the previous tutorial, this lesson assumes the reader hasalready completed the regular tutorial and has a working knowledge of VectorWorks.

After the model is constructed, the reader will be expected to use AccuTrans, or an equivalent translation package, totranslate his or her model into VRML format.As the reader progresses through this tutorial it is important that he or she realizes that:

• The purpose of constructing a VRML model is to produce a model that can be viably added to anurban landscape that will be transmitted via the Internet. This means that the memory size of yourpresent CAD model, which likely is between 5 to 35 M of memory, must be reduced to a figure between 10and 100K of memory.

• Only abstract the basic shapes necessary to produce a simple rendering of the building. Stated anotherway, stay away from complex shapes. As you can see in Figure 1, curved surfaces such as the canisterabove require the software to generate large numbers of polygons, and the more polygons you have, themore memory you use. You will also need to avoid producing objects of ornamentation, such as tiles, andpolygon heady objects such as window frames, chimneys, and gables. Instead of reproducing an entirewindow unit, simply draw a plane to represent the window. Remember, the important task here is toproduce a rudimentary facsimile of the model, if the user wants to see a detailed rendition, he or she canconsult the QuickTime VR representation of the structure.

Page 2: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

2

Figure 1:

• While constructing the VRML model it is important to keep the number of polygons in your model toan absolute minimum. The complex shapes in CAD models are produced by adding large numbers ofsimpler, smaller shapes together. Most CAD software packages, for example, generate curved surfaces byadding large numbers of small rectangles -- or polygons -- together. The software produces the curvedeffect by altering the angular orientation of each polygon, so that it is slighltly different from the polygonthat preceded it. See Figure 1.

Creating a VRML Model from CADTo illustrate how these points may be realized, this tutorial will take the user through the process that was followedto convert the Hope building shown in Figure 2. This tutorial will not be a step by step tutorial, simply a statementof points modelers should keep in mind while generating their own VRML models.

Figure 2:

Part A: Don't Reinvent the Wheel

It's important to remember that this exercise is not meant to be labour intensive. You want to produce a goodfacsimile, but in short order, and the first way to do that is to build on what you know already. Use your existingCAD model as the basis for your new model. You already made measurements for your structure while constructingthe CAD model, so needn't repeat that process. Use the information you already have to determine the position ofwindows in your new model As well, use copies of existing components wherever possible. If you need to modifythe shape of a component to reduce its polygon, use the CAD component as a reference shape.

Page 3: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

3

Part B: Use your Reference Shape

As well, use the reference shape the same way you employed it with your CAD model. It will help you position thewalls and roof of your structure.

Figure 3:

Part C: Simplify your model

Figure 4 shows the VRML model which we generated from the CAD model shown in Figure 2 in order todemonstrate the degree of simplification that is required.

Page 4: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

4

Figure 4:

This step requires you to simplify in two ways. The first is deciding which objects are superfluous for your presentneeds. Note that there are no doors or windows on the first floor. Note also that there are no tiles on the columns,and that all window frames have been removed. All we want are basic shapes to portray the basic features of thestructure. Simplification also requires you to alter the shape of the components that remain. Note for example, thestructures from the CAD model and the columns of the original structure shown respectively in Figures 6a and 6b.

Figure 6a:

Figure 6b:

Page 5: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

5

Figure 7a shows the modifications we made to the structures shown in Figure 6a. Note that all curved surfaces in thebase and [buttress] have been removed and replaced with a flat surface. The ridge on the sign level has also beenremoved, and neither the sign level nor the base are wrapped around the columns, but simply traverse the length ofFacade 1 in the VRML model. These changes substantially reduced the number of polygons required to model Level1.

Figure 7a:

In Figure 7b note how the columns have been simplified. All tiles have been removed. The objects attached to thecolumn on Level 3 have been removed, and the dimensions for the columns on all three levels have been madeuniform. Note also that the arches and other ornaments on the surrounding windows have either been removed orreduced.

Figure 7b:

Page 6: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

6

Part D: Reduce Polygon Count

As you generate your model it is important to realize that most VRML modelers regard CAD modeling packages asone of the worst possible options for generating VRML representations. One reason for this unfavourable attitude isthat CAD packages produce far more polygons than required to produce a viable VRML model. One way toovercome this difficulty is to rely on a basic rule of thumb while constructing your model: if the shape you areconstructing has any surfaces or polygons which will not be visible to the future viewer, delete them. Consider, forexample, the roof of the CAD Hope building shown in Figure 8.

Figure 8:

Aside from possessing far too many polygons, the shape also has unnecessary sections in the back, underside, leftand back edges and intersections points. To reduce the polygon count, we constructed a new roof first by copyingthe roof from our CAD model and pasting it in a new layer.

We then switched to the "Right View" of VectorWorks and traced the shape indicated in Figure 9.

Figure 9:

Once the new roof was generated it looked like Figure 10.

Page 7: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

7

Figure 10:

While eliminating the curve of the roof has substantially reduced the number of polygons in our object, more can beeliminated, particularly the polygons indicated in Figures 11 and 12.

Figure 11:

Page 8: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

8

Figure 12:

To remove the surplus polygons, we highlighted the entire object using the Selection Arrow . We then convertedthe object to polygons by opening the "Model" menu and selecting "Convert to 3D Polys". The object was thendivided into individual polygons by opening the Organize menu and selecting "Ungroup."Once that was done we were in a position to move or remove individual polygons. Our roof appeared as in Figure 13after the polygons were removed.

Figure 13:

Page 9: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

9

Converting the CAD Model to VRML

Part A: Divide Model into Separate Parts

Figure 14 shows the appearance of our model once it was completed in VectorWorks.

Figure 14:

While the structure is finished, we are still not in a position to convert the model to VRML format. If we were to doso, the conversion software would convert the entire structure into a single object and render it into a single colour,as shown in Figure 15.

Figure 15:

The rule of thumb with VRML, as with other 3D modeling formats, is one colour or texture is assigned to eachobject. The challenge at this stage of the modeling process is to find a way to divide the VRML model into separateobjects so that the model will have multiple colours. The first step in this process is to divide your CAD model intoseparate files. Each file will contain all the objects in your model that will have a particular colour. For example,Figure 16 shows the sections of the model which we decided to render brown.

Page 10: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

10

Figure 16:

To generate a new file:

• Open the File menu and select "New" to generate a new file.

• Open the Page menu and select "Layer scale" to ensure that the scale of yournew file matches that of your VRML model. If you want the scale to be thesame as your original CAD model, select 1" = 20'.

• Adjust the view in your screen so that it is the same as the file containing yourVRML model.

For example, if the file containing your VRML structure is

presently in the "Right Isometric" of VectorWorks, you willneed to ensure that your new file is in the same position.

• Open the Window menu to return to the file containing your VRML model.Select the objects you want to copy from your old file to your new file. Activatethe "Copy" command in the Edit menu.

• Open the Window menu to return to your new file. Open the Edit menu andselect "Paste in Place." Figure 17 shows what you should see in your screen.

Page 11: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

11

Figure 17:

Part B: Export Model from VectorWorks

Once you've divided your model into separate files, you will be in a position to export them from VectorWorks. Todo so, open the File menu and move the Selection Arrow down to "Export". After the new menu emerges select"Export DXF/DWG". Here we are converting our model into *.dxf format, the format associated with AutoCADmodeling software. As a format, it is useful for exporting and importing 3D models into a variety of softwarepackages.

Once the "DXF DWG Export Options" panel opens, ensure:

• That in the section marked "2D/3D Conversions" that the "Export 2Dand 3D Objects" option is selected. Also ensure that the box"Triangulate to preserve 3D Fills" is checked.

• That in the section "Invisible Classes are:" that the selection "NotExported" is chosen.

• That in the section marked "Objects in Invisible Layers are:" that theselection "Not exported" is chosen.

• Once you've ensured that all correct parameters have been selected, hit"OK".

• After the "Write DXF File to" panel appears, select a name for yourfile, such as the colour "brown", and then hit "Save".

• Hit "OK" when the "Map Line Weights to Color" panel appears.

Page 12: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

12

• Save your file and close VectorWorks.

Part C: Convert File to VRML

Open AccuTrans, the conversion package we will be using to convert our *.dxf model into VRML:

• Open the File menu and move the selection arrow to "Open". After thenew menu emerges move the selection arrow to "DXF (*.dxf) andselect it.

• Open your file.

• After the model appears in your screen open the File menu again andselect "Save As".

• After the "Save Object as" panel emerges, proceed to the "Save FileType" section of the panel.

• Open the selection menu by pressing , and move your selectionarrow to "VRML 2.0 (*.wrl).

• Once you've entered the correct file type, hit the "Save" button in thelower left corner of the panel.

• Enter a name for your VRML file. Again, we suggest the name of yourfile match the colour of the objects you are representing in this file. Eg."brown.wrl."

• Once you've saved your file, press the "Close" button in the lower leftcorner of the panel. Answer "Yes" when the program asks if you wantto clear your work and layer attributes.

• Close AccuTrans.

Page 13: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

13

Part D: Adjust VRML Code

Figure 18 indicates what your file should look like after AccuTrans has generated the file.

Figure 18:

As you can see from the diagram, the model looks incomplete. Several polygons appear to be missing. They aren't.It's important to remember in many computer modeling formats if an object or polygon is not rendered, it willappear invisible to a viewer using a browser such as the one displayed in Figure 18. The problem with the model inits present state is that only one side of the polygon is rendered. If you are looking at the polygon from the rightdirection you will be able to see it. If you are observing it from the opposite direction, the polygon will be invisible.Our objective here will be to change the code so that the polygons are rendered on both sides.

To change the code, you will need to open brown.wrl or other files into a software package that will enable you toread the code, such as "Notepad" or "Microsoft Word". Any software package capable of reading a text file will do.Once you've opened your file, code similar to what you see in Figure 19 should appear in your screen.

Page 14: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

14

Figure 19:

Your object here will be to alter a line of code at the end of the file. Move the scroll bar on the right side of yourscreen to the bottom. Figure 20 indicates what you should see.

Figure 20:

Change the line indicated in Figure 20. Erase the word "TRUE" and write the word "FALSE" in block letters. Save

Page 15: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

15

your file, and open it in your browser. Figure 21 indicates what you should see in your screen.

Figure 21:

Part E: Alter the Colour of your Model

To alter the colour of your object, we will again need to adjust the code. Open your file in Notepad, Microsoft Word,or equivalent package:

1. Note at the top of your file that there is code which reads: "DEF VP1 Viewpoint". Thiscode is intended to establish points of view -- coordinates -- for viewers to observe themodel in a browser. It's a command designed to enable viewers to rapidly view theirobject from above, from the right, left or the back.

2. While interesting, the "DEF VP1 Viewpoint" command is not our primary concern, weare only using it as a reference point. Scroll down until you see "DEF VP6 Viewpoint".Below it you should see the code indicated in Figure 22.

Page 16: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

16

Figure 22:

3. The first line refers to "DEF VP6 Viewpoint" indicated above. The second line refers tothe line of code which we will need to modify.

4. Colours in VRML are generated by mixing three basic colours: Red, Green and Blue. Thefirst number refers to Red, the second to Green, the third to Blue.

5. For each figure, you will need to enter a figure between 0.0 and 1.0. For example, youcan enter 0.75 as a value for Blue.

6. The colours you generate will depend on the values you enter for each colour. In the fileabove, AccuTrans entered the value 1.0 1.0 1.0 to produce the colour white. If you enter0.0 0.0 0.0 you will generate the colour black.

7. Figure 23 provides a list of colours and the values you will need to enter to realize themin your VRML model.

Page 17: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

17

Figure 23:

Colour: Red Green Blue

Black 0.0 0.0 0.0

Blue 0.0 0.0 0.0

Green 0.0 1.0 0.0

Light Blue 0.0 1.0 1.0

Red 1.0 0.0 0.0

Violet 1.0 0.0 0.0

Yellow 1.0 1.0 1.0

White 1.0 1.0 1.0

Grey 0.5 0.5 0.5

Brown 0.5 0.5 0.0

Realize that the colours listed above are not the only ones you have at your disposal. If the colour produced is notwhat you want, you can increase the amount of say red or blue to alter the shade of your colour. For example, toproduce the brown used in our VRML Hope building, we entered 0.9 0.5 0.4 instead of the values listed in the tableabove. Figure 24 was the result.

Page 18: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

18

Figure 24:

Part F: Combine VRML Files to Produce Model

Once you've encoded the requisite colour to each component of your model, you will be in a position to combinethem to produce the final model. To start, open Notepad, Microsoft Word, or an equivalent package.

• Type the code indicated in Figure 25.

Figure 25:

• Once you've typed the title of your program save your document. Enter any name you wish in the "FileName" text entry field, but do not save the file as a text or Word File. In the "Save as type" text entry bar

Page 19: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

19

choose "All files", and before you save your file write the file extension *.wrl to the name of your file. Forexample, if you want to use the word "Combine", write "Combine.wrl" in the "File Name" text entry field.Doing so will enable your browser to read your file as a VRML file.

• To generate your model, you will need to do two things. First, ensure that your new file is in the samedirectory as the other files associated with your model. In other words, "Combine.wrl" needs to be in thesame directory as "brown.wrl."

• Second, you will need to use the Transform command indicated in Figure 26 to recombine the various files-- such as "brown.wrl" -- into a single file.

Figure 26:

• Type the code in exactly as you see it in Figure 26. You will need to use this sequence of code for each filethat you want to import into your finished model. For example, if you want to add "Blue.wrl" to your file,you would add the code shown in Figure 27.

Page 20: Translating your CAD Model to a VRML Model your CAD Model to a VRML Model ... facsimile, but in short order, and the first way to do that is to build on what you know already. Use

20

Figure 27:

• Once you've added the indicated sequence of code for each file that you wish to incorporate into your finalmodel, save your file and close Notepad or the equivalent package.

• Open your new file in your browser. Figure 28 indicates what you should see. Congratulations! You've justcompleted your VRML model.

Figure 28: