Exemplo n.º 1
0
from cyclops import *
from math import *
import random
import sprite


size = sprite.createSizeUniform()

for i in range(0, 1000):
	x = random.random() * 10 - 5
	y = random.random() * 10 - 5
	z = -random.random() * 10
	star = sprite.createSprite('star.png', size)
	
	# just for fun: color each star randomly.
	r = random.random()
	g = random.random()
	b = random.random()
	star.getMaterial().setColor(Color(r, g, b, 1), Color(0,0,0,1))
	
	star.setPosition(x, y, z)

# just for fun: animate star size
def onUpdate(frame, time, dt):
	sz = (sin(time) + 1) * 0.1
	size.setFloat(sz)
	
setUpdateFunction(onUpdate)
Exemplo n.º 2
0
light = SphereShape.create(0.3, 2)
light.setPosition(-2, 2, -4)
light.setEffect('colored -e yellow')

window_size = sprite.createWindowSizeUniform()
window_size.setVector2f(Vector2(854, 480))

getSceneManager().setBackgroundColor(Color('black'))

lf = []

for i in range(0, 15):
	size = sprite.createSizeUniform()
	size.setFloat(150 - i * 32)
	star = sprite.createSprite('monochromatic/img%i.png'%i, size, window_size, False)
	star.setCullingActive(False)
	star.getMaterial().setTransparent(True)
	star.getMaterial().setAdditive(True)
	lf.append(star)

def onUpdate(frame, time, dt):
	screenDistance = 2
	opticsWidth = 0.5
	
	localHeadPos = getDefaultCamera().getHeadOffset()
	worldHeadPos = getDefaultCamera().localToWorldPosition(localHeadPos)
	screenCenter = getDefaultCamera().localToWorldPosition(localHeadPos - Vector3(0,0,screenDistance))
	
	lightDir = (light.getPosition() - worldHeadPos).normalize()
	
Exemplo n.º 3
0
from cyclops import *
from math import *
import random
import sprite


size = sprite.createSizeUniform()
window_size = sprite.createWindowSizeUniform()
window_size.setVector2f(Vector2(854, 480))

for i in range(0, 1000):
    x = random.random() * 10 - 5
    y = random.random() * 10 - 5
    z = -random.random() * 10
    star = sprite.createSprite("star.png", size, window_size, True)
    # disable culling for the sprite: since culling would be based on its center
    # the sprite would be culled before actually being out of screen.
    star.setCullingActive(False)
    # just for fun: color each star randomly.
    r = random.random()
    g = random.random()
    b = random.random()
    star.getMaterial().setColor(Color(r, g, b, 1), Color(0, 0, 0, 1))
    star.setPosition(x, y, z)

# just for fun: animate star size
def onUpdate(frame, time, dt):
    sz = (sin(time) + 1) * 64
    size.setFloat(sz)

Exemplo n.º 4
0
from cyclops import *
from math import *
import random
import sprite

size = sprite.createSizeUniform()

for i in range(0, 1000):
    x = random.random() * 10 - 5
    y = random.random() * 10 - 5
    z = -random.random() * 10
    star = sprite.createSprite('star.png', size)

    # just for fun: color each star randomly.
    r = random.random()
    g = random.random()
    b = random.random()
    star.getMaterial().setColor(Color(r, g, b, 1), Color(0, 0, 0, 1))

    star.setPosition(x, y, z)


# just for fun: animate star size
def onUpdate(frame, time, dt):
    sz = (sin(time) + 1) * 0.1
    size.setFloat(sz)


setUpdateFunction(onUpdate)