Permalink
Browse files

Utility functions ftw

  • Loading branch information...
1 parent b8b9b7e commit 232ccbb79900253cb2690cb36564fe268486d28b Amos Wenger committed Mar 3, 2011
Showing with 42 additions and 16 deletions.
  1. +13 −2 README.md
  2. BIN screenshots/003-yi-vs-akali.png
  3. +17 −0 source/SKNLoader.cpp
  4. +3 −0 source/SKNLoader.h
  5. +9 −14 source/main.cpp
View
@@ -1,8 +1,19 @@
Raiders of Legend
------------------
+=================
+
+Description
+-----------
Ssshhhh. It's secret.
-hit make and pray, you need irrlicht-1.7.2 in the parent directory
+Instructions
+------------
+
+Hit make and pray, you need irrlicht-1.7.2 in the parent directory.
+
+Data files not included, find them and place them in data/ yourself :)
+
+Disclaimer
+----------
Don't sue me. It's a proof of concept.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -15,6 +15,11 @@ typedef struct SKNMaterial {
int startVertex, numVertices, startIndex, numIndices;
} SKNMaterial;
+ITexture *DDS_loadTexture(IVideoDriver* driver, char *texturePath) {
+ DdsImage *ddsImage = new DdsImage(texturePath, driver);
+ return driver->addTexture(texturePath, ddsImage->getImage());
+}
+
IMesh *SKN_load(char *path) {
FILE *file = fopen(path, "rb");
@@ -102,3 +107,15 @@ IMesh *SKN_load(char *path) {
return mesh;
}
+
+IMeshSceneNode* SKN_addCharacter(IVideoDriver* driver, ISceneManager* smgr, char *skinPath, char *texturePath) {
+
+ IMesh *mesh = SKN_load(skinPath);
+ IMeshSceneNode* node = smgr->addMeshSceneNode(mesh);
+ if (node) {
+ node->setMaterialFlag(EMF_LIGHTING, true);
+ node->setMaterialTexture(0, DDS_loadTexture(driver, texturePath));
+ }
+ return node;
+
+}
View
@@ -2,13 +2,16 @@
#define ROFL_SKNLoader_H
#include <irrlicht.h>
+#include "ddslib/DdsImage.h"
using namespace irr;
+using namespace irrutils;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
IMesh *SKN_load(char *path);
+IMeshSceneNode* SKN_addCharacter(IVideoDriver* driver, ISceneManager* smgr, char *skinPath, char *texturePath);
#endif // ROFL_SKNLoader_H
View
@@ -1,6 +1,5 @@
#include <irrlicht.h>
#include "SKNLoader.h"
-#include "ddslib/DdsImage.h"
using namespace irr;
using namespace irrutils;
@@ -41,27 +40,23 @@ int main() {
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
- smgr->setAmbientLight(SColorf(0.3,0.3,0.3,1));
+ smgr->setAmbientLight(SColorf(1.0, 1.0, 1.0, 1));
- IMesh *mesh = SKN_load("data/Characters/Akali/Akali.skn");
- IMeshSceneNode* node = smgr->addMeshSceneNode(mesh);
- if (node) {
- node->setMaterialFlag(EMF_LIGHTING, false);
-
- char *texturePath = "data/Characters/Akali/Akali_Red_TX_CM.dds";
- DdsImage *ddsImage = new DdsImage(texturePath, driver);
- ITexture *texture = driver->addTexture(texturePath, ddsImage->getImage());
- node->setMaterialTexture(0, texture);
- }
+ IMeshSceneNode *node = SKN_addCharacter(driver, smgr, "data/Characters/Akali/Akali.skn", "data/Characters/Akali/Akali_Red_TX_CM.dds");
+ node->setPosition(vector3df(-70, 0, 0));
+
+ IMeshSceneNode *node2 = SKN_addCharacter(driver, smgr, "data/Characters/MasterYi/MasterYi.skn", "data/Characters/MasterYi/AssassinMasterYi.dds");
+ node2->setPosition(vector3df(70, 0, 0));
- smgr->addCameraSceneNode(0, vector3df(0, 160, 150), vector3df(0, 150, 60));
+ smgr->addCameraSceneNode(0, vector3df(0, 150, 250), vector3df(0, 130, 60));
float angle = 0.0f;
while(device->run()) {
driver->beginScene(true, true, SColor(0, 0, 0, 0));
- node->setRotation(vector3df(0, angle, 0));
+ node-> setRotation(vector3df(0, angle, 0));
+ node2->setRotation(vector3df(0, angle, 0));
smgr->drawAll();
driver->endScene();

0 comments on commit 232ccbb

Please sign in to comment.