Skip to content
Alessandro Febretti edited this page Feb 8, 2014 · 6 revisions

module cyclops extends Entity wraps cyclops::LineSet

Defines a container of 3D line primitives. Lines are drawn as cylinders. Using this class instead of the CylinderShape class is better if:

  • You have to draw lots of lines (or cylinders) that share the same material / effect
  • You want to place lines in the scene defining a start / end point and thickness (instead of position / orientation / scale)

Methods

Method(s) Description
static LineSet create() Creates a new LineSet object
Line addLine() Creates a new line
removeLine(Line line) Removes the specified line

addLine() returns an object of type Line that supports the following methods:

Method(s) Description
setStart(Vector3 position) Sets the start position of the line. See Vector3.
setEnd(Vector3 position) Sets the end position of the line. See Vector3.
float getThickness() setThickness(float value) Gets or sets the line thickness

###Example

# Use lines and spheres to create a disc.
from math import *
from euclid import *
from omega import *
from cyclops import *

circle = LineSet.create()

segments = 32
radius = 1
thickness = 0.1

a = 0.0
while a <= 360:
	x = cos(radians(a)) * radius
	y = sin(radians(a)) * radius
	a += 360.0 / segments 
	nx = cos(radians(a)) * radius
	ny = sin(radians(a)) * radius
	
	l = circle.addLine()
	l.setStart(Vector3(x, y, 0))
	l.setEnd(Vector3(nx, ny, 0))
	l.setThickness(thickness)
	
	s = SphereShape.create(thickness / 2, 2)
	circle.addChild(s)
	# Use a full emissive color. Using transparent colors does not work very well due
	# to overlapping polygons.
	s.setEffect('colored -e red')
	s.setPosition(Vector3(nx, ny, 0))
	
circle.setPosition(Vector3(0,2,-4))
circle.setEffect('colored -e red')

# Squish z to turn the torus into a disc-like shape.
circle.setScale(Vector3(1.0,1.0,0.1))
Clone this wiki locally