Skip to content

Commit

Permalink
Updated module attributes to the actual types
Browse files Browse the repository at this point in the history
Also added KX_PythonComponent class, for UPBGE use.
Probably I will create a fork of this project dedicated to
UPBGE when the 2.79 version become a bit more complete.
  • Loading branch information
joelgomes1994 committed Apr 23, 2020
1 parent fa87755 commit 7a2d05b
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 517 deletions.
31 changes: 13 additions & 18 deletions bge/constraints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Module to create and control physics constraints."""

from .. import types

## Functions
def createConstraint(physicsid_1, physicsid_2, constraint_type, pivot_x=0.0, pivot_y=0.0, pivot_z=0.0, axis_x=0.0, axis_y=0.0, axis_z=0.0, flag=0):
Expand All @@ -23,8 +22,8 @@ def createConstraint(physicsid_1, physicsid_2, constraint_type, pivot_x=0.0, piv
Return type:
KX_ConstraintWrapper"""
value = types.KX_ConstraintWrapper
return value
from .. import types
return types.KX_ConstraintWrapper()

def createVehicle(physicsid):
"""Creates a vehicle constraint.
Expand All @@ -37,8 +36,8 @@ def createVehicle(physicsid):
Return type:
KX_VehicleWrapper"""
value = types.KX_VehicleWrapper
return value
from .. import types
return types.KX_VehicleWrapper

def exportBulletFile(filename):
"""Exports a file representing the dynamics world (usually using .bullet extension).
Expand All @@ -53,24 +52,20 @@ def getAppliedImpulse(constraintId):
"""Parameters:
constraintId (int) - The id of the constraint.
Returns:
The most recent applied impulse.
Returns: The most recent applied impulse.
Return type:
float"""
Return type: float"""
return True

def getVehicleConstraint(constraintId):
"""Parameters:
constraintId (int) - The id of the vehicle constraint.
Returns:
A vehicle constraint object.
Returns: A vehicle constraint object.
Return type:
KX_VehicleWrapper"""
value = types.KX_VehicleWrapper
return value
Return type: KX_VehicleWrapper"""
from .. import types
return types.KX_VehicleWrapper

def getCharacter(gameobj):
"""Parameters:
Expand All @@ -81,8 +76,8 @@ def getCharacter(gameobj):
Return type:
KX_CharacterWrapper"""
value = types.KX_CharacterWrapper
return value
from .. import types
return types.KX_CharacterWrapper

def removeConstraint(constraintId):
"""Removes a constraint.
Expand Down Expand Up @@ -207,7 +202,7 @@ def setUseEpa(epa):
pass

## Constants
error = "str"
error = ""

# Debug Mode Constants
DBG_NODEBUG = 0
Expand Down
11 changes: 4 additions & 7 deletions bge/logic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,14 @@ def getCurrentController():
Return type:
bge.types.SCA_PythonController"""
value = types.SCA_PythonController
return value
return types.SCA_PythonController()

def getCurrentScene():
"""Gets the current Scene.
Return type:
bge.types.KX_Scene"""
value = types.KX_Scene
return value
return types.KX_Scene()

def getSceneList():
"""Gets a list of the current scenes loaded in the game engine.
Expand All @@ -340,7 +338,7 @@ def getSceneList():
list of bge.types.KX_Scene
Note: Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes."""
return []
return [types.KX_Scene()]

def loadGlobalDict():
"""Loads bge.logic.globalDict from a file."""
Expand Down Expand Up @@ -381,8 +379,7 @@ def LibLoad(blend, type, data, load_actions=False, verbose=False, load_scripts=T
bge.types.KX_LibLoadStatus
Note: Asynchronously loaded libraries will not be available immediately after LibLoad() returns. Use the returned KX_LibLoadStatus to figure out when the libraries are ready."""
value = types.KX_LibLoadStatus
return value
return types.KX_LibLoadStatus()

def LibNew(name, type, data):
"""Uses existing datablock data and loads in as a new library.
Expand Down
49 changes: 24 additions & 25 deletions bge/texture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(self, file, capture=-1, rate=25.0, width=0, height=0):
self.deinterlace = True

# Functions
def play():
def play(self):
"""Play (restart) video.
Returns:
Expand All @@ -210,7 +210,7 @@ def play():
bool"""
return True

def pause():
def pause(self):
"""Pause video.
Returns:
Expand All @@ -220,7 +220,7 @@ def pause():
bool"""
return True

def stop():
def stop(self):
"""Stop video (play will replay it from start).
Returns:
Expand All @@ -230,7 +230,7 @@ def stop():
bool"""
return True

def refresh(buffer=None, format="RGBA", timestamp=-1.0):
def refresh(self, buffer=None, format="RGBA", timestamp=-1.0):
"""Refresh video - get its status.
Value:
Expand All @@ -257,7 +257,7 @@ def __init__(self, format, capture=0):
self.flip = False
self.filter = None

def play():
def play(self):
"""Kick-off the capture after creation of the object.
Returns:
Expand All @@ -267,7 +267,7 @@ def play():
bool"""
return True

def pause():
def pause(self):
"""Temporary stops the capture. Use play() to restart it.
Returns:
Expand All @@ -277,7 +277,7 @@ def pause():
bool"""
return True

def pause():
def pause(self):
"""Stops the capture.
Returns:
Expand All @@ -303,7 +303,7 @@ def __init__(self, file):
self.flip = True
self.filter = None

def refresh():
def refresh(self):
"""Refresh image, i.e. load it.
Value:
Expand All @@ -313,7 +313,7 @@ def refresh():
int"""
return 0

def reload():
def reload(self):
"""Reload image, i.e. reopen it.
Parameters:
Expand All @@ -339,7 +339,7 @@ def __init__(self, width, height, color=0, scale=False):
self.size = (0,0)
self.valid = True

def load(imageBuffer, width, height):
def load(self, imageBuffer, width, height):
"""Load image from buffer.
Parameters:
Expand All @@ -348,7 +348,7 @@ def load(imageBuffer, width, height):
height (int) - Height of the image to load."""
pass

def plot(imageBuffer, width, height, positionX, positionY, mode=IMB_BLEND_COPY):
def plot(self, imageBuffer, width, height, positionX, positionY, mode=IMB_BLEND_COPY):
"""Update image buffer.
Parameters:
Expand Down Expand Up @@ -384,7 +384,7 @@ def __init__(self, scene, observer, mirror, material=0, width=0, height=0, sampl
self.valid = True
self.whole = True

def refresh(buffer=None, format="RGBA"):
def refresh(self, buffer=None, format="RGBA"):
"""Refresh image - invalidate its current content."""
pass

Expand All @@ -401,7 +401,7 @@ def __init__(self):
self.size = (0,0)
self.valid = True

def getSource(id):
def getSource(self, id):
"""Get image source.
Parameters:
Expand All @@ -421,7 +421,7 @@ def getSource(id):
ImageViewport"""
pass

def getWeight(id):
def getWeight(self, id):
"""Get image source weight.
Parameters:
Expand All @@ -434,11 +434,11 @@ def getWeight(id):
int"""
return 0

def refresh(buffer=None, format="RGBA"):
def refresh(self, buffer=None, format="RGBA"):
"""Refresh image - invalidate its current content."""
pass

def setSource(id, image):
def setSource(self, id, image):
"""Set image source - all sources must have the same size.
Parameters:
Expand All @@ -454,7 +454,7 @@ def setSource(id, image):
ImageViewport"""
pass

def setWeight(id, weight):
def setWeight(self, id, weight):
"""Set image source weight - the sum of the weights should be 256 to get full color intensity in the output.
Parameters:
Expand Down Expand Up @@ -489,7 +489,7 @@ def __init__(self, scene, camera, width, height, samples, hdr):
self.depth = True
self.zbuff = True

def render():
def render(self):
"""Render the scene but do not extract the pixels yet. The function returns as soon as the render commands have been send to the GPU. The render will proceed asynchronously in the GPU while the host can perform other tasks. To complete the render, you can either call refresh() directly of refresh the texture of which this object is the source. This method is useful to implement asynchronous render for optimal performance: call render() on frame n and refresh() on frame n+1 to give as much as time as possible to the GPU to render the frame while the game engine can perform other tasks.
Returns:
Expand All @@ -499,7 +499,7 @@ def render():
bool"""
return True

def refresh(buffer, format="RGBA"):
def refresh(self, buffer, format="RGBA"):
"""Refresh video - render and optionally copy the image to an external buffer then invalidate its current content. The render may have been started earlier with the render() method, in which case this function simply waits for the render operations to complete. When called without argument, the pixels are not extracted but the render is guaranteed to be completed when the function returns. This only makes sense with offscreen render on texture target (see bge.render.offScreenCreate()).
Parameters:
Expand Down Expand Up @@ -531,7 +531,7 @@ def __init__(self):
self.depth = True
self.zbuff = True

def refresh(buffer=None, format="RGBA"):
def refresh(self, buffer=None, format="RGBA"):
"""Refresh video - copy the viewport to an external buffer (optional) then invalidate its current content.
Parameters:
Expand All @@ -556,11 +556,11 @@ def __init__(self, gameObj, materialID=0, textureID=0, textureObj=None):
self.mipmap = True
self.source = None

def close():
def close(self):
"""Close dynamic texture and restore original."""
pass

def refresh(refresh_source, timestamp=-1.0):
def refresh(self, refresh_source, timestamp=-1.0):
"""Refresh texture from source.
Parameters:
Expand All @@ -570,7 +570,6 @@ def refresh(refresh_source, timestamp=-1.0):

pass


class DeckLink:
"""Certain DeckLink devices can be used to playback video: the host sends video frames regularly for immediate or scheduled playback. The video feed is outputted on HDMI or SDI interfaces. This class supports the immediate playback mode: it has a source attribute that is assigned one of the source object in the bge.texture module. Refreshing the DeckLink object causes the image source to be computed and sent to the DeckLink device for immediate transmission on the output interfaces. Keying is supported: it allows to composite the frame with an input video feed that transits through the DeckLink card.
Expand All @@ -585,11 +584,11 @@ def __init__(self, cardIdx=0, format=""):
level = 0
extend = False

def close():
def close(self):
"""Close the DeckLink device and release all resources. After calling this method, the object cannot be reactivated, it must be destroyed and a new DeckLink object created from fresh to restart the output."""
pass

def refresh(refresh_source, ts):
def refresh(self, refresh_source, ts):
"""This method must be called frequently to update the output frame in the DeckLink device.
Parameters:
Expand Down
Loading

0 comments on commit 7a2d05b

Please sign in to comment.