Log In
New Account
Home My Page Projects Blender 2.x BF release
Summary Activity Tracker SCM Files

Patches: Browse

[#13622] A Number Of Ray Sensor Improvements

Date:
2008-06-04 06:45
Priority:
3
State:
Open
Submitted by:
Jason R (scabootssca)
Assigned to:
Benoit Bolsee (ben2610)
Category:
Game engine
Group:
None
Resolution(Old, use status):
None
Resolution:
Patch for:
 
Summary:
A Number Of Ray Sensor Improvements
Detailed description
Added additional python methods to the ray sensor.

setRange,setAxis,setProperty,setMaterial,setVector,
setMaxHits,recast,getHitObjectList,getHitPositionList,
getHitNormalList,seeThroughUnmatched,getNumHits

Here is an excerpt from the KX_RaySensor.py explaining what each does.

def setRange(range):
"""
Sets how far the ray casts, in blender units.

@param range: How far the ray should cast
@type range: number
"""
def setAxis(axis):
"""
Sets which axis for the ray to cast on.
0,1,2 = X,Y,Z accordingly.
3,4,5 = -X,-Y,-Z accordingly.

@param axis: Which axis the ray should cast on
@type axis: number
"""
def setProperty(property):
"""
Set the ray to look for objects with the property of (property).

@param property: What property to look for
@type property: string
"""
def setMaterial(material):
"""
Set the ray to look for objects with the material of (pmaterial).

@param material: What material to look for
@type material: string
"""
def setVector(x,y,z):
"""
Sets the say to cast along the vector of x,y,z instead of constrained to an axis.
"""
def recast():
"""
Recasts the ray immediately, so you can do changes on property,axis,range whatever and then cast again multiple times a frame.
"""
def setMaxHits(maxHits):
"""
Enables the ray to hit multiple objects/positions per raycast up to (maxHits) default is 1.

@param maxHits: Maxmimum hits per cast
@type maxHits: number
"""
def seeThroughUnmatched(seeThrough):
"""
If (seeThrough) is true then the ray will see through objects that do not match the property or material
instead of stopping at them or counting them towards max hits.

@param seeThrough: Whether or not to hit unmatching objects.
@type seeThrough: number or boolean
"""
def getHitObjectList():
"""
Gets a list of objects hit by this ray closest first.

@return: A list of the objects hit
"""
def getHitPositionList():
"""
Gets a list of positions hit by this ray closest first.

@return: A list of the positions hit
"""
def getHitNormalList():
"""
Gets a list of normals hit by this ray closest first.

@return: A list of the normals hit
"""
def getNumHits():
"""
Gets how many things were hit by this ray.

@return: How many things were hit
"""

This makes it way easier to make more advanced games like shooters, shooting though glass, using rays for accurate bullet collisions is made very easy by this with other things as well. Makes it possible for rays to hit multiple objects or see through objects that do not match the property/material and casting the ray along any vector instead of being fixed to an axis.

Followup

No Followups Have Been Posted

 

Attached Files:

Name Date Download
rayUpdates.patch 2008-06-04 06:45 Download
raysensortestmultiple.blend 2008-06-05 07:20 Download
raysensortest_version2.blend 2008-06-05 12:06 Download
rayUpdatesv2.patch 2008-06-05 12:06 Download
rayUpdatesv3.patch 2008-06-27 11:44 Download

Changes:

Field Old Value Date By
File Added6188: rayUpdatesv3.patch2008-06-27 11:45scabootssca
File Added6055: rayUpdatesv2.patch2008-06-05 12:06scabootssca
File Added6054: raysensortest_version2.blend2008-06-05 12:06scabootssca
File Added6053: raysensortestmultiple.blend2008-06-05 07:20scabootssca
assigned_tonone2008-06-04 12:46ben2610
File Added6050: rayUpdates.patch2008-06-04 06:45scabootssca