Inital Push

This commit is contained in:
Rubenwardy 2012-09-02 22:36:01 +01:00
commit c2417c9407
10 changed files with 491 additions and 0 deletions

22
.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

163
.gitignore vendored Normal file
View File

@ -0,0 +1,163 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover
## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
# Visual Studio profiler
*.psess
*.vsp
# ReSharper is a .NET coding add-in
_ReSharper*
# Installshield output folder
[Ee]xpress
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish
# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
############
## Windows
############
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
# Mac crap
.DS_Store

46
CommonFunctions.cpp Normal file
View File

@ -0,0 +1,46 @@
#include "define.h"
#include <iostream>
irr::core::vector3df* calcVectors(irr::io::IrrXMLReader* xml,const char* prefix){
std::cout << "calcVectors::Start" << std::endl;
char px[3];
char py[3];
char pz[3];
std::cout << "calcVectors::setting" << std::endl;
strcpy(px,prefix); // copy string one into the result.
strcpy(py,prefix);
strcpy(pz,prefix);
std::cout << "calcVectors::appending" << std::endl;
strcat(px,"x"); // append string two to the result.
strcat(py,"y");
strcat(pz,"z");
std::cout << "calcVectors::declaring v3df" << std::endl;
irr::core::vector3df* tmp;
std::cout << "calcVectors::reading xml" << std::endl;
tmp=new irr::core::vector3df(xml->getAttributeValueAsInt(px),xml->getAttributeValueAsInt(py),xml->getAttributeValueAsInt(pz));
std::cout << "calcVectors::End" << std::endl;
return tmp;
}
const wchar_t* convert(const char* input){
char* orig=(char*)input;
size_t origsize = strlen(orig) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
wcscat_s(wcstring, L"");
//outp=wcstring;
return wcstring;
}
char* convert(wchar_t* input){
char* tmp=new char();
wcstombs(tmp,input,0);
return tmp;
}

7
README.md Normal file
View File

@ -0,0 +1,7 @@
The NodeBox Generator
=====================
Currently Indevelopment
Copyright (c) 2012 to Andrew "rubenwardy" Ward

165
cEditor.cpp Normal file
View File

@ -0,0 +1,165 @@
#include "cEditor.h"
#include <iostream>
enum
{
GUI_ID_HELP=200,
GUI_ID_NEW=201,
GUI_ID_LOAD=202,
GUI_ID_SAVE=203,
GUI_ID_IMPORT=204,
GUI_ID_EXPORT=205,
GUI_ID_ADDNODE=206,
GUI_ID_SWITCH=207,
GUI_ID_BOX=208,
};
bool cEditor::run(IrrlichtDevice* irr_device){
// Get Pointers
device=irr_device;
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
loadUI();
coli=smgr->getSceneCollisionManager();
device->setWindowCaption(L"The NodeBox Generator");
device->setResizable(true);
//Add Camera and Pivot
pivot=smgr->addEmptySceneNode(0,199);
pivot->setPosition(vector3df(0,0,0));
camera=smgr->addCameraSceneNode(pivot,vector3df(0,0,-2));
camera->setTarget(vector3df(0,0,0));
//Add Light
ILightSceneNode* light=smgr->addLightSceneNode(0,vector3df(25,50,0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
//Add Plane
IMeshSceneNode* plane = smgr->addCubeSceneNode(1,0,-1,vector3df(0,-5.5,0),vector3df(0,0,0),vector3df(10,10,10));
plane->setMaterialTexture(0, driver->getTexture("default_grass.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10,10);
while (device->run()){
driver->beginScene(true, true, irr::video::SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
return true;
}
void cEditor::loadUI(){
std::cout << "Loading the User Interface" << std::endl;
guienv->clear();
// The Status Text
guienv->addStaticText(L"NodeBox: -",rect<s32>(5,20,100,35));
guienv->addStaticText(L"Position: - , - , -",rect<s32>(5,35,100,50));
guienv->addStaticText(L"Rotation: - , - , -",rect<s32>(5,50,100,65));
// The Menu
IGUIContextMenu* menubar=guienv->addMenu();
menubar->addItem(L"Node",-1,true,true);
menubar->addItem(L"Insert",-1,true,true);
menubar->addItem(L"Help",-1,true,true);
gui::IGUIContextMenu* submenu;
submenu = menubar->getSubMenu(0);
submenu->addItem(L"New",GUI_ID_NEW);
submenu->addItem(L"Load",GUI_ID_LOAD);
submenu->addItem(L"Save",GUI_ID_SAVE);
submenu->addSeparator();
submenu->addItem(L"Import",GUI_ID_IMPORT);
submenu->addItem(L"Export",GUI_ID_EXPORT);
submenu->addSeparator();
submenu->addItem(L"Add a Node",GUI_ID_ADDNODE);
submenu->addItem(L"Switch Node",GUI_ID_SWITCH);
submenu = menubar->getSubMenu(1);
submenu->addItem(L"Node Box",GUI_ID_BOX);
submenu = menubar->getSubMenu(2);
submenu->addItem(L"Help",GUI_ID_HELP);
submenu->addSeparator();
submenu->addItem(L"About");
}
bool cEditor::OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP ){
ISceneNode* hit=coli->getSceneNodeFromScreenCoordinatesBB(core::vector2d<s32>(event.MouseInput.X,event.MouseInput.Y));
if (hit==0){
std::cout << "No Nodes at that position" << std::endl;
}else{
nodes[curId];
}
}else if (event.EventType == EET_KEY_INPUT_EVENT){
if (event.KeyInput.Key== KEY_DOWN){
pivot->setRotation(vector3df(pivot->getRotation().X-1,pivot->getRotation().Y,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_UP){
pivot->setRotation(vector3df(pivot->getRotation().X+1,pivot->getRotation().Y,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_LEFT){
pivot->setRotation(vector3df(pivot->getRotation().X,pivot->getRotation().Y+1,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_RIGHT){
pivot->setRotation(vector3df(pivot->getRotation().X,pivot->getRotation().Y-1,pivot->getRotation().Z));
}
}else if (event.EventType == EET_GUI_EVENT){
irr::s32 id = event.GUIEvent.Caller->getID();
irr::gui::IGUIEnvironment* env = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_MENU_ITEM_SELECTED:
OnMenuItemSelected( (IGUIContextMenu*)event.GUIEvent.Caller );
break;
case irr::gui::EGET_BUTTON_CLICKED:
switch(id)
{
case 0:
break;
default:
return false;
}
break;
default:
break;
}
}
return false;
}
void cEditor::OnMenuItemSelected( IGUIContextMenu* menu )
{
s32 id = menu->getItemCommandId(menu->getSelectedItem());
IGUIEnvironment* env = device->getGUIEnvironment();
std::cout << "MenuItem Selected" << std::endl;
switch(id)
{
case GUI_ID_HELP:
std::cout << "--Help" << std::endl;
guienv->addMessageBox(L"Help",L"Use insert>node box to add a node box. Use arrows to move the selected box, and wasd to resize it.");
break;
case GUI_ID_BOX:
std::cout << "--Node Box Added" << std::endl;
smgr->addCubeSceneNode(1,0,-1,vector3df(0,0,0));
break;
}
}

26
cEditor.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _cEditor_h_included_
#define _cEditor_h_included_
#include "cNodes.h"
class cEditor : public IEventReceiver
{
public:
bool run(IrrlichtDevice* irr_device);
void loadUI();
virtual bool OnEvent(const SEvent& event);
private:
cNode* nodes[5];
int curId;
void OnMenuItemSelected(IGUIContextMenu* menu);
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
ISceneCollisionManager* coli;
IGUIEnvironment* guienv;
ISceneNode* pivot;
ICameraSceneNode* camera;
};
#endif

1
cNodes.cpp Normal file
View File

@ -0,0 +1 @@
#include "cNodes.h"

23
cNodes.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef _cNodes_h_included_
#define _cNodes_h_included_
#include <irrlicht.h>
#include "define.h"
using namespace irr;
using namespace gui;
using namespace scene;
using namespace core;
using namespace video;
class cNode
{
public:
bool load(wchar_t* input);
bool save(wchar_t* output);
bool switchFocus(ISceneNode* hit);
private:
};
#endif

8
define.h Normal file
View File

@ -0,0 +1,8 @@
#include <irrlicht.h>
//Convertors
const wchar_t* convert(const char* input); //Convertor: char to wchar_t
char* convert(wchar_t* input); //Convertor: wchar_t to char
//Other useful funcs
irr::core::vector3df* calcVectors(irr::io::IrrXMLReader* xml,const char* prefix);

30
main.cpp Normal file
View File

@ -0,0 +1,30 @@
// Copyright (c) to Andrew "rubenwardy" Ward
#include <irrlicht.h>
#include "define.h"
#include "cEditor.h"
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
using namespace irr;
using namespace gui;
using namespace scene;
using namespace core;
using namespace video;
bool main()
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Loading Engine...");
cEditor* editor=new cEditor();
device->setEventReceiver(editor);
editor->run(device);
}