Hey Leute,
Ich hab vor eiin paar Tagen begonnen mich mit der AU3Irrlicht2 udf zu beschäftigen und jetzt will ich mich mal versuchen ein Spiel zu ersellen.
Das klappt eigentlich auch aber hier kommtm mein Problem:
Also Ich habe eine map und ein charakter,
jetzt will ich das die kamera immer auf den char zeigt, also Rollenspielansicht.
Das der CHarakter immer dort ist wo auch die kammera ist hab ich bereits, aber leider steht er immer in einem abstand zur kamera und dreht sich nicht mit.
Ich benutze noch die FPSCamera da ich mit der normalen (_IrrAdCamera) noch nicht so ganz zurrecht komme.
Aber wenn jemand es gleich mit einer _IrrAdCamera() machen könnte währe ich noch glücklicher
So genug geredet, hier ist mein script :
€hab das mit der sicht hinbekommen und das auf mausbewegungen gedreht wird hier ist mein neues script:
Spoiler anzeigen
#include <au3Irrlicht2.au3>
#include <misc.au3>
#include <math.au3>
Opt("MustDeclareVars", True)
HotKeySet("{ESC}", "_exit")
Func _exit()
_IrrStop()
Exit
EndFunc ;==>_exit
Dim $Camera
Dim $NodeGround
Dim $NodeBox
Dim $aPosition[3] = [0, 100, 0]
Dim $iDegree = 0
Dim $iDistance = 300
Dim $m_pos
Dim $m_desk_w
Dim $m_desk_h
Dim $font
Global $size[2]
Global $a, $b
Func _b()
$b = MouseGetPos()
Sleep(1)
EndFunc ;==>_b
$m_desk_h = @DesktopHeight
$m_desk_w = @DesktopWidth
$size[0] = $m_desk_w
$size[1] = $m_desk_h
_IrrStart($IRR_EDT_OPENGL, $size[0], $size[1], 32, $IRR_WINDOWED, _
$IRR_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON)
_IrrSetWindowCaption("Example 49: Collision in a Loaded Scene")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_IrrChangeWorkingDirectory("media")
_IrrLoadScene("CollisionScene.irr")
$font = _IrrGetFont("media/bitmapfont.bmp")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$Camera = _IrrAddCamera($aPosition[0] - 300, $aPosition[1] + 100, $aPosition[2], 0, 0, 0)
[/autoit] [autoit][/autoit] [autoit]$NodeGround = _IrrGetSceneNodeFromName("Ground")
$NodeBox = _IrrGetSceneNodeFromName("Pillar")
_IrrSetNodePosition($NodeBox, $aPosition[0], $aPosition[1], $aPosition[2])
_IrrHideMouse()
MouseMove(0, 0)
While _IrrRunning()
$a = MouseGetPos()
_IrrBeginScene(200, 200, 255)
;_Irr2DFontDraw($font, $m_pos[0] & $m_pos[1], 4, 4, 250, 24)
[/autoit] [autoit][/autoit] [autoit]_b()
If $a[0] <> $b[0] Then
If $a[0] > $b[0] Then
$iDegree -= 1
_IrrSetNodeRotation($NodeBox, 0, $iDegree, 0)
ElseIf $a[0] < $b[0] Then
$iDegree += 1
_IrrSetNodeRotation($NodeBox, 0, $iDegree, 0)
EndIf
EndIf
_IrrSetNodeRotation($NodeBox, 0, $iDegree, 0)
If _IsPressed(26) Then
$aPosition[0] += Cos(_Radian($iDegree)) * 2
$aPosition[2] -= Sin(_Radian($iDegree)) * 2
_IrrSetNodePosition($NodeBox, $aPosition[0], $aPosition[1], $aPosition[2])
EndIf
_CalcCamera()
_IrrDrawScene()
[/autoit] [autoit][/autoit] [autoit]_IrrEndScene()
WEnd
_IrrStop()
[/autoit] [autoit][/autoit] [autoit]Func _CalcCamera()
Local $aPos[3]
$aPos[0] = $aPosition[0] - Cos(_Radian($iDegree)) * $iDistance
$aPos[2] = $aPosition[2] + Sin(_Radian($iDegree)) * $iDistance
$aPos[1] = $aPosition[1] + 100
_IrrSetNodePosition($Camera, $aPos[0], $aPos[1], $aPos[2])
_IrrSetCameraTarget($Camera, $aPosition[0], $aPosition[1], $aPosition[2])
EndFunc ;==>_CalcCamera
Jetzt funktioniert es teilweise aber es ruckelt stark beim drehen, wer ne bessere Methode hat die sicht zu drehen bitte hier posten^^ am besten direkt am beispiel
Das Alte Script:
Spoiler anzeigen
; ----------------------------------------------------------------------------
; Example 13: Camera Position
; This example creates a map for you to move around and displays the current
; position of the camera and its rotation on the screen
; ----------------------------------------------------------------------------
; ////////////////////////////////////////////////////////////////////////////
; Includes for extension libraries
#include "au3Irrlicht2.au3"
Opt("MustDeclareVars", True)
HotKeySet("{ESC}", "_exit")
Func _exit()
_IrrStop()
Exit
EndFunc ;==>_exit
; ////////////////////////////////////////////////////////////////////////////
; global variables
; irrlicht objects
Dim $BSPMesh ; irr_mesh
Dim $BSPNode ; irr_node
Dim $Camera ; irr_camera
Dim $BitmapFont ; irr_font
Dim $X ; Single
Dim $Y ; Single
Dim $Z ; Single
Dim $metrics ; String
Dim $a_vector3df[3]
Dim $MapCollision ;
Global $grav[3], $rad[3], $pos[3], $tar[3], $char[3], $pos1[3]
Global $mesh1, $texture, $node1, $frame, $posit
; ////////////////////////////////////////////////////////////////////////////
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; -----------------------------------------------------------------------------
; start the irrlicht interface
_IrrStart($IRR_EDT_DIRECT3D9, 800, 600, $IRR_BITS_PER_PIXEL_32, _
$IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON)
; set the window caption
_IrrSetWindowCaption("Example 13: Camera Position and Rotation")
; create a frist person perspective camera that can be controlled with mouse
; and cursor keys
$pos[0] = 1750 ;x
$pos[1] = 144 ;y
$pos[2] = 1369 ;z
$tar[0] = 1175;x
$tar[1] = 130;y
$tar[2] = 1364;z
$Camera = _IrrAddFpsCamera()
;$Camera = _IrrAddCamera($pos[0], $pos[1], $pos[2], $tar[0], $tar[1], $tar[2])
;_IrrSetNodePosition($node1, $tar[0], $tar[1], $tar[2])
;$Camera = _IrrAddFpsCamera()
; reposition and rotate the camera to look at a nice part of the map
_IrrSetNodePosition($Camera, 1750, 149, 1369)
_IrrSetNodeRotation($Camera, 4, -461.63, 0)
; load a Quake 3 BSP Map from a zip archive
_IrrAddZipFile("media/map-20kdm2.pk3", $IRR_IGNORE_CASE, $IRR_IGNORE_PATHS)
$BSPMesh = _IrrGetMesh("20kdm2.bsp")
$BSPNode = _IrrAddMeshToSceneAsOcttree($BSPMesh)
$rad[0] = 20;x rechts
$rad[1] = 30;y oben
$rad[2] = 20;z hinten
;Gravitation => wie stark nach x, y, z ,zieht
$grav[0] = 0;x
$grav[1] = -9.8;y
$grav[2] = 0;z
$MapCollision = _IrrGetCollisionGroupFromComplexMesh($BSPMesh, $BSPNode)
_IrrAddCollisionAnimator($MapCollision, $Camera, $rad[0], $rad[1], $rad[2], $grav[0], $grav[1], $grav[2], 0.0, 50.0, 0.0)
$char[0] = 1
$char[1] = 2
$char[2] = 3
$mesh1 = _IrrGetMesh("media/zumlin.md2")
$texture = _IrrGetTexture("media/zumlin.pcx")
$node1 = _IrrAddMeshToScene($mesh1)
_IrrSetNodeMaterialTexture($node1, $texture, 0)
_IrrSetNodeMaterialFlag($node1, $IRR_EMF_LIGHTING, $IRR_OFF)
_IrrPlayNodeMD2Animation($node1, $IRR_EMAT_RUN)
_IrrSetNodeAnimationSpeed($node1, 30)
$BitmapFont = _IrrGetFont("media/bitmapfont.bmp")
[/autoit] [autoit][/autoit] [autoit]; we also hide the mouse pointer to see the view better
_IrrHideMouse()
; -----------------------------------------------------------------------------
; while the irrlicht environment is still running
While _IrrRunning()
; begin the scene, erasing the canvas with sky-blue before rendering
_IrrBeginScene(50, 50, 50)
; draw the scene
_IrrDrawScene()
$posit = _IrrGetNodePosition($Camera)
$pos1[0] = $posit[0] - 100
$pos1[1] = $posit[1] - 45
$pos1[2] = $posit[2]
_IrrSetNodePosition($node1, $pos1[0], $pos1[1], $pos1[2])
; get the position of the camera into the supplied array
$a_vector3df = _IrrGetNodePosition($Camera)
; create a wide string with a list of the positions in
$metrics = "POSITION " & Int($a_vector3df[0]) & " " & Int($a_vector3df[1]) & " " & Int($a_vector3df[2]) & " "
; draw this position information to the screen
_Irr2DFontDraw($BitmapFont, $metrics, 4, 4, 250, 24)
; get the rotation of the camera into the supplied array
$a_vector3df = _IrrGetNodeRotation($Camera)
; create a wide string with a list of the rotations in
$metrics = "ROTATION " & Int($a_vector3df[0]) & " " & Int($a_vector3df[1]) & " " & Int($a_vector3df[2]) & " "
; draw this position information to the screen
_Irr2DFontDraw($BitmapFont, $metrics, 4, 32, 250, 52)
; end drawing the scene and display it
_IrrEndScene()
WEnd
; -----------------------------------------------------------------------------
; Stop the irrlicht engine and release resources
_IrrStop()
Ich hab noch ein Problem entdeckt:
Also ich wollte den Collision punkt dem zumlin modell zuweisen wenn ich jetzt aber bei _IrrAddCollisionAnimator anstatt
Spoiler anzeigen
($MapCollision, $Camera, $rad[0], $rad[1], $rad[2], $grav[0], $grav[1], $grav[2], 0.0, 50.0, 0.0)
das einfüge:
Spoiler anzeigen
($MapCollision, $mesh1, $rad[0], $rad[1], $rad[2], $grav[0], $grav[1], $grav[2], 0.0, 50.0, 0.0)
kommt dieser Fehler: http://www.bilder-upload.eu/show.php?file=…-1325619401.png