DirectPython extensions. This module contains some useful utilities written in Python.
Many objects (Mesh, Sprite, HeightMap and SkyBox) can be configured to use your effect files (as long as they have compatible input layout). See Resource for instructions.
Most included shaders tend to be extremely simple and mostly for general demonstration purposes, so you probably want to replace them with your own versions or even create your own classes. If you are not familiar with HLSL (High Level Shader Language) you could even use some existing fixed function pipeline “emulator” effect.
Flags for Sprite.drawText()
Fake italic, the text is tilted slightly.
All line breaks are ignored.
Text is drawn with a strikeout.
Text is drawn with an underline.
Text is centered horizontally (x-axis). Requires TEXT_SINGLELINE.
Text is centered vertically (y-axis). Requires TEXT_SINGLELINE.
Text is centerd horizontally and vertically (TEXT_XCENTER | TEXT_YCENTER | TEXT_SINGLELINE).
Module level functions.
Returns the low order word of a integer value. Useful when handling window messages.
Returns the high order word of a integer value. Useful when handling window messages.
Returns True if the message is a mouse message.
Returns True if the message is a keyboard message.
Returns the value from d3d11.Device.getFeatureLevel() as a tuple.
Returns the default resource directory where effects, meshes, textures etc. are looked from. If any arguments are passed the function behaves similary to os.path.join.
path = getResourceDir("Effects", "MyEffect.fx")
You can (and possibly should if you are using py2exe or anything similar) replace this function with your own version.
def myGetResourceDir(*args):
...
return path
#Do this before loading any d3d11x-objects.
d3d11x.getResourceDir = myGetResourceDir
This utility class can be used to handle data returned when slicing Texture-objects. Only useful when using “normal” (non-compressed) textures.
| Parameters: |
|
|---|
Constucts a new Accessor.
Index the 1D-data using 2D-values. The coordinates are naturally relative to the orginal slice.
Assign byte data.
t = Texture(...) #Mapped texture (MAP_READ_WRITE), assume RGBA8 format
S = (128, 64) #Size of the slice.
data = t[:S[0], :S[1]] #Read some data.
accessor = Accessor(data, S, 4) #RGBA8 has a bytesize of 4.
accessor[64, 50] = [255, 0, 0, 0] #Change pixel x=64, y=50 to red (relative to the slice).
... #Maybe do someting else with the data.
t[:S[0], :S[1]] = data #Write it back.
A simple camera class which handles user input and moves the camera accordingly. Default controls:
You can also move the camera with the mouse. Holding the left mouse button down and then moving the mouse will rotate the camera’s viewing direction without moving the camera itself. With the mouse wheel you can lower or raise the camera.
| Parameters: |
|
|---|
Creates a new Camera.
| Parameters: |
|
|---|
Starts a camera “drive” from camera’s current location to the target position. During this time user input is ignored. When the camera has reached the target position the drive is stopped and user resumes control.
Returns True if the camera is currently in drive mode.
| Parameters: |
|
|---|
Should be called once per frame (unless paused etc). This updates cameras position and checks if the user is pressing any movement keys.
Sets the position and viewing direction.
Current (normalized) viewing direction of the camera.
Current position of the camera.
A simple framework class for all samples. This class offers some basic functionality common to all samples so that they can fully focus on their subject rather than spend time with basic tasks like creating resources and handling messages. It also provides some trivial convenience methods so that certain non-relevant but common tasks can be “removed from sight”.
It is recommended that you examine how this class is implemented before you try to write your own - especially if you are not familiar with Windows programming.