Feeds:
Posts
Comments

Archive for the ‘ogre3d’ Category

i’ve finished a set of basic ogre examples – since the ones coming with ogre 1.7+ are not very good. you can download them from github.com/qknight, see [1]. i’ve added a README which explains all in detail, again see [1]. i wish i had the time to create more of these examples. so here are a few screenshots.

mars example (about texturing)

ninja-camera (about using the mouse navigation)

mars-rings (about creating circles in ogre)

mars-rings-shader-cg (about using shaders)

so basically my examples are about:

  • how to create fully self-contained simple examples independent of each other
  • how to get ogre running (with the example framework from the ogre wiki tutorials)
  • using ois or sdl joystick/gamepad support in ogre
  • how to create spheres and how to texture them properly
  • how to approximate rings which are approximated circles using line segments
  • how to use cg (nvidia) and glsl (opengl) shaders
  • how to use cmake
  • how to write small but yet powerful example
  • i’ve also put attention at a very light weight CustomMedia system, it will be easy for you to understand how to use materials and textures together with shaders

all of these use cmake and you can use them for whatever purpose you like. just note that i’ve included code from the ogre wiki and i don’t know which copyright or license they use which is ‘yet’ another criticism (but i will stop right here). i would like to thank the irc folks in #ogre3d@irc.freenode.net for their support.

it would be nice if you would drop me a email with feedback on how you liked/used my examples.

links

[1] http://github.com/qknight/ogre-examples

Advertisements

Read Full Post »

ogre 3d III

why ois did not work on my linux installation

what is ois? i quote [1]:

Object Oriented Input System (OIS) is meant to be a cross platform, simple solution for using all kinds of Input Devices (KeyBoards, Mice, Joysticks, etc) and feedback devices (e.g. forcefeedback). Written in C++ using Object Oriented Design patterns

i’ve finally found out why ois [1] does not work with my linux system. see this:

ls -la /dev/input
crw-r—–  1 root root 13, 73 Feb 28 12:46 event9
crw-r–r–  1 root root 13,  0 Feb 28 12:46 js0

as most linux users will instantly see: js0 can be read but not be written to. so is this bad? or does this degrade useage? probably it is not bad since a user might only have to write to a jsX device if it is a ‘force feedback’ supporting device. but for only reading from the device it should be useable  as expected. but the joystick/gamepad did not work with OIS at all, so i wondered why and i started to look at the code of OIS. i found a ReadMe.txt file with an obsolete autotools toggle – guess what – i hate autotools.

anyway, the ReadMe.txt states:

./configure –disable-joyevents — Uses /dev/input/jsX instead of /dev/input/eventX

so i tried –disable-joyevents but it seems that this option is not used anymore because ./configure complains with:

configure: WARNING: unrecognized options: –disable-joyevents

however, this made me think: what is that event9 device when plugging in the gamepad (still the ps3 controller). it is yet another interface to access the gamepad. so one can either use js0 or event9 (on my system, since the names are autogenerated by the system).

after changing the permissions of event9 (as root) with:

chmod 0777 /dev/input/event9

and trying the ois demo again it worked! no wonder but took me at least about  1h to find out. so why don’t they try to open the js0 device? why don’t they complain about permission issues? at least the console demo application could do that (it can’t since the input opening and handling is in the linux part of the library anyway) but what about some lines like:

event1: can’t open device for reading
event2: can’t open device for reading

event9: can’t open device for reading

this would be very handy for debugging the situation. or seen from a different point of view,  is this a gentoo issue? is this a udev issue? why does that device not have read permissions per default? maybe for securty? how knows…

ois and udev

thanks to [3] i found this handy udevadm command:

udevadm info -a -p  $(udevadm info -q path -n /dev/input/js0)

this can be combined to what i’ve written about udev already at [4]. in short (looking at the output of the above command we search for these two parameters):

  • ATTRS{idVendor}==”054c”
  • ATTRS{idProduct}==”0268″

these two parameters will do the work. so the new udev rule looks like this:

# cat /etc/udev/rules.d/99-myrules.rules
KERNEL==”event[0-9]*”, SYSFS{idVendor}==”054c”, SYSFS{idProduct}==”0268″, MODE=”0666″, GROUP=”games”, SYMLINK+=”eventPS3″
KERNEL==”js[0-9]*”, MODE=”0664′”, GROUP=”games”

WARNING: i named that file 11-myrules.rules with the result that the group was changed but never the mode so i wondered why. later i found out that there is some other rule which had overwritten the MODE but not the GROUP. (so i renamed it to 99-myrules.rules)
WARNING: using 0666 makes the GROUP=”games” useless since every user can attache that device now, you might want to add your local user to the ‘games’ group and change MODE=”0660″ instead

so after making changes to /etc/udev/rules.d one MUST NOT forget to do this:

udevadm trigger

this will reload the rules (and one of these rules we just changed). now replug your gamepad and see if the permissions were changed in /dev/input, probably with: ‘ls -la /dev/input’

ois packaging on gentoo

debugging ois is not easy if the software isn’t installed correctly. that is the case with the linux package since they don’t install

  • ConsoleApp – application to test input devices as (mouse/keyboard/gamepad/joystick)
  • FFConsoleTest – probably the same but this time with ‘force feedback’ support

this is again a complaint about package management…

ois concepts

ois is designed cross platform which is very good. ogre 3d can use ois and as far as i can tell the design of ois is sound. it does not detect my ps3 controller as a ‘force feedback’ device but i can live with that. what really bugs me is the fact that ois (same goes for libSDL) does not support device hotplugging – i’ve not tried on windows but i’m sure of linux and mac (since mac uses libSDL as backend currently).

every person who has once used a ps3 or a xbox knows how cool device hotplugging is!

there was a project for sdl to make device hot-plugging for linux work. however this was – if i recall correctly – not implemented into the library but instead the library was queried for a list of devices if the linux hardware abstraction layer (HAL) called a callback via dbus to notify of device changes. the new device was then opened as any normal joystick device using sdl.

what i want is different: i don’t want to use dbus in my application. and i don’t want to code like that. i just want to have a additional event which informs me about the state-change of currently opened joysticks (that is for instance js0 which is in use). right after it is unplugged my callback for new events (same goes if i poll the device every frame) i will receive the event that the device is now gone so i can close the device handler and the game could also react to it probably with a game pause or a screen showing: you don’t have any input device attached, can’t continue… please attache at least one device.

this way one could also switch from one player to two player mode or one could display a device manager dialog when plugging a second device… basically whatever you want to do.

device hotplugging is on the todo list for ‘sdl 1.3’. i wonder when that is released… (according to [2])

links

[1] http://sourceforge.net/projects/wgois/

[2] http://lists.libsdl.org/pipermail/sdl-libsdl.org/2009-January/068344.html

[3] http://raftaman.net/?p=343

[4] http://lastlog.de/wiki/index.php/Udev_permission

Read Full Post »

some updates about ogre 3d

  • 1.7 will have a samples browser
    i actually do hate the sample browser deployment as well as the concept it does implement. if one uses cmake and forgets to modify the ‘CMAKE_INSTALL_PREFIX’ but afterwars installs the library using ‘DESTDIR=/tmp make install’ nothing will work since all resources.cfg, plugins.cfg and media.cfg contain the wrong location and since the program is installed as root but executed as normal user it fails horribly when starting the SampleBrowser. but more important – since the sample browser loads the plugins as shared objects (for example ./lib/Sample_Water.so) the samples are degraded as ‘showcase’ only but can’t be used to play with directly as it requires a complicated installation mechanism. i see two fixes: either create another CMakeLists.txt which can build standalone runners for each sample or write a standalone runner for this create .so files. but in general i don’t like what they did, it degrades the quality of the samples since you have to run the SampleBrowser, find the plugin you want to have a look at and next you have to search the soure directory for the plugin.
    let’s see how the trolls (authors of qt) did that in comparison: they build standalone examples; they give you the source-code and the binary in one directory; they do code documentation based on a comment system which parses the example code.
  • 1.7 will use cmake for the ogre library (instead of autotools) -> i absolutely love this! this still has some quirks but i think it’s very good work!
  • using ogre disabled ‘key repeat’ every time i start my application, i need to type: ‘xset r on‘ to re-enable it. did not find out why…
    UPDATE: seems to be fixed in 1.7rc1
  • ogre displays a configurator everytime i start my application which configures the ogre ‘ogre.cfg’. this window shows up and since 1.7rc1 i  CAN NOT press ‘return’ directly to continue with the default settings – instead i have to click the ‘accept’ button with the mouse.  every time! this is VERY ANNOYING! maybe this has something todo with my ‘focus widget’ policy but since all other programs on my system work and especially since ogre 1.6 did work that way i wonder why this ‘ogre configuration widget’ does not have focus after i start my application…?
  • freeimage issue: the old ogre 1.6 had devil support but they probably dropped it (i’m not sure about that but i tried to find ‘devil’ in the source code (1.7rc1) but came up with only a few references, most were in the documentation) and therefore one needs freeimage for which i don’t even have an ebuild. so i installed freeimage and afterwards – once again – ogre. i basically compiled and installed ogre a couple of times to find that out – since freeimage is very important and without it no sample works and all you can see is this yello/black textures all over the place and some errors in the log which don’t make much sense without massive googling.
    why does the cmake script not stop with a BIG WARNING: you have samples enabled but freeimage wasn’t found instead the whole library can be built without support for the Media/ archives coming with the samples but then the samples are completely useless.
    not to forget: since ogre installed into /usr/local i needed to alter my /etc/ld.so.conf to reflect the new libOgreMain.so location (and others) and afterwards i had to run ldconfig as root (this is now done by the ebuild i wrote automatically)
  • i wanted to have a look at the samples (despite of naming them samples instead of examples one thinks they are of help). however all samples share one giant resource system. this might make sense at first however if you – the newcomer – don’t have any clue about unique namespaces in material scripts and textures and compositing of texutres using various vertex and fragment shaders renders the samples are pretty useless because of their complexity.
    i want simple samples which have all they need in ONE folder with a clean structure and NOT having to rely on external files which are referenced in mystical ways.

i’m not the only person who has serious problems getting ogre to work, see [1] and [2]. [2] is exactly what i meant by low quality downstream support.

AND before anyone asked, NO i did not fill any bug tracker. if you like to do that, please feel free to do so. i hate to waste my time using email and ‘gray listening’ , then after i get a login. i’ve filled quite some bugs on bug trackers but as long as they don’t provide a frontend i consider ‘usable’ i won’t fill any bugs anymore. i often don’t even know where to fill the bugs anyway since they have lots of things you have to fill in… waste of time

right now i’m going back to ogre 1.6 since ogre 1.7 gave me this error when compiling my project:

An exception has occurred: OGRE EXCEPTION(5:ItemIdentityException): Cannot find a group named debugger in ResourceGroupManager::isResourceGroupInitialised at /home/joachim/Desktop/projects/space-game/ogre/OgreMain/src/OgreResourceGroupManager.cpp (line 1880)

i have absolutely no clue what could cause this, i did not edit OgreResourceGroupManager.cpp at all. googling didn’t reveal anything and the really nice ppl on irc.freenode.org#ogre3d couldn’t help me either.

summary: working with ogre 3d does not make much fun currently

nvidia cg support in ogre

actually i did get the cg (nvidia shader stuff) running. i noticed that in plugins.cfg i had*:

#Plugin=Plugin_CgProgramManager.so

why does ogre say:

WARNING: material shader/ring has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program shader/gradientVP cannot be used – not supported.

instead of:

WARNING: you disabled cg support by not using any Plugin_CgProgramManager.so extension so no cg file will work for every use of cg

* this is because we use git and since the project was developed by me the nvidia user and seitz the ati user, he disabled the cg programmanger in his plugins.cfg, i probably updated the file without knowing that

ogre 3d 1.7rc1 ebuild

i’ve writte an ebuild for ogre 1.7rc1, it can be downloaded at [4], i copied some parts from [3] which was very helpful since i never did write an ebuild using cmake before.

i did not check the dependencies and they might probably be incomplete. if you want to use my ebuild you might just install ogre 1.6.5 with all use flags you want and then update to my package without cleaning ‘world dependencies’. also note that using my ebuild all samples will be built but the SampleBrowser binary and some others won’t be installed. i currently don’t understand why but the reason is that CMAKE_BUILD_TYPE=Gentoo is set but the CMakeLists.txt somehow expects CMAKE_BUILD_TYPE=RelWithDebInfo but i wasn’t able to overwrite that value with -D in the ebuild. i’ve asked in #gentoo-sunrise for support and they told me that this probably has to be fixed upstream. also don’t forget to install freeimage!

i did not upload that ebuild to bugs.gentoo.org – if you want to, please feel free to do so

links

[1] http://www.ogre3d.org/forums/viewtopic.php?f=2&t=54756&start=0

[2] http://gpnfn.blogspot.com/2010/01/building-cegui-ogre-renderer-in-gentoo.html

[3] http://aur.archlinux.org/packages/ogre/ogre/PKGBUILD

[4] http://lastlog.de/misc/ogre-1.7.0_rc1.ebuild

update

2010-02-20: my ebuild does not install the library as well (that is the .so files) so currently everything is built but both the library and the bin/* files are not installed

Documentation about this is in ‘/usr/portage/eclass/cmake-utils.eclass‘. About CMAKE_BUILD_TYPE=Gentoo i’d like to quote the cmake-utils.eclass comment:

# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type
# specific compiler flags overriding make.conf.

My current fix is to overwrite that buildtype with:

CMAKE_BUILD_TYPE=RelWithDebInfo just before src_configure()

NOTE: i’ve also updated the ebuild at [4]

Read Full Post »

ogre 3d

i’ve been using ogre 3d lately and here are some issues i had:

  • in gentoo there is no way to install ogre WITH the samples in one go, if one wants the samples as well one would have to install the library based from the source (bypassing the package manager) or hack the ebuild
  • to update ogre i had to uninstall ‘ogre’ with emerge -C ogre first and then install the new version with ‘emerge ogre‘ in a second go. if not done so ogre would screw up the build for some unknown reason?! if i recall correctly that was a linker issue
  • autotools is so ugly, i don’t see any way to compile the samples when not using ./configure from the base library directory which means also compiling all the library as well…
  • i think that writing all the ogre documentation must have taken a lot of time – and i honor that – but i prefer how the trolltech guys do  it. the trolls use a ‘incode documetation’ syntax (probably doxygen with some markup) and no external documentation. in contrast the ogre developers use a mixture of  mediawiki/html documetation/library doxygen/internal samples and external samples. if they would for instance only use templates in the wiki. currently not doing so makes it very confusing finding related things.
  • most of the ogre examples don’t include any screenshot of what is actually done, this makes searching much more ‘fun’…
  • they use autotools for the library and they use autotools for the samples. i used cmake for my project instead. since i don’t know much about autotools i had problems finding out what linker and compiler switches i needed and since my package manager removed all Makefiles after installation of the samples (or probably never build them at all) i had to do ugly things to find out how things work.
    FIX: so if you want to find that out i urge you to download the ogre release by hand (bypassing the package manager) and use ./configure; make, then have a look at the samples directory
  • the ‘package manager’ of gentoo (portage) has the latest ogre included but kubuntu didn’t, so we had to use the custom build script there by hand…
  • using the package manager of gentoo i set the useflag for double-precision which resulted in linker errors and also ‘our’ codebase which worked on a different machine using the custom build of ogre probably not using ‘double-precision’ at all using mesa for 3d rendering. but it did not work on my laptop after i removed the linker error. it just showed a black screen. took me hours to find out with lots of library recompiles…
  • the kubuntu defaults for the ogre library are acceptable but they had only a very old version in contrast gentoo didn’t provide good defaults since cg and devil was disabled but had a very recent version of ogre. funny, isn’t  it?
    this is how i have it working now:
    % equery u ogre
    [ Searching for packages matching ogre… ]
    [ Colour Code : set unset ]
    [ Legend : Left column  (U) – USE flags from make.conf              ]
    [        : Right column (I) – USE flags packages was installed with ]
    [ Found these USE variables for dev-games/ogre-1.6.5 ]
    U I
    + + cg               : NVIDIA toolkit plugin
    + + devil            : image loading support with DevIL
    + + doc              : Adds extra documentation (API, Javadoc, etc)
    – – double-precision : more precise calculations at the expense of speed
    + + examples         : Install examples, usually source code
    + + gtk              : Adds support for x11-libs/gtk+ (The GIMP Toolkit)
    + + threads          : Adds threads support for various packages. Usually pthreads
    you might wonder what that there is a ‘examples‘ use flag. but all it does it to install the example source but not the compiled examples NOR any Makefile, so …. again this autotools issue i don’t know how to compile it then… not in any documentation i could find either.
  • documentation how to use custom shaders is really missing in ogre, i managed to compile my own shader (cg file) with cgc (that is the nvidia shader compiler) but the library wasn’t able to use it no matter what i tried…
    it seems that most developers use windows and directX anyway which makes the situation on linux even worse.
  • in ogre one has several cfg files which are essential to run a sample application. but one has to create these files individually for every sample. so mixing a ‘package manager ogre library install’ with a ‘bypassing source ogre library build’ makes the situation even worse. the files are:
    • ogre.cfg (can be deleted, since it can be generated at program start with a gui)
    • plugins.cfg (i hate this file since it is required but no sample includes it after build), basically this file contains paths to shared objects .so files which are used by the ogre core backend
    • resources.cfg (this file contains a list of used textures, shaders and other graphics related stuff), this needs to be done per application. but there is a collection of Media files for the samples but the copyright is somehow strange since parts of it may not be redistributed…. so why do they included it at all?
  • ogre contains OIS for input handling but i couldn’t figure out how to get joystick support working. this probably might be broken completely. so instead of using OIS for joystick handling i had to include libSDL for that. i wrote a libSDL joystick example some time ago, can be found [1] on my wiki. i wonder what that joystick-support in OIS is all about…?
  • in general there are tutorials, about how to use ogre from an ide, in the wiki. there is also tutorials how to use ogre and how to import objects from blender and stuff. finding these resources is very time consuming. they have the tendency to be for ‘pro uses’ only and tend to be incomplete as well.
  • there is a ogre documentation which covers the basic concepts. i’ve been reading some stuff and it seems to be very good. however i can’t tell if it’s complete as my current use case is quite limited.

my project

you can find the code at [2]. but i’d like to warn you since:

  • we didn’t have much time so guess how the code looks
  • has no documentation
  • might not compile
  • voids many coding standards (especially c++ class/file naming schemes)

but still it might still be useful for some coders to look at, for instance the joystick integration or how i did use cmake with ogre…

so why do i write this post at all?

  • i hate the fact that there are multiple distributions – all factoring the same package of ogre – one more incomplete than the other….
  • the samples are not pre-built – if included at all
    i found a forum thread where developers did not see the samples as part of the ogre core distribution at all – how backward is that? examples and documentation is basically everything if one distributes a ‘library’!
  • the buildsystem of ogre and the samples is very confusing and badly documented
  • there is no qtdemo like program for ogre included, although there was a summer of code project assigned and completed recently, it’s refered as ‘sample interface’ and will be included in ogre 1.7 – i love that!
  • despite the fact that there is no ‘sample interface’ the samples are hard to build, no documentation about ‘how they can be built’ is included in the release

summary: i don’t like the way the documentation is handled in the ogre project and i don’t like the build system as well. my main criticism however is that the distributions do a very bad job at including the library (with all the samples missing & misc quirks).

possible fix: take a look at how trolltech did it with the qt release. they have assistant for the documentation (no need to open a webbrowser with a distribution specific installation of the doxygen and html documents). they have qtdemo and they build all the examples while also having the source around. they don’t have any external documentation as in a wiki for instance.

links

[1] http://lastlog.de/wiki/index.php/SDL-joystick

[2] http://github.com/qknight/space-game

[3] http://www.ogre3d.org/2009/08/27/google-summer-of-code-2009-projects-coding-time-is-up

Read Full Post »