Jump to content

Train Demo - obsolete (using T1 version)


A. Percy
 Share

Recommended Posts

I never owned a "Ferrorama", a popular toy in Brazil some years ago (80's)

So I made this:

Posted Image

Download: Train.zip

Edit: glut32 and glaux can be found here.

Edited by A. Percy

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

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

glut32 and glaux can be found here

:)

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

that's FANTASTIC :) !!!!! well done!

Thank you! ;)

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

Very complicated! Well done :) I'd never be able to work that out.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Hi,

not bad man!

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

this is awsome ;) i modifyed it a bit to make you able to turn change camera angle, maybe implant moveable camera??

im not sure if i understod the setcamera function :)

the only problem with the way im doing the camera thing is that if you click it returns to the orignal pos

;#include "GlPluginUtils.au3"
#include "TrainUDF.au3"
#Include <Misc.au3>

;hide icon!!!!!!
AutoItSetOption( "TrayIconHide", 1 )
$Title = "Demo Train - AutoIt OpenGl Plugin"
DefineGlWindow( 800, 600, $Title )
SetClearColor( 0.6, 0.6, 0.9 )

CreateLight( 0, 600, 1000, 600 )
SetLightAmbient( 0, 0.2, 0.2, 0.2 )
SetLightDiffuse( 0, 0.7, 0.7, 0.7 )
SetLightSpecular( 0, 0, 0, 0 )

;... make some objects...
;Setcamera( ?,?,?,anglex,angley,hight)
$anglex = 0
$angley = 50
$hight = 0
$posx = 0
$posy = 50
$posz = 180
;the dffinitions are proberly wrong :P i didnt look it up
SetCamera( $posx, $posy, $posz,$anglex, $angley, $hight)

AddObject( "plain" )
AddGlCylinder( "plain", 0, -0.4, 0, 85, 71, 0.00, 180, 180, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( "plain", 0, -0.42, 0, 95, 61, 0.00, 180, 180, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( "plain", 0, -0.44, 0, 300, 0.00, 0.00, 180, 180, 0.4, 0.7, 0.4, 1.0 )

$Tunel = "tunel"
AddObject( $Tunel )
;AddGlCylinder( Name, X, Y, Z, Radius1, Radius2, Height, Slices, Stacks, Red, Green, Blue, Alpha )
AddGlCylinder( $Tunel, 0,  15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 10, 10, 30, 20, 20, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 20, 30, 20, 20, 0.4, 0.7, 0.4, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
RotateObject( $Tunel, 90, 0, 0 )
TranslateObject( $Tunel, 78.3, 0, 0 )

$trilhos = "Trilhos"
AddObject( $trilhos )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.0, 80.0, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 80.0, 80.4, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.4, 80.4, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

AddGlCylinder( $trilhos, 0, -0.40, 0, 76.6, 76.6, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 76.2, 76.6, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 76.2, 76.2, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

CreateGroup( "Composition" )
_MakeLocomotive( "Train" )
TranslateGroup( "Train", 0, 0, 78.3 )
SetToGroup( "Composition", "Train" )

;~ SetToGroup( "Train", "Trilhos" )
;~ RotateGroup( "Train", 0, -120, 0 )

Opt( "WinTitleMatchMode", 3 )
WinWait( $Title )
WinMove( $Title, "", ( @DesktopWidth / 2 ) - 400, ( @DesktopHeight / 2 ) - 300 )

$CheckWindowTimer = TimerInit( )
$Y_Axis = 0
$timer = TimerInit()
While 1
    if _IsPressed(01) Then
        $Mousepos =MouseGetPos()
        Do
            $Newmousepos = MouseGetPos()
            $angley = ($Newmousepos[1]-$Mousepos[1])/1.5
            $anglex = ($Newmousepos[0]-$Mousepos[0])/1.5
            SetCamera( 0,50,180, $anglex,$angley,$hight)
            SceneDraw()
            Animation()
        Until _IsPressed(01)=0
    ;Elseif _IsPressed(02) Then
    ;   $Mousepos =MouseGetPos()
    ;   Do
    ;       $Newmousepos = MouseGetPos()
    ;       $hight = $Newmousepos[1]-$Mousepos[1]
    ;       SetCamera( 0,50,180, $anglex,$angley,$hight)
    ;       SceneDraw()
    ;       Animation()
    ;   Until _IsPressed(02)=0
    EndIf
    Animation()
Wend

Func Animation()
    if TimerDiff($timer) > 50 then
        SceneDraw( )
        RotateGroup( "Composition", 0, $Y_Axis, 0 )
        RotateTrainWheels( "Train", $Y_Axis * 30 )
        
        $Y_Axis = $Y_Axis + 1
        If $Y_Axis < 1 Then $Y_Axis += 360 
        If $Y_Axis > 360 Then $Y_Axis -= 360
        $timer = TimerInit()
    EndIf
    ;check if window exist... (using a timer to reduce CPU usage by WinExists function)
    If TimerDiff( $CheckWindowTimer ) > 1000 Then
        If WinExists( $Title ) = 0 Then Exit
        $CheckWindowTimer = TimerInit( )
    EndIf
EndFunc

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

this is awsome ;) i modifyed it a bit to make you able to turn change camera angle, maybe implant moveable camera??

im not sure if i understod the setcamera function :)

the only problem with the way im doing the camera thing is that if you click it returns to the orignal pos

;#include "GlPluginUtils.au3"
#include "TrainUDF.au3"
#Include <Misc.au3>

;hide icon!!!!!!
AutoItSetOption( "TrayIconHide", 1 )
$Title = "Demo Train - AutoIt OpenGl Plugin"
DefineGlWindow( 800, 600, $Title )
SetClearColor( 0.6, 0.6, 0.9 )

CreateLight( 0, 600, 1000, 600 )
SetLightAmbient( 0, 0.2, 0.2, 0.2 )
SetLightDiffuse( 0, 0.7, 0.7, 0.7 )
SetLightSpecular( 0, 0, 0, 0 )

;... make some objects...
;Setcamera( ?,?,?,anglex,angley,hight)
$anglex = 0
$angley = 50
$hight = 0
$posx = 0
$posy = 50
$posz = 180
;the dffinitions are proberly wrong :P i didnt look it up
SetCamera( $posx, $posy, $posz,$anglex, $angley, $hight)

AddObject( "plain" )
AddGlCylinder( "plain", 0, -0.4, 0, 85, 71, 0.00, 180, 180, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( "plain", 0, -0.42, 0, 95, 61, 0.00, 180, 180, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( "plain", 0, -0.44, 0, 300, 0.00, 0.00, 180, 180, 0.4, 0.7, 0.4, 1.0 )

$Tunel = "tunel"
AddObject( $Tunel )
;AddGlCylinder( Name, X, Y, Z, Radius1, Radius2, Height, Slices, Stacks, Red, Green, Blue, Alpha )
AddGlCylinder( $Tunel, 0,  15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 10, 10, 30, 20, 20, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 20, 30, 20, 20, 0.4, 0.7, 0.4, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
RotateObject( $Tunel, 90, 0, 0 )
TranslateObject( $Tunel, 78.3, 0, 0 )

$trilhos = "Trilhos"
AddObject( $trilhos )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.0, 80.0, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 80.0, 80.4, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.4, 80.4, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

AddGlCylinder( $trilhos, 0, -0.40, 0, 76.6, 76.6, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 76.2, 76.6, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 76.2, 76.2, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

CreateGroup( "Composition" )
_MakeLocomotive( "Train" )
TranslateGroup( "Train", 0, 0, 78.3 )
SetToGroup( "Composition", "Train" )

;~ SetToGroup( "Train", "Trilhos" )
;~ RotateGroup( "Train", 0, -120, 0 )

Opt( "WinTitleMatchMode", 3 )
WinWait( $Title )
WinMove( $Title, "", ( @DesktopWidth / 2 ) - 400, ( @DesktopHeight / 2 ) - 300 )

$CheckWindowTimer = TimerInit( )
$Y_Axis = 0
$timer = TimerInit()
While 1
    if _IsPressed(01) Then
        $Mousepos =MouseGetPos()
        Do
            $Newmousepos = MouseGetPos()
            $angley = ($Newmousepos[1]-$Mousepos[1])/1.5
            $anglex = ($Newmousepos[0]-$Mousepos[0])/1.5
            SetCamera( 0,50,180, $anglex,$angley,$hight)
            SceneDraw()
            Animation()
        Until _IsPressed(01)=0
    ;Elseif _IsPressed(02) Then
    ;   $Mousepos =MouseGetPos()
    ;   Do
    ;       $Newmousepos = MouseGetPos()
    ;       $hight = $Newmousepos[1]-$Mousepos[1]
    ;       SetCamera( 0,50,180, $anglex,$angley,$hight)
    ;       SceneDraw()
    ;       Animation()
    ;   Until _IsPressed(02)=0
    EndIf
    Animation()
Wend

Func Animation()
    if TimerDiff($timer) > 50 then
        SceneDraw( )
        RotateGroup( "Composition", 0, $Y_Axis, 0 )
        RotateTrainWheels( "Train", $Y_Axis * 30 )
        
        $Y_Axis = $Y_Axis + 1
        If $Y_Axis < 1 Then $Y_Axis += 360 
        If $Y_Axis > 360 Then $Y_Axis -= 360
        $timer = TimerInit()
    EndIf
    ;check if window exist... (using a timer to reduce CPU usage by WinExists function)
    If TimerDiff( $CheckWindowTimer ) > 1000 Then
        If WinExists( $Title ) = 0 Then Exit
        $CheckWindowTimer = TimerInit( )
    EndIf
EndFunc
Good! You took the idea. The SetCamera function works like a eye, with a start position and a target point. ;)

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

Good! You took the idea. The SetCamera function works like a eye, with a start position and a target point. :)

oh, so its like setcamera(viewpointx,viewpointy,viewpointz,viewfromx,viewfromy,viewfromz)??

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

oh, so its like setcamera(viewpointx,viewpointy,viewpointz,viewfromx,viewfromy,viewfromz)??

Yes :)

I've made a help, placed at OpenGl Plugin topic (link in my signature).

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

maybe you could help me a bit :) i cant get the camera to turn around properly, here is a img to describe what i want and how it is atm

the blue dot is the camera,

the green line is where the target moves when i try to make to the camera turn

and the red sircel is where i whould like the target point to move.

the problem is that the camera can only turn almost 180* and at about 60* each way from the middel it start to slow down the turn movement because the target point

moves to far away from the camera, how can i make the target point move in a sircel??

Posted Image

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

Posted Image

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

ok, now the camera can turn around, but not up and down (dont know why the function wont work)

;#include "GlPluginUtils.au3"
#include "TrainUDF.au3"
#Include <Misc.au3>
#include <GUIConstants.au3>

;hide icon!!!!!!
AutoItSetOption( "TrayIconHide", 1 )
$Title = "Demo Train - AutoIt OpenGl Plugin"
DefineGlWindow( 800, 600, $Title )
SetClearColor( 0.6, 0.6, 0.9 )

CreateLight( 0, 600, 1000, 600 )
SetLightAmbient( 0, 0.2, 0.2, 0.2 )
SetLightDiffuse( 0, 0.7, 0.7, 0.7 )
SetLightSpecular( 0, 0, 0, 0 )

;... make some objects...
;Setcamera( ?,?,?,anglex,angley,hight)
$camposx = 50
$camposy = 0
$camposz = 150
$posx = 50
$posy = 0
$posz = 180
$Angle = 45
$angleupdown = 180
;the dffinitions are proberly wrong :P i didnt look it up
SetCamera( $posx, $posy, $posz,$camposx, $camposy, $camposz)
$New_Pos = Turncamera($Angle,$posx,$posy,$posz,$camposx,$camposy,$camposz)
$posx = $New_Pos[0]
$posz = $New_Pos[1]

AddObject( "plain" )
AddGlCylinder( "plain", 0, -0.4, 0, 85, 71, 0.00, 180, 180, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( "plain", 0, -0.42, 0, 95, 61, 0.00, 180, 180, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( "plain", 0, -0.44, 0, 300, 0.00, 0.00, 180, 180, 0.4, 0.7, 0.4, 1.0 )

$Tunel = "tunel"
AddObject( $Tunel )
;AddGlCylinder( Name, X, Y, Z, Radius1, Radius2, Height, Slices, Stacks, Red, Green, Blue, Alpha )
AddGlCylinder( $Tunel, 0,  15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 10, 10, 30, 20, 20, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 20, 30, 20, 20, 0.4, 0.7, 0.4, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
RotateObject( $Tunel, 90, 0, 0 )
TranslateObject( $Tunel, 78.3, 0, 0 )

$trilhos = "Trilhos"
AddObject( $trilhos )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.0, 80.0, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 80.0, 80.4, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.4, 80.4, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

AddGlCylinder( $trilhos, 0, -0.40, 0, 76.6, 76.6, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 76.2, 76.6, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 76.2, 76.2, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

CreateGroup( "Composition" )
_MakeLocomotive( "Train" )
TranslateGroup( "Train", 0, 0, 78.3 )
SetToGroup( "Composition", "Train" )

;~ SetToGroup( "Train", "Trilhos" )
;~ RotateGroup( "Train", 0, -120, 0 )

Opt( "WinTitleMatchMode", 3 )
WinWait( $Title )
WinMove( $Title, "", ( @DesktopWidth / 2 ) - 400, ( @DesktopHeight / 2 ) - 300 )

$CheckWindowTimer = TimerInit( )
$Y_Axis = 0
$timer = TimerInit()
While WinExists( $Title )
    if WinActive($Title) then
        if _IsPressed(41) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posx -=$speed
                 $camposx -=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(41) = 0
        elseif _IsPressed(44) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posx +=$speed
                $camposx +=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(44) = 0
        elseif _IsPressed(57) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posz -=$speed
                $camposz -=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(57) = 0
        elseif _IsPressed(53) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posz +=$speed
                $camposz +=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(53) = 0
        elseif _IsPressed(58) Then
            Do
                $posy +=1
                $camposy +=1
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(58) = 0
        elseif _IsPressed("5a")  And $posy > 0 Then
            Do
                $posy -=1
                $camposy -=1
                if $posy < 0 then ExitLoop
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed("5a") = 0 or $posy = 0
        elseif _IsPressed(25) Then
            Do
                $Angle -= 1
                if $Angle < 1 then $Angle = 360
                $New_pos = Turncamera($Angle,$posx,$posy,$posz, $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(25) = 0
            $posx = $New_pos[0]
            $posz = $New_Pos[1]
        ;ElseIf _IsPressed(26) Then
        ;   Do
        ;       $angleupdown += 1
        ;       Turncameraupdown($angleupdown,$posx,$posy,$posz,$camposx,$camposy,$camposz)
        ;       SceneDraw()
        ;       Animation()
        ;       Sleep(1)
        ;   Until _IsPressed(26) = 0
        elseif _IsPressed(27) Then
            Do
                $Angle += 1
                if $Angle > 360 then $Angle = 1
                $New_pos = Turncamera($Angle,$posx,$posy,$posz, $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(10)
            Until _IsPressed(27) = 0
            $posx = $New_pos[0]
            $posz = $New_Pos[1]
        ;ElseIf _IsPressed(28) Then
        ;   Do
        ;       $angleupdown -= 1
        ;       Turncameraupdown($angleupdown,$posx,$posy,$posz,$camposx,$camposy,$camposz)
        ;       SceneDraw()
        ;       Animation()
        ;       Sleep(1)
        ;   Until _IsPressed(27) = 0
        EndIf
    EndIf
    Animation()
Wend

Func Animation()
    if TimerDiff($timer) > 20 then
        SceneDraw()
        RotateGroup( "Composition", 0, $Y_Axis, 0 )
        RotateTrainWheels( "Train", $Y_Axis * 20 )
        $Y_Axis = $Y_Axis + 1
        If $Y_Axis < 1 Then $Y_Axis += 360 
        If $Y_Axis > 360 Then $Y_Axis -= 360
        $timer = TimerInit()
    EndIf
EndFunc

Func Turncamera($S_Angle,$current_Targetx,$current_Targety,$current_Targetz,$current_posx,$current_posy,$current_posz)
    Local $Array[2]
    $r = 40
    $S_angle = (6.2/360)*$S_angle
    $New_posx = $current_posx + $r * Cos($S_angle)
    $New_Posz = $current_posz + $r * Sin($S_angle)
    SetCamera($New_posx,$current_Targety,$New_Posz,$current_posx,$current_posy,$current_posz)
    $Array[0] = $New_posx
    $Array[1] = $New_Posz
    Return $Array
EndFunc

Func Turncameraupdown($S_Angle,$current_Targetx,$current_Targety,$current_Targetz,$current_posx,$current_posy,$current_posz)
    $r = 40
    $S_angle = (6.2/360)*$S_angle
    $New_posy = $current_posy + $r * Cos($S_angle)
    SetCamera($current_Targetx,$New_Posy,$current_Targetz,$current_posx,$current_posy,$current_posz)
    Return $New_Posy
EndFunc

Problems:

-1: if you try to use the truncameraupdown fucntion it jumps around like crazy

-2: the movement follows the x,y and z axis, its ok until you turn the camera around, then it still follows the axis, so left may become right and in becomes out

needs a better movement system that follows the angle of the camera

anyone have any idea how to fix the 2 problems??

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

ok, now the camera can turn around, but not up and down (dont know why the function wont work)

;#include "GlPluginUtils.au3"
#include "TrainUDF.au3"
#Include <Misc.au3>
#include <GUIConstants.au3>

;hide icon!!!!!!
AutoItSetOption( "TrayIconHide", 1 )
$Title = "Demo Train - AutoIt OpenGl Plugin"
DefineGlWindow( 800, 600, $Title )
SetClearColor( 0.6, 0.6, 0.9 )

CreateLight( 0, 600, 1000, 600 )
SetLightAmbient( 0, 0.2, 0.2, 0.2 )
SetLightDiffuse( 0, 0.7, 0.7, 0.7 )
SetLightSpecular( 0, 0, 0, 0 )

;... make some objects...
;Setcamera( ?,?,?,anglex,angley,hight)
$camposx = 50
$camposy = 0
$camposz = 150
$posx = 50
$posy = 0
$posz = 180
$Angle = 45
$angleupdown = 180
;the dffinitions are proberly wrong :P i didnt look it up
SetCamera( $posx, $posy, $posz,$camposx, $camposy, $camposz)
$New_Pos = Turncamera($Angle,$posx,$posy,$posz,$camposx,$camposy,$camposz)
$posx = $New_Pos[0]
$posz = $New_Pos[1]

AddObject( "plain" )
AddGlCylinder( "plain", 0, -0.4, 0, 85, 71, 0.00, 180, 180, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( "plain", 0, -0.42, 0, 95, 61, 0.00, 180, 180, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( "plain", 0, -0.44, 0, 300, 0.00, 0.00, 180, 180, 0.4, 0.7, 0.4, 1.0 )

$Tunel = "tunel"
AddObject( $Tunel )
;AddGlCylinder( Name, X, Y, Z, Radius1, Radius2, Height, Slices, Stacks, Red, Green, Blue, Alpha )
AddGlCylinder( $Tunel, 0,  15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 10, 10, 30, 20, 20, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 20, 30, 20, 20, 0.4, 0.7, 0.4, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
RotateObject( $Tunel, 90, 0, 0 )
TranslateObject( $Tunel, 78.3, 0, 0 )

$trilhos = "Trilhos"
AddObject( $trilhos )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.0, 80.0, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 80.0, 80.4, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.4, 80.4, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

AddGlCylinder( $trilhos, 0, -0.40, 0, 76.6, 76.6, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 76.2, 76.6, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 76.2, 76.2, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

CreateGroup( "Composition" )
_MakeLocomotive( "Train" )
TranslateGroup( "Train", 0, 0, 78.3 )
SetToGroup( "Composition", "Train" )

;~ SetToGroup( "Train", "Trilhos" )
;~ RotateGroup( "Train", 0, -120, 0 )

Opt( "WinTitleMatchMode", 3 )
WinWait( $Title )
WinMove( $Title, "", ( @DesktopWidth / 2 ) - 400, ( @DesktopHeight / 2 ) - 300 )

$CheckWindowTimer = TimerInit( )
$Y_Axis = 0
$timer = TimerInit()
While WinExists( $Title )
    if WinActive($Title) then
        if _IsPressed(41) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posx -=$speed
                 $camposx -=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(41) = 0
        elseif _IsPressed(44) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posx +=$speed
                $camposx +=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(44) = 0
        elseif _IsPressed(57) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posz -=$speed
                $camposz -=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(57) = 0
        elseif _IsPressed(53) Then
            $speedtimer = TimerInit()
            $speed = 0.5
            Do
                if TimerDiff($speedtimer) > 500 and $speed < 10 Then
                    $speed +=0.1
                    $speedtimer = TimerInit()
                EndIf
                $posz +=$speed
                $camposz +=$speed
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(53) = 0
        elseif _IsPressed(58) Then
            Do
                $posy +=1
                $camposy +=1
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(58) = 0
        elseif _IsPressed("5a")  And $posy > 0 Then
            Do
                $posy -=1
                $camposy -=1
                if $posy < 0 then ExitLoop
                SetCamera( $posx,$posy,$posz,  $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed("5a") = 0 or $posy = 0
        elseif _IsPressed(25) Then
            Do
                $Angle -= 1
                if $Angle < 1 then $Angle = 360
                $New_pos = Turncamera($Angle,$posx,$posy,$posz, $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(1)
            Until _IsPressed(25) = 0
            $posx = $New_pos[0]
            $posz = $New_Pos[1]
        ;ElseIf _IsPressed(26) Then
        ;   Do
        ;       $angleupdown += 1
        ;       Turncameraupdown($angleupdown,$posx,$posy,$posz,$camposx,$camposy,$camposz)
        ;       SceneDraw()
        ;       Animation()
        ;       Sleep(1)
        ;   Until _IsPressed(26) = 0
        elseif _IsPressed(27) Then
            Do
                $Angle += 1
                if $Angle > 360 then $Angle = 1
                $New_pos = Turncamera($Angle,$posx,$posy,$posz, $camposx,$camposy,$camposz)
                SceneDraw()
                Animation()
                Sleep(10)
            Until _IsPressed(27) = 0
            $posx = $New_pos[0]
            $posz = $New_Pos[1]
        ;ElseIf _IsPressed(28) Then
        ;   Do
        ;       $angleupdown -= 1
        ;       Turncameraupdown($angleupdown,$posx,$posy,$posz,$camposx,$camposy,$camposz)
        ;       SceneDraw()
        ;       Animation()
        ;       Sleep(1)
        ;   Until _IsPressed(27) = 0
        EndIf
    EndIf
    Animation()
Wend

Func Animation()
    if TimerDiff($timer) > 20 then
        SceneDraw()
        RotateGroup( "Composition", 0, $Y_Axis, 0 )
        RotateTrainWheels( "Train", $Y_Axis * 20 )
        $Y_Axis = $Y_Axis + 1
        If $Y_Axis < 1 Then $Y_Axis += 360 
        If $Y_Axis > 360 Then $Y_Axis -= 360
        $timer = TimerInit()
    EndIf
EndFunc

Func Turncamera($S_Angle,$current_Targetx,$current_Targety,$current_Targetz,$current_posx,$current_posy,$current_posz)
    Local $Array[2]
    $r = 40
    $S_angle = (6.2/360)*$S_angle
    $New_posx = $current_posx + $r * Cos($S_angle)
    $New_Posz = $current_posz + $r * Sin($S_angle)
    SetCamera($New_posx,$current_Targety,$New_Posz,$current_posx,$current_posy,$current_posz)
    $Array[0] = $New_posx
    $Array[1] = $New_Posz
    Return $Array
EndFunc

Func Turncameraupdown($S_Angle,$current_Targetx,$current_Targety,$current_Targetz,$current_posx,$current_posy,$current_posz)
    $r = 40
    $S_angle = (6.2/360)*$S_angle
    $New_posy = $current_posy + $r * Cos($S_angle)
    SetCamera($current_Targetx,$New_Posy,$current_Targetz,$current_posx,$current_posy,$current_posz)
    Return $New_Posy
EndFunc

Problems:

-1: if you try to use the truncameraupdown fucntion it jumps around like crazy

-2: the movement follows the x,y and z axis, its ok until you turn the camera around, then it still follows the axis, so left may become right and in becomes out

needs a better movement system that follows the angle of the camera

anyone have any idea how to fix the 2 problems??

Here is an example of the camera moving in a semicircle over the train, needs the train UDF.

;#include "GlPluginUtils.au3"
#include "TrainUDF.au3"

;hide icon!!!!!!
AutoItSetOption( "TrayIconHide", 1 )
$Title = "Demo Train - AutoIt OpenGl Plugin"
DefineGlWindow( 800, 600, $Title )
SetClearColor( 0.6, 0.6, 0.9 )

CreateLight( 0, 600, 1000, 600 )
SetLightAmbient( 0, 0.2, 0.2, 0.2 )
SetLightDiffuse( 0, 0.7, 0.7, 0.7 )
SetLightSpecular( 0, 0, 0, 0 )

;... make some objects...

SetCamera( 00, 10, 200, 0, 0, 0 )

AddObject( "plain" )
AddGlCylinder( "plain", 0, -0.4, 0, 85, 71, 0.00, 180, 180, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( "plain", 0, -0.42, 0, 95, 61, 0.00, 180, 180, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( "plain", 0, -0.44, 0, 300, 0.00, 0.00, 180, 180, 0.4, 0.7, 0.4, 1.0 )

$Tunel = "tunel"
AddObject( $Tunel )
;AddGlCylinder( Name, X, Y, Z, Radius1, Radius2, Height, Slices, Stacks, Red, Green, Blue, Alpha )
AddGlCylinder( $Tunel, 0,  15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 10, 10, 30, 20, 20, 0.5, 0.5, 0.5, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 20, 30, 20, 20, 0.4, 0.7, 0.4, 1.0 )
AddGlCylinder( $Tunel, 0, -15, 0, 20, 10, 0, 20, 20, 0.6, 0.5, 0.3, 1.0 )
RotateObject( $Tunel, 90, 0, 0 )
TranslateObject( $Tunel, 78.3, 0, 0 )

$trilhos = "Trilhos"
AddObject( $trilhos )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.0, 80.0, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 80.0, 80.4, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 80.4, 80.4, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

AddGlCylinder( $trilhos, 0, -0.40, 0, 76.6, 76.6, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0,  0.00, 0, 76.2, 76.6, 0.00, 180, 4, 0.7, 0.7, 0.7, 1.0 )
AddGlCylinder( $trilhos, 0, -0.40, 0, 76.2, 76.2, 0.40, 180, 4, 0.7, 0.7, 0.7, 1.0 )

CreateGroup( "Composition" )
_MakeLocomotive( "Train" )
TranslateGroup( "Train", 0, 0, 78.3 )
SetToGroup( "Composition", "Train" )

;~ SetToGroup( "Train", "Trilhos" )
;~ RotateGroup( "Train", 0, -120, 0 )

Opt( "WinTitleMatchMode", 3 )
WinWait( $Title )
WinMove( $Title, "", ( @DesktopWidth / 2 ) - 400, ( @DesktopHeight / 2 ) - 300 )

$CheckWindowTimer = TimerInit( )
$Y_Axis = 0
$dx = 0
$dy = 0
While 1
    SceneDraw( )
    sleep( 50 )
    
    RotateGroup( "Composition", 0, $Y_Axis, 0 )
    RotateTrainWheels( "Train", $Y_Axis * 30 )
    
    $Y_Axis = $Y_Axis + 1
    If $Y_Axis < 1 Then $Y_Axis += 360 
    If $Y_Axis > 360 Then $Y_Axis -= 360
    
;check if window exist... (using a timer to reduce CPU usage by WinExists function)
    If TimerDiff( $CheckWindowTimer ) > 100 Then
        $dx += 1/360
        $dy +=1
        SetCamera( 0, 200*Sin($dx), 200*Cos($dx), 0,0,0 )
        If WinExists( $Title ) = 0 Then ExitLoop
        $CheckWindowTimer = TimerInit( )
    EndIf
Wend
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...