Irrlicht Wrapper for 3D games and applications

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

irrclose

Post by chung »

did you check my code in irr_chung.bas ?
i use irrclose inside the main loop as

debut:
irrstart ...
...
while irr_running ...
restart=1:irrclose
wend

irrstop
if restart=1 the goto debut

and it works...
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Hello Chung

Yes I did try it and when the device restarted IrrRunning always returned false meaning the device wasn't actually open what I have done is place the deviceClose call into IrrStop so you only have to make the IrrStop Call (this is actually a part of the development DLL I posted last night).

However I just tried it again this morning and I found that if I closed the application with the windows close button the device closed properly!? Previously I was closing it with a GUI button. Perhaps it just needs an additional WM_CLOSE message sent to it.
Last edited by Frank Dodd on Jun 23, 2011 6:04, edited 1 time in total.
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Hello Everyone

I have concluded including the code contributions that we have discussed since page 32. They appear to be working well there appear to only by issues that will be outstanding at the point of release on monday.

IrrStop and closeDevice are working and do tidy up the environment and provide resolution changes on the fly however once IrrStop is called IrrRunning will not always reliably return true.

A new function is supplied IrrScaleMesh this scales the mesh and does not effect the normals allowing for correct lighting without any additional processing. However scaling has had to be uniform in all 3 axis at the moment.
Last edited by Frank Dodd on Jun 23, 2011 6:06, edited 1 time in total.
rcobra
Posts: 43
Joined: Feb 21, 2010 19:19
Location: Poland
Contact:

Post by rcobra »

hi i have a problem, I want to use the style of movement in a small demo rpg
I mean something like the mouse movement by individuals on the plane as in Diablo
where the mouse is down clik move.
how to do this using Irrlicht wrapper?
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

Rcobra, this is the best I have been able to come up with.

Code: Select all

dim mainMapCamera as irr_camera
 dim as cameraInfo camera, cameraDefault, cameraLast, cameraMax, cameraMin

...

perspectiveFieldOfViewAngle = 60

...

mainMapCamera = irrAddCamera(0, 0, -1, 0, 0, 0)
irrSetCameraFOV (mainMapCamera, perspectiveFieldOfViewAngle * degToRadRat)


...

irrSetCameraClipDistance (mainMapCamera, zFar, 1)

...

cameraDefault.x = -(mapMaxX+1)/(mapMaxY+1)*mapMaxY/2
cameraDefault.y = -mapMaxY/2
cameraDefault.zoom = cos(perspectiveFieldOfViewAngle*degToRadRat/2)*MapMaxY+1
zFar = 50000'cameraDefault.zoom*4

...

do

...

 readMultikeyIrrlicht()

 if cameraLast = camera then cameraChanged = 0 else cameraChanged = 1


 irrSetCameraTarget (mainMapCamera, 0,0,0)
 irrSetNodePosition (mainMapCamera,0,0,1)
 irrSetCameraUpDirection (mainMapCamera, 0,-1,0)
 irrRevolveCamera (mainMapCamera, 0, 0, 0, 0, camera.x, camera.y)
 irrRevolveCamera (mainMapCamera, 0, 0, camera.rotate*degToRadRat, 0, 0, 0)
 irrRevolveCamera (mainMapCamera, -camera.tiltSide*degToRadRat, 0, 0, 0, 0, 0)
 irrRevolveCamera (mainMapCamera, 0, camera.tiltUp*degToRadRat, 0, 0, 0, 0)
 irrRevolveCamera (mainMapCamera, 0, 0, 0, -camera.zoom, 0, 0)

...

loop


Code: Select all

type cameraInfo
 dim as double zoom, x, y
 dim as double tiltUp, tiltSide, rotate
 declare operator let (byref rhs as cameraInfo)
end type

declare operator = (byref lhs as cameraInfo, byref rhs as cameraInfo) as integer
declare operator <> (byref lhs as cameraInfo, byref rhs as cameraInfo) as integer

operator cameraInfo.let ( byref rhs as cameraInfo)
 zoom = rhs.zoom: x = rhs.x: y = rhs.y
 tiltUp = rhs.tiltUp: tiltSide = rhs.tiltSide: rotate = rhs.rotate
end operator

operator = ( byref lhs as cameraInfo, byref rhs as cameraInfo) as integer
 if lhs.zoom     <> rhs.zoom     then return 0
 if lhs.x        <> rhs.x        then return 0
 if lhs.y        <> rhs.y        then return 0
 if lhs.tiltUp   <> rhs.tiltUp   then return 0
 if lhs.tiltSide <> rhs.tiltSide then return 0
 if lhs.rotate   <> rhs.rotate   then return 0
 return -1
end operator

operator <> ( byref lhs as cameraInfo, byref rhs as cameraInfo) as integer
 if lhs.zoom     <> rhs.zoom     then return -1
 if lhs.x        <> rhs.x        then return -1
 if lhs.y        <> rhs.y        then return -1
 if lhs.tiltUp   <> rhs.tiltUp   then return -1
 if lhs.tiltSide <> rhs.tiltSide then return -1
 if lhs.rotate   <> rhs.rotate   then return -1
 return 0
end operator
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

This routine is so slow :

shotTexture = IrrGetScreenShot( x0,y0,64,64 )
pixelsSource= IrrLockTexture( shotTexture )
IrrUnlockTexture( shotTexture )

gruss

Code: Select all

#include "IrrlichtWrapper.bi"
#include "windows.bi"
#include "fbgfx.bi"
#include  "crt.bi"
Using FB

DIM loadTexture as irr_texture
DIM shotTexture as irr_texture
Dim pixelsSource as UInteger ptr
DIM Shared As Integer x,y,x0,y0,zz
Dim As byte Ptr bild

ScreenRes 300,300,32
ScreenControl SET_WINDOW_POS, 10,200

IrrStart( IRR_EDT_DIRECT3D8, 256, 256, IRR_BITS_PER_PIXEL_32, _
          IRR_WINDOWED, IRR_NO_SHADOWS, IRR_IGNORE_EVENTS )
IrrSetWindowCaption( "texture-image" )

loadTexture = IrrGetTexture( "./media/hin00.png" )

x0=0
y0=0
zz=0
bild = ImageCreate(64,64,RGBA(0,0,0,0))

While IrrRunning
	
	If MultiKey( FB.SC_q ) Then
		zz=0
		x0=x0-1
		If x0 < 0 Then x0=0
		shotTexture = IrrGetScreenShot( x0,y0,64,64 )
		pixelsSource= IrrLockTexture( shotTexture )
		IrrUnlockTexture( shotTexture )
		For y=0 To 64-1
		For x=0 To 64-1
    		PSet (x+10,y+10),pixelsSource[zz]
    		If (pixelsSource[zz] AND &Hffffff) = &H00f000 Then
    			Locate 16,2	
				Print "c=      "
				Locate 16,2	
				Print "c= ";zz
    		EndIf	
    		zz=zz+1
		Next x
		Next y
		zz=0
	EndIf
	
	If MultiKey( FB.SC_e ) Then
		zz=0
		x0=x0+1
		shotTexture = IrrGetScreenShot( x0,y0,64,64 )
		pixelsSource= IrrLockTexture( shotTexture )
		IrrUnlockTexture( shotTexture )
		For y=0 To 64-1
		For x=0 To 64-1
    		PSet (x+10,y+10),pixelsSource[zz]
    		If (pixelsSource[zz] AND &Hffffff) = &H00f000 Then
				Locate 16,2	
				Print "c=      "
				Locate 16,2	
				Print "c= ";zz
    		EndIf	
    		zz=zz+1
		Next x
		Next y
	EndIf
	
	If MultiKey( FB.SC_w ) Then
		zz=0
		y0=y0+1
		shotTexture = IrrGetScreenShot( x0,y0,64,64 )
		pixelsSource= IrrLockTexture( shotTexture )
		IrrUnlockTexture( shotTexture )
		For y=0 To 64-1
		For x=0 To 64-1
    		PSet (x+10,y+10),pixelsSource[zz]
    		If (pixelsSource[zz] AND &Hffffff) = &H00f000 Then
				Locate 16,2	
				Print "c=      "
				Locate 16,2	
				Print "c= ";zz
    		EndIf	
    		zz=zz+1
		Next x
		Next y
	EndIf
	
	If MultiKey( FB.SC_s ) Then
		zz=0
		y0=y0-1
		If y0 < 0 Then y0=0
		shotTexture = IrrGetScreenShot( x0,y0,64,64 )
		pixelsSource= IrrLockTexture( shotTexture )
		IrrUnlockTexture( shotTexture )
		For y=0 To 64-1
		For x=0 To 64-1
    		PSet (x+10,y+10),pixelsSource[zz]
    		If (pixelsSource[zz] AND &Hffffff) = &H00f000 Then
				Locate 16,2	
				Print "c=      "
				Locate 16,2	
				Print "c= ";zz
    		EndIf	
    		zz=zz+1
		Next x
		Next y
	EndIf
	
   IrrBeginScene( 255,255,0 )
   	IrrDraw2DImageElement(loadTexture,4, 4,0,0,64,64, IRR_USE_ALPHA )
   IrrEndScene
    
Wend

IrrStop
rcobra
Posts: 43
Joined: Feb 21, 2010 19:19
Location: Poland
Contact:

Post by rcobra »

thanks Agamemnus
actually I already have a code for a long time and thought it would be something like that http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=27781
but unfortunately in C + + may be able to rewrite it in the code irrlichtwrapper.
I have a few questions?
- In Irrlichtwrapper underlying libraries can be freely combined or somehow does not affect performance
- I could make something like gamepack (models, graphics, gui, etc) of course if it would be interesting.
Since I like Linux provides a script that allows you to move and run the game on various Linux distributions without installing the libraries in usr / lib might be useful to someone oh so there were no problems due to compile Irrlicht and irrlichtwrapper in the lower version of glibc and make the right to run the script.
how to use
* Our game
/lib -> library here upload
/ media -> You can also be / date here you throw models, maps, sounds, etc
game_name -> our game
game_run -> script which runs the game

Code: Select all

#!/bin/sh
GAME_DIST_BIN=`dirname "$0"`
GAME_PROGRAM="game_name" # GAME_PROGRAM=`basename "$0"`-bin
exitcode=0

LD_LIBRARY_PATH=${GAME_DIST_BIN}/lib:${LD_LIBRARY_PATH}

if [ -n "$LD_LIBRARYN32_PATH" ]; then
    LD_LIBRARYN32_PATH=${GAME_DIST_BIN}/lib:${LD_LIBRARYN32_PATH}
fi

export LD_LIBRARY_PATH LD_LIBRARYN32_PATH  LD_PRELOAD

"$GAME_DIST_BIN/$GAME_PROGRAM" ${1+"$@"}
exitcode=$?
exit $exitcode
ps.if there are any ambiguities sorry I'm using google translate
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

I need something for a Node :

IrrRevolveNode ( Node, NodeYaw, NodePitch, NodeRoll, NodeDrive, NodeStrafe, NodeElevate )

IrrRevolveCamera ( CameraObject, CameraYaw, CameraPitch, CameraRoll, CameraDrive, CameraStrafe, CameraElevate )

need it for an airplane !

gruss
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

super_castle:
IrrRevolveNode ( Node, NodeYaw, NodePitch, NodeRoll, NodeDrive, NodeStrafe, NodeElevate )
Use the node rotation and node position functions!


Rcobra:
rcobra wrote:thanks Agamemnus
I have a few questions?
- In Irrlichtwrapper underlying libraries can be freely combined or somehow does not affect performance
Of course libraries can be combined with the Irrlicht wrapper (even Irrlicht-specific libraries). It will or will not affect performance depending on what the library does and how it does it.
- I could make something like gamepack (models, graphics, gui, etc) of course if it would be interesting.
The thing that's missing is a really customizable GUI layer. I'm working on that by making a CEGUI wrapper-- CEGUI is compatible with Irrlicht.
Since I like Linux provides a script that allows you to move and run the game on various Linux distributions without installing the libraries in usr / lib might be useful to someone oh so there were no problems due to compile Irrlicht and irrlichtwrapper in the lower version of glibc and make the right to run the script.
I have no idea what this means.
how to use
* Our game
/lib -> library here upload
/ media -> You can also be / date here you throw models, maps, sounds, etc
game_name -> our game
game_run -> script which runs the game

Code: Select all

#!/bin/sh
GAME_DIST_BIN=`dirname "$0"`
GAME_PROGRAM="game_name" # GAME_PROGRAM=`basename "$0"`-bin
exitcode=0

LD_LIBRARY_PATH=${GAME_DIST_BIN}/lib:${LD_LIBRARY_PATH}

if [ -n "$LD_LIBRARYN32_PATH" ]; then
    LD_LIBRARYN32_PATH=${GAME_DIST_BIN}/lib:${LD_LIBRARYN32_PATH}
fi

export LD_LIBRARY_PATH LD_LIBRARYN32_PATH  LD_PRELOAD

"$GAME_DIST_BIN/$GAME_PROGRAM" ${1+"$@"}
exitcode=$?
exit $exitcode
Again, no idea what you're trying to do here.

What's your native language?
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Thanks for posting those replies Agamemnus they were very helpful and quick.

super_castle
Looking at you code that uses the IrrGetScreenShot that will be slow, it is transferring images across pixel by pixel. I am not familiar with the FreeBasic graphics functions to any great extent but I would recommend copying the image into a freeBasic image just the once and then using whatever sprite or blitting functions are available to copy the data more rapidly.

As for your question on the aircraft camera your best results are probably going to be with the 6DOF camera (Six Degrees of Freedom) this camera object is specifically created for the view point of an aircraft or spacecraft that needs to move with six degrees of freedom you will find an example for this in "62_Example_6D0F_Camera".

The problem with normal node camera rotations is the singularities that the poles these have been the bane of mine and many peoples lives when I was working in 3D graphics and also in Realtime 3D programming.

Edited to remove inaccurate information

Hello rcobra
I am sorry but I can't help too much with the Linux functionality, I am only providing it as a proof of concept at the moment, I have been unable to get 3D hardware drivers functioning under Linux and consequentially I do all of the testing using the mesa libraries with software emulation, as you can imagine this is very slow and does not support some of the examples.

Good luck with the RTS project Agamemnus and eric have discussed some of the elements of it in detail in these past few pages hopefully there will be plenty of help in there.
Last edited by Frank Dodd on Apr 20, 2010 23:09, edited 1 time in total.
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

This function must be created first, which does not exist:

IrrRevolveNode ( Node, NodeYaw, NodePitch, NodeRoll, NodeDrive, NodeStrafe, NodeElevate )
rcobra
Posts: 43
Joined: Feb 21, 2010 19:19
Location: Poland
Contact:

Post by rcobra »

agamemnus
I'm Polish

I wrote a little bit incomprehensible this may be better
I mean here is that this script allows a game written to run on other versions of Linux

frank
thanks
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

I wrote a little bit incomprehensible this may be better
I mean here is that this script allows a game written to run on other versions of Linux
Ok.
super_castle wrote:This function must be created first, which does not exist:

IrrRevolveNode ( Node, NodeYaw, NodePitch, NodeRoll, NodeDrive, NodeStrafe, NodeElevate )
Either you are looking to rotate a node, or you are looking to rotate the camera view. Which is it? If it's a node, you need to use IrrSetNodeRotation. If it is the camera, you need to use IrrRevolveCamera.
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Hello super_castle

I have run a few experiments and have had problems creating the 6dof animation of a node. I do think that your suggestion of the use of a IrrRevolveNode is worthwhile and I will look into it.

The difference between the IrrRevolveNode and IrrSetNodeRotation calls will be that the IrrRevolveNode will utilise quaterions to provide accumulative rotations that also help to avoid 'Gimbal Lock' the IrrRevolveNode call would be particularly useful for positioning a cockpit or aircraft model.

There is no certainty that this one will work without problems however. Thanks for your input on this one too Agamemnus.
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

Ok, I see what he's saying. He was an accumulator instead of a setter. I would name it "irrSetRotationChange" though, instead...

I wouldn't recommend using it anyway because then you would need to call irrlicht for an accurate reading on the position of your model instead of using your game's internal data (otherwise you'd.. accumulate errors). I don't like doing this because I like keeping the rendering and picking separate from the overall logic (like the logical position of an object in a game).
Post Reply