Hi there great makers and testers of the PB irrlicht wrapper,
First off, great work, cool to play arround with irrlicht.
i was wondering, how can i delete a texture, because all commands
contain irradd, but no irrdelete or irrremove, so it's memory consuming
when you for instance add realtime generated self made textures.
Second, the terrain functions contain a function: IrrTerrainHeight,
this functions obtains the height of the x/z position, thats very
handy but how is it possible to change this height, i would expect
to have a IrrGetTerrainHeight and IrrSetTerrainHeight function.
And how to obtain the terrain width/height?
And the documentation overal should contain example images,
specialy for the GUI part.
But very nice work! Love it!
Gr,
Phil.
irrlicht - questions
-
- Enthusiast
- Posts: 135
- Joined: Sat Aug 18, 2007 7:09 am
- Location: Netherlands
Re: irrlicht - questions
Hi Phil,
sorry for the late response.
You are right, there is no command to remove a texture. But all pointers in Irrlicht contains a 'counter', to know if the Object (behind the pointer)
stil in use. So C++ ha not GarbageCollector and we have to remove the objects/pointers self. In the IrrlichtWrappe4r is a Command IrrDropPointer(). That decreases the 'counter' and removes the object if the counter is 0.
You can use this to 'remove' textures. But keep in mind - if the Texture(-Object) still used from another Object, it will not be removed !
* Don't use LOD
* recalculate the Terrain (with a new Node and removing the old one... )
Both are not really nice, but you can also use your own Mesh (IrrCreateMesh() ) and then change the vertices by yourself.
Long time ago (Irrlicht 0.11) i made a min-terrain-editor without LOD.
It works. So if that what you want, i can (if i got the time), add some functions to make this also possible from PB. (Please send a PM)
(In the Irrlicht-Snippets-Forum was a addition : http://irrlicht.sourceforge.net/phpBB2/ ... ht=terrain
But with the same anwers as i explained above.
Hope this helps....
Mike
sorry for the late response.
You are right, there is no command to remove a texture. But all pointers in Irrlicht contains a 'counter', to know if the Object (behind the pointer)
stil in use. So C++ ha not GarbageCollector and we have to remove the objects/pointers self. In the IrrlichtWrappe4r is a Command IrrDropPointer(). That decreases the 'counter' and removes the object if the counter is 0.
You can use this to 'remove' textures. But keep in mind - if the Texture(-Object) still used from another Object, it will not be removed !
The Terrain-SceneNode in Irrlicht has a nice feature - called 'Level of Detail (LOD)'. And that is the problem with changing the height a point in the terrain. Irrlicht 'precalculates' the Meshes for the all LOD of the Terrain on init. So there a re onle 2 ways around thet -Philippe-felixer76-2 wrote: Second, the terrain functions contain a function: IrrTerrainHeight,
this functions obtains the height of the x/z position, thats very
handy but how is it possible to change this height, i would expect
to have a IrrGetTerrainHeight and IrrSetTerrainHeight function.
* Don't use LOD
* recalculate the Terrain (with a new Node and removing the old one... )
Both are not really nice, but you can also use your own Mesh (IrrCreateMesh() ) and then change the vertices by yourself.
Long time ago (Irrlicht 0.11) i made a min-terrain-editor without LOD.
It works. So if that what you want, i can (if i got the time), add some functions to make this also possible from PB. (Please send a PM)
(In the Irrlicht-Snippets-Forum was a addition : http://irrlicht.sourceforge.net/phpBB2/ ... ht=terrain
But with the same anwers as i explained above.
The Terrain Width/Height based on the size of the Texture and the scaling.Philippe-felixer76-2 wrote: And how to obtain the terrain width/height?
Hope this helps....
Mike
-
- Enthusiast
- Posts: 135
- Joined: Sat Aug 18, 2007 7:09 am
- Location: Netherlands
Re: irrlicht - questions
Tnx for the reply..neotoma wrote:Hi Phil,
sorry for the late response.
You are right, there is no command to remove a texture. But all pointers in Irrlicht contains a 'counter', to know if the Object (behind the pointer)
stil in use. So C++ ha not GarbageCollector and we have to remove the objects/pointers self. In the IrrlichtWrappe4r is a Command IrrDropPointer(). That decreases the 'counter' and removes the object if the counter is 0.
You can use this to 'remove' textures. But keep in mind - if the Texture(-Object) still used from another Object, it will not be removed !
The Terrain-SceneNode in Irrlicht has a nice feature - called 'Level of Detail (LOD)'. And that is the problem with changing the height a point in the terrain. Irrlicht 'precalculates' the Meshes for the all LOD of the Terrain on init. So there a re onle 2 ways around thet -Philippe-felixer76-2 wrote: Second, the terrain functions contain a function: IrrTerrainHeight,
this functions obtains the height of the x/z position, thats very
handy but how is it possible to change this height, i would expect
to have a IrrGetTerrainHeight and IrrSetTerrainHeight function.
* Don't use LOD
* recalculate the Terrain (with a new Node and removing the old one... )
Both are not really nice, but you can also use your own Mesh (IrrCreateMesh() ) and then change the vertices by yourself.
Long time ago (Irrlicht 0.11) i made a min-terrain-editor without LOD.
It works. So if that what you want, i can (if i got the time), add some functions to make this also possible from PB. (Please send a PM)
(In the Irrlicht-Snippets-Forum was a addition : http://irrlicht.sourceforge.net/phpBB2/ ... ht=terrain
But with the same anwers as i explained above.
The Terrain Width/Height based on the size of the Texture and the scaling.Philippe-felixer76-2 wrote: And how to obtain the terrain width/height?
Hope this helps....
Mike
Can i pass a texture pointer to IrrDropPointer() ?!
About the terrain height, the C code is to difficult for
me to create a PB lib out of that. You might wanne
help?!

Or the mesh way might be the solution.
Offcourse i like the terrain editor ...
Gr,
Phil.
Hi Phil 
About Terrain:
The Terraindimension is the Dimension of your heightmapimagefile^2 multiplied by your nodescale as mike said.
Alternatively where Get and Set height Functions are available one can use The TlT ( TiledTerrain) functions ( which i am playing around currently to docu for the stable ... ).
Heres the modified Terrain Example to demonstrate this.
Cheers,
Thalius

About Terrain:
The Terraindimension is the Dimension of your heightmapimagefile^2 multiplied by your nodescale as mike said.
Alternatively where Get and Set height Functions are available one can use The TlT ( TiledTerrain) functions ( which i am playing around currently to docu for the stable ... ).
Heres the modified Terrain Example to demonstrate this.
Code: Select all
;; ----------------------------------------------------------------------------
;; Irrlicht Wrapper For Imperative Languages - Purebasic Examples
;; IrrlichtWrapper and FreeBasic-Example by Frank Dodd (2006)
;; Improved IrrlichtWrapper - Michael Taupitz (2007)
;; PureBasic-Examples by Michael Taupitz (neotoma) & Marius Eckardt (Thalius)
;; Last Edit: 25.10.2007
;; ----------------------------------------------------------------------------
;; Example 10 : Terrain And Fog
;; This example creates a terrain from a bitmap heightfield And displays it in
;; a foggy scene
;; ----------------------------------------------------------------------------
;;
;; ////////////////////////////////////////////////////////////////////////////
;; Include the Irr3D-Requester
XIncludeFile "Irr3DRequester.pb"
;; ////////////////////////////////////////////////////////////////////////////
;; Global variables
; irrlicht objects
*terrain.irr_terrain
*TerrainNode.irr_node
*TerrainTexture0.irr_texture
*TerrainTexture1.irr_texture
*camera.irr_camera
*CameraNode.irr_node
; Defines
Define x.f, y.f, z.f, Height.f
; Little helper function to get an ImageDimension...
; // Result = ImageDimension( FileName$ [, Axis])
; // Axis can be 0 -> X (Width) or 1 -> Y (Height) : Default Width is returned.
; // Returns X or Y Dimensions of given Imagefile or 0 if fail ( kinda bulletproof ... ) =p
Procedure ImageDimension(file.s,axis.l = 0)
Result.l = 0
If LoadImage(0, file.s)
If IsImage(0)
Select axis.l
Case 1 ; Y
Result.l = ImageHeight(0)
Default ; X
Result.l = ImageWidth(0)
EndSelect
FreeImage(0)
EndIf
EndIf
ProcedureReturn Result.l
EndProcedure
; -----------------------------------------------------------------------------
; To Start the Irrlicht-Device we use the Irr3DRequester, to make it more comfortable
; for the Users, and also easier to test different resolutions and devices.
If Irr3DRequester()
; send the window caption
IrrSetWindowCaption( "Example 10: Terrain and Fog" )
; here we create the terrain from a greyscale bitmap where bright pixels are
; high points and black pixels are low points. the command generates the mesh
; and automatically adds it as a node to the scene
*terrain = IrrAddTerrain( "media\terrain-heightmap.bmp" )
; We Read out the ImageWidth which is our Terrain Dimension
TerrainWidth.l = ImageDimension( "media\terrain-heightmap.bmp" )
; the node is too small to be a proper terrain so we get the node object of the
; terrain and scale its size up 40 times along the X and Z axis and just 4 times
; along the Y axis
*TerrainNode = *terrain
TerrainScaleXZ.f = 40.0
TerrainScaleY.f = 4.0
IrrSetNodeScale( *TerrainNode, TerrainScaleXZ.f, TerrainScaleY.f, TerrainScaleXZ.f )
; we load two textures in to apply to the terrain node
*TerrainTexture0 = IrrGetTexture( "media\terrain-texture.jpg" )
*TerrainTexture1 = IrrGetTexture( "media\detailmap3.jpg" )
; the first texture is a color texture that is applied across the entire
; surface of the map. this needs to be a fairly high resoloution as the map is
; very large now
IrrSetNodeMaterialTexture( *TerrainNode, *TerrainTexture0, 0 )
; the second texture is tiled many times across the map this adds fine detail
; and structure to the first enlarged terain color
IrrSetNodeMaterialTexture( *TerrainNode, *TerrainTexture1, 1 )
; we set the scale of the detail map so its repeated 20 times across the map in
; the x and y axis
IrrScaleTexture( *terrain, 1.0, 20.0 )
; finally we apply some material texuring effects to the node
; the terrain is self illuminating
IrrSetNodeMaterialFlag( *TerrainNode, #IRR_EMF_LIGHTING, #IRR_OFF )
; the material type is detail type. this type applies the first texture across
; the entire node and then scales and applies the second texture across the node
; there are many different material types you can set, these can be found in the
; .bi definition file, experiment with them
IrrSetNodeMaterialType ( *TerrainNode, #IRR_EMT_DETAIL_MAP )
; finally we switch on fog for this material so that this terrain will fade out
; into a fog in the distance
IrrSetNodeMaterialFlag( *TerrainNode, #IRR_EMF_FOG_ENABLE, #IRR_ON )
; now we need to add the fog to the scene. the first three parameters are the
; fog color, we set this to the same color as our sky so the scene fogs out
; nicely into nothing, the next parameter specifies whether you want the fog
; to increase in a linear mannar or exponentially - exponential fog usually
; looks more atmospheric while linear looks more like a dense sea fog, the next
; two parameters specify the distance at which the fog starts and the distance
; at which the fog reaches its maximum density and finally the fog density -
; this is only used with exponential fog and determines how quickly the
; exponential change takes place
IrrSetFog ( 240,240,255,255, #IRR_EXPONENTIAL_FOG, 0.0,8000.0, 0.5 )
; we add a first person perspective camera to the scene so you can look about
; and move it into the center of the map
*camera = IrrAddFPSCamera()
*CameraNode = *camera
IrrSetNodePosition( *CameraNode, 3942.8, 1102.7, 5113.9 )
IrrSetNodeRotation( *CameraNode, 19, -185.5, 0 )
; the clipping distance of a camera is a distance beyond which no triangles are
; rendered, this speeds the scene up by not showing geometry that is in the
; distance and too small to see however our terrain is so huge we need to
; extend this distance out
IrrSetCameraClipDistance( *camera, 12000 )
; we also hide the mouse pointer to see the view better
IrrHideMouse()
; Create GUI
*Status_Terrain = IrrGuiAddStaticText( "", 4,0,400,16, #IRR_GUI_NO_BORDER, #IRR_GUI_NO_WRAP )
*Status_Actual = IrrGuiAddStaticText( "", 4,12,400,28, #IRR_GUI_NO_BORDER, #IRR_GUI_NO_WRAP )
; Set Static GUI
IrrGuiSetText(*Status_Terrain, "Terrain Dimensions (X/Z): "+StrF(TerrainWidth.l * TerrainScaleXZ.f)+" * "+StrF(TerrainWidth.l * TerrainScaleXZ.f)+" Y->Height = "+StrF(TerrainWidth.l * TerrainScaleY.f))
; -----------------------------------------------------------------------------
; while the irrlicht environment is still running
While IrrRunning()
; Update Status
IrrGetNodePosition(*camera,@x.f,@y.f,@z.f)
IrrTerrainHeight(*terrain,x.f,y.f,@Height.f)
IrrGuiSetText(*Status_Actual, "Actual-> Position: X= "+StrF(x.f)+" Y= "+StrF(y.f)+" Z="+StrF(z.f)+" TerrainHeight: "+StrF(Height.f))
; begin the scene, erasing the canvas with sky-blue before rendering
IrrBeginScene( 240, 255, 255 )
; draw the scene
IrrDrawScene()
; Draw the GUI ( Our Status Text in this Case )
IrrDrawGUI()
; end drawing the scene and render it
IrrEndScene()
Wend
; -----------------------------------------------------------------------------
; Stop the irrlicht engine and release resources
IrrStop()
EndIf
End
YesCan i pass a texture pointer to IrrDropPointer() ?!

Cheers,
Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
"
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!

-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
Height map
I found those TlT commands, but i couln't get it working. Hope you canThalius wrote:Hi Phil
About Terrain:
The Terraindimension is the Dimension of your heightmapimagefile^2 multiplied by your nodescale as mike said.
Alternatively where Get and Set height Functions are available one can use The TlT ( TiledTerrain) functions ( which i am playing around currently to docu for the stable ... ).

YesCan i pass a texture pointer to IrrDropPointer() ?!

Cheers,
Thalius[/quote]
WOW
