initial commit

master
Glenn Engelbart 2013-09-29 12:32:06 -05:00
commit b05b6192f3
27 changed files with 2569 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

215
.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## 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/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# 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/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# 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
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

60
CMakeLists.txt Normal file
View File

@ -0,0 +1,60 @@
# Set up project
cmake_minimum_required(VERSION 2.6)
project(NodeBoxGenerator)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Dependancies
find_package(Irrlicht REQUIRED)
find_package(ZLIB REQUIRED)
find_package(X11 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(JPEG REQUIRED)
find_package(BZip2 REQUIRED)
find_package(PNG REQUIRED)
# Source files
set(NBGEN_SRC
main.cpp
Editor.cpp
Node.cpp
NBPropertiesDialog.cpp
CodeDialog.cpp
CommonFunctions.cpp
)
# Include Directories
include_directories(
${PROJECT_BINARY_DIR}
${IRRLICHT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${CMAKE_BUILD_TYPE}
${X11_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
)
add_executable(${PROJECT_NAME} ${NBGEN_SRC})
target_link_libraries(
${PROJECT_NAME}
${IRRLICHT_LIBRARY}
${ZLIB_LIBRARIES}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
${JPEG_LIBRARIES}
${BZIP2_LIBRARIES}
${PNG_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME NodeBoxGenerator
)
# Install DLLs
if(WIN32)
if(DEFINED IRRLICHT_DLL)
message(Installing irrlicht dll)
install(FILES ${IRRLICHT_DLL})
endif()
endif()

50
CodeDialog.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "CodeDialog.h"
CodeDialog::CodeDialog(IGUIEnvironment* guidevice, const wchar_t* input)
:save(NULL),guienv(guidevice)
{
win = guidevice->addWindow(rect<irr::s32>(50,50,50+320,50+360),false,L"Raw Code");
codebox = guidevice->addEditBox(input,rect<irr::s32>(10,30,310,310),true,win);
codebox->setMultiLine(true);
codebox->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
codebox->setToolTipText(L"Ctrl+A, Ctrl+C to copy");
guidevice->addButton(rect<irr::s32>(110,320,210,350),win,GUI_ID_SUBMIT,L"Save",L"Save the code to a file");
}
bool CodeDialog::OnEvent(const SEvent& event)
{
if (!win)
return false;
irr::s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
switch(id)
{
case 0:
break;
case GUI_ID_SUBMIT:
if (win && win->getElementFromId(GUI_ID_SUBMIT)==event.GUIEvent.Caller){
guienv->addMessageBox(L"Feature not implemented",L"Save feature not yet implemented");
}
break;
}
break;
case EGET_FILE_SELECTED:
//event.GUIEvent.Caller->gett
case EGET_FILE_CHOOSE_DIALOG_CANCELLED:
if (event.GUIEvent.Caller == save){
save = NULL;
}
break;
case EGDT_WINDOW_CLOSE:
if (event.GUIEvent.Caller == win){
win = NULL;
}
break;
}
return false;
}

17
CodeDialog.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _CODEDIALOG_H_INCLUDED_
#define _CODEDIALOG_H_INCLUDED_
#include "common.h"
class CodeDialog :public IEventReceiver
{
public:
CodeDialog(IGUIEnvironment* guidevice, const wchar_t* input);
virtual bool OnEvent(const SEvent& event);
private:
IGUIEnvironment* guienv;
IGUIWindow* win;
IGUIEditBox* codebox;
IGUIFileOpenDialog* save;
};
#endif

17
CommonFunctions.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "common.h"
const wchar_t* convert(const char* input){
#define MAXSIZE 1024
size_t origsize = strlen(input) + 1;
static wchar_t wcstring[MAXSIZE];
mbstowcs(wcstring, input, origsize);
wcscat(wcstring, L"");
return wcstring;
#undef MAXSIZE
}
char* convert(wchar_t* input){
char* tmp=new char();
wcstombs(tmp,input,0);
return tmp;
}

635
Editor.cpp Normal file
View File

@ -0,0 +1,635 @@
#include "Editor.h"
Editor::Editor()
:isSplitScreen(true),currentWindow(0),point_on(-1),mouse_down(false),KEY_MOVE_DOWN(false),KEY_SCALE_DOWN(false),menubar(NULL)
{
for (int i=0;i<4;i++){
camera[i]=NULL;
}
for (int i=0;i<12;i++){
points[i]=NULL;
}
menus = new list<IEventReceiver*>();
}
bool Editor::run(IrrlichtDevice* irr_device){
// Irrlicht Device
device=irr_device;
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
coli=smgr->getSceneCollisionManager();
device->setEventReceiver(this);
// Editor Settings
data=new ed_data();
data->snapping = true;
data->limiting = true;
data->type = TOOL_NODEB;
data->menu = NULL;
// Load editor
Load_Scene();
Load_UI();
// Create project
project = new Project();
project->nodes[0] = new Node(device,data);
MoveTarget(project->nodes[0]->getPosition());
// Set up window
device->setWindowCaption(convert((project->mod + stringc(" - The NodeBox Editor")).c_str()));
device->setResizable(true);
// Step data
unsigned int counter=0;
dimension2d<irr::u32> last_render_size = driver->getCurrentRenderTargetSize();
while (device->run()){
counter++;
driver->beginScene(true, true, irr::video::SColor(255,100,101,140));
int ResX = driver->getScreenSize().Width;
int ResY = driver->getScreenSize().Height;
if (isSplitScreen==true)
{
// Draw Camera 0
if (camera[0]){
smgr->setActiveCamera(camera[0]);
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
smgr->drawAll();
}
// Draw Camera 1
if (camera[1]){
smgr->setActiveCamera(camera[1]);
driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
smgr->drawAll();
updatePoint(0,5);
}
// Draw Camera 2
if (camera[2]){
smgr->setActiveCamera(camera[2]);
driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
smgr->drawAll();
updatePoint(5,10);
}
// Draw Camera 3
if (camera[3]){
smgr->setActiveCamera(camera[3]);
driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
smgr->drawAll();
updatePoint(10,15);
}
// Draw GUI
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
driver->draw2DLine(vector2d<irr::s32>(0,ResY/2),vector2d<irr::s32>(ResX,ResY/2),SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(0,ResY/2-1),vector2d<irr::s32>(ResX,ResY/2-1),SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(ResX/2,0),vector2d<irr::s32>(ResX/2,ResY),SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(ResX/2+1,0),vector2d<irr::s32>(ResX/2+1,ResY),SColor(175,255,255,255));
}else if (camera[currentWindow]){
smgr->setActiveCamera(camera[currentWindow]);
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
smgr->drawAll();
updatePoint(0,15);
}
guienv->drawAll();
driver->endScene();
if ( driver->getCurrentRenderTargetSize() != last_render_size){
printf("Adjusting FOV to new screen size...\n");
last_render_size = driver->getCurrentRenderTargetSize();
camera[0]->setAspectRatio((float)driver->getScreenSize().Width/(float)driver->getScreenSize().Height);
// reset matrix
matrix4 projMat;
irr::f32 orth_w = (float)driver->getScreenSize().Width / (float)driver->getScreenSize().Height;
orth_w = 3 * orth_w;
projMat.buildProjectionMatrixOrthoLH(orth_w,3,1,100);
for (int i=1;i<4;i++){
if (camera[i]){
camera[i]->remove();
camera[i]=NULL;
}
}
// Remake cameras
camera[1]=smgr->addCameraSceneNode(target,vector3df(0,2,-0.01),vector3df(0,0,0));
camera[1]->setProjectionMatrix(projMat,true);
camera[2]=smgr->addCameraSceneNode(target,vector3df(0,0,-5),vector3df(0,0,0));
camera[2]->setProjectionMatrix(projMat,true);
camera[3]=smgr->addCameraSceneNode(target,vector3df(-5,0,0),vector3df(0,0,0));
camera[3]->setProjectionMatrix(projMat,true);
}
if (counter>500){
counter=0;
if (project->GetCurNode())
project->GetCurNode()->update();
}
}
return true;
}
void Editor::Load_UI(){
std::cout << "Loading the User Interface" << std::endl;
guienv->clear();
guienv->getSkin()->setFont(guienv->getFont("fontlucida.png"));
// The Status Text
int tmp_b=driver->getScreenSize().Height-58;
data->d_nb=guienv->addStaticText(L"NodeBox: -",rect<s32>(5,tmp_b,200,tmp_b+15));
data->d_pos=guienv->addStaticText(L"One: - , - , -",rect<s32>(5,tmp_b+15,300,tmp_b+30));
data->d_rot=guienv->addStaticText(L"Two: - , - , -",rect<s32>(5,tmp_b+30,300,tmp_b+45));
data->d_nb->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
data->d_pos->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
data->d_rot->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
// The Menu
{
menubar=guienv->addMenu();
menubar->addItem(L"File",-1,true,true);
menubar->addItem(L"Edit",-1,true,true);
menubar->addItem(L"View",-1,true,true);
menubar->addItem(L"Project",-1,true,true);
menubar->addItem(L"Node",-1,true,true);
menubar->addItem(L"Help",-1,true,true);
gui::IGUIContextMenu* submenu;
// File
submenu = menubar->getSubMenu(0);
submenu->addItem(L"New",GUI_ID_NEW);
submenu->addItem(L"Load",GUI_ID_LOAD,false);
submenu->addItem(L"Save",GUI_ID_SAVE,false);
submenu->addSeparator();
submenu->addItem(L"Import",GUI_ID_IMPORT,false);
submenu->addItem(L"Export",-1,true,true);
submenu->addSeparator();
submenu->addItem(L"Exit",GUI_ID_EXIT);
// Export
submenu = submenu->getSubMenu(5);
if (submenu){
submenu->addItem(L"Project",GUI_ID_EX_PROJ);
submenu->addSeparator();
submenu->addItem(L"Entire Node",GUI_ID_EX_NODE);
submenu->addItem(L"Nodebox table",GUI_ID_EX_NBS);
submenu->addItem(L"Raw nodebox data",GUI_ID_EX_NB);
}
// Edit
submenu = menubar->getSubMenu(1);
submenu->addItem(L"Snap to grid",GUI_ID_SNAP,true,false,true,true);
submenu->addItem(L"Limit to node size",GUI_ID_LIMIT,true,false,true,true);
submenu->addSeparator();
submenu->addItem(L"Node creator tool",GUI_ID_TOOL_NNODE);
submenu->addItem(L"Node tool",GUI_ID_TOOL_NODE);
submenu->addItem(L"Nodebox tool",GUI_ID_TOOL_NODEB);
submenu->addItem(L"Texture tool",GUI_ID_TOOL_TEXT);
UpdateEditToolMode();
// View
submenu = menubar->getSubMenu(2);
submenu->addItem(L"Tiles",GUI_ID_SP_ALL);
submenu->addSeparator();
submenu->addItem(L"Perspective",GUI_ID_SP_PER);
submenu->addItem(L"Top",GUI_ID_SP_TOP);
submenu->addItem(L"Front",GUI_ID_SP_FRT);
submenu->addItem(L"Right",GUI_ID_SP_RHT);
// Project
submenu = menubar->getSubMenu(3);
submenu->addItem(L"Add a Node",GUI_ID_ADDNODE,false);
submenu->addItem(L"Switch Node",GUI_ID_SWITCH,false);
// Node
submenu = menubar->getSubMenu(4);
submenu->removeAllItems();
submenu->addItem(L"Node properties",-1,false);
submenu->addSeparator();
submenu->addItem(L"Add a nodebox",GUI_ID_BOX);
submenu->addItem(L"Nodebox properties",GUI_ID_TEXT);
submenu->addItem(L"Delete current nodebox",GUI_ID_DELETENB);
data->menu = submenu;
// Help
submenu = menubar->getSubMenu(5);
submenu->addItem(L"Help",GUI_ID_HELP,false);
submenu->addSeparator();
submenu->addItem(L"About",GUI_ID_ABOUT);
}
// CDRs
{
// Add Topdown camera's CDRs
addPoint(0,CDR_Z_P,1);
addPoint(1,CDR_X_N,1);
addPoint(2,CDR_X_P,1);
addPoint(3,CDR_Z_N,1);
addPoint(4,CDR_XZ,1);
// Add front camera's CDRs
addPoint(5,CDR_Y_P,2);
addPoint(6,CDR_X_N,2);
addPoint(7,CDR_X_P,2);
addPoint(8,CDR_Y_N,2);
addPoint(9,CDR_XY,1);
// Add side camera's CDRs
addPoint(10,CDR_Y_P,3);
addPoint(11,CDR_Z_P,3);
addPoint(12,CDR_Z_N,3);
addPoint(13,CDR_Y_N,3);
addPoint(14,CDR_ZY,1);
}
}
void Editor::Load_Scene(){
// Calculate Projection Matrix
matrix4 projMat;
irr::f32 orth_w = (float)driver->getScreenSize().Width / (float)driver->getScreenSize().Height;
orth_w = 3 * orth_w;
projMat.buildProjectionMatrixOrthoLH(orth_w,3,1,100);
// Create target
target = smgr->addEmptySceneNode(0,200);
target->setPosition(vector3df(0,0,0));
// Add rotational camera
pivot=smgr->addEmptySceneNode(target,199);
camera[0]=smgr->addCameraSceneNode(NULL,vector3df(0,0,-2),vector3df(0,0,0));
camera[0]->setParent(pivot);
pivot->setRotation(vector3df(25,-45,0));
// Add Topdown camera
camera[1]=smgr->addCameraSceneNode(target,vector3df(0,2,-0.01),vector3df(0,0,0));
camera[1]->setProjectionMatrix(projMat,true);
// Add front camera
camera[2]=smgr->addCameraSceneNode(target,vector3df(0,0,-5),vector3df(0,0,0));
camera[2]->setProjectionMatrix(projMat,true);
// Add side camera
camera[3]=smgr->addCameraSceneNode(target,vector3df(-5,0,0));
camera[3]->setProjectionMatrix(projMat,true);
// Add Light
ILightSceneNode* light=smgr->addLightSceneNode(target,vector3df(25,50,0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
// Add Plane
IMeshSceneNode* plane = smgr->addCubeSceneNode(1,0,-1,vector3df(0.5,-5.5,0.5),vector3df(0,0,0),vector3df(10,10,10));
plane->setMaterialTexture(0, driver->getTexture("texture_terrain.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10,10);
// Add sky box
scene::IMeshSceneNode* skybox=smgr->addCubeSceneNode(50);
skybox->setMaterialTexture(0, driver->getTexture("sky.jpg"));
skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
skybox->setMaterialFlag(video::EMF_LIGHTING,false);
smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh());
plane_tri=smgr->createOctreeTriangleSelector(skybox->getMesh(),skybox);
}
bool Editor::OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP ){
mouse_down=false;
// drop scale drag point
if (point_on != -1)
point_on = -1;
}else if (event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ){
mouse_down=true;
}else if (event.EventType == irr::EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_MOUSE_MOVED ){
mouse_position.X=event.MouseInput.X;
mouse_position.Y=event.MouseInput.Y;
}else if (event.EventType == EET_KEY_INPUT_EVENT){
printf("key down %i \n",event.KeyInput.Key);
if (event.KeyInput.Key== KEY_DOWN || event.KeyInput.Key== KEY_KEY_S){
pivot->setRotation(vector3df(pivot->getRotation().X-1,pivot->getRotation().Y,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_UP || event.KeyInput.Key== KEY_KEY_W){
pivot->setRotation(vector3df(pivot->getRotation().X+1,pivot->getRotation().Y,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_LEFT || event.KeyInput.Key== KEY_KEY_A){
pivot->setRotation(vector3df(pivot->getRotation().X,pivot->getRotation().Y+1,pivot->getRotation().Z));
}else if (event.KeyInput.Key== KEY_RIGHT || event.KeyInput.Key== KEY_KEY_D){
pivot->setRotation(vector3df(pivot->getRotation().X,pivot->getRotation().Y-1,pivot->getRotation().Z));
}else if (event.KeyInput.Key == 162){
printf("cntrl toggle\n");
KEY_SCALE_DOWN = event.KeyInput.PressedDown;
}else if (event.KeyInput.Key == 160){
printf("shift toggle\n");
KEY_MOVE_DOWN = event.KeyInput.PressedDown;
}
}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 EGET_ELEMENT_LEFT:
if (id > 299 && id < 324){
if (mouse_down == true && point_on == -1){
printf("Selected scaler id %i\n",id);
point_on = id - 300;
}
}
break;
case EGET_MESSAGEBOX_OK:
if (event.GUIEvent.Caller->getID()==GUI_ID_NEW){
printf("New project...\n");
delete project;
project = new Project();
project->nodes[0] = new Node(device,data);
MoveTarget(project->nodes[0]->getPosition());
}else if (event.GUIEvent.Caller->getID()==GUI_ID_EXIT){
printf("Exiting...\n");
device->closeDevice();
}
break;
}
for(list<IEventReceiver*>::Iterator Iterator = menus->begin(); Iterator != menus->end(); ++Iterator)
{
IEventReceiver* m = *Iterator;
if (m && m->OnEvent(event)==true)
return true;
}
}
return false;
}
void Editor::OnMenuItemSelected( IGUIContextMenu* menu )
{
s32 id = menu->getItemCommandId(menu->getSelectedItem());
IGUIEnvironment* env = device->getGUIEnvironment();
switch(id)
{
case GUI_ID_NEW:
guienv->addMessageBox(L"Are you sure?",L"You will lose all unsaved changes.",true,(EMBF_OK|EMBF_CANCEL),0,GUI_ID_NEW);
break;
case GUI_ID_EXIT:
guienv->addMessageBox(L"Are you sure?",L"You will lose all unsaved changes.",true,(EMBF_OK|EMBF_CANCEL),0,GUI_ID_EXIT);
break;
case GUI_ID_EX_NODE:
{
stringc* res = project->GetCurNode()->build(NBT_FULL);
menus->push_back(new CodeDialog(guienv,convert(res->c_str())));
}
break;
case GUI_ID_EX_NBS:
{
stringc* res = project->GetCurNode()->build(NBT_NBS);
menus->push_back(new CodeDialog(guienv,convert(res->c_str())));
}
break;
case GUI_ID_EX_NB:
{
stringc* res = project->GetCurNode()->build(NBT_NB);
menus->push_back(new CodeDialog(guienv,convert(res->c_str())));
}
break;
case GUI_ID_TEXT:
menus->push_back(new NBPropertiesDialog(guienv,project->GetCurNode()->GetCurrentNodeBox(),project->GetCurNode()));
break;
case GUI_ID_DELETENB:
project->GetCurNode()->deleteNodebox(project->GetCurNode()->GetId());
break;
case GUI_ID_BOX:
project->GetCurNode()->addNodeBox();
break;
case GUI_ID_ABOUT:
{
core::stringw* msg = new core::stringw(L"The Nodebox Editor\n");
msg->append("Version: ");
msg->append(EDITOR_TEXT_VERSION);
msg->append("\n\n");
msg->append("This free nodebox editor was made by Rubenwardy in C++ and Irrlicht.\n");
msg->append("You can download newer versions from the Minetest forum.");
guienv->addMessageBox(L"About",msg->c_str());
}
break;
case GUI_ID_SP_ALL:
printf("View mode changed to tiles\n");
isSplitScreen=true;
currentWindow=0;
break;
case GUI_ID_SP_PER:
printf("View mode changed to perspective\n");
isSplitScreen=false;
currentWindow=0;
break;
case GUI_ID_SP_TOP:
printf("View mode changed to top\n");
isSplitScreen=false;
currentWindow=1;
break;
case GUI_ID_SP_FRT:
printf("View mode changed to front\n");
isSplitScreen=false;
currentWindow=2;
break;
case GUI_ID_SP_RHT:
printf("View mode changed to right\n");
isSplitScreen=false;
currentWindow=3;
break;
case GUI_ID_SNAP:
data->snapping = menu->isItemChecked(menu->getSelectedItem());
break;
case GUI_ID_LIMIT:
data->limiting = menu->isItemChecked(menu->getSelectedItem());
break;
case GUI_ID_TOOL_NNODE:
data->type = TOOL_NEWNODE;
UpdateEditToolMode();
break;
case GUI_ID_TOOL_NODE:
data->type = TOOL_NODE;
UpdateEditToolMode();
break;
case GUI_ID_TOOL_NODEB:
data->type = TOOL_NODEB;
UpdateEditToolMode();
break;
case GUI_ID_TOOL_TEXT:
data->type = TOOL_TEXT;
UpdateEditToolMode();
break;
default:
if (id>=250){
int i = id - 250;
project->GetCurNode()->select(i);
}
}
}
void Editor::UpdateEditToolMode(){
gui::IGUIContextMenu* submenu = menubar->getSubMenu(1);
submenu->setItemChecked(3,(data->type==TOOL_NEWNODE));
submenu->setItemChecked(4,(data->type==TOOL_NODE));
submenu->setItemChecked(5,(data->type==TOOL_NODEB));
submenu->setItemChecked(6,(data->type==TOOL_TEXT));
}
void Editor::updatePoint(int start, int count){
for (int id=start;id<count;id++){
if (!points[id])
continue;
bool visible = (
project->GetCurNode() &&
data->type == TOOL_NODEB &&
project->GetCurNode()->GetCurrentNodeBox()!=NULL &&
(isSplitScreen==true || currentWindow==points[id]->camera) &&
((KEY_MOVE_DOWN==false && points[id]->type < CDR_XZ) || (KEY_MOVE_DOWN==true && points[id]->type > CDR_Z_N))
);
points[id] -> image -> setVisible (visible);
if (!visible)
continue;
if (point_on == id){
// get mouse position
position2di target = mouse_position;
target.X -= 5;
target.Y -= 5;
// correct out of bounds
if (target.X < driver->getViewPort().UpperLeftCorner.X){
target.X = driver->getViewPort().UpperLeftCorner.X-5;
}else if (target.X > driver->getViewPort().LowerRightCorner.X){
target.X = driver->getViewPort().LowerRightCorner.X-5;
}
if (target.Y < driver->getViewPort().UpperLeftCorner.Y){
target.Y = driver->getViewPort().UpperLeftCorner.Y-5;
}else if (target.Y > driver->getViewPort().LowerRightCorner.Y){
target.Y = driver->getViewPort().LowerRightCorner.Y-5;
}
// set image location
points[id] -> image -> setRelativePosition(target);
position2di tar2 = target;
tar2.X -= driver->getViewPort().UpperLeftCorner.X - 5;
tar2.Y -= driver->getViewPort().UpperLeftCorner.Y - 5;
// get the ray
line3d<irr::f32> ray = coli -> getRayFromScreenCoordinates(tar2,smgr->getActiveCamera());
// contains the output values
vector3df wpos = vector3df(0,0,0); // the collision position
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
const ISceneNode* tmpNode; // not needed, but required for function
#else
ISceneNode* tmpNode; // not needed, but required for function
#endif
triangle3df tmpTri; // not needed, but required for function
// Execute ray
coli->getCollisionPoint(ray,plane_tri,wpos,tmpTri,tmpNode);
// Call required function
if (points[id]->type < CDR_XZ){
project->GetCurNode()->resizeNodeBoxFace(points[id]->type,wpos,KEY_SCALE_DOWN);
}else{
project->GetCurNode()->moveNodeBox(points[id]->type,wpos);
}
}else{
vector3df position;
switch (points[id]->type){
case CDR_X_P:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.X = project->GetCurNode()->GetCurrentNodeBox()->two.X;
break;
case CDR_X_N:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.X = project->GetCurNode()->GetCurrentNodeBox()->one.X;
break;
case CDR_Y_P:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.Y = project->GetCurNode()->GetCurrentNodeBox()->two.Y;
break;
case CDR_Y_N:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.Y = project->GetCurNode()->GetCurrentNodeBox()->one.Y;
break;
case CDR_Z_P:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.Z = project->GetCurNode()->GetCurrentNodeBox()->two.Z;
break;
case CDR_Z_N:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
position.Z = project->GetCurNode()->GetCurrentNodeBox()->one.Z;
break;
case CDR_XZ:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
break;
case CDR_XY:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
break;
case CDR_ZY:
position = project->GetCurNode()->GetCurrentNodeBox()->GetCenter();
break;
}
position.X+=project->GetCurNode()->getPosition().X;
position.Y+=project->GetCurNode()->getPosition().Y;
position.Z+=project->GetCurNode()->getPosition().Z;
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
vector2d<irr::s32> cpos = coli -> getScreenCoordinatesFrom3DPosition(position,smgr->getActiveCamera());
#else
vector2d<irr::s32> cpos = coli -> getScreenCoordinatesFrom3DPosition(position,smgr->getActiveCamera(),true);
#endif
points[id] -> image -> setRelativePosition(position2di(driver->getViewPort().UpperLeftCorner.X+cpos.X-5, driver->getViewPort().UpperLeftCorner.Y+cpos.Y-5));
}
}
}
void Editor::addPoint(int id, CDR_TYPE type, int camera){
points[id] = new CDR();
points[id] -> type = type;
points[id] -> camera = camera;
points[id] -> image = guienv->addImage(rect<irr::s32>(0,0,10,10),NULL,300+id);
points[id] -> image -> setImage(driver->getTexture("gui_scale.png"));
points[id] -> image -> setVisible (false);
}
void Editor::MoveTarget(vector3df pos){
target->setPosition(pos);
for (int i=0;i<4;i++){
camera[i]->setTarget(pos);
}
}

66
Editor.h Normal file
View File

@ -0,0 +1,66 @@
#ifndef _EDITOR_H_INCLUDED_
#define _EDITOR_H_INCLUDED_
#include "common.h"
#include "Project.h"
#include "NBPropertiesDialog.h"
#include "CodeDialog.h"
class Editor : public IEventReceiver
{
public:
Editor();
// Run the editor
bool run(IrrlichtDevice* irr_device);
// Load the GUI
void Load_UI();
void Load_Scene();
// OnEvent handler
virtual bool OnEvent(const SEvent& event);
private:
// Current project
Project* project;
// Handle MenuItem Selection
void OnMenuItemSelected(IGUIContextMenu* menu);
// Label data
ed_data* data;
// Hold Irrlicht Stuff
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
ISceneCollisionManager* coli;
// GUI
IGUIEnvironment* guienv;
bool isSplitScreen;
int currentWindow;
vector2di mouse_position;
bool mouse_down;
bool KEY_MOVE_DOWN;
bool KEY_SCALE_DOWN;
ITriangleSelector* plane_tri;
list<IEventReceiver*>* menus;
void UpdateEditToolMode();
IGUIContextMenu* menubar;
// Hold Navigation
ISceneNode* target;
ISceneNode* pivot;
ICameraSceneNode* camera[4];
bool allow_input;
// Points and Scalers
CDR* points[16];
int point_on;
void updatePoint(int start, int count);
void addPoint(int id, CDR_TYPE type, int camera);
void MoveTarget(vector3df pos);
};
#endif

BIN
Irrlicht.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
# :mode=makefile:noTabs=false:
nbgen: main.o Editor.o Node.o NBPropertiesDialog.o CodeDialog.cpp CommonFunctions.o
g++ -o nbgen main.o Editor.o Node.o NBPropertiesDialog.o CodeDialog.cpp CommonFunctions.o -lIrrlicht
%.o: %.cpp
g++ -I/usr/include/irrlicht -o $@ -c $<

78
NBPropertiesDialog.cpp Normal file
View File

@ -0,0 +1,78 @@
#include "NBPropertiesDialog.h"
#include <wchar.h>
NBPropertiesDialog::NBPropertiesDialog(IGUIEnvironment* guidevice, NodeBox* box, Node* node)
:guienv(guidevice),nodebox(box),_node(node)
{
if (!guienv || !nodebox || !_node){
win = 0;
return;
}
win = guienv->addWindow(rect<irr::s32>(50,50,50+320,50+162),false,L"Properties");
guienv->addEditBox(box->name.c_str(),rect<irr::s32>(32,32,290,52),true,win,GUI_ID_BOX_NAME);
// Add the co-ordinate boxes
{
guienv->addEditBox(convert(stringc(nodebox->one.X).c_str()),rect<irr::s32>(32,60,112,80),true,win,230);
guienv->addEditBox(convert(stringc(nodebox->one.Y).c_str()),rect<irr::s32>(32+90,60,112+90,80),true,win,231);
guienv->addEditBox(convert(stringc(nodebox->one.Z).c_str()),rect<irr::s32>(32+180,60,112+180,80),true,win,232);
guienv->addEditBox(convert(stringc(nodebox->two.X).c_str()),rect<irr::s32>(32,60+30,112,80+30),true,win,233);
guienv->addEditBox(convert(stringc(nodebox->two.Y).c_str()),rect<irr::s32>(32+90,60+30,112+90,80+30),true,win,234);
guienv->addEditBox(convert(stringc(nodebox->two.Z).c_str()),rect<irr::s32>(32+180,60+30,112+180,80+30),true,win,235);
}
guienv->addButton(rect<irr::s32>(100,120,220,152),win,GUI_ID_SUBMIT,L"Save");
}
bool NBPropertiesDialog::OnEvent(const SEvent& event)
{
if (!win)
return false;
irr::s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
switch(id)
{
case 0:
break;
case GUI_ID_SUBMIT:
save(event.GUIEvent.Caller);
break;
}
break;
case EGDT_WINDOW_CLOSE:
if (event.GUIEvent.Caller == win){
win = NULL;
}
break;
}
return false;
}
void NBPropertiesDialog::save(IGUIElement* button){
if (win && win->getElementFromId(GUI_ID_SUBMIT)==button){
printf("Submitting Properties \n");
// Set name
nodebox->name = win->getElementFromId(GUI_ID_BOX_NAME)->getText();
// Set one
nodebox->one.X = wcstod(win->getElementFromId(230)->getText(),NULL);
nodebox->one.Y = wcstod(win->getElementFromId(231)->getText(),NULL);
nodebox->one.Z = wcstod(win->getElementFromId(232)->getText(),NULL);
// Set two
nodebox->two.X = wcstod(win->getElementFromId(233)->getText(),NULL);
nodebox->two.Y = wcstod(win->getElementFromId(234)->getText(),NULL);
nodebox->two.Z = wcstod(win->getElementFromId(235)->getText(),NULL);
// Recreate node mesh
_node->remesh();
_node->defrag();
}
}

19
NBPropertiesDialog.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef _NBPropertiesDialog_H_INCLUDED_
#define _NBPropertiesDialog_H_INCLUDED_
#include "common.h"
#include "Node.h"
class NBPropertiesDialog :public IEventReceiver
{
public:
NBPropertiesDialog(IGUIEnvironment* guidevice, NodeBox* box, Node* node);
virtual bool OnEvent(const SEvent& event);
void save(IGUIElement* button);
private:
IGUIEnvironment* guienv;
IGUIWindow* win;
Node* _node;
NodeBox* nodebox;
};
#endif

518
Node.cpp Normal file
View File

@ -0,0 +1,518 @@
#include "Node.h"
// Construction / Destruction
Node::Node(IrrlichtDevice* mdevice, ed_data* n_ed)
:device(mdevice),editor(n_ed),_id(0),number(0)
{
driver = device->getVideoDriver();
smgr = device->getSceneManager();
nd_position = vector3df(0,0,0);
for (int i=0;i<NODEB_MAX;i++){
boxes[i]=NULL;
}
for (int i=0;i<17;i++){
snappers[i]=NULL;
}
printf("Making 16 pixel snap grid: \n");
for (int a=-(NODE_RES/2);a<(NODE_RES/2)+1;a++){
snappers[a+(NODE_RES/2)] = a*((float)1/(float)NODE_RES);
printf(">> %f\n",snappers[a+8]);
}
defrag();
}
Node::~Node(){
for (int i=0;i<NODEB_MAX;i++){
if (boxes[i])
delete boxes[i];
}
}
// Get functions
int Node::GetId(){
return _id;
}
NodeBox* Node::GetCurrentNodeBox(){
return GetNodeBox(GetId());
}
NodeBox* Node::GetNodeBox(int id){
return boxes[id];
}
// Operation functions
NodeBox* Node::addNodeBox(){
if (!number)
number = 0;
// Name it
core::stringw nb=L"NodeBox ";
nb+=(number+1);
// Set up structure
NodeBox* tmp =new NodeBox(nb,vector3df(0,-0.5,-0.5),vector3df(0.5,0.5,0.5));
if (!tmp)
return NULL;
boxes[number] = tmp;
select(number);
update(number);
// Increment and print message
number++;
printf("Nodebox added\n");
// Clean up list
defrag();
return tmp;
}
void Node::select(int id){
_id = id;
}
void Node::update(){
if (editor->type==TOOL_NODEB){
if (GetCurrentNodeBox() && number>GetId()){
NodeBox* tmp = GetCurrentNodeBox();
// Name label
core::stringw nb=L"NodeBox: ";
nb+=tmp->name;
editor->d_nb->setText(nb.c_str());
// One label
core::stringw ps=L"One: ";
ps+=tmp->one.X;
ps+=" , ";
ps+=tmp->one.Y;
ps+=" , ";
ps+=tmp->one.Z;
editor->d_pos->setText(ps.c_str());
// Two label
core::stringw rt=L"Two: ";
rt+=tmp->two.X;
rt+=" , ";
rt+=tmp->two.Y;
rt+=" , ";
rt+=tmp->two.Z;
editor->d_rot->setText(rt.c_str());
}else{
editor->d_nb->setText(L"NodeBox: -");
editor->d_pos->setText(L"One: - , - , -");
editor->d_rot->setText(L"Two: - , - , -");
}
}else if (editor->type==TOOL_NODE){
editor->d_nb->setText(L"Node: -");
editor->d_pos->setText(L"Type: -");
editor->d_rot->setText(L"Boxes: -");
}else{
editor->d_nb->setText(L"EDITOR MODE UNAVAILABLE");
editor->d_pos->setText(L"This tool has not yet been coded.");
editor->d_rot->setText(L"Use a newer version if available.");
return;
}
}
void Node::resizeNodeBoxFace(CDR_TYPE type,vector3df position,bool both){
NodeBox* node = GetCurrentNodeBox();
if (!node)
return;
position.X-=getPosition().X;
position.Y-=getPosition().Y;
position.Z-=getPosition().Z;
// Do snapping
if (editor->snapping==true){
for (int i=0;i<15;i++){
if (position.X > snappers[i]-0.0313 && position.X < snappers[i]+0.0313){
position.X = snappers[i];
}
if (position.Y > snappers[i]-0.0313 && position.Y < snappers[i]+0.0313){
position.Y = snappers[i];
}
if (position.Z > snappers[i]-0.0313 && position.Z < snappers[i]+0.0313){
position.Z = snappers[i];
}
}
}
// Do node limiting
if (editor->limiting==true){
// X Axis
if (position.X < -0.5)
position.X = -0.5;
else if (position.X > 0.5)
position.X = 0.5;
// Y Axis
if (position.Y < -0.5)
position.Y = -0.5;
else if (position.Y > 0.5)
position.Y = 0.5;
// Z Axis
if (position.Z < -0.5)
position.Z = -0.5;
else if (position.Z > 0.5)
position.Z = 0.5;
}
switch(type){
case CDR_X_P:
if (both){
printf("Doing both... \n");
f32 new_opp = node->one.X - (position.X - node->two.X);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->one.X = new_opp;
}
node->two.X = position.X;
break;
case CDR_X_N:
if (both){
printf("Doing both... \n");
f32 new_opp = node->two.X - (position.X - node->one.X);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->two.X = new_opp;
}
node->one.X = position.X;
break;
case CDR_Y_P:
if (both){
printf("Doing both... \n");
f32 new_opp = node->one.Y - (position.Y - node->two.Y);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->one.Y = new_opp;
}
node->two.Y = position.Y;
break;
case CDR_Y_N:
if (both){
printf("Doing both... \n");
f32 new_opp = node->two.Y - (position.Y - node->one.Y);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->two.Y = new_opp;
}
node->one.Y = position.Y;
break;
case CDR_Z_P:
if (both){
printf("Doing both... \n");
f32 new_opp = node->one.Z - (position.Z - node->two.Z);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->one.Z = new_opp;
}
node->two.Z = position.Z;
break;
case CDR_Z_N:
if (both){
printf("Doing both... \n");
f32 new_opp = node->two.Z - (position.Z - node->one.Z);
if (editor->limiting==true){
if (new_opp > 0.5 || new_opp < -0.5)
return;
}
node->two.Z = new_opp;
}
node->one.Z = position.Z;
break;
}
update(GetId());
}
void Node::moveNodeBox(CDR_TYPE type,vector3df position){
NodeBox* node = GetCurrentNodeBox();
if (!node)
return;
position.X-=getPosition().X;
position.Y-=getPosition().Y;
position.Z-=getPosition().Z;
vector3df new_one = node->one;
vector3df new_two = node->two;
vector3df move_dist = vector3df(0,0,0);
switch(type){
case CDR_XZ:
move_dist = vector3df(
position.X - node->GetCenter().X,
0,
position.Z - node->GetCenter().Z
);
break;
case CDR_XY:
move_dist = vector3df(
position.X - node->GetCenter().X,
position.Y - node->GetCenter().Y,
0
);
break;
case CDR_ZY:
move_dist = vector3df(
0,
position.Y - node->GetCenter().Y,
position.Z - node->GetCenter().Z
);
break;
}
if (move_dist.X != 0){
if ((new_one.X+move_dist.X <= 0.5 && new_one.X+move_dist.X >= -0.5 && new_two.X+move_dist.X <= 0.5 && new_two.X+move_dist.X >= -0.5)||editor->limiting==false){
new_one.X+=move_dist.X;
new_two.X+=move_dist.X;
}
}
if (move_dist.Y != 0){
if ((new_one.Y+move_dist.Y <= 0.5 && new_one.Y+move_dist.Y >= -0.5 && new_two.Y+move_dist.Y <= 0.5 && new_two.Y+move_dist.Y >= -0.5)||editor->limiting==false){
new_one.Y+=move_dist.Y;
new_two.Y+=move_dist.Y;
}
}
if (move_dist.Z != 0){
if ((new_one.Z+move_dist.Z <= 0.5 && new_one.Z+move_dist.Z >= -0.5 && new_two.Z+move_dist.Z <= 0.5 && new_two.Z+move_dist.Z >= -0.5)||editor->limiting==false){
new_one.Z+=move_dist.Z;
new_two.Z+=move_dist.Z;
}
}
node->one = new_one;
node->two = new_two;
update(GetId());
}
void Node::deleteNodebox(int id){
if (!GetNodeBox(id))
return;
delete boxes[id];
boxes[id] = NULL;
defrag();
}
vector3df Node::getPosition() const{
return nd_position;
}
void Node::setPosition(vector3df in){
nd_position = in;
}
// Build node models
void Node::update(int id){
NodeBox* box = GetNodeBox(id);
if (!box)
return;
if (box->model){
box->model->remove();
box->model = NULL;
}
vector3df position = vector3df(
nd_position.X + box->one.X + ((box->two.X - box->one.X)/2),
nd_position.Y + box->one.Y + ((box->two.Y - box->one.Y)/2),
nd_position.Z + box->one.Z + ((box->two.Z - box->one.Z)/2)
);
vector3df size = vector3df(
box->two.X - box->one.X,
box->two.Y - box->one.Y,
box->two.Z - box->one.Z
);
// Create the scene node
box->model=smgr->addCubeSceneNode(1,0,-1,position);
if (!box->model)
return;
box->model->setMaterialTexture(0, driver->getTexture("texture_box.png"));
box->model->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
box->model->setName(box->name);
box->model->setScale(size);
}
void Node::remesh(){
for (int i=0;i<NODEB_MAX;i++){
update(i);
}
}
// Build code
// This build individual nodebox tables
stringc* Node::build(NodeBox* nodebox){
if (!nodebox)
return NULL;
stringc* res = new stringc();
res->append("{");
// Bounds one
res->append(stringc(nodebox->one.X));
res->append(",");
res->append(stringc(nodebox->one.Y));
res->append(",");
res->append(stringc(nodebox->one.Z));
res->append(",");
// Bounds two
res->append(stringc(nodebox->two.X));
res->append(",");
res->append(stringc(nodebox->two.Y));
res->append(",");
res->append(stringc(nodebox->two.Z));
res->append("}");
res->append(", --");
res->append(nodebox->name);
return res;
}
// This puts all the nodeboxes together
stringc* Node::build(BUILD_TYPE type){
stringc* res = new stringc();
if (type == NBT_FULL)
res->append("minetest.register_node(\"test:node\",{\n");
if (type >= NBT_NBS)
if (type == NBT_FULL)
res->append("\tdrawtype=\"nodebox\",\n\tparamtype = \"light\",\n\tnode_box = {\n\t\ttype = \"fixed\",\n\t\tfixed = {\n");
else
res->append("drawtype=\"nodebox\",\nparamtype = \"light\",\nnode_box = {\n\ttype = \"fixed\",\n\tfixed = {\n");
int a;
for (a=0;a<number;a++){
stringc tmp = *build(boxes[a]);
if (tmp!=NULL){
for (int i=0;i<type;i++){
res->append("\t");
}
res->append(tmp);
res->append("\n");
}
}
if (type >= NBT_NBS)
if (type == NBT_FULL)
res->append("\t\t}\n\t}\n");
else
res->append("\t}\n}\n");
if (type == NBT_FULL)
res->append("})");
// Print result
printf("\n===== res =====\n");
printf("%s\n",res->c_str());
printf("===============\n");
return res;
}
// Private functions
void Node::defrag(){
bool sep=false;
// Delete context menu stuff
if (editor->menu)
{
editor->menu->removeAllItems();
editor->menu->addItem(L"Node properties",-1,false);
editor->menu->addSeparator();
editor->menu->addItem(L"Add a nodebox",GUI_ID_BOX);
editor->menu->addItem(L"Nodebox properties",GUI_ID_TEXT);
editor->menu->addItem(L"Delete current nodebox",GUI_ID_DELETENB);
}
int a=0;
for (int i=0;i<NODEB_MAX;i++){
if (boxes[i]!=NULL){
boxes[a]=boxes[i];
// Add menu item
if (editor->menu)
{
if (sep==false){
sep=true;
editor->menu->addSeparator();
}
editor->menu->addItem(convert(boxes[a]->model->getName()),250+a);
}
if (GetId()==i)
_id=a;
a++;
}else{
boxes[a]=NULL;
}
}
number = a;
#ifdef _DEBUG
for (int i=0;i<NODEB_MAX;i++){
if (boxes[i]!=NULL && boxes[i]->model->getName()){
printf("%i> ",i);
printf("%s \n",boxes[i]->model->getName());
}else
printf("%i> NULL \n",i);
}
printf("There are %i boxes\n",a);
#endif
}

51
Node.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef _NODE_H_INCLUDED_
#define _NODE_H_INCLUDED_
#include "common.h"
class Node
{
public:
// Construction / Destruction
Node(IrrlichtDevice* mdevice,ed_data* n_ed);
~Node();
// Get functions
int GetId();
NodeBox* GetCurrentNodeBox();
NodeBox* GetNodeBox(int id);
// Operation functions
NodeBox* addNodeBox();
void select(int id);
void update();
void resizeNodeBoxFace(CDR_TYPE type,vector3df position,bool both);
void moveNodeBox(CDR_TYPE type,vector3df position);
void deleteNodebox(int id);
vector3df getPosition() const;
void setPosition(vector3df in);
// Build node models
void update(int id);
void remesh();
// Build code
stringc* build(BUILD_TYPE type); // Build full node
stringc* build(NodeBox* nodebox); // Build node box
void defrag();
private:
// Data
NodeBox* boxes[NODEB_MAX];
ed_data* editor;
int _id;
int number;
f32 snappers[NODE_RES+1];
vector3df nd_position;
// Irrlicht
video::IVideoDriver* driver;
IrrlichtDevice* device;
ISceneManager* smgr;
};
#endif

41
NodeBox.h Normal file
View File

@ -0,0 +1,41 @@
#include "common.h"
#ifndef _NODEBOX_H_INCLUDED_
#define _NODEBOX_H_INCLUDED_
class NodeBox
{
public:
NodeBox(){};
NodeBox(core::stringw _name, vector3df _one, vector3df _two)
:name(_name),one(_one),two(_two),model(NULL){};
~NodeBox(){
if (model)
model->remove();
}
irr::core::vector3df one;
irr::core::vector3df two;
core::stringw name;
irr::scene::IMeshSceneNode* model;
irr::core::vector3df GetCenter(){
return vector3df(
one.X + ((two.X - one.X)/2),
one.Y + ((two.Y - one.Y)/2),
one.Z + ((two.Z - one.Z)/2)
);
}
irr::core::vector3df GetScale(){
return vector3df(
(two.X - one.X)/2,
(two.Y - one.Y)/2,
(two.Z - one.Z)/2
);
}
};
#endif

20
NodeBoxEditor.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NodeBoxEditor", "NodeBoxEditor.vcxproj", "{2DD93C13-5E9E-4777-B8FA-8656814915EF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2DD93C13-5E9E-4777-B8FA-8656814915EF}.Debug|Win32.ActiveCfg = Debug|Win32
{2DD93C13-5E9E-4777-B8FA-8656814915EF}.Debug|Win32.Build.0 = Debug|Win32
{2DD93C13-5E9E-4777-B8FA-8656814915EF}.Release|Win32.ActiveCfg = Release|Win32
{2DD93C13-5E9E-4777-B8FA-8656814915EF}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

95
NodeBoxEditor.vcxproj Normal file
View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2DD93C13-5E9E-4777-B8FA-8656814915EF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>C:\Users\Glenn\Projects\irrlicht-1.8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>C:\Users\Glenn\Projects\irrlicht-1.8\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CodeDialog.cpp" />
<ClCompile Include="CommonFunctions.cpp" />
<ClCompile Include="Editor.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="NBPropertiesDialog.cpp" />
<ClCompile Include="Node.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CodeDialog.h" />
<ClInclude Include="common.h" />
<ClInclude Include="Editor.h" />
<ClInclude Include="NBPropertiesDialog.h" />
<ClInclude Include="Node.h" />
<ClInclude Include="NodeBox.h" />
<ClInclude Include="Project.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CodeDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CommonFunctions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Editor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NBPropertiesDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Node.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CodeDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Editor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NBPropertiesDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Node.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NodeBox.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Project.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

55
Project.h Normal file
View File

@ -0,0 +1,55 @@
#ifndef _PROJECT_H_INCLUDED_
#define _PROJECT_H_INCLUDED_
#include "common.h"
#include "Node.h"
class Project
{
public:
// Constructors
Project(io::path file)
{
Project();
// Encode reader here
filepath = file;
}
Project()
{
filepath = "";
mod = "untitled";
_id = 0;
for (int i=0;i<5;i++){
nodes[i]=NULL;
}
}
~Project(){
for (int i=0;i<5;i++){
if (nodes[i])
delete nodes[i];
}
}
// Data
stringc mod;
io::path filepath;
// Nodes
Node* nodes[5];
Node* GetNode(int id){
if (id>=5)
return NULL;
return nodes[id];
}
Node* GetCurNode(){
return GetNode(_id);
}
private:
int _id;
};
#endif

121
common.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef _COMMON_H_INCLUDED_
#define _COMMON_H_INCLUDED_
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace gui;
using namespace video;
// Enums
enum CDR_TYPE
{
CDR_X_P = 1,
CDR_X_N = 2,
CDR_Y_P = 3,
CDR_Y_N = 4,
CDR_Z_P = 5,
CDR_Z_N = 6,
CDR_XZ = 7,
CDR_XY = 8,
CDR_ZY = 9
};
// CDR_TYPE::CDR_<axis>_<positive/negitive-direction>
enum BUILD_TYPE
{
NBT_NB = 1, // Just the node box table
NBT_NBS = 2, // The node box table with draw type and parent holder (nodebox={})
NBT_FULL = 3 // Whole node definition
};
enum TOOL_TYPE
{
TOOL_NEWNODE = 1,
TOOL_NODE = 2,
TOOL_NODEB = 3,
TOOL_TEXT = 4
};
enum GUI_ID
{
// File
GUI_ID_NEW=201,
GUI_ID_LOAD=202,
GUI_ID_SAVE=203,
GUI_ID_IMPORT=204,
GUI_ID_EX_PROJ=205,
GUI_ID_EX_NODE=206,
GUI_ID_EX_NBS=207,
GUI_ID_EX_NB=208,
GUI_ID_EXIT=230,
// Project
GUI_ID_ADDNODE=209,
GUI_ID_SWITCH=210,
GUI_ID_DELETENODE = 211,
// Node
GUI_ID_BOX=212,
GUI_ID_DELETENB = 213,
GUI_ID_TEXT = 214,
// Help
GUI_ID_HELP=215,
GUI_ID_ABOUT=216,
// View
GUI_ID_SP_ALL=217,
GUI_ID_SP_PER=218,
GUI_ID_SP_TOP=219,
GUI_ID_SP_FRT=220,
GUI_ID_SP_RHT=221,
// Edit
GUI_ID_SNAP = 222,
GUI_ID_LIMIT = 223,
GUI_ID_TOOL_NNODE = 224,
GUI_ID_TOOL_NODE = 225,
GUI_ID_TOOL_NODEB = 226,
GUI_ID_TOOL_TEXT = 227,
// Windows
GUI_ID_SUBMIT = 228,
GUI_ID_BOX_NAME = 229
};
// Defines
#define EDITOR_TEXT_VERSION "0.5.0 - Dirt"
#define EDITOR_VERSION 1
#define EDITOR_PARSER 1
#define NODE_RES 16 // The resolution of the snapping (16)
#define NODE_THIN 1/NODE_RES // The smallest a box can be (1/NODE_RES)
#define NODEB_MAX 50 // Maximum amount of nodeboxes (50)
// Structures
struct ed_data
{
IGUIStaticText* d_nb;
IGUIStaticText* d_pos;
IGUIStaticText* d_rot;
IGUIContextMenu* menu;
bool snapping;
bool limiting;
TOOL_TYPE type;
};
struct CDR
{
CDR_TYPE type;
irr::gui::IGUIImage* image;
int camera;
};
#include "NodeBox.h"
// Functions: Convertors
const wchar_t* convert(const char* input); //Convertor: char to wchar_t
char* convert(wchar_t* input); //Convertor: wchar_t to char
#endif

BIN
fontlucida.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
gui_scale.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

394
irrlicht.h Normal file
View File

@ -0,0 +1,394 @@
/* irrlicht.h -- interface of the 'Irrlicht Engine'
Copyright (C) 2002-2012 Nikolaus Gebhardt
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Please note that the Irrlicht Engine is based in part on the work of the
Independent JPEG Group, the zlib and the libPng. This means that if you use
the Irrlicht Engine in your product, you must acknowledge somewhere in your
documentation that you've used the IJG code. It would also be nice to mention
that you use the Irrlicht Engine, the zlib and libPng. See the README files
in the jpeglib, the zlib and libPng for further informations.
*/
#ifndef __IRRLICHT_H_INCLUDED__
#define __IRRLICHT_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "aabbox3d.h"
#include "CDynamicMeshBuffer.h"
#include "CIndexBuffer.h"
#include "CMeshBuffer.h"
#include "coreutil.h"
#include "CVertexBuffer.h"
#include "dimension2d.h"
#include "ECullingTypes.h"
#include "EDebugSceneTypes.h"
#include "EDriverFeatures.h"
#include "EDriverTypes.h"
#include "EGUIAlignment.h"
#include "EGUIElementTypes.h"
#include "EHardwareBufferFlags.h"
#include "EMaterialFlags.h"
#include "EMaterialTypes.h"
#include "EMeshWriterEnums.h"
#include "EMessageBoxFlags.h"
#include "ESceneNodeAnimatorTypes.h"
#include "ESceneNodeTypes.h"
#include "ETerrainElements.h"
#include "fast_atof.h"
#include "heapsort.h"
#include "IAnimatedMesh.h"
#include "IAnimatedMeshMD2.h"
#include "IAnimatedMeshMD3.h"
#include "IAnimatedMeshSceneNode.h"
#include "IAttributeExchangingObject.h"
#include "IAttributes.h"
#include "IBillboardSceneNode.h"
#include "IBillboardTextSceneNode.h"
#include "IBoneSceneNode.h"
#include "ICameraSceneNode.h"
#include "ICursorControl.h"
#include "IDummyTransformationSceneNode.h"
#include "IDynamicMeshBuffer.h"
#include "IEventReceiver.h"
#include "IFileList.h"
#include "IFileSystem.h"
#include "IGeometryCreator.h"
#include "IGPUProgrammingServices.h"
#include "IGUIButton.h"
#include "IGUICheckBox.h"
#include "IGUIColorSelectDialog.h"
#include "IGUIComboBox.h"
#include "IGUIContextMenu.h"
#include "IGUIEditBox.h"
#include "IGUIElement.h"
#include "IGUIElementFactory.h"
#include "IGUIEnvironment.h"
#include "IGUIFileOpenDialog.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
#include "IGUIImage.h"
#include "IGUIInOutFader.h"
#include "IGUIListBox.h"
#include "IGUIMeshViewer.h"
#include "IGUIScrollBar.h"
#include "IGUISkin.h"
#include "IGUISpinBox.h"
#include "IGUISpriteBank.h"
#include "IGUIStaticText.h"
#include "IGUITabControl.h"
#include "IGUITable.h"
#include "IGUIToolbar.h"
#include "IGUIWindow.h"
#include "IGUITreeView.h"
#include "IImage.h"
#include "IImageLoader.h"
#include "IImageWriter.h"
#include "IIndexBuffer.h"
#include "ILightSceneNode.h"
#include "ILogger.h"
#include "IMaterialRenderer.h"
#include "IMaterialRendererServices.h"
#include "IMesh.h"
#include "IMeshBuffer.h"
#include "IMeshCache.h"
#include "IMeshLoader.h"
#include "IMeshManipulator.h"
#include "IMeshSceneNode.h"
#include "IMeshWriter.h"
#include "IColladaMeshWriter.h"
#include "IMetaTriangleSelector.h"
#include "IOSOperator.h"
#include "IParticleSystemSceneNode.h" // also includes all emitters and attractors
#include "IQ3LevelMesh.h"
#include "IQ3Shader.h"
#include "IReadFile.h"
#include "IReferenceCounted.h"
#include "irrArray.h"
#include "IRandomizer.h"
#include "IrrlichtDevice.h"
#include "irrList.h"
#include "irrMap.h"
#include "irrMath.h"
#include "irrString.h"
#include "irrTypes.h"
#include "path.h"
#include "irrXML.h"
#include "ISceneCollisionManager.h"
#include "ISceneLoader.h"
#include "ISceneManager.h"
#include "ISceneNode.h"
#include "ISceneNodeAnimator.h"
#include "ISceneNodeAnimatorCameraFPS.h"
#include "ISceneNodeAnimatorCameraMaya.h"
#include "ISceneNodeAnimatorCollisionResponse.h"
#include "ISceneNodeAnimatorFactory.h"
#include "ISceneNodeFactory.h"
#include "ISceneUserDataSerializer.h"
#include "IShaderConstantSetCallBack.h"
#include "IShadowVolumeSceneNode.h"
#include "ISkinnedMesh.h"
#include "ITerrainSceneNode.h"
#include "ITextSceneNode.h"
#include "ITexture.h"
#include "ITimer.h"
#include "ITriangleSelector.h"
#include "IVertexBuffer.h"
#include "IVideoDriver.h"
#include "IVideoModeList.h"
#include "IVolumeLightSceneNode.h"
#include "IWriteFile.h"
#include "IXMLReader.h"
#include "IXMLWriter.h"
#include "ILightManager.h"
#include "Keycodes.h"
#include "line2d.h"
#include "line3d.h"
#include "matrix4.h"
#include "plane3d.h"
#include "position2d.h"
#include "quaternion.h"
#include "rect.h"
#include "S3DVertex.h"
#include "SAnimatedMesh.h"
#include "SceneParameters.h"
#include "SColor.h"
#include "SExposedVideoData.h"
#include "SIrrCreationParameters.h"
#include "SKeyMap.h"
#include "SLight.h"
#include "SMaterial.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "SMeshBufferLightMap.h"
#include "SMeshBufferTangents.h"
#include "SParticle.h"
#include "SSharedMeshBuffer.h"
#include "SSkinMeshBuffer.h"
#include "SVertexIndex.h"
#include "SViewFrustum.h"
#include "triangle3d.h"
#include "vector2d.h"
#include "vector3d.h"
/*! \mainpage Irrlicht Engine 1.8 API documentation
*
* <div align="center"><img src="logobig.png" ></div>
*
* \section intro Introduction
*
* Welcome to the Irrlicht Engine API documentation.
* Here you'll find any information you'll need to develop applications with
* the Irrlicht Engine. If you are looking for a tutorial on how to start, you'll
* find some on the homepage of the Irrlicht Engine at
* <A HREF="http://irrlicht.sourceforge.net" >irrlicht.sourceforge.net</A>
* or inside the SDK in the examples directory.
*
* The Irrlicht Engine is intended to be an easy-to-use 3d engine, so
* this documentation is an important part of it. If you have any questions or
* suggestions, just send a email to the author of the engine, Nikolaus Gebhardt
* (niko (at) irrlicht3d.org).
*
*
* \section links Links
*
* <A HREF="namespaces.html">Namespaces</A>: A very good place to start reading
* the documentation.<BR>
* <A HREF="annotated.html">Class list</A>: List of all classes with descriptions.<BR>
* <A HREF="functions.html">Class members</A>: Good place to find forgotten features.<BR>
*
* \section irrexample Short example
*
* A simple application, starting up the engine, loading a Quake 2 animated
* model file and the corresponding texture, animating and displaying it
* in front of a blue background and placing a user controlable 3d camera
* would look like the following code. I think this example shows the usage
* of the engine quite well:
*
* \code
* #include <irrlicht.h>
* using namespace irr;
*
* int main()
* {
* // start up the engine
* IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8,
* core::dimension2d<u32>(640,480));
*
* video::IVideoDriver* driver = device->getVideoDriver();
* scene::ISceneManager* scenemgr = device->getSceneManager();
*
* device->setWindowCaption(L"Hello World!");
*
* // load and show quake2 .md2 model
* scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode(
* scenemgr->getMesh("quake2model.md2"));
*
* // if everything worked, add a texture and disable lighting
* if (node)
* {
* node->setMaterialTexture(0, driver->getTexture("texture.bmp"));
* node->setMaterialFlag(video::EMF_LIGHTING, false);
* }
*
* // add a first person shooter style user controlled camera
* scenemgr->addCameraSceneNodeFPS();
*
* // draw everything
* while(device->run() && driver)
* {
* driver->beginScene(true, true, video::SColor(255,0,0,255));
* scenemgr->drawAll();
* driver->endScene();
* }
*
* // delete device
* device->drop();
* return 0;
* }
* \endcode
*
* Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh()
* for a detailed list. So if you would like to replace the simple blue screen background by
* a cool Quake 3 Map, optimized by an octree, just insert this code
* somewhere before the while loop:
*
* \code
* // add .pk3 archive to the file system
* device->getFileSystem()->addZipFileArchive("quake3map.pk3");
*
* // load .bsp file and show it using an octree
* scenemgr->addOctreeSceneNode(
* scenemgr->getMesh("quake3map.bsp"));
* \endcode
*
* As you can see, the engine uses namespaces. Everything in the engine is
* placed into the namespace 'irr', but there are also 5 sub namespaces.
* You can find a list of all namespaces with descriptions at the
* <A HREF="namespaces.html"> namespaces page</A>.
* This is also a good place to start reading the documentation. If you
* don't want to write the namespace names all the time, just use all namespaces like
* this:
* \code
* using namespace core;
* using namespace scene;
* using namespace video;
* using namespace io;
* using namespace gui;
* \endcode
*
* There is a lot more the engine can do, but I hope this gave a short
* overview over the basic features of the engine. For more examples, please take
* a look into the examples directory of the SDK.
*/
#include "SIrrCreationParameters.h"
//! Everything in the Irrlicht Engine can be found in this namespace.
namespace irr
{
//! Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.
/** If you need more parameters to be passed to the creation of the Irrlicht Engine device,
use the createDeviceEx() function.
\param deviceType: Type of the device. This can currently be video::EDT_NULL,
video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL.
\param windowSize: Size of the window or the video mode in fullscreen mode.
\param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode.
\param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise
the device runs in windowed mode.
\param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true,
if you want the engine be able to draw stencil buffer shadows. Note that not all
devices are able to use the stencil buffer. If they don't no shadows will be drawn.
\param vsync: Specifies vertical syncronisation: If set to true, the driver will wait
for the vertical retrace period, otherwise not.
\param receiver: A user created event receiver.
\return Returns pointer to the created IrrlichtDevice or null if the
device could not be created.
*/
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(
video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE,
// parantheses are necessary for some compilers
const core::dimension2d<u32>& windowSize = (core::dimension2d<u32>(640,480)),
u32 bits = 16,
bool fullscreen = false,
bool stencilbuffer = false,
bool vsync = false,
IEventReceiver* receiver = 0);
//! typedef for Function Pointer
typedef IrrlichtDevice* (IRRCALLCONV *funcptr_createDevice )(
video::E_DRIVER_TYPE deviceType,
const core::dimension2d<u32>& windowSize,
u32 bits,
bool fullscreen,
bool stencilbuffer,
bool vsync,
IEventReceiver* receiver);
//! Creates an Irrlicht device with the option to specify advanced parameters.
/** Usually you should used createDevice() for creating an Irrlicht Engine device.
Use this function only if you wish to specify advanced parameters like a window
handle in which the device should be created.
\param parameters: Structure containing advanced parameters for the creation of the device.
See irr::SIrrlichtCreationParameters for details.
\return Returns pointer to the created IrrlichtDevice or null if the
device could not be created. */
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
const SIrrlichtCreationParameters& parameters);
//! typedef for Function Pointer
typedef IrrlichtDevice* (IRRCALLCONV *funcptr_createDeviceEx )( const SIrrlichtCreationParameters& parameters );
// THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES
// EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN.
//! Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
namespace core
{
}
//! The gui namespace contains useful classes for easy creation of a graphical user interface.
namespace gui
{
}
//! This namespace provides interfaces for input/output: Reading and writing files, accessing zip archives, xml files, ...
namespace io
{
}
//! All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees and billboards, ...
namespace scene
{
}
//! The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done here.
namespace video
{
}
}
/*! \file irrlicht.h
\brief Main header file of the irrlicht, the only file needed to include.
*/
#endif

28
main.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <irrlicht.h>
#include "common.h"
#include "Editor.h"
//#include "stdafx.h"
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#ifndef _DEBUG
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
#endif
int main(){
// create device
irr::IrrlichtDevice* device = irr::createDevice(irr::video::EDT_OPENGL, irr::core::dimension2d<irr::u32>(640, 480));
if (device == 0)
return 0; // could not create selected driver.
irr::video::IVideoDriver* driver = device->getVideoDriver();
irr::scene::ISceneManager* smgr = device->getSceneManager();
irr::gui::IGUIEnvironment* gui = device->getGUIEnvironment();
Editor* editor = new Editor();
editor->run(device);
return 1;
}

BIN
sky.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
texture_box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

BIN
texture_terrain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB