Jump to content

Rendering 3D object to transparent window


JRowe
 Share

Recommended Posts

Here's a demo script. You'll need the latest Au3Irrlicht package.

Save this script into the same directory as the examples.

Use Esc to exit.

And, here's a video preview.

:mellow:

CODE
#include <GUIConstants.au3>

#include <Constants.au3>

#include <WindowsConstants.au3>

#include <WINAPI.au3>

#include "IrrlichtPluginUtils.au3"

HotKeySet("{ESC}", "Terminate")

#Region - GUI Create

$gui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)

GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)

GUICtrlSetTip(-1, "Click label to drag layered window")

$layButt = GUICtrlCreateButton("Button", 10, 40, 40)

GUISetBkColor(0xABCDEF)

_WinAPI_SetLayeredWindowAttributes($gui, 0x010101)

CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 10, 10, 320, 240, 32, 0, 0 )

GUISetState()

$Camera = AddCameraSceneNode( 0, 0, 25, -40, 0, 0, 0 )

$Node = AddCubeSceneNode( 20 )

$Au3Texture = GetTexture( "data\au3.bmp" )

SetMaterialTexture( $Node, 0, $Au3Texture )

SetMaterialFlag( $Node, $EMF_LIGHTING, 0 )

$Y = 0

$Direction = 2

#Region - GUI SelectLoop

GUISetStyle($WS_POPUP, -1, $gui)

_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)

While IrrRun( )

SetRotation( $Node, 0, $Y, 0 )

BeginScene( true, true, 0, 171, 205, 239 )

SceneDraw( )

GuiDraw( )

EndScene( )

sleep( 20 )

$Y += $Direction

If $Y > 360 Then $Y -= 360

If $Y < 0 Then $Y += 360

WEnd

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)

If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

If Not $isColorRef Then

$i_transcolor = Hex(String($i_transcolor), 6)

$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))

EndIf

Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)

Select

Case @error

Return SetError(@error, 0, 0)

Case $Ret[0] = 0

Return SetError(4, _WinAPI_GetLastError(), 0)

Case Else

Return 1

EndSelect

EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

Func Terminate()

Exit 0

EndFunc

Link to comment
Share on other sites

Yup. I'm still working on how to interact with it, probably a transparent gif overlay in a child gui. Not entirely practical at this point, but there's a lot of potential for 3D interfaces. I'm working on a talking head, atm. Modeling is fun :mellow:

Link to comment
Share on other sites

Thanks.

I have not used yet IrrlichtPlugin but seems interesting. I'll try to learn. :mellow:

Since it rotates, the following code had to have something to do with the rotation. That's why I thought putting $Direction to a higher number would alter the speed.

$Y += $Direction
If $Y > 360 Then $Y -= 360
If $Y < 0 Then $Y += 360
Link to comment
Share on other sites

SetRotation( $Node, 0, $Y, 0 ) sets the rotation of $Node to $Y on every pass through the main While loop.

:mellow:

Link to comment
Share on other sites

Yesterday I played a little with your example and I put a red triplane crossing my desktop :mellow:

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

Yesterday I played a little with your example and I put a red triplane crossing my desktop :mellow:

The same as your avatar... and where's the post of your example!
Link to comment
Share on other sites

The same as your avatar... and where's the post of your example!

In my pen-drive :mellow:

After work, I'll go to home of a friend to upload it.

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

As I promissed...

Dreidecker.zip

PS: pk3 file = zip file

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

I've had it running with onTop, no taskbar, and no tray icon for about 5 hours now, with the time offscreen set to about 1 second, and it's slowly gaining memory.

It started at 8k, and now it's at 11k :mellow:

Only 4% CPU usage.

Also, it runs on top of the screensaver, and when I my little brother ran it on his computer, something borked and turned everything the screen rendered a dark shade of blue (he was alt-tabbing in and out of warcraft.) After reboot, everything was fine, so if this happens to you, I'm sorry. Just reboot and everything should be fine.

Link to comment
Share on other sites

I was thinking yesterday about transparency and decided to try support it natively in plugin... :mellow:

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

I made a few modifications to the original. Looks like an entrance for AutoIt. I made it sleep for 5 seconds at 0,0,0 when it got close but for some reason that didn't look the box head on so I took that out

#include <GUIConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include "IrrlichtPluginUtils.au3"


HotKeySet("{ESC}", "Terminate")

#Region - GUI Create
$gui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")
$layButt = GUICtrlCreateButton("Button", 10, 40, 40)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($gui, 0x010101)
CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 10, 10, 320, 240, 32, 0, 0 )
GUISetState()

$Camera = AddCameraSceneNode( 0, 0, 25, -40, 0, 0, 0 )
$Node = AddCubeSceneNode( 10 )
$Au3Texture = GetTexture( "data\au3.bmp" )
SetMaterialTexture( $Node, 0, $Au3Texture )
SetMaterialFlag( $Node, $EMF_LIGHTING, 0 )
$Y = 0
$x = 0
$z = 0
$Ys = 0
$xs = 0
$zs = 0
$start = 0
$directionz = 3
$Directiony = 3
$directionx = 3
$directionzs = 1/64
$Directionys = 1/64
$directionxs = 1/64
#Region - GUI SelectLoop
GUISetStyle($WS_POPUP, -1, $gui)
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)

While IrrRun( )
setscale($node,$xs,$ys,$zs)
SetRotation( $Node, $x, $Y, $z )

BeginScene( true, true, 0, 171, 205, 239 )

SceneDraw( )
GuiDraw( )

EndScene( )

sleep( 20 )
$ys += $directionys
$xs += $directionxs
$zs += $directionzs
If $ys = 3 Then
    $directionys = 0
    $directionxs = 0
    $directionzs = 0
ElseIf $ys = 0 Then
    Exit
EndIf

$Y += $Directiony
If $Y > 360 Then $Y -= 363
If $Y < 0 Then $Y += 360

$x += $Directionx
If $x > 360 Then $x -= 363
If $x < 0 Then $x += 360

$z += $Directionz
If $z > 360 Then $z -= 363
If $z < 0 Then $z += 360
If $x = 3 and $y = 3 and $z = 3 Then
    If $start < 3 Then
        $start += 1
    ElseIf $start = 3 Then
    $directiony = -10
    $directionx = -10
    $directionz = -10
    $directionys = -1/16
    $directionxs = -1/16
    $directionzs = -1/16
    EndIf
EndIf


WEnd

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
Select
Case @error
Return SetError(@error, 0, 0)
Case $Ret[0] = 0
Return SetError(4, _WinAPI_GetLastError(), 0)
Case Else
Return 1
EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes

Func Terminate()
Exit 0
EndFunc

Giggity

Link to comment
Share on other sites

Does this only work in 3ds? I would have to go 3 ways to make my files 3ds, but if it accepted dwg or ckd or a few others then I could really do something with this. Of course I could always convert to 3ds, but the others would be quicker.

Edit: sorry for double post, thought I hit edit, but hit reply instead.

Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

Does this only work in 3ds? I would have to go 3 ways to make my files 3ds, but if it accepted dwg or ckd or a few others then I could really do something with this. Of course I could always convert to 3ds, but the others would be quicker.

Edit: sorry for double post, thought I hit edit, but hit reply instead.

I did some edit in your code, test it :mellow:

#include <GUIConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include "IrrlichtPluginUtils.au3"


HotKeySet("{ESC}", "Terminate")

#Region - GUI Create
$gui = GUICreate("trans", 320, 300, -1, -1, 0x9C800000, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
GUISetStyle( $WS_POPUP, -1, $gui )
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)
GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")
CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 0, 30, 320, 240, 32, 0, 0 )
GUISetState()

$Camera = AddCameraSceneNode( 0, 0, 25, -40, 0, 0, 0 )
$Node = AddCubeSceneNode( 10 )
$Au3Texture = GetTexture( "data\au3.bmp" )
SetMaterialTexture( $Node, 0, $Au3Texture )
SetMaterialFlag( $Node, $EMF_LIGHTING, 0 )
$Y = 0
$x = 0
$z = 0
$Ys = 0
$xs = 0
$zs = 0
$start = 0
$directionz = 3
$Directiony = 3
$directionx = 3
$directionzs = 1/64
$Directionys = 1/64
$directionxs = 1/64


While IrrRun( )
setscale($node,$xs,$ys,$zs)
SetRotation( $Node, $x, $Y, $z )

BeginScene( true, true, 0, 171, 205, 239 )

SceneDraw( )
GuiDraw( )

EndScene( )

sleep( 20 )
$ys += $directionys
$xs += $directionxs
$zs += $directionzs
If $ys = 3 Then
    $directionys = 0
    $directionxs = 0
    $directionzs = 0
ElseIf $ys = 0 Then
    Exit
EndIf

$Y += $Directiony
If $Y > 360 Then $Y -= 363
If $Y < 0 Then $Y += 360

$x += $Directionx
If $x > 360 Then $x -= 363
If $x < 0 Then $x += 360

$z += $Directionz
If $z > 360 Then $z -= 363
If $z < 0 Then $z += 360
If $x = 3 and $y = 3 and $z = 3 Then
    If $start < 3 Then
        $start += 1
    ElseIf $start = 3 Then
    $directiony = -10
    $directionx = -10
    $directionz = -10
    $directionys = -1/16
    $directionxs = -1/16
    $directionzs = -1/16
    EndIf
EndIf


WEnd

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes

Func Terminate()
    Exit 0
EndFunc

About another 3d format, it supports .obj(Alias Wavefront Maya), .ms3d(Milkshape3D), .bsp(Quake3 Level), .md2(Quake2 Model), .3ds(3D Studio), .x(Microsoft DirectX).

:(

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...