purple flower - can't remember what it's modelled on

Scripts in 3D Canvas

Chapter 4: More Complex Objects

The flowers in the corners of these pages were made with a script. If you like them you'll have to write your own script, but I'll tell you how I did it.

Here's part of the code.


       'set up the  Petals object
        Set Petalsgroup = Scene.Creategroup
        group.AddChild Petalsgroup
        Petalsgroup.SetName "Flower group"
        Set Petals = Scene.CreateObject()
        Dim PetalsPointCounter
        PetalsPointCounter=0
        'add a dummy normal to the object (we need one to add the points)
        Petals.AddNormal 0,0,-1

The petals are planes with transparent textures on them. That is the petal faces are all rectangles. The different shaped petals are made by making the texture transparent around the edge of the petals.

I plan to use the same technique soon to make grass and billboards. Grass could be done by scattering the rectangles randomly over a plane or a fractal terrain, or by placing them in a tight spiral to create a tuft.

My paint strip

Check out this marvel of 3D modelling at it's most exciting.

paint strip 6 colours

This is created with six planes. The add material part of the code isn't working properly and I had to colour it in outside the script. Here's the code.

And yes it does have a serious purpose. I call it my paint strip after the samples, or chits, you get in paint shops. If I am creating an object that I want to add texture to in the script, I put the texture or textures on my paint strip. Then in the script I suck them off the paint strip and copy them to the new object.

This is why I wrote the script (from Chapter 3) to get the objet numbers in the model: so I know the number of the cut and paste objects. Then I analyse the altitude of each face in the paint strip to fill an array with 6 textures.

You can't just step through faces of the paint strip. Even though they are created in order from 0 to 5, as soon as you start adding material to individual faces of a 3D Canvas object, the faces are reordered.

We'll use the paint strip in the next chapter.


Next is Chapter 5

Introduction and Contentspurple flower - can't remember what it's modelled on