A Number Of Ray Sensor Improvements #13622

Closed
opened 2008-06-04 06:45:11 +02:00 by Jason R · 4 comments

%%%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.%%%

%%%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.%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @Moguri

Added subscriber: @Moguri

This type of functionality seems better suited to the raycasting API (KX_GameObject.rayCast/rayCastTo()). If this is something you still want reviewed (kind of doubtful after 6 years), please add it to Differential.

This type of functionality seems better suited to the raycasting API (KX_GameObject.rayCast/rayCastTo()). If this is something you still want reviewed (kind of doubtful after 6 years), please add it to Differential.

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#13622
No description provided.