Jump to content

Au3IrrLicht


A. Percy
 Share

Recommended Posts

  • Replies 231
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I've been thinking a bit over the array limitation, wouldn't it be quite a clean work around to have the function return a pointer to a struct that holds the elements?

The problem is that plugin support architecture, that forbids return pointers. An option could be make a "normal" dll, calling each function through DllCall...

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

  • 3 weeks later...

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

  • 2 weeks later...

The VW bug in your sig turns far too smoothly for a back-heavy vehicle. New bugs corner like that, old bugs weight is distributed toward the back, so the front will spin out. :( I only say that because I drive a new bug from time to time. Fast, fun car, way too small for my liking, tho.

Excellent update, as usual. The render to texture stuff is great, lots of neat effects are possible with that :P

I have an idea as to the arrays problem... Valiks comments on iterators made some measure of sense to me, so I've been playing with the plugin stuff to try to prototype an array bridge.

I see two workarounds:

1.) You can encode an array in a string and pass the string, then decode it on the AutoIt side. Probably not a great method, but would be possible to implement.

2.) An ArrayTransfer function, which takes the name of an array on the plugin side and creates the equivalent array in AutoIt. You'd need a simple plugin function to get the size of $PluginArray, then to iterate through all locations of the plugin array, then write them to a new array.

Func ArrayTransfer($PluginArray)
For $i = 0 to $SizeOfPluginArray-1 Step 1
  $Au3Array[$i] = GetPluginArrayData($PluginArray, $i)
Next
Return $Au3Array
EndFunc

Something like that. We'd have to work out something for multidimensional arrays. I use For...Next because it's fastest for simple iteration.

There's something I was wondering... do you need the data in the arrays on the AutoIt side? Manipulating large arrays of information in AutoIt would be a lot slower than doing it with a plugin. Passing array handles between plugin functions by name would seem to be the better solution, and you could implement that by creating a generic array of pointers, then passing the location within the pointer array to AutoIt. From there, you could pass things transparently.

Unless, of course, the pointers change between function calls, in which case I would be thoroughly flabbergasted.

Edited by jrowe
Link to comment
Share on other sites

Nevermind, that was just silly. I'm trying to work out a subterranean terrain system by flipping a normal terrain node upside down. So far, so good, I'm just having trouble aligning the tiles. SetRotation rotates along the edge. A good parameter to add would be a point to rotate a node at, both SetRotationByAxis and SetRotation.

Cool stuff.

I want to get a simple caverunner demo going. We will see, tho :P

Link to comment
Share on other sites

Fog and stuff, yay. I've already got a few convenience functions to throw on the heap, like having lights automatically follow a designated node, instead of having to specify and link with a particular node in the IrrRun loop.

Link to comment
Share on other sites

So I've gotten a simple setup here, with ground and ceiling layers, and a basic FPS monitor. My issue is that when I'm moving forward, or jumping and moving forward, my FPS increases from 40-50 to 140-300. Common sense would tell me that when I'm moving the scene should get more complex and my FPS should drop. Perhaps the terrain collision detection is a big bottleneck?

When moving downhill, FPS goes up, and when moving uphill, FPS goes down. In fact, if I switch to the maya camera, I get a huge boost in fps.

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.4.9

Author: A. Percy

Mod-Author: J.Rowe

Script Function:

Template AutoIt IrllLicht script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include "IrrlichtPluginUtils.au3"

AutoItSetOption( "TrayIconHide", 1 )

Opt( "WinTitleMatchMode", 3 )

;creating the device

CreateDevice( $EDT_OPENGL, 640, 480, 16, 0, 0, 0 )

;setting window caption

SetWindowCaption( "Terrain" )

;Add Light

;$Light = AddLightSceneNode( 0, 500, 500, 0, 1, 1, 1, 100000 )

;Add Camera

$Camera = AddCameraSceneNodeFPS( 0, 100, 200, 0, 0.8 )

SetPosition( $Camera, 700, 550, 100 ) ;setting position

SetTarget( $Camera, 1000, 25, 0 ) ;setting target

SetFarValue( $Camera, 4000 )

; Add Text Monitor Stuff

$Static = AddStaticText( "test", 10, 10, 130, 40, 1 )

;Add Terrain Ground

$HeightMap = CreateImageFromFile( @ScriptDir & "\data\terrain-heightmap.bmp" )

$TextureMap = CreateImageFromFile( @ScriptDir & "\data\terrain-texture.jpg" )

$MapMesh = AddTerrainMesh( "Height1", $TextureMap, $HeightMap, 15.0, 15.0, 350, 64, 64 )

$Node = AddOctTreeSceneNode( $MapMesh )

SetPosition( $Node, 0, 0, 0 )

;Add Terrain Ceiling

$HeightMap2 = CreateImageFromFile( @ScriptDir & "\data\terrain-heightmap.bmp" )

$TextureMap2 = CreateImageFromFile( @ScriptDir & "\data\terrain-texture.jpg" )

$MapMesh2 = AddTerrainMesh( "Height2", $TextureMap2, $HeightMap2, 15.0, 15.0, 350, 64, 64 )

$Node2 = AddOctTreeSceneNode( $MapMesh2 )

SetRotation( $Node2, 180, -180, 0 )

SetPosition( $Node2, 3840, 1000, 0 )

SetMaterialFlag( $Node, $EMF_FOG_ENABLE, 1 )

SetMaterialFlag( $Node2, $EMF_FOG_ENABLE, 1 )

;Playing with automatic collision detection

$MapSelector = CreateOctTreeTriangleSelector( $MapMesh, $Node )

SetTriangleSelector( $Node, $MapSelector )

$MapCameraAnimator = CreateCollisionResponseAnimator( $MapSelector, $Camera, 20, 50, 20, 0, -1, 0, 0, -24, 0 ) ;character can collide it

AddAnimator( $Camera, $MapCameraAnimator )

DropAnimator( $MapCameraAnimator )

$Red = 120

$Green = 120

$Blue = 120

$Start = 400

$End = 4000

SetFog( $Red , $Green , $Blue , 1, $Start, $End )

$FrameRate = 0

$Frames = 0

$myLight = AddLightSceneNode($Camera, 10, 0, 0, 1, 1, 1, 100)

$begin = TimerInit()

While IrrRun( )

$Frames += 1

;BeginScene( bool backBuffer, bool zBuffer, int Alpha, int Red, int Green, int Blue )

BeginScene( true, true, 255, 255, 255, 255 )

SceneDraw( )

GuiDraw( )

EndScene( )

$dif = TimerDiff($begin)

If $dif > 1000 Then

SetText($Static, $Frames & @CRLF & "Blah" )

$begin = TimerInit()

$Frames = 0

EndIf

Wend

Link to comment
Share on other sites

Note to all: Create a character object and have the camera follow that. Do not try to get the character object to follow the camera. Chaos will ensue.

Link to comment
Share on other sites

Here's a demo. Uses the TRIPLANE.3ds (have it in the same folder as the script.)

Lots of random crap, but it shows a few things, like terrain, customizing a camera, timer based motion calculation, and yaw. I'm working on pitch and roll, but I thought I'd throw this out there. Soon as I have the plane thing figured out, I'll throw the paging terrain thing out there. :P

This creates an Attractor node, then forces the plane/ship node to follow the attractor node wherever it goes. It only does left/right and forward/back. I'm working on the up/down stuff, lol. It involves getting horizontal and vertical angles relative to the world, and is basically confusing the hell out of me.

CODE
;Initialize Engine

#include <Misc.au3>

#include "IrrlichtPluginUtils.au3"

#include <Math.au3>

AutoItSetOption( "TrayIconHide", 1 )

Opt( "WinTitleMatchMode", 3 )

CreateDevice( $EDT_OPENGL, 800, 600, 32, 0, 0, 0 )

SetWindowCaption( "Flying Around" )

;Create minimal HUD

$Data = AddStaticText( "DATA", 10, 10, 130, 80, 1 )

;Create terrain

$HeightMap = CreateImageFromFile( @ScriptDir & "\data\terrain-heightmap.bmp" )

$TextureMap = CreateImageFromFile( @ScriptDir & "\data\terrain-texture.jpg" )

$MapMesh = AddTerrainMesh( "Height1", $TextureMap, $HeightMap, 15.0, 15.0, 50, 64, 64 )

$Node = AddOctTreeSceneNode( $MapMesh )

SetPosition( $Node, 0, 0, 0 )

;Create Movable Ship positional increment/decrement

$ShipMesh = GetMesh( "TRIPLANE.3ds" )

$ShipNode = AddOctTreeSceneNode( $ShipMesh )

SetPosition( $ShipNode, 1920, 150, 1920 ) ;center of terrain

;Create Camera

$MyCamera = AddCameraSceneNode( $ShipNode, 250, 150, 0, GetPosition( $ShipNode, "X" ), GetPosition( $ShipNode, "Y" ), GetPosition( $ShipNode, "Z" ) )

;Let There Be Light

$Light = AddLightSceneNode( 1920, 500, 1920, 0, .7, 1, 1, 100000)

;Motivator Cube, heh

$AttractorNode = AddCubeSceneNode( 20 , $ShipNode )

SetPosition( $AttractorNode, 0, 150, 0)

;Set Errata

$Frames = 0

$begin = TimerInit()

$a = 1

$ShipTimer = TimerInit()

$XAcceleration = 0

$ZAcceleration = 0

$Yaw = 0

;Run

While IrrRun( )

$Frames += 1

;BeginScene( bool backBuffer, bool zBuffer, int Alpha, int Red, int Green, int Blue )

BeginScene( true, true, 255, 255, 255, 255 )

MoveShip()

SceneDraw( )

GuiDraw( )

EndScene( )

$BlahX = GetAbsolutePosition($MyCamera, "X")

$BlahY = GetAbsolutePosition($MyCamera, "Y")

$BlahZ = GetAbsolutePosition($MyCamera, "Z")

$dif = TimerDiff($begin)

If $dif > 500 Then

SetText($Data, "FPS:" & 2*$Frames & @CRLF & "Left/Right" & GetPosition($AttractorNode, "X") & @CRLF & "Up/Down:" & GetPosition($AttractorNode, "Y") & @CRLF & "Forward/Back:" & GetPosition($AttractorNode, "Z") & @CRLF & GetRotation($ShipNode, "Y" ))

$begin = TimerInit()

$Frames = 0

EndIf

$ShipTimerDif = TimerDiff($ShipTimer)

If $ShipTimerDif > 40 Then

If $XAcceleration > 0 and Not _IsPressed(28) Then ;Up

$XAcceleration -= 1

EndIf

If $XAcceleration < 0 and Not _IsPressed(26) Then ;Down

$XAcceleration += 1

EndIf

If $ZAcceleration > 0 and Not _IsPressed(25) Then ; Left

$ZAcceleration -= 1

EndIf

If $ZAcceleration < 0 and Not _IsPressed(27) Then ; Right

$ZAcceleration += 1

EndIf

$ShipTimer = TimerInit()

EndIf

If _IsPressed(57) Or _IsPressed(28) Then ;Up

$ZAcceleration += 2

If $ZAcceleration > 20 Then $ZAcceleration = 20

EndIf

If _IsPressed(41) Or _IsPressed(25) Then ;Right

SetRotationByAxis($ShipNode, "Y", GetRotation($ShipNode, "Y")-4)

$XAcceleration -= 2

If $XAcceleration > 10 Then $XAcceleration = 10

EndIf

If _IsPressed(53) Or _IsPressed(26) Then ;Down

$ZAcceleration -= 2

If $ZAcceleration < -20 Then $ZAcceleration = -20

EndIf

If _IsPressed(44) Or _IsPressed(27) Then ; Left

SetRotationByAxis($ShipNode, "Y", GetRotation($ShipNode, "Y")+4)

$XAcceleration += 2

If $XAcceleration < -10 Then $XAcceleration = -10

EndIf

Sleep(15)

Wend

Func MoveShip()

Local $Yaw

;Sets Ship rotation to Absolute position of Attractor, then sets position to absolute position of Attractor

$AttractorX = GetPosition($AttractorNode, "X")

$AttractorY = GetPosition($AttractorNode, "Y")

$AttractorZ = GetPosition($AttractorNode, "Z")

SetPosition($AttractorNode, $ZAcceleration, 0, $XAcceleration)

SetPosition($ShipNode, GetAbsolutePosition($AttractorNode, "X"), 100, GetAbsolutePosition($AttractorNode, "Z"))

SetTarget($MyCamera, GetAbsolutePosition($AttractorNode, "X"),GetAbsolutePosition($AttractorNode, "Y"), GetAbsolutePosition($AttractorNode, "Z"))

$Yaw = _Degree(ATan((0 - $AttractorX) / (0 - $AttractorZ)))

SetRotationByAxis($AttractorNode, "Y", $Yaw )

EndFunc

Edited by jrowe
Link to comment
Share on other sites

Also, any idea how I'd add two terrain nodes? :P

Not tested, but try adding another node...

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

Nevermind, that was just silly. I'm trying to work out a subterranean terrain system by flipping a normal terrain node upside down. So far, so good, I'm just having trouble aligning the tiles. SetRotation rotates along the edge. A good parameter to add would be a point to rotate a node at, both SetRotationByAxis and SetRotation.

Cool stuff.

I want to get a simple caverunner demo going. We will see, tho :P

Interesting!

I forgot (again) to send that "code" to you. Yesterday I slept in front of TV. I need write it on my pen drive before bed.

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

@jrowe: I noticed an improvement in the direction of my VW Bug when installed radial tires, but nothing that comes close to the turning of the gif. Maybe if I pull the hand brake :P

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, very cool :mellow:

This is one project I will follow like a fox (or something) :(

Your script totally traps your mouse in the GUI. I had to navigate in taskmanager with the keyboard to shut it down, so even if it's just an alpha version it's very annoying .

Ps. Is this openGL or D3D?

The engine supports GL & D3D. It runs off Irrlicht. It's basically an wrapper for AutoIT. To exit out of the mouse problem ALT-F4 it, Cuase I couldn't taskmanage it as my mouse was locked.

Btw. Darth Vader is not supposed to appear white. I think something is wrong with your graphics card, or maybe even quite possibly - your monitor. There are different graphic modes to pick, So I suggest you pick up a copy of the Irrlicht3D Manual and look through that.

Link to comment
Share on other sites

The engine supports GL & D3D. It runs off Irrlicht. It's basically an wrapper for AutoIT. To exit out of the mouse problem ALT-F4 it, Cuase I couldn't taskmanage it as my mouse was locked.

Btw. Darth Vader is not supposed to appear white. I think something is wrong with your graphics card, or maybe even quite possibly - your monitor. There are different graphic modes to pick, So I suggest you pick up a copy of the Irrlicht3D Manual and look through that.

Heh, I made that post over 5 months ago, I know all this by now :mellow:

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

The engine supports GL & D3D. It runs off Irrlicht. It's basically an wrapper for AutoIT. To exit out of the mouse problem ALT-F4 it, Cuase I couldn't taskmanage it as my mouse was locked.

Btw. Darth Vader is not supposed to appear white. I think something is wrong with your graphics card, or maybe even quite possibly - your monitor. There are different graphic modes to pick, So I suggest you pick up a copy of the Irrlicht3D Manual and look through that.

to the developer of this project:

device.CursorControl.Visible = false;

needs to be included in the DLL.

Link to comment
Share on other sites

You can set the cursor to be invisible using AutoIt:

Place this in your code, it will cause the cursor to disappear.

GUISetCursor(16)

Also, use the following to escape from the program using the Esc key.

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit 0
EndFunc
Edited by jrowe
Link to comment
Share on other sites

Here's a spaceship demo.

You'll need these files, plus the Au3Irrlicht files from this thread.

CODE
#include <WinAPI.au3>

#include <Misc.au3>

#include "IrrlichtPluginUtils.au3"

#include <Math.au3>

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

AutoItSetOption( "TrayIconHide", 1 )

CreateDevice( $EDT_OPENGL, 1024, 768, 32, 1, 0, 0 )

SetWindowCaption( "Testing Ship" )

$HeightMap = CreateImageFromFile( @ScriptDir & "\data\terrain-heightmap.bmp" )

$TextureMap1 = CreateImageFromFile("testtex.jpg" )

$MapMesh1 = AddTerrainMesh( "Height1", $TextureMap1, $HeightMap, 100.0, 100.0, 5000, 64, 64 )

$MapNode = AddOctTreeSceneNode($MapMesh1)

SetPosition( $MapNode, 0, 0, 0)

AddSkyBoxSceneNode( GetTexture( "data\skybox\irrlicht2_up.jpg" ), GetTexture( "data\skybox\irrlicht2_dn.jpg" ), GetTexture( "data\skybox\irrlicht2_lf.jpg" ), GetTexture( "data\skybox\irrlicht2_rt.jpg" ), GetTexture( "data\skybox\irrlicht2_ft.jpg" ), GetTexture( "data\skybox\irrlicht2_bk.jpg" ) )

;Minimal HUD

$Data = AddStaticText( "DATA", 10, 10, 130, 80, 1 )

;Let There Be Light!

$Light = AddLightSceneNode( 0, 2000, 2000, 0, 1, 1, 1, 10000 )

;The ship to fly around in, and its texture (attributed to Apocalyx engine demos)

$ShipMesh = GetMesh( "astro5a.3ds" )

ScaleMesh( $ShipMesh, 10, 10, 10 )

$ShipNode = AddOctTreeSceneNode( $ShipMesh )

$ShipTexture = GetTexture( @ScriptDir & "\astro5.jpg" )

SetMaterialTexture( $ShipNode, 0, $ShipTexture)

SetMaterialFlag( $ShipNode, $EMF_LIGHTING, 0 )

SetRotationByAxis($ShipNode, "Y", 180)

$MyCamera = AddCameraSceneNode( $ShipNode, 180, 50, 0, GetPosition( $ShipNode, "X" ), GetPosition( $ShipNode, "Y" ), GetPosition( $ShipNode, "Z" ) )

SetFarValue( $MyCamera, 40000)

$AttractorNodeX = AddCubeSceneNode(1, $ShipNode)

$AttractorNodeY = AddCubeSceneNode(1, $ShipNode)

;Random variable initialization

SetPosition( $ShipNode, 12800, 5000, 12800 )

$dll = DllOpen("user32.dll")

$ShipYAngle = GetRotation($ShipNode, "Y")

$Rotation = 0

$Pitch = 0

$AccelerationX = 0

$AccelMagnitude = 1

$Initializing = 1

$AngleOfRotation = 0

$Timer = TimerInit()

$MapSelector = CreateOctTreeTriangleSelector( $MapMesh1, $MapNode )

SetTriangleSelector( $MapNode, $MapSelector )

$MapCameraAnimator = CreateCollisionResponseAnimator( $MapSelector, $ShipNode, 20, 50, 20, 0, 0, 0, 0, -24, 0 ) ;character can collide it

AddAnimator( $ShipNode, $MapCameraAnimator )

;DropAnimator( $MapCameraAnimator )

;SetGravity( $MapCameraAnimator, 0, -.0001, 0 )

$Gravity = 1

While IrrRun( )

$a = TimerDiff($Timer)

If $Initializing = 1 And $a > 1000 Then $Initializing = 0

If $Initializing = 0 Then GetInput()

$ShipYAngle = GetRotation($ShipNode, "Y")

BeginScene( true, true, 255, 0, 0, 0 )

SceneDraw( )

GuiDraw( )

EndScene( )

sleep( 10 )

Wend

Func Terminate()

Exit 0

EndFunc

Func GetInput()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Rotation of the ship updated and managed here.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If _IsPressed("41", $dll) Then

$Rotation -= .2

EndIf

If _IsPressed("44", $dll) Then

$Rotation += .2

EndIf

If Not _IsPressed("41", $dll) And $Rotation < 0 Then

$Rotation += .1

EndIf

If Not _IsPressed("44", $dll) And $Rotation > 0 Then

$Rotation -= .1

EndIf

If $Rotation > 0 And $Rotation < .1 Then $Rotation = 0

If $Rotation < 0 And $Rotation > -.1 Then $Rotation = 0

If $Rotation > 4 Then $Rotation = 4

If $Rotation < -4 Then $Rotation = -4

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Acceleration of the Ship updated and managed here

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If _IsPressed("53", $dll) Then

$AccelerationX += .5

EndIf

If _IsPressed("57", $dll) Then

$AccelerationX -= .5

EndIf

If Not _IsPressed("53", $dll) And $AccelerationX < 0 Then

$AccelerationX += .1

EndIf

If Not _IsPressed("57", $dll) And $AccelerationX > 0 Then

$AccelerationX -= .1

EndIf

If $AccelerationX > 0 And $AccelerationX < .2 Then $AccelerationX = 0

If $AccelerationX < 0 And $AccelerationX > -.2 Then $AccelerationX = 0

If $AccelerationX > 50 Then $AccelerationX = 50

If $AccelerationX < -20 Then $AccelerationX = -20

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Pitch of the Ship updated and managed here

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$iX = _WinAPI_GetMousePosX()

$iY = _WinAPI_GetMousePosY()

$Value = 4*(($iY-368)/768)

If $Value < -.85 Then

$Pitch += 1

EndIf

If $Value > .85 Then

$Pitch -= 1

EndIf

If $Pitch < 0 Then $Pitch += .5

If $Pitch > 0 Then $Pitch -= .5

If $Pitch > 0 And $Pitch < .1 Then $Pitch = 0

If $Pitch < 0 And $Pitch > -.1 Then $Pitch = 0

If $Pitch > 15 Then $Pitch = 15

If $Pitch < -15 Then $Pitch = -15

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Set and manage the Ship node and Camera Node position and rotation

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If $AccelerationX > 0 Then $AccelMagnitude = -1

If $AccelerationX < 0 Then $AccelMagnitude = 1

$AngleOfRotation = Mod($ShipYAngle, 360)

$PitchModifier = Abs(Abs($AngleOfRotation)-180)/360

$ZAngle = 2*$Pitch

SetRotation($ShipNode, $Rotation*15*$AccelMagnitude, 180, $ZAngle-4*$PitchModifier)

$AccelerationY = GetAbsolutePosition($AttractorNodeY, "Y")

SetPosition($ShipNode, GetAbsolutePosition($AttractorNodeX, "X"), $AccelerationY-$Gravity, GetAbsolutePosition($AttractorNodeX, "Z"))

SetRotation($ShipNode, $Rotation*15*$AccelMagnitude, $ShipYAngle + $Rotation, 0)

SetTarget($MyCamera, GetAbsolutePosition($ShipNode, "X"), GetAbsolutePosition($ShipNode, "Y"), GetAbsolutePosition($ShipNode, "Z"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Set and manage Position of the Attractor node X and Y

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$AttractorX = $AccelerationX

$AttractorY = 0

$AttractorZ = 0

SetPosition($AttractorNodeX, $AttractorX, $AttractorY, $AttractorZ)

SetPosition($AttractorNodeY, 0, $Pitch, 0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Update HUD

$AngleOfRotation = Mod($ShipYAngle, 360)

$X = GetAbsolutePosition($ShipNode, "X")

$Y = GetAbsolutePosition($ShipNode, "Y")

$Z = GetAbsolutePosition($ShipNode, "Z")

SetText($Data, Abs($AngleOfRotation) & @CRLF & GetAbsolutePosition($AttractorNodeY, "Y") & @CRLF & Abs(Mod(GetRotation($ShipNode, "Z"), 360)) & @CRLF & $Rotation & @CRLF & $AccelerationX*-1 & @CRLF & "X: " & $X & @CRLF & "Y: " & $Y & @CRLF & "Z: " & $Z & @CRLF & "Pitch: " & $Pitch)

EndFunc

All that's left is fixing the pitch display, adding some camera smoothing, and then I'll add some guns. :mellow:

Edit: added custom gravity effect, terrain collision. Pitch effect still a pain in the butt... almost got it though.

Edited by jrowe
Link to comment
Share on other sites

i see that this is totaly diffrent then Au3GlPlugin, and even more confusing :mellow:

i dont understand two things and i hope that you jrowe or someone else can help me understand

AddCameraSceneNodeFPS when i look at "It's Darth Vader!" scipt, my mouse is trapted on the milde of the game screen and he is rotating camera, on your exsample i see that your using AddCameraSceneNode and you have free mouse.

do you lose SceneNodeFromCameraBB when you use AddCameraSceneNode to free your mouse so that camera isnt moveing or is there other way to detect your mouse over object instead of camera midle over object?

AddCameraSceneNode is basicly folowing obects from prefered distance, but not rotating with object angle, so do we need to use canculation of obect angle with distane of camera, to set new position of camera to new object angle on the map, or there is some other command that will track object and move camera to the object angle with prefered distance?

edit: tupo (i hate this kboard)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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