OpenGL VRML
Home Books Applications Tools Docs Models Textures

Please send me your comments
Tutorials List

Primitives Tutorial

Index

Introduction
Model Resources
Models

Primitive Types

Box
Cylinder
Plane
Sphere

Interactive Section

[Previous: Plane] [Next: Interact]

Primitives Tutorial


Sphere


The sphere primitive is very powerful since it lets you create slices of a sphere.

The set of properties for a sphere model resource are:

NameDefaultDescriptionRange
radius25.0The radius of the sphere.Any float larger than zero
resolution20Determines the smoothness of the sphere. The higher the value, the larger the number of faces used to build the sphere. Note however that the number you set is not the number of faces, think of it as a smoothness factor. This setting has a direct influence on the performance. High values will produce smooth spheres but will make your application run slower.Any positive integer, larger than zero
startAngle0.0A sphere is built sweeping a semi circle arc along a circular trajectory on the XZ plane, i.e. rotating the semi circle arc around the Y axis. The start and end angles determine where the sweep starts and ends. A full sphere has a startAngle of 0.0 and an endAngle of 360.0. Half a sphere can be defined for instance setting the startAngle to 0.0 and the endAngle to 180.0. Any float between 0.0 and the endAngle
endAngle360.0Any float larger than startAngle and smaller or equal to 360.0
Half a sphere: startAngle=0, endAngle=180 (the sphere was rotated to get a better view) Sphere with resolution set to 2

In order to retrieve the actual value of the startAngle of a model resource called "aSphere" you could write something like:


    
	len = member("world").modelResource("aSphere").startAngle



The following script creates a sphere with resolution equal to 3. To try it create a new movie, add a Shockwave 3D member to the score, name it "world" and attach this script to the sprite.


    
on beginSprite me
  
  w = member("world")
  w.resetWorld()
  mr = w.newModelResource("ball",#sphere,#front)
  mr.resolution = 3
  m = member("world").newModel("aBallInstance",mr)
end



[Previous: Plane] [Next: Interact]



Site designed and maintained by António Ramires Fernandes
Your comments, suggestions and references to further material are welcome!

Lighthouse 3D privacy statement