Would you like to react to this message? Create an account in a few clicks or log in to continue.
Similar topics
Chat Box

User Yang Sedang Online
Total 2 uses online :: 0 Terdaftar, 0 Tersembunyi dan 2 Tamu

Tidak ada

[ View the whole list ]


User online terbanyak adalah 24 pada Mon Oct 04, 2010 10:03 am
Total Pengunjung
Website counter
Visitor
Code Static Geometry Labels=0

Code Static Geometry

2 posters

Go down

Code Static Geometry Empty Code Static Geometry

Post by risdo Tue May 04, 2010 1:44 pm

#include "ExampleApplication.h"

class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}

~TutorialApplication()
{
}
protected:
MeshPtr mGrassMesh;

void createGrassMesh()
{
const float width = 25;
const float height = 30;
ManualObject mo("GrassObject");

Vector3 vec(width/2, 0, 0);
Quaternion rot;
rot.FromAngleAxis(Degree(60), Vector3::UNIT_Y);

mo.begin("Examples/GrassBlades", RenderOperation::OT_TRIANGLE_LIST);
for (int i = 0; i < 3; ++i)
{
mo.position(-vec.x, height, -vec.z);
mo.textureCoord(0, 0);

mo.position(vec.x, height, vec.z);
mo.textureCoord(1, 0);

mo.position(-vec.x, 0, -vec.z);
mo.textureCoord(0, 1);

mo.position(vec.x, 0, vec.z);
mo.textureCoord(1, 1);

int offset = i * 4;
mo.triangle(offset, offset+3, offset+1);
mo.triangle(offset, offset+2, offset+3);

vec = rot * vec;
}
mo.end();

mo.convertToMesh("GrassBladesMesh");
}

void createScene(void)
{
createGrassMesh();
mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));

mCamera->setPosition(150, 50, 150);
mCamera->lookAt(0, 0, 0);

Entity *robot = mSceneMgr->createEntity("robot", "robot.mesh");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(robot);

Plane plane;
plane.normal = Vector3::UNIT_Y;
plane.d = 0;
MeshManager::getSingleton().createPlane("floor",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
450,450,10,10,true,1,50,50,Vector3::UNIT_Z);
Entity* pPlaneEnt = mSceneMgr->createEntity("plane", "floor");
pPlaneEnt->setMaterialName("Examples/GrassFloor");
pPlaneEnt->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);

Entity *grass = mSceneMgr->createEntity("grass", "GrassBladesMesh");
StaticGeometry *sg = mSceneMgr->createStaticGeometry("GrassArea");

const int size = 375;
const int amount = 20;

sg->setRegionDimensions(Vector3(size, size, size));
sg->setOrigin(Vector3(-size/2, 0, -size/2));

for (int x = -size/2; x < size/2; x += (size/amount))
for (int z = -size/2; z < size/2; z += (size/amount))
{
Real r = size / (float)amount / 2;
Vector3 pos(x + Math::RangeRandom(-r, r), 0, z + Math::RangeRandom(-r, r));
Vector3 scale(1, Math::RangeRandom(0.9, 1.1), 1);
Quaternion orientation;
orientation.FromAngleAxis(Degree(Math::RangeRandom(0, 359)), Vector3::UNIT_Y);

sg->addEntity(grass, pos, orientation, scale);
}

sg->build();
}
};

#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
TutorialApplication app;

try {
app.go();
} catch(Exception& e) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\\n",
e.getFullDescription().c_str());
#endif
}

return 0;
}
risdo
risdo
Admin
Admin

Posts : 209
Reputasi : 377
Cendol : 1
Join date : 26.10.09
Location : Bekasi

https://c0b4d1b4c4.indonesianforum.net

Kembali Ke Atas Go down

Code Static Geometry Empty Re: Code Static Geometry

Post by irfan Fri Mar 18, 2011 9:53 am

gan kalo code geometry yang gerak ada ga gan?
ane mnt donk source code+ langkah - langkahnya donk

irfan

Posts : 4
Reputasi : 4
Cendol : 0
Join date : 18.03.11

Kembali Ke Atas Go down

Code Static Geometry Empty Re: Code Static Geometry

Post by irfan Fri Mar 18, 2011 10:00 am

gan ane juga minta code stimulasi leading ama take off pesawat terbang ada ga gan??
ane bagi donk ...

irfan

Posts : 4
Reputasi : 4
Cendol : 0
Join date : 18.03.11

Kembali Ke Atas Go down

Code Static Geometry Empty Re: Code Static Geometry

Post by irfan Fri Mar 18, 2011 10:01 am

1 lagy gan ini w ada tugas grafkom lep
ane ambil judul Animasi Pengenalan Bangun Ruang
ada source code ma langkah - langkahnya ga?
thanks

irfan

Posts : 4
Reputasi : 4
Cendol : 0
Join date : 18.03.11

Kembali Ke Atas Go down

Code Static Geometry Empty Re: Code Static Geometry

Post by Sponsored content


Sponsored content


Kembali Ke Atas Go down

Kembali Ke Atas

- Similar topics

 
Permissions in this forum:
Anda tidak dapat menjawab topik