Jump to content
Sign in to follow this  
JRowe

Rendering 3D object to transparent window

Recommended Posts

JRowe

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

Share this post


Link to post
Share on other sites
Pain

Nice, cool to see 3D in AutoIt. This really got some potential in the future.

Great job.

Share this post


Link to post
Share on other sites
Andreik

Very nice.

How can I make to rotate more fast?


When the words fail... music speaks

Share this post


Link to post
Share on other sites
JRowe

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:

Share this post


Link to post
Share on other sites
Andreik

Set $Direction to a higher number.

Thanks.

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


When the words fail... music speaks

Share this post


Link to post
Share on other sites
jvanegmond

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

Share this post


Link to post
Share on other sites
JRowe

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

:mellow:

Share this post


Link to post
Share on other sites
A. Percy

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[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites
thomaatje

This is very nice! good job! :mellow:

Is it possible to create a cube with 6 difrent textures with 1 texture on each side?

Share this post


Link to post
Share on other sites
BrettF

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!

Share this post


Link to post
Share on other sites
A. Percy

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[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites
A. Percy

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[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites
JRowe
JRowe

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.

Share this post


Link to post
Share on other sites
A. Percy

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[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites
youknowwho4eva

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

Share this post


Link to post
Share on other sites
youknowwho4eva

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

Share this post


Link to post
Share on other sites
A. Percy

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[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.