forked from LeenkxTeam/LNXSDK
Repe [T3DU] and Moises Jpelaez updates
This commit is contained in:
54
leenkx/blender/lnx/logicnode/draw/LN_draw_image_render.py
Normal file
54
leenkx/blender/lnx/logicnode/draw/LN_draw_image_render.py
Normal file
@ -0,0 +1,54 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class DrawImageRenderNode(LnxLogicTreeNode):
|
||||
"""Draws an image render target.
|
||||
|
||||
@input Draw: Activate to draw the image on this frame. The input must
|
||||
be (indirectly) called from an `On Render2D` node.
|
||||
|
||||
@input In: Activate to retrieve the imaga render target.
|
||||
@input Camera: the render target image of the camera.
|
||||
@input Color: The color that the image's pixels are multiplied with.
|
||||
@input Left/Center/Right: Horizontal anchor point of the image.
|
||||
|
||||
0 = Left, 1 = Center, 2 = Right
|
||||
@input Top/Middle/Bottom: Vertical anchor point of the image.
|
||||
|
||||
0 = Top, 1 = Middle, 2 = Bottom
|
||||
@input X/Y: Position of the anchor point in pixels.
|
||||
@input Width/Height: Size of the image in pixels.
|
||||
@input sX/Y: Position of the sub anchor point in pixels.
|
||||
@input sWidth/sHeight: Size of the sub image in pixels.
|
||||
@input Angle: Rotation angle in radians. Image will be rotated cloclwiswe
|
||||
at the anchor point.
|
||||
@input Render2D: include Render 2D draws.
|
||||
|
||||
@output Out: Activated after the image has been drawn.
|
||||
|
||||
@see [`kha.graphics2.Graphics.drawImage()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawImage).
|
||||
"""
|
||||
bl_idname = 'LNDrawImageRenderNode'
|
||||
bl_label = 'Draw Image Render'
|
||||
lnx_section = 'draw'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'Draw')
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxNodeSocketObject', 'Camera')
|
||||
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
|
||||
self.add_input('LnxIntSocket', '0/1/2 = Left/Center/Right', default_value=0)
|
||||
self.add_input('LnxIntSocket', '0/1/2 = Top/Middle/Bottom', default_value=0)
|
||||
self.add_input('LnxFloatSocket', 'X')
|
||||
self.add_input('LnxFloatSocket', 'Y')
|
||||
self.add_input('LnxFloatSocket', 'Width')
|
||||
self.add_input('LnxFloatSocket', 'Height')
|
||||
self.add_input('LnxFloatSocket', 'sX')
|
||||
self.add_input('LnxFloatSocket', 'sY')
|
||||
self.add_input('LnxFloatSocket', 'sWidth')
|
||||
self.add_input('LnxFloatSocket', 'sHeight')
|
||||
self.add_input('LnxFloatSocket', 'Angle')
|
||||
self.add_input('LnxBoolSocket', 'Render2D')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
@ -12,9 +12,9 @@ class DrawSubImageNode(LnxLogicTreeNode):
|
||||
@input Top/Middle/Bottom: Vertical anchor point of the image.
|
||||
0 = Top, 1 = Middle, 2 = Bottom
|
||||
@input X/Y: Position of the anchor point in pixels.
|
||||
@input Width/Height: Size of the sub image in pixels.
|
||||
@input sX/Y: Position of the sub anchor point in pixels.
|
||||
@input sWidth/Height: Size of the image in pixels.
|
||||
@input Width/Height: Size of the image in pixels.
|
||||
@input sX/sY: Position of the sub anchor point in pixels.
|
||||
@input sWidth/sHeight: Size of the sub image in pixels.
|
||||
@input Angle: Rotation angle in radians. Image will be rotated cloclwiswe
|
||||
at the anchor point.
|
||||
@output Out: Activated after the image has been drawn.
|
||||
|
||||
37
leenkx/blender/lnx/logicnode/draw/LN_draw_to_image.py
Normal file
37
leenkx/blender/lnx/logicnode/draw/LN_draw_to_image.py
Normal file
@ -0,0 +1,37 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class DrawToImageNode(LnxLogicTreeNode):
|
||||
"""Writes the given draw image to the given file. If the image
|
||||
already exists, the existing content of the image is overwritten.
|
||||
|
||||
@input Image File: the name of the image
|
||||
@input Color: The color that the image's pixels are multiplied with.
|
||||
@input Width: width of the image file.
|
||||
@input Height: heigth of the image file.
|
||||
@input sX: sub position of first x pixel of the sub image (0 for start).
|
||||
@input sY: sub position of first y pixel of the sub image (0 for start).
|
||||
@input sWidth: width of the sub image.
|
||||
@input sHeight: height of the sub image.
|
||||
|
||||
WARNING: Calling getPixels() on a renderTarget with non-standard non-POT dimensions
|
||||
can cause a system crash. Ensure renderTarget resolution is a power of two
|
||||
(e.g., 256x256) or a common standard resolution (e.g., 1920x1080).
|
||||
"""
|
||||
bl_idname = 'LNDrawToImageNode'
|
||||
bl_label = 'Draw To Image'
|
||||
lnx_section = 'draw'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Image File')
|
||||
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
|
||||
self.add_input('LnxIntSocket', 'Width')
|
||||
self.add_input('LnxIntSocket', 'Height')
|
||||
self.add_input('LnxIntSocket', 'sX')
|
||||
self.add_input('LnxIntSocket', 'sY')
|
||||
self.add_input('LnxIntSocket', 'sWidth')
|
||||
self.add_input('LnxIntSocket', 'sHeight')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
69
leenkx/blender/lnx/logicnode/draw/LN_draw_to_screen.py
Normal file
69
leenkx/blender/lnx/logicnode/draw/LN_draw_to_screen.py
Normal file
@ -0,0 +1,69 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
import bpy
|
||||
|
||||
|
||||
class DrawToScreenNode(LnxLogicTreeNode):
|
||||
"""Draws a Render Target image to screen.
|
||||
|
||||
@input Draw: Activate to draw the Render Target image to screen. The input must
|
||||
be (indirectly) called from an `On Render2D` node.
|
||||
@input In: Activate to get the Render Target image of the render 2d draws.
|
||||
@input Draw Width/Height: Size of the Render Target image in pixels.
|
||||
@input Image: The filename of the image.
|
||||
@input Color: The color that the image's pixels are multiplied with.
|
||||
@input Left/Center/Right: Horizontal anchor point of the image.
|
||||
|
||||
0 = Left, 1 = Center, 2 = Right
|
||||
@input Top/Middle/Bottom: Vertical anchor point of the image.
|
||||
|
||||
0 = Top, 1 = Middle, 2 = Bottom
|
||||
@input X/Y: Position of the anchor point in pixels.
|
||||
@input Width/Height: Size of the sub image in pixels.
|
||||
@input sX/Y: Position of the sub anchor point in pixels.
|
||||
@input sWidth/Height: Size of the image in pixels.
|
||||
@input Angle: Rotation angle in radians. Image will be rotated cloclwiswe
|
||||
at the anchor point.
|
||||
@input Clear Image: Clear the image before drawing to it
|
||||
|
||||
@output Out: Activated after the image has been drawn.
|
||||
@output Draw: Input for the render 2d draws.
|
||||
|
||||
@see [`kha.graphics2.Graphics.drawImage()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawImage).
|
||||
"""
|
||||
bl_idname = 'LNDrawToScreenNode'
|
||||
bl_label = 'Draw To Screen'
|
||||
lnx_section = 'draw'
|
||||
lnx_version = 2
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'Draw')
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxIntSocket', 'Draw Width')
|
||||
self.add_input('LnxIntSocket', 'Draw Height')
|
||||
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
|
||||
self.add_input('LnxIntSocket', '0/1/2 = Left/Center/Right', default_value=0)
|
||||
self.add_input('LnxIntSocket', '0/1/2 = Top/Middle/Bottom', default_value=0)
|
||||
self.add_input('LnxFloatSocket', 'X')
|
||||
self.add_input('LnxFloatSocket', 'Y')
|
||||
self.add_input('LnxFloatSocket', 'Width')
|
||||
self.add_input('LnxFloatSocket', 'Height')
|
||||
self.add_input('LnxFloatSocket', 'sX')
|
||||
self.add_input('LnxFloatSocket', 'sY')
|
||||
self.add_input('LnxFloatSocket', 'sWidth')
|
||||
self.add_input('LnxFloatSocket', 'sHeight')
|
||||
self.add_input('LnxFloatSocket', 'Angle')
|
||||
self.add_input('LnxBoolSocket', 'Clear Image')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxNodeSocketAction', 'Draw')
|
||||
|
||||
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
|
||||
if self.lnx_version not in (0, 1):
|
||||
raise LookupError()
|
||||
|
||||
return NodeReplacement(
|
||||
"LNDrawToScreenNode", self.lnx_version,
|
||||
"LNDrawToScreenNode", 2,
|
||||
in_socket_mapping={0:1, 1:2, 2:3, 3:4, 4:5, 5:6, 6:7, 7:8, 8:9, 9:10, 10:11, 11:12, 12:13, 13:14, 14:15},
|
||||
out_socket_mapping={0:0},
|
||||
)
|
||||
Reference in New Issue
Block a user