Jump to content

My latest and greatest 3D project


youknowwho4eva
 Share

Recommended Posts

http://www.box.net/shared/t217kp06bx

It's complete until I find something else to add. I'm contemplating making a 3D presentation program much like powerpoint, but Idono maybe if you ask nicely :).

What is it? Just a program that I made to possibly, in the future, be a catalog of products. Something we can send to a customer to show what their product would look like or to display existing products such as the plate. The frame is from my Happy Holidays program.

Edit: And in case you want to learn anything from it I guess the source would be nice. Or if you don't trust lil ole me yet here you go.

Another Edit: opps wrong code

#include <GUIConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
;~ #include <WINAPI.au3>
#include <IrrlichtPluginUtils.au3>
#include <GUIConstantsEx.au3>
#include <math.au3>
#include <color.au3>
#include <misc.au3>
#include <IE.au3>

dim $seq[100000], $folder[1000000], $model[1000000], $mouse[1000000], $product[1000000], $productnode[1000000], $productnodetexture[1000000], $cursor[1000000], $cursornode[1000000], $cursornodetexture[1000000]
$dll = "user32.dll"
Global $y,$y2,$y3,$guess,$modely,$modelx
$num = 1
$cameraz = 0
$out = -.25

$folder = dirgetsize(@scriptdir & "\models",1)
$modelsearch = FileFindFirstFile(@scriptdir & "\models\*.3ds")
For $i = 1 To $folder[1]
$model[$i] = FileFindNextFile($modelsearch)
Next
$3ds = @scriptdir & "\models\"


$mousesearch = FileFindFirstFile(@scriptdir & "\mouse*.3ds")
For $b = 1 To 3
$mouse[$b] = FileFindNextFile($mousesearch)
Next
$mice = @scriptdir & "\"


$turn = 0
$r= 155
$g= 230
$b= 255
HotKeySet("{ESC}", "Terminate")

;pink, pink, pink
$Hwnd = CreateLayeredDevice( "Trans", 0, 0, @DesktopWidth, @DesktopHeight, 0, 255, 0, 1 )


;Don't forget the light! Never.
$Light1 = AddLightSceneNode( 0, 10, 10, -500, 0, 0, 0, 1000 )
;AddNewSLight( CastShadows, Falloff, InnerCone, OuterCone, Radius [, Type ] )
$SLight = AddNewSLight( 0, 50, 1, 500, 3000, $ELT_DIRECTIONAL )
SetLightSpecularColor( $SLight, 0.1, 0.1, 0.1 )
;~ SetLightDiffuseColor( $SLight, 0.7, 0.7, 0.7 )
SetLightData( $Light1, $SLight )

$Light2 = AddLightSceneNode( 0, -300, 50, -20, 0, 0, 0, 1000 )
$SLight2 = AddNewSLight( 0, 100, 1, 500, 3000, $ELT_DIRECTIONAL )
SetLightSpecularColor( $SLight2, 0.1, 0.1, 0.1 )
;~ SetLightDiffuseColor( $SLight2, 0.7, 0.7, 0.7 )
SetLightData( $Light2, $SLight2 )
;~ SetRotation( $Light2, 0, 90, 0 )


$Camera = AddCameraSceneNode( 0, 0, 0, -20, 0, 0, 0 )


$m = MouseGetPos()
$mx = $mouse[0]
$my = $mouse[1]

;~ MsgBox(0,"",$mouse[$i])
For $a = 1 To 3
$cursor[$a] = getmesh($mice  & $mouse[$a])
$cursornode[$a] = addmeshscenenode($cursor[$a])
$cursornodetexture[$a] = getmaterial ($cursornode[$a],0)
;~ setdiffusecolor($cursornodetexture,0,255,255,255)
SetMaterialTexture( $cursorNode[$a], 0, GetTexture( @scriptdir & "\white.bmp" ) )
SetMaterialFlag( $cursornode[$a], Bitand($EMF_GOURAUD_SHADING,$EMF_LIGHTING), 1 )
setvisible($cursornode[$a],0)
;~ MsgBox(0,"",$mouse[$h])
Next
setvisible($cursornode[1],1)
;~ setscale($cursornode[1],2,2,2)
setrotation($cursornode[1],0,0,-45)
setvisible($cursornode[2],1)
setposition($cursornode[2],-5.8,3.5,-10)
setscale($cursornode[2],5,5,5)
setvisible($cursornode[3],1)
setposition($cursornode[3],-4,1,-10)
setscale($cursornode[3],5,5,5)
$cursornum = 1
setvisible($cursornode[2],0)
setvisible($cursornode[3],0)

;~ $mouse = getmesh(@scriptdir &  "\mouse.3ds")
;~ $mousenode = addmeshscenenode($mouse)
;~ $mousenodetexture = getmaterial ($mousenode,0)
;~ setdiffusecolor($mousenodetexture,0,0,0,0)
;~ setscale($mousenode,1,1,1)
;~ SetMaterialFlag( $mousenode, $EMF_NORMALIZE_NORMALS, 1 )
;~ setrotation($mousenode,0,0,-45)

;~ SetMaterialTexture( $mouseNode, 0, GetTexture( @scriptdir & "\white.bmp" ) )
;~ SetMaterialFlag( $mousenode, $EMF_LIGHTING, 0 )
;~ setvisible($mousenode,0)


;~ $rotate = getmesh(@scriptdir &  "\rotate.3ds")
;~ $rotatenode = addmeshscenenode($rotate)
;~ $rotatenodetexture = getmaterial ($rotatenode,0)
;~ setdiffusecolor($rotatenodetexture,0,0,0,0)
;~ setposition($rotatenode,-13,5,0)
;~ setscale($rotatenode,10,10,10)
;~ SetMaterialFlag( $rotatenode, $EMF_NORMALIZE_NORMALS, 1 )
;~ setrotation($rotatenode,0,0,-45)
;~ SetMaterialTexture( $rotateNode, 0, GetTexture( @scriptdir & "\white.bmp" ) )
;~ SetMaterialFlag( $rotatenode, $EMF_LIGHTING, 0 )
;~ setvisible($rotatenode,0)

;~ $mag = getmesh(@scriptdir &  "\magglass.3ds")
;~ $magnode = addmeshscenenode($mag)
;~ $magnodetexture = getmaterial ($magnode,0)
;~ setdiffusecolor($magnodetexture,0,0,0,0)
;~ setposition($magnode,-9,0,0)
;~ setscale($magnode,10,10,10)
;~ SetMaterialFlag( $magnode, $EMF_NORMALIZE_NORMALS, 1 )
;~ setrotation($magnode,0,5,0)
;~ SetMaterialTexture( $magNode, 0, GetTexture( @scriptdir & "\white.bmp" ) )
;~ SetMaterialFlag( $magnode, $EMF_LIGHTING, 0 )
;~ setvisible($magnode,1)


$rarrow = getmesh(@scriptdir &  "\arrow.3ds")
$rarrownode = addmeshscenenode($rarrow)
$rarrownodetexture = getmaterial ($rarrownode,0)
;~ setdiffusecolor($rarrownodetexture,0,0,0,0)
setposition($rarrownode,12,-10,0)
setscale($rarrownode,150,150,150)
SetMaterialFlag( $rarrownode, $EMF_NORMALIZE_NORMALS, 1 )
setrotation($rarrownode,0,0,0)
SetMaterialTexture( $rarrowNode, 0, GetTexture( @scriptdir & "\white.bmp" ) )
;~ SetMaterialFlag( $rarrownode, $EMF_LIGHTING, 0 )
;~ setvisible($rarrownode,0)

$larrow = getmesh(@scriptdir &  "\arrow.3ds")
$larrownode = addmeshscenenode($larrow)
$larrownodetexture = getmaterial ($larrownode,0)
;~ setdiffusecolor($larrownodetexture,0,0,0,0)
setposition($larrownode,-12,-10,0)
setscale($larrownode,150,150,150)
SetMaterialFlag( $larrownode, $EMF_NORMALIZE_NORMALS, 1 )
setrotation($larrownode,0,0,180)
SetMaterialTexture( $larrowNode, 0, GetTexture( @scriptdir & "\white.bmp" ) )
;~ SetMaterialFlag( $larrownode, $EMF_LIGHTING, 0 )
;~ setvisible($larrownode,0)


For $h = 1 To $i - 1
$product[$h] = getmesh($3ds  & $model[$h])
$productnode[$h] = addmeshscenenode($product[$h])
$productnodetexture[$h] = getmaterial ($productnode[$h],0)
;~ setdiffusecolor($productnodetexture,0,255,255,255)
If $h <> 1 Then
setposition($productnode[$h],-12,-10,0)
Else
setposition($productnode[$h],1,0,0)
EndIf
setscale($productnode[$h],2,2,2)
setrotation($productnode[$h],0,0,0)
SetMaterialTexture( $productNode[$h], 0, GetTexture( @scriptdir & "\white.bmp" ) )
SetMaterialFlag( $productnode[$h], Bitand($EMF_GOURAUD_SHADING,$EMF_LIGHTING), 1 )
setvisible($productnode[$h],0)
;~ MsgBox(0,"",$model[$h])
Next
setvisible($productnode[1],1)
setscale($productnode[1],1.25,1.25,1.25)

$mprotate = 0
$right = 0
$key = "01"
$node = $productnode[1]
$left = 0
$up = 55
$right = 0
$down = 0

$y = 0

$hgui = GUICreate("", @DesktopWidth + 20, @DesktopHeight - 80, -10, 0, -1, 0x00000080);$WS_EX_TOOLWINDOW = 0x00000080
    WinSetTrans($hGUI, "", 1)
    WinSetOnTop($hGUI, "", 1)
    GUISetState(@SW_SHOW, $hGUI)
    GUISetCursor(16)
    

    $speed = 53 
While 1
    
;~  SetRotation( $Light1, 0, $y, 0 )
;~  $y += 5
;~  if $y > 360 Then $y -= 360
   
    If $node = $productnode[1] Then
;~      MsgBox(0,"","should be here")
        setrotation($node,0,$mprotate,0)
        If $right = 1 Then
            $mprotate += 1
            If $mprotate > 44 Then $right = 0
        Else
            $mprotate -= 1
            If $mprotate < -44 Then $right = 1
        EndIf
        BeginScene( true, true, 0, $r, $g, $b)

        SceneDraw( )
        GuiDraw( )

        EndScene( )
    
    EndIf

    $m = mouseGetPos( )
    
    $CurrNode = GetSceneNodeFromScreenCoordinatesBB( $m[0], $m[1] )
    If $m[1] > @DesktopHeight/2 Then
   $my = (@DesktopHeight/2 - $m[1]) / $speed
   Else
       $my = (-($m[1] - @DesktopHeight/2)) / $speed
   EndIf
   If $m[0] > @DesktopWidth/2 Then
   $mx = (-(@DesktopWidth/2 - $m[0])) / $speed
   Else
       $mx = ($m[0] - @DesktopWidth/2) / $speed
   EndIf
   If $cursornum = 2 Then
       $mx += .8
       $my += .7
   ElseIf $cursornum = 3 Then
       $mx += 2
       $my += .7
   EndIf
   
setposition($cursornode[$cursornum],$mx,$my,-10)

        BeginScene( true, true, 0, $r, $g, $b)

        SceneDraw( )
        GuiDraw( )

        EndScene( )
    Switch $CurrNode
    
    Case $node
    
    
        If _IsPressed($key) Then
            
If $node = $productnode[1] then _IECreate("http://www.marylandplastics.com",0,1,0)

    
    
        EndIf
       
;~       Case _IsPressed($key)
;~          If $rotate = "up" Then
;~  MsgBox(0,"","up")
;~  $modely = $m[1] - $my
;~  setrotation($node, $modelx,$modely,0)
;~                  BeginScene( true, true, 0, $r, $g, $b)

;~                  SceneDraw( )
;~                  GuiDraw( )

;~                  EndScene( )
;~ ElseIf $rotate = "side" Then
;~  MsgBox(0,"","up")
;~  $modelx = $cursor[0] - $cursorx
;~  setrotation($node, $modelx,$modely,0)
;~                  BeginScene( true, true, 0, $r, $g, $b)

;~                  SceneDraw( )
;~                  GuiDraw( )

;~                  EndScene( )
;~              EndIf
;~          Case $rotatenode
;~              ToolTip ("Rotate Tool")
;~          case $magnode
;~              ToolTip ("Magnify Tool")
            Case $rarrownode
                
    
            setscale($rarrownode,130,130,130)
            If _IsPressed( $Key ) Then
                setposition($productnode[$num],0,0,0)
    setrotation($productnode[$num],0,0,0)
                $up = 55
                $down = 0
                $left = 0
                $right = 0
;~              MsgBox(0,"","Is it getting this message?")
                $move = 1
                $num -= 1
                $prenode = $node
            If $num = 0 Then
                $node = $productnode[$i - 1]
                $num = $i - 1
                $cursornum = 1
                setposition($cursornode[2],-5.8,3.5,-10)
                setposition($cursornode[3],-4,1,-10)
;~              MsgBox(0,$i,"should be here")
            ElseIf  $num = $i Then
                $node = $productnode[1]
                $num = 1
                $cursornum = 1
                setposition($cursornode[2],-5.8,3.5,-10)
                setposition($cursornode[3],-4,1,-10)
;~              MsgBox(0,"","should not be here")
            Else
                $node = $productnode[$num]
;~              MsgBox(0,$i & $num,"should never be here")
                EndIf
            
                For $n = 0 to -@DesktopWidth Step - $move
                    If $n < -30 Then ExitLoop
                    setposition($prenode,$n,0,0)
                    BeginScene( true, true, 0, $r, $g, $b)

                    SceneDraw( )
                    GuiDraw( )

                    EndScene( )
                Next
                setvisible($prenode,0)
                setrotation($productnode[$num],0,0,0)
                If $prenode = $productnode[1] Then 
                    $move = 4
                    setrotation($node,0,0,0)
                ElseIf $node = $productnode[1] Then
                    $move = 1
                    setrotation($node,0,0,0)
                Else
                    
                    setrotation($node,0,0,0)
                EndIf
                
                setvisible($node,1)
                For $n = 30 To -$move Step - $move
                    If $n < 0 Then $n = 0
                    setposition($node,$n,0,0)
                    BeginScene( true, true, 0, $r, $g, $b)

                    SceneDraw( )
                    GuiDraw( )

                    EndScene( ) 
                    If $n = 0 Then ExitLoop
                Next
                
            EndIf
       
        Case $larrownode
             setscale($larrownode,130,130,130)
            If _IsPressed( $Key ) Then
    setposition($productnode[$num],0,0,0)
    setrotation($productnode[$num],0,0,0)
                $up = 55
                $down = 0
                $left = 0
                $right = 0
;~              MsgBox(0,"","Is it getting this message?")
                $move = 1
                $num += 1
                $prenode = $node
            If $num = 0 Then
                $node = $productnode[$i - 1]
                $num = $i - 1
                $cursornum = 1
                setposition($cursornode[2],-5.8,3.5,-10)
                setposition($cursornode[3],-4,1,-10)
;~              MsgBox(0,$i,"should be here")
            ElseIf  $num = $i Then
                $node = $productnode[1]
                $cursornum = 1
                $num = 1
                setposition($cursornode[2],-5.8,3.5,-10)
                setposition($cursornode[3],-4,1,-10)
;~              MsgBox(0,"","should not be here")
            Else
                $node = $productnode[$num]
;~              MsgBox(0,$i & $num,"should never be here")
                EndIf
            
                For $n = 0 to @DesktopWidth Step $move
                    If $n > 30 Then ExitLoop
                    setposition($prenode,$n,0,0)
                    BeginScene( true, true, 0, $r, $g, $b)

                    SceneDraw( )
                    GuiDraw( )

                    EndScene( )
                Next
                setvisible($prenode,0)
                setrotation($productnode[$num],0,0,0)
                If $prenode = $productnode[1] Then 
                    $move = 4
                    setrotation($node,0,0,0)
                ElseIf $node = $productnode[1] Then
                    $move = 1
                    setrotation($node,0,0,0)
                Else
                    
                    setrotation($node,0,0,0)
                EndIf
                
                setvisible($node,1)
                For $n = -30 To 0 Step $move
                    If $n = 0 Then ExitLoop
                    setposition($node,$n,0,0)
                    BeginScene( true, true, 0, $r, $g, $b)

                    SceneDraw( )
                    GuiDraw( )

                    EndScene( ) 
                Next
                
            EndIf
       
   EndSwitch
   If $num = 1 and $cursornum <> 1 Then
                $cursornum = 1
    EndIf
    If _IsPressed($key) Then
        setvisible($cursornode[$cursornum],0)
;~      Sleep(60)
        $CurrNode = GetSceneNodeFromScreenCoordinatesBB( $m[0], $m[1] )
        If $currnode = $cursornode[2] Then
            $zoomcontrol = 0
            If $cursornum = 1 Then
            setposition($cursornode[1],-7.5,6,-10)
            ElseIf $cursornum = 2 Then
            setposition($cursornode[2],-5.8,3.5,-10)
            ElseIf $cursornum = 3 Then
            setposition($cursornode[3],-4,1,-10)
            EndIf
            $cursornum = 2
            $speed = 58
        
    ElseIf $currnode = $cursornode[1] Then
        $zoomcontrol = 0
        If $cursornum = 1 Then
            setposition($cursornode[1],-7.5,6,-10)
            ElseIf $cursornum = 2 Then
            setposition($cursornode[2],-5.8,3.5,-10)
            ElseIf $cursornum = 3 Then
            setposition($cursornode[3],-4,1,-10)
            EndIf
        $cursornum = 1
    $speed = 53
    
ElseIf $currnode = $cursornode[3] Then
    $zoomcontrol = 0
            If $cursornum = 1 Then
            setposition($cursornode[1],-7.5,6,-10)
            ElseIf $cursornum = 2 Then
            setposition($cursornode[2],-5.8,3.5,-10)
            ElseIf $cursornum = 3 Then
            setposition($cursornode[3],-4,1,-10)
            EndIf
        $cursornum = 3
    $speed = 65
EndIf
    
        If $node <> $productnode[1] and $cursornum = 2 Then
    $modely = -$m[0] - $my
    $modelx = $m[1] - $mx
    setrotation($node, $modelx,$modely,0)
                    BeginScene( true, true, 0, $r, $g, $b)

                    SceneDraw( )
                    GuiDraw( )

                    EndScene( )
                EndIf
                If $m[0] > @DesktopWidth/2 + 160 Then
                MouseMove(@DesktopWidth/2 + 160,$m[1])
                ElseIf $m[1] > @DesktopHeight/2 + 160 Then
                MouseMove($m[0],@DesktopHeight/2 + 160)
                ElseIf $m[0] < @DesktopWidth/2 - 160 Then
                MouseMove(@DesktopWidth/2-160,$m[1])
                ElseIf $m[1] < @DesktopHeight/2 - 160 Then
                MouseMove($m[0],@DesktopHeight/2-160)
            EndIf
            If $node <> $productnode[1] and $cursornum = 3 Then
                
                If $zoomcontrol = 0 Then
$zoomcontrol = 1
            setvisible($cursornode[1],1)
            setvisible($cursornode[2],1)
            setvisible($cursornode[3],1)
ElseIf $zoomcontrol = 1 Then
                $cameraz += $out
                If $cameraz > 0 Then $cameraz = 0
                If $cameraz < -10 Then $cameraz = -10
    setposition($productnode[$num],0,0,$cameraz)
    Sleep(60)
EndIf
EndIf
                Else
            setscale($rarrownode,150,150,150)
            setscale($larrownode,150,150,150)
                    
            setvisible($cursornode[1],1)
            setvisible($cursornode[2],1)
            setvisible($cursornode[3],1)
        EndIf
        

;~   Sleep( 50 )
;~   BeginScene( true, true, 0, $r, $g, $b)

;~   SceneDraw( )
;~   GuiDraw( )

;~   EndScene( )
If _IsPressed("4f") Then 
    setposition($productnode[$num],0,0,0)
    $cameraz = 0
EndIf

If _IsPressed("5a") Then
                    If $out = .25 Then
                    $out = -.25
                Else
                    $out = .25
                EndIf
            EndIf
            If $cursornum = 1 Then
                ToolTip("Pointer Tool" & @LF & "Used to select tools or rotate between models")
            ElseIf $cursornum = 2 Then
                ToolTip("Rotate Tool" & @lf & "Click and drag to rotate")
            ElseIf $cursornum = 3 Then
                ToolTip("Zoom Tool" & @lf & "Press Z to switch between zoom in and out" & @lf & "Press O to zoom completely out")
            EndIf
            If $num = 1 Then
                setvisible($cursornode[2],0)
                setvisible($cursornode[3],0)
            Else
                setvisible($cursornode[1],1)
                setvisible($cursornode[2],1)
                setvisible($cursornode[3],1)
            EndIf
            
                
            
WEnd

Func terminate()
    Exit
EndFunc
Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

Yea, well the links been there, I just added the source download at the bottom

Edit: Oh yea thank you FireFox, I tried to make it as complete as possible with the functions it currently has. Any thoughts on the 3D slide show program?

Another Edit: Wow I just noticed, you don't even get to see half the coolness. I forgot to add my arrow models. Have to do that tomorrow when I get to work.

Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

how did you make the 3d modles? i couldnt find a program that would do that other than blender and blender has a really bad gui

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Well I use KeyCreator. Pricey stuff. Try out truespace. I haven't had enough experience in it yet, but it looks simpler then blender. Even simpler is the free version of sketchup. I acquired the full version :) and it's really simple, but I don't think you'd be able to create very complex models with it. If you want accuracy "acquire" yourself KeyCreator, AutoCAD, SolidWorks. Rhinoceros has a free trial, I believe you can save 5 models. AutoDesk (owners of AutoCAD, MIA, and a few others I cant think of) offer free trial versions. But the models can't be for commercial purposes and all that blahdy blah. I grew up with AutoCAD, and have fideled with MIA but KC is a good bit simpler. Stability is it's only real issue. If you get KC 8 it can export to obj and au3irrlicht supports obj files. I have to export to STL then to .3DS from Truespace. If you don't know CAD it's all about as hard as picking up scripting. I've been doing it for 9 years now. So the modeling was the easy part. I've only been coding for less then 6 months :o.

Giggity

Link to comment
Share on other sites

Forgive my late, finaly I got internet connection in my house :)

The problem is this line, you don't need it:

CreateLayeredDevice( "Trans", 0, 0, @DesktopWidth, @DesktopHeight, 0, 255, 0, 1 )

Put this line instead:

CreateDevice( $EDT_DIRECT3D8, @DesktopWidth, @DesktopHeight, 32, 0, 0, 0 )

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

It's complete until I find something else to add. I'm contemplating making a 3D presentation program much like powerpoint, but Idono maybe if you ask nicely :).

excuse me my good sir,

this is me asking you nicely,

could you please make a 3D presentation program much like powerpoint? i am sure that many poeple would be made happy with its compleation

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

A 3D presentation program would only require some edits to this one to have a start. Then I'd just need to add a gui for model adding, and effect adding. Believe me TehWhale I put a lot of thought into it before asking if it's wanted. My goal would be for it to display how to use the au3irrlicht more completely. The only problem is with it is most of my scripting time is at work. So I would need to find some free time to work on it.

@Percy, WOW why didn't you tell me that before :). That is amazingly fast. Now I have to slow it down for my PC. Maybe I'll add a processor and memory check. Set some limits for how fast to move

Edited by youknowwho4eva

Giggity

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...