ogre 3d animation
Download
Skip this Video
Download Presentation
Ogre 3D Animation

Loading in 2 Seconds...

play fullscreen
1 / 18

Ogre 3D Animation - PowerPoint PPT Presentation


  • 264 Views
  • Uploaded on

Ogre 3D Animation. Agung Toto Wibowo http://gameprogramming.blog.ittelkom.ac.id/blog/ Materi tutorial diambil dari wiki Ogre : http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials. Pendahuluan.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Ogre 3D Animation' - jania


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ogre 3d animation

Ogre 3D Animation

Agung Toto Wibowo

http://gameprogramming.blog.ittelkom.ac.id/blog/

Materi tutorial diambil dari wiki Ogre : http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials

pendahuluan
Pendahuluan
  • Di pelajaranini, padadasarnya Ogre tidakmembuatalgoritmauntukanimasidengansendirinya.
  • Animasidibuatdari 3D modelling tools yang lain seperti 3ds max, blender dlsb.
  • Yang dilakukanhanyamentranslasidanmerotasikanentitas yang memilikianimasi.
persiapan animasi
PersiapanAnimasi

using namespace std;

class MoveDemoListener : public ExampleFrameListener

{ public:

MoveDemoListener(RenderWindow* win, Camera* cam, SceneNode *sn, Entity *ent,

deque<Vector3> &walk)

: ExampleFrameListener(win, cam, false, false), mNode(sn), mEntity(ent), mWalkList(walk)

{ } // MoveDemoListener

/* This function is called to start the object moving to the next position

in mWalkList. */

boolnextLocation()

{ return true; } // nextLocation()

boolframeStarted(const FrameEvent &evt)

{ return ExampleFrameListener::frameStarted(evt); }

protected:

Real mDistance; // sisajarak yang masihharusditempuh

Vector3 mDirection, mDestination; // vektorarahdanlokasitujuan

AnimationState*mAnimationState; // State animasidariobjek

Entity *mEntity; // Entitas yang dianimasikan

SceneNode *mNode; // SceneNodetempat Entity diletakkan

std::deque<Vector3> mWalkList; // list lokasi yang akandilalui

Real mWalkSpeed; // kecepatanentitasberjalan

};

  • BuataplikasidengannamaOgre “MoveDemoApplication”

Extend ExampleFrameListener

Jalurpergerakananimasi

slide4

Persiapan Animasi

class MoveDemoApplication : public ExampleApplication

{

protected:

public:

MoveDemoApplication()

{ }

~MoveDemoApplication()

{ }

protected:

Entity *mEntity; // entitasdariobjek yang akandianimasikan

SceneNode *mNode; // SceneNodedari object yang bergerak

std::deque<Vector3> mWalkList; // deque yang berisititikpergerakan

void createScene(void)

{ }

void createFrameListener(void)

{

mFrameListener= new MoveDemoListener(mWindow, mCamera, mNode,

mEntity, mWalkList);

mFrameListener->showDebugOverlay(true);

mRoot->addFrameListener(mFrameListener);

}

};

skenario
Skenario
  • Kita letakkanobjek yang akanbergerak.
  • Kita letakkanobjek lain sebagaiacuan agar terlihatbahwaobjektelahbergerak.
  • Kita set list point pergerakanobjek.
  • Kita amatidengankameraberadadilokasi ideal.
meletakkan objek
MeletakkanObjek

Buatpencahayaanenvirontmentmenjaditerang

  • TambahkankodeberikutpadaMoveDemoApplication::createScene()

// Set the default lighting.

mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

// Create the entity

mEntity= mSceneMgr->createEntity("Robot", "robot.mesh");

// Create the scene node

mNode= mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode",

Vector3(0.0f, 0.0f, 25.0f));

mNode->attachObject(mEntity);

menambahkan list pergerakan
Menambahkan list pergerakan
  • TambahkankodeberikutpadaMoveDemoApplication::createScene()

// Create the walking list

mWalkList.push_back(Vector3(550.0f, 0.0f, 50.0f ));

mWalkList.push_back(Vector3(-100.0f, 0.0f, -200.0f));

// bisakitatambahkanlagisesukakita, ataudarihasilalgoritma A*

menambahkan objek lain acuan
MenambahkanObjek lain (acuan)
  • TambahkankodeberikutpadaMoveDemoApplication::createScene()

// Create objects so we can see movement

Entity *ent; SceneNode *node;

ent = mSceneMgr->createEntity("Knot1", "knot.mesh");

node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Knot1Node",

Vector3(0.0f, -10.0f, 25.0f));

node->attachObject(ent);

node->setScale(0.1f, 0.1f, 0.1f);

ent = mSceneMgr->createEntity("Knot2", "knot.mesh");

node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Knot2Node",

Vector3(550.0f, -10.0f, 50.0f));

node->attachObject(ent);

node->setScale(0.1f, 0.1f, 0.1f);

meletakkan kamera
MeletakkanKamera
  • TambahkankodeberikutpadaTutorialApplication:: createCamera()

// Set the camera to look at our handiwork

mCamera->setPosition(90.0f, 280.0f, 535.0f);

mCamera->pitch(Degree(-30.0f));

mCamera->yaw(Degree(-15.0f));

animasi
Animasi
  • TambahkankodeberikutpadakontructorMoveDemoListener

// Set idle animation

mAnimationState= ent->getAnimationState("Idle");

mAnimationState->setLoop(true);

mAnimationState->setEnabled(true);

  • Kompiledanjalankanaplikasi.

// perlukita update animationstatedenganevt.timeSinceLastFrame

// padaMoveDemoListener::frameStarted

mAnimationState->addTime(evt.timeSinceLastFrame);

menggerakkan robot
Menggerakkan Robot
  • Kita gantikonstruktorpadaMoveDemoListenerdengan

// Set default values for variables

mWalkSpeed= 35.0f; // kecepatanpergerakan

mDirection= Vector3::ZERO; // untuk status tidakbergerakkemanapun.

  • SedangpadaMoveDemoListener::frameStartedkitatambahkandengankodeberikut (sebelumAnimationState::addTime) :

if (mDirection == Vector3::ZERO)

{

if (nextLocation())

{

// Set walking animation

mAnimationState = mEntity->getAnimationState("Walk");

mAnimationState->setLoop(true);

mAnimationState->setEnabled(true);

}

}

mengimplementasikan nextlocation
MengimplementasikannextLocation()
  • nextLocationberfungsiuntukmengecekapakahobjekmasihmemiliki point untuktujuanpergerakanatautidak.
  • TambahkankodeberikutpadanextLocation()

if (mWalkList.empty())

return false;

mDestination= mWalkList.front(); // mengambilnilaiterdepandeque

mWalkList.pop_front(); // membuang front darideque

mDirection= mDestination - mNode->getPosition();

mDistance= mDirection.normalise();

// mengubaharahwajah robot

Vector3 src = mNode->getOrientation() * Vector3::UNIT_X;

Ogre::Quaternion quat = src.getRotationTo(mDirection);

mNode->rotate(quat);

kembali ke menggerakkan robot
Kembalikemenggerakkan Robot
  • Robot yang adabelumberjalan, meskianimasisudahberubah. Untukmembuat robot berjalan, kitatambahkankodeberikutpadaMoveDemoListener::frameStarted();

else

{

Real move = mWalkSpeed * evt.timeSinceLastFrame;

mDistance -= move;

if (mDistance <= 0.0f)

{

mNode->setPosition(mDestination);

mDirection = Vector3::ZERO;

// Set animation based on if the robot has another point to walk to.

if (! nextLocation())

{

// Set Idle animation

mAnimationState = mEntity->getAnimationState("Idle");

mAnimationState->setLoop(true);

mAnimationState->setEnabled(true);

}

kembali ke menggerakkan robot1
Kembalikemenggerakkan Robot
  • Lanjutan

else

{

// Rotation Code will go here later

}

}

else

{

mNode->translate(mDirection * move);

} // else

} // if

if (mWalkList.empty())

return false;

blender dan ogre 3d

Blender dan Ogre 3D

Agung Toto Wibowo

http://gameprogramming.blog.ittelkom.ac.id/blog/

Materi tutorial diambil dari wiki Ogre : http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials

blender dan ogre
Blender dan Ogre
  • Objek yang dibuatdi blender dapatdiloadke Ogre.
  • Format pada ogre *.mesh, blender *.blend
    • Butuhkonversi (meshes exporter) http://www.ogre3d.org/wiki/index.php/Blender_Exporter
    • Download danintegrasikan Blender Exporter.
    • Copy ogremeshesexporter.py dan subfolders kelokasi ...\blender\.blender\scripts.
    • Install Python 2.5.4 (ataulebihtinggi) yang dibutuhkanoleh exporter.
melihat hasil konversi
Melihathasilkonversi
  • Aplikasiceguimeshviewer
    • Informasilebihlanjutpada link : http://www.ogre3d.org/forums/viewtopic.php?p=136714
  • Mengintegrasikanlangsungkekode Ogre dengankode.
ad