Archive for the ‘OGRE 3D’ Category




Right now i’m experimenting with Kinect to animate a 3D model or model skinning by using Kinect. To calculate the joint orientation, first i need to obtain the three orthonormal axes (X, Y, and Z) and create Quaternion to change every bone orientation. By this way, the noise produces by Kinect can be reduced and character movement can look smoother and independent from position. Another advantage of using joint orientation, character movement isn’t depended to body posture and model scaling.

More info and source code: http://code.google.com/p/ogrekinect/

Hi, it’s been long time since my last post. I’ve just finished a project titled “Launch Launch Launch Saturn V”.  I made this using OGRE 3D and Bullet Physics. Oh yeah, if you want to look at the code you can get it from google code: http://code.google.com/p/azbullet/

To get ray intersect on worldGeometry is can be read here (http://www.ogre3d.org/tikiwiki/Intermediate+Tutorial+2&structure=Tutorials), but if Terrain or TerrainGroup is used, the code will be slightly different:

Ogre::Vector3 camPos = mCamera->getPosition();
Ogre::Terrain* pTerrain = mTerrainGroup->getTerrain(0, 0);
Ogre::Ray mouseRay(Ogre::Vector3(camPos.x, 5000.0f, camPos.z), Ogre::Vector3::NEGATIVE_UNIT_Y);
std::pair <bool, Ogre::Vector3> test;
test = pTerrain->rayIntersects(mouseRay, true, 0);

if (test.first)
{
    // do something
}

On the code above, instead RaySceneQUery, RayIntersect is used, a variable std::pair <bool, Ogre::Vector3> is used to store value of RayIntersects function, use test.fisrt to check if the Ray intersect with terrain, and test.second to get intersection point of Vector3.

This article is small tips that can be used to debug Ogre Project. By using this std::cout can be used.

Open your project Properties, then on Configuration Properties -> Linker -> System, change value of SubSystem to Console (/SUBSYSTEM:CONSOLE).

Then on your source code change

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )

to this

int main()

The last step, add #include<iostream>

Precompiled header is used to boost build time since an OGRE project will take quite long time when it is compiled. A complete tutorial to build precompiled header can be found here. But additional configurations will be needed when Visual Studio 2010 is used.

Right click project -> Properties -> Configuration -> All Configuration, C/C++ -> Precompiled Headers, the configurations will be like this :

Try to build the project and errors will appear:

Right click project (again) -> Configuration -> Active (Debug), C/C++ -> Command Line, add “-Zm134” to Additional Options.

Program OGRE Saya yang Pertama

Posted: August 10, 2008 in OGRE 3D, Programming
Tags: , ,

Setelah dipelajari sampe otak panas, kemampuan OGRE saya yang nasibnya “gelap gak jelas” akhirnya menunjukkan titik terang….he he he

berikut ini aplikasi OGRE yang suderrrhana banget :)


#include 
#include 

class SampleApp : public ExampleApplication
{
public:
    // Basic constructor
    SampleApp()
    {}

protected:

    // Just override the mandatory create scene method
    void createScene(void)
    {
        // Create the SkyBox

        mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");  //latar langit

        // Create a light
        Light* myLight = mSceneMgr->createLight("Light0");
        myLight->setType(Light::LT_POINT);
        myLight->setPosition(0, 40, 0);
        myLight->setDiffuseColour(1, 1, 1);
        myLight->setSpecularColour(1, 1, 1);

        Entity *ent1 = mSceneMgr->createEntity( "Ogre", "ogrehead.mesh" );  //bikin objeknya (kepalanya ogre)
        SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreNode" );
        node1->attachObject( ent1 );

        Entity *ent2 = mSceneMgr->createEntity( "Ninja", "ninja.mesh" );  //bikin objek ninja
        SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "NinjaNode", Vector3( 50, 0, 1000 ) );  // letaknya x=50, y=0, z=1000
        node2->attachObject( ent2 );

        node2->scale( 5, 2, 3 ); // memanipulasi skala dari objek 3D

        //ent1->setVisible(false);  //disable tampilan

    }
};

// ----------------------------------------------------------------------------
// Main function, just boots the application object
// ----------------------------------------------------------------------------
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    // Create application object
    SampleApp app;

    try
    {
        app.go();
    }
    catch( Exception& e )
    {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else

        std::cerr << &quot;An exception has occured: &quot; <scale( 5, 2, 3 );
&#91;/sourcecode&#93;

gunanya adalah memanipulasi ukuran objek, kalau kita memperbesar skala y nanti karakter kita akan menjadi jangkung, bisa juga diubah jadi gendut atau pendek :)

Dalam OGRE, terdapat berbagai macam jenis vektor, yang saya bahas ini vektor 3D, nah, kalau sumbu x itu adalah garis dari sebelah kiri monitor sampai sebelah kanan monitor, subu y adalah bagian bawah monitor ke bagian atas monitor, sedangkan sumbu z berasal dari dalam monitor lalu ke luar monitor.

kalau kita mau merotasi objek pada sumbu x

&#91;sourcecode language='cpp'&#93;
node2->pitch( Degree( -90 ) );

kalau kita mau merotasi objek pada sumbu y

node1->yaw( Degree( -90 ) );

kalau kita mau merotasi objek pada sumbu z

node3->roll( Degree( -90 ) );

nih…screenshotnya:

Game Programming With OGRE 3D

Posted: August 8, 2008 in OGRE 3D, Programming
Tags: , ,

Ahh…apaan lagi ini? kali ini saya lagi membicarakan game programming, yep, saya pernah posting tentang Allegro, nah, setelah diberi tahu oleh teman, saya baru tahu kalau ada library grafis khusus untuk 3D, ya, library ini bernama OGRE 3D, atau singkatnya disebut OGRE saja (kepanjangannya sih Object-Oriented Graphics Rendering Engine). Library ini termasuk open source. O ya, library ini dikhususkan untuk bahasa C++, kalau C ? kayaknya tidak bisa karena diwajibkan untuk pemrograman berorientasi objek, untuk IDE-nya sendiri saya pake CodeBlocks+MinGw.

Awal pertama kali tahu tentang OGRE saya kayaknya mulai tertarik, wow, keren nih, soalnya kalau pake Allegro agak susah kalau pemrograman 3D-nya. Sebenarnya waktu itu saya ditawari teman untuk bikin proyek animasi dan game. Dia fokus ke desain 3D dan saya bagian programmingnya, menarik banget!

Pada saat tulisan ini ditulis–>kemampuan saya tentang OGRE masih nol besar, hahaha, cuman baru bisa compile doang, langkah awal saya belajar OGRE ya..baru menginstall aplikasi MinGw+CodeBlocks+OGRE,nah, pas dicoba compile aplikasi OGRE-nya, wah error! Katanya tidak diketemukan d3dx9d_30.dll. Wah bingung saya, kalo gak salah, d3dx9d_30.dll itu DirectX 10, nah saya tambah bingung, kan saya pakai Vista,sudah pasti ada DirectX 10-nya, tapi kok masi error aja ya? Wah terpaksa saya donwload d3dx9d_30.dll dari internet, awalnya saya pikir,bisa gak ya? Jangan-jangan d3dx9d_30.dll yang saya download palsu… Ah, mau gimana lagi, langsung saja d3dx9d_30.dll yang baru saya download kukopi ke folder OGRE-nya, dan..berhasil dicompile…..oke jeehhh…bisa! Moga-moga nanti gak ada error lagi gara-gara d3dx9d_30.dll yang didownload dari sumber yang tidak jelas.

Wew..kapan saya bisa jadi master OGRE? tunggu tanggal mainnya! hehehe….