Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
198 changed files
with
3,931 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/offline/ | ||
/files/ | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
River: Panorama - shot just across the Ohio River from Louisville, KY, the "Falls of the Ohio". | ||
courtesy of Sam Schad (c) www.blendedskies.com | ||
|
||
This image was tone-mapped to LDR and downsized for its usage in the book. | ||
|
||
The original HDR panorama can be downloaded for free at: | ||
http://www.blendedskies.com/MediaDetails/tabid/89/ProductID/44/Default.aspx | ||
|
||
The original file license can be found at: | ||
http://www.blendedskies.com/ExtraInfo/GeneralUsageLicense |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Most of those files were originally part of Blender test suite. | ||
They were adjusted to work in the latest Blender, and at some point | ||
will be re-uploaded back to Blender SVN test suite. | ||
|
||
Their licenses are independent as of the other book files, and we claim | ||
no ownership over them. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
# ############################# | ||
# Vehicle Physics Demo | ||
# ############################# | ||
# This file is part of the book: | ||
# "Game Development with Blender" | ||
# by Dalai Felinto and Mike Pan | ||
# | ||
# Published by "CENGAGE Learning" in 2013 | ||
# | ||
# You are free to use-it, modify it and redistribute | ||
# as long as you keep the original credits when pertinent. | ||
# | ||
# File tested with Blender 2.66 | ||
# | ||
# Copyright - February 2013 | ||
# This work is licensed under the Creative Commons | ||
# Attribution-Share Alike 3.0 Unported License | ||
# ############################# | ||
|
||
## First, we import all the python module | ||
from bge import constraints | ||
from bge import logic | ||
from bge import events | ||
from bge import render | ||
|
||
import math | ||
|
||
## Set specific vehicle characteristics ## | ||
wheelRadius = 0.5 | ||
wheelBaseWide = 1.0 | ||
wheelFrontOffset = 0.7 | ||
wheelBackOffset = -1.8 | ||
AttachHeightLocal = 0.2 | ||
suspensionLength = 0.8 | ||
influence = 0.02 | ||
stiffness = 20.0 | ||
damping = 2.0 | ||
compression = 4.0 | ||
friction = 10.0 | ||
Stability = 0.05 | ||
|
||
## This is called from the car object | ||
## is run once at the start of the game | ||
def carInit(): | ||
|
||
## setup aliases for Blender API access ## | ||
cont = logic.getCurrentController() | ||
logic.scene = logic.getCurrentScene() | ||
logic.car = cont.owner | ||
|
||
## setup general vehicle characteristics ## | ||
wheelAttachDirLocal = [0,0,-1] | ||
wheelAxleLocal = [-1,0,0] | ||
|
||
## setup vehicle physics ## | ||
vehicle = constraints.createConstraint(logic.car.getPhysicsId(),0,11) | ||
logic.car["cid"] = vehicle.getConstraintId() | ||
vehicle = constraints.getVehicleConstraint(logic.car["cid"]) | ||
|
||
## initialize temporary variables ## | ||
logic.car["dS"] = 0.0 | ||
|
||
## attached wheel based on actuator name ## | ||
wheel0 = logic.scene.objects["Wheel0"] | ||
wheelAttachPosLocal = [wheelBaseWide ,wheelFrontOffset, AttachHeightLocal] | ||
vehicle.addWheel(wheel0,wheelAttachPosLocal,wheelAttachDirLocal,wheelAxleLocal,suspensionLength,wheelRadius,1) | ||
|
||
wheel1 = logic.scene.objects["Wheel1"] | ||
wheelAttachPosLocal = [-wheelBaseWide ,wheelFrontOffset, AttachHeightLocal] | ||
vehicle.addWheel(wheel1,wheelAttachPosLocal,wheelAttachDirLocal,wheelAxleLocal,suspensionLength,wheelRadius,1) | ||
|
||
wheel2 = logic.scene.objects["Wheel2"] | ||
wheelAttachPosLocal = [wheelBaseWide ,wheelBackOffset, AttachHeightLocal] | ||
vehicle.addWheel(wheel2,wheelAttachPosLocal,wheelAttachDirLocal,wheelAxleLocal,suspensionLength,wheelRadius,0) | ||
|
||
wheel3 = logic.scene.objects["Wheel3"] | ||
wheelAttachPosLocal = [-wheelBaseWide ,wheelBackOffset, AttachHeightLocal] | ||
vehicle.addWheel(wheel3,wheelAttachPosLocal,wheelAttachDirLocal,wheelAxleLocal,suspensionLength,wheelRadius,0) | ||
|
||
## set vehicle roll tendency ## | ||
vehicle.setRollInfluence(influence,0) | ||
vehicle.setRollInfluence(influence,1) | ||
vehicle.setRollInfluence(influence,2) | ||
vehicle.setRollInfluence(influence,3) | ||
|
||
## set vehicle suspension hardness ## | ||
vehicle.setSuspensionStiffness(stiffness,0) | ||
vehicle.setSuspensionStiffness(stiffness,1) | ||
vehicle.setSuspensionStiffness(stiffness,2) | ||
vehicle.setSuspensionStiffness(stiffness,3) | ||
|
||
## set vehicle suspension dampness ## | ||
vehicle.setSuspensionDamping(damping,0) | ||
vehicle.setSuspensionDamping(damping,1) | ||
vehicle.setSuspensionDamping(damping,2) | ||
vehicle.setSuspensionDamping(damping,3) | ||
|
||
## set vehicle suspension compression ratio ## | ||
vehicle.setSuspensionCompression(compression,0) | ||
vehicle.setSuspensionCompression(compression,1) | ||
vehicle.setSuspensionCompression(compression,2) | ||
vehicle.setSuspensionCompression(compression,3) | ||
|
||
## set vehicle tire friction ## | ||
vehicle.setTyreFriction(friction,0) | ||
vehicle.setTyreFriction(friction,1) | ||
vehicle.setTyreFriction(friction,2) | ||
vehicle.setTyreFriction(friction,3) | ||
|
||
|
||
## called from main car object | ||
## is run once at the start of the game | ||
def carHandler(): | ||
vehicle = constraints.getVehicleConstraint(logic.car["cid"]) | ||
|
||
## calculate speed by using the back wheel rotation speed ## | ||
S = vehicle.getWheelRotation(2)+vehicle.getWheelRotation(3) | ||
logic.car["speed"] = (S - logic.car["dS"])*10.0 | ||
|
||
## apply engine force ## | ||
vehicle.applyEngineForce(logic.car["force"],0) | ||
vehicle.applyEngineForce(logic.car["force"],1) | ||
vehicle.applyEngineForce(logic.car["force"],2) | ||
vehicle.applyEngineForce(logic.car["force"],3) | ||
|
||
## calculate steering with varying sensitivity ## | ||
if math.fabs(logic.car["speed"])<15.0: s = 2.0 | ||
elif math.fabs(logic.car["speed"])<28.0: s=1.5 | ||
elif math.fabs(logic.car["speed"])<40.0: s=1.0 | ||
else: s=0.5 | ||
|
||
## steer front wheels | ||
vehicle.setSteeringValue(logic.car["steer"]*s,0) | ||
vehicle.setSteeringValue(logic.car["steer"]*s,1) | ||
|
||
## slowly ease off gas and center steering ## | ||
logic.car["steer"] *= 0.6 | ||
logic.car["force"] *= 0.9 | ||
|
||
## align car to Z axis to prevent flipping ## | ||
logic.car.alignAxisToVect([0.0,0.0,1.0], 2, Stability) | ||
|
||
## store old values ## | ||
logic.car["dS"] = S | ||
|
||
|
||
|
||
## called from main car object | ||
def keyHandler(): | ||
cont = logic.getCurrentController() | ||
keys = cont.sensors["key"].events | ||
for key in keys: | ||
## up arrow | ||
if key[0] == events.UPARROWKEY: | ||
logic.car["force"] = -15.0 | ||
## down arrow | ||
elif key[0] == events.DOWNARROWKEY: | ||
logic.car["force"] = 10.0 | ||
## right arrow | ||
elif key[0] == events.RIGHTARROWKEY: | ||
logic.car["steer"] -= 0.05 | ||
## left arrow | ||
elif key[0] == events.LEFTARROWKEY: | ||
logic.car["steer"] += 0.05 | ||
## Reverse | ||
elif key[0] == events.RKEY: | ||
if key[1] == 1: | ||
# re-orient car | ||
if logic.car["jump"] > 2.0: | ||
pos = logic.car.worldPosition | ||
logic.car.position = (pos[0], pos[1], pos[2]+3.0) | ||
logic.car.alignAxisToVect([0.0,0.0,1.0], 2, 1.0) | ||
logic.car.setLinearVelocity([0.0,0.0,0.0],1) | ||
logic.car.setAngularVelocity([0.0,0.0,0.0],1) | ||
logic.car["jump"] = 0 | ||
## Spacebar | ||
elif key[0] == events.SPACEKEY: | ||
# hackish Brake | ||
if logic.car["speed"] > 2.0: | ||
logic.car["force"] = 15.0 | ||
if logic.car["speed"] < -2.0: | ||
logic.car["force"] = -15.0 | ||
|
||
|
||
## called from shadow lamp | ||
def shadow(): | ||
cont = logic.getCurrentController() | ||
ownpos = [-5.0,0.0,8.0] | ||
pos = logic.car.worldPosition | ||
cont.owner.worldPosition = [pos[0]+ownpos[0], pos[1]+ownpos[1], pos[2]+ownpos[2]] | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ############################# | ||
# Python Module Controller Demo | ||
# ############################# | ||
# This file is part of the book: | ||
# "Game Development with Blender" | ||
# by Dalai Felinto and Mike Pan | ||
# | ||
# Published by "CENGAGE Learning" in 2013 | ||
# | ||
# You are free to use-it, modify it and redistribute | ||
# as long as you keep the original credits when pertinent. | ||
# | ||
# File tested with Blender 2.66 | ||
# | ||
# Copyright - February 2013 | ||
# This work is licensed under the Creative Commons | ||
# Attribution-Share Alike 3.0 Unported License | ||
# ############################# | ||
|
||
from bge import logic | ||
|
||
""" this script will be re-load every frame. | ||
Remember to save the file after you change-it. """ | ||
def reload_me(controller): | ||
# controller = logic.getCurrentController() | ||
own = controller.owner | ||
|
||
# edit the speed value and you will see the rotation changing | ||
# (try with values from 0.01 to 0.05) | ||
speed = 0.025 | ||
|
||
# now try to comment and uncomment the following lines | ||
# adding or removing # from the begin of the line) | ||
own.applyRotation([0,0,speed],0) | ||
# own.applyRotation([speed,0,0],0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# ############################# | ||
# Oriented Object Programming Demo | ||
# ############################# | ||
# This file is part of the book: | ||
# "Game Development with Blender" | ||
# by Dalai Felinto and Mike Pan | ||
# | ||
# Published by "CENGAGE Learning" in 2013 | ||
# | ||
# You are free to use-it, modify it and redistribute | ||
# as long as you keep the original credits when pertinent. | ||
# | ||
# File tested with Blender 2.66 | ||
# | ||
# Copyright - February 2013 | ||
# This work is licensed under the Creative Commons | ||
# Attribution-Share Alike 3.0 Unported License | ||
# ############################# | ||
|
||
import bge | ||
from bge import logic as G | ||
from bge import render as R | ||
|
||
# showing the mouse cursor | ||
R.showMouse(True) | ||
|
||
# storing the current scene in a variable | ||
scene = G.getCurrentScene() | ||
|
||
# define a class to store all group elements and the click object | ||
class Group(): | ||
def __init__(self, name): | ||
self.name = name | ||
self.click = None | ||
self.objects = [] | ||
|
||
# create new element groups | ||
cube_group = Group("cubes") | ||
sphere_group = Group("sphere") | ||
|
||
# add all objects with an "ui" property to the created element | ||
for obj in scene.objects: | ||
if "cube" in obj: | ||
cube_group.objects.append(obj) | ||
elif "sphere" in obj: | ||
sphere_group.objects.append(obj) | ||
elif "click" in obj: | ||
exec("%s_group.click = obj" % (obj["click"])) | ||
# note exec here is replacing: | ||
# if obj["click"] == "cube": | ||
# cube_group.click = obj | ||
# elif obj["click"] == "sphere": | ||
# sphere_group.click = obj | ||
|
||
G.groups = {"cube":cube_group, "sphere":sphere_group} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# ############################# | ||
# Oriented Object Programming Demo | ||
# ############################# | ||
# This file is part of the book: | ||
# "Game Development with Blender" | ||
# by Dalai Felinto and Mike Pan | ||
# | ||
# Published by "CENGAGE Learning" in 2013 | ||
# | ||
# You are free to use-it, modify it and redistribute | ||
# as long as you keep the original credits when pertinent. | ||
# | ||
# File tested with Blender 2.66 | ||
# | ||
# Copyright - February 2013 | ||
# This work is licensed under the Creative Commons | ||
# Attribution-Share Alike 3.0 Unported License | ||
# ############################# | ||
|
||
import bge | ||
from bge import logic as G | ||
|
||
# defines a function to hide/turn visible all the objects passed as argument | ||
def change_visibility(objects, on_off): | ||
for obj in objects: | ||
obj.visible = on_off | ||
|
||
# retrieve the stored groups to local variables | ||
cube_group = G.groups["cube"] | ||
sphere_group = G.groups["sphere"] | ||
|
||
# read the current value of the "on_off" property in the cube/sphere | ||
cube_visible = cube_group.click["on_off"] | ||
sphere_visible = sphere_group.click["on_off"] | ||
|
||
# calls the function into the group object with the visibility flag | ||
change_visibility(cube_group.objects, cube_visible) | ||
change_visibility(sphere_group.objects, sphere_visible) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ############################# | ||
# Simple Sensor, Controller and Actuator Demo | ||
# ############################# | ||
# This file is part of the book: | ||
# "Game Development with Blender" | ||
# by Dalai Felinto and Mike Pan | ||
# | ||
# Published by "CENGAGE Learning" in 2013 | ||
# | ||
# You are free to use-it, modify it and redistribute | ||
# as long as you keep the original credits when pertinent. | ||
# | ||
# File tested with Blender 2.66 | ||
# | ||
# Copyright - February 2013 | ||
# This work is licensed under the Creative Commons | ||
# Attribution-Share Alike 3.0 Unported License | ||
# ############################# | ||
|
||
import bge | ||
from bge import logic | ||
|
||
cont = logic.getCurrentController() | ||
owner = cont.owner | ||
|
||
scene = logic.getCurrentScene() | ||
objects = scene.objects | ||
text_obj = objects["Text"] | ||
|
||
sens = cont.sensors['my_sensor'] | ||
act = cont.actuators['my_actuator'] | ||
|
||
if sens.positive: | ||
cont.activate(act) | ||
text_obj.text = "CADABRA" | ||
else: | ||
cont.deactivate(act) | ||
text_obj.text = "ABRA" | ||
|
Oops, something went wrong.