[Irrlicht] Eigenes Model -> Textur ?

  • Hi,
    Ich beschäftige mich nun seid langem mit Irrlicht (http://irrlicht.sourceforge.net/) und möchte zu einem Objekt, das ich in Blender (http://www.blender.org/) erstellt habe auch eine Textur haben. Wenn ich jedoch eine Textur wähle, kommt immer bloß die DUrchschnittsfarbe der Textur als Objektfarbe =(

    [autoit]

    ; ----------------------------------------------------------------------------
    ; Irrlicht Wrapper for Imperative Languages - Freebasic Examples
    ; Frank Dodd (2006)
    ; Converted/modified for the au3Irr2 project by linus
    ; ----------------------------------------------------------------------------
    ; Example 29 : Skydome
    ; This example adds a skydome around the whole scene that makes a backdrop
    ; for your scene to be rendered against
    ; ----------------------------------------------------------------------------

    [/autoit][autoit][/autoit][autoit]

    ; ////////////////////////////////////////////////////////////////////////////
    ; Includes for extension libraries
    #include "..\au3Irrlicht2.au3"
    HotKeySet("{ESC}", "_exit")

    [/autoit][autoit][/autoit][autoit]

    Func _exit()
    _IrrStop()
    Exit
    EndFunc ; _exit

    [/autoit][autoit][/autoit][autoit]

    ; ////////////////////////////////////////////////////////////////////////////

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ; -----------------------------------------------------------------------------
    ; start the irrlicht interface
    _IrrStart( $IRR_EDT_DIRECT3D9, 800, 600, $IRR_BITS_PER_PIXEL_32, _
    $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON )

    [/autoit][autoit][/autoit][autoit]

    ; send the window caption
    _IrrSetWindowCaption( "Skydome Script" )

    [/autoit][autoit][/autoit][autoit]

    ; the skydome is a simple hollow sphere that surrounds the whole scene. a single
    ; texture is applied to the entire surface of the sphere. Portions of the sphere
    ; can be rendered to optimise the performance of the scene
    local $SkyDome = _IrrAddSkyDomeToScene( _
    _IrrGetTexture("../media/skydome2.jpg"), _
    16, 8, 1.0, 1.2)
    _IrrAddRotationAnimator($SkyDome, 0, 0.003, 0)

    [/autoit][autoit][/autoit][autoit]

    ; we add a terrain to the scene for demonstration purposes, for a detailed
    ; explaination of the process please refer to example 10
    local $TerrainNode = _IrrAddTerrain( "../media/terrain-heightmap.bmp" )
    _IrrSetNodeScale( $TerrainNode, 100.0, 10.4, 100.0 )
    local $TerrainTexture0 = _IrrGetTexture( "../media/terrain-texture.jpg" )
    local $TerrainTexture1 = _IrrGetTexture( "../media/detailmap3.jpg" )
    _IrrSetNodeMaterialTexture( $TerrainNode, $TerrainTexture0, 0 )
    _IrrSetNodeMaterialTexture( $TerrainNode, $TerrainTexture1, 1 )
    _IrrScaleTexture( $TerrainNode, 1.0, 60.0 )
    _IrrSetNodeMaterialFlag( $TerrainNode, $IRR_EMF_LIGHTING, $IRR_OFF )
    _IrrSetNodeMaterialType ( $TerrainNode, $IRR_EMT_DETAIL_MAP )

    [/autoit][autoit][/autoit][autoit]

    ; we add a first person perspective camera to the scene so you can look about
    ; and move it into the center of the map
    local $Camera = _IrrAddFPSCamera()
    _IrrSetNodePosition( $Camera, 3942.8, 1102.7, 5113.9 )
    _IrrSetCameraClipDistance( $Camera, 12000 )
    $objekt=Add4CObjekt("Form.3ds","default_texture.png")
    _IrrSetNodePosition($objekt,3942,1000,5100)
    ; hide the mouse pointer
    _IrrHideMouse()

    [/autoit][autoit][/autoit][autoit]

    ; -----------------------------------------------------------------------------
    ; while the irrlicht environment is still running
    WHILE _IrrRunning()
    ; begin the scene, erasing the canvas with sky-blue before rendering
    _IrrBeginScene( 240, 255, 255 )

    [/autoit][autoit][/autoit][autoit]

    ; draw the scene
    _IrrDrawScene()

    [/autoit][autoit][/autoit][autoit]

    ; end drawing the scene and render it
    _IrrEndScene()
    WEND

    [/autoit][autoit][/autoit][autoit]

    ; -----------------------------------------------------------------------------
    ; Stop the irrlicht engine and release resources
    _IrrStop()

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func Add4CObjekt($objket,$texture)
    $MD2Mesh = _IrrGetMesh( "../media/"&$objket )
    $MeshTexture = _IrrGetTexture( "../media/"&$texture )
    $SceneNode = _IrrAddMeshToScene( $MD2Mesh )
    _IrrSetNodeMaterialTexture( $SceneNode, $MeshTexture, 0 )
    _IrrSetNodeMaterialFlag( $SceneNode, $IRR_EMF_LIGHTING, $IRR_ON )
    Return $SceneNode
    EndFunc

    [/autoit]

    Anmerkungen:
    1) Ist das Skydome Beispiel mit meiner Testfunktion zum Objekteinfügen.
    2) Objekt erscheint richtig, nur wie erwähnt die Farbe stimmt nicht ganz.
    3) Objekt habe ich in Blender erstellt und in 3ds exportiert.
    4) Um das Script laufen zu lassen braucht ihr die Irrlicht Dateien!

    Hoffe jemand kann helfen!
    Lg

  • Ich hatte mir für Irrlicht einige Modell in 3ds exportieren lassen, und da wurde die Textur immer einen extraordner abgelegt der hieß so wie das Model heisst. Da hatte ich auch iwelche probleme gahabt...
    versuch sonst mal die MaterialFlag zu ändern.

    Grüsse!

  • Ja, das habe ich auch schon geschnallt ... trotzdem danke.
    Bleibt noch das Problem, das es sich immer nur in der Durchschnittsfarbe der Textur einfärbt. Zumindest bei mir ... kann mal jemand testen ob es bei ihm mit meiner Form geht?
    Habe ich eventuell die Form schon beim Bearbeiten versaut? (Würfel gemacht -> Zylinder drüber -> File -> Save as -> 3ds -> gespeichert)
    Lg

  • ... bei mir kann ich nur als .dae .ply .stl .3ds .fbx .obj .x3d exportieren. Wie exportiere ich als MD2? Welche Version von Blender hast du?
    Lg

  • 2.49b unter Linux... Export md2. gibt es aber, dafür wird glaub ich so ein Python Script benötigt, wovon die Seite gerade down ist. Ich meine mich aber errinnern zu können, dass das bei uns auch nicht funktioniert hat, darum haben wir uns dann irgendeinen Konverter runtergeladen, oder das irgendwie anders gemacht...Musst du noch mal Fresapore fragen... Kannst aber mal mit der .md2 aus unserem Projekt ausprobieren...Ist in meiner Signatur...