add textures and face resize one

master
Rubenwardy 2013-03-04 19:16:34 +00:00
parent 053177f79e
commit e85013f5ed
5 changed files with 54 additions and 70 deletions

View File

@ -60,7 +60,7 @@ bool cEditor::run(IrrlichtDevice* irr_device){
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,10);
projMat.buildProjectionMatrixOrthoLH(orth_w,3,1,100);
// Add rotational camera
pivot=smgr->addEmptySceneNode(0,199);
@ -104,12 +104,19 @@ bool cEditor::run(IrrlichtDevice* irr_device){
light->setLightType(ELT_POINT);
light->setRadius(2000);
//Add Plane
// 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);
plane_tri=smgr->createOctreeTriangleSelector(plane->getMesh(),plane);
// 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);
//Setup Current Manager
nodes[0]=new cNode(device,data);
@ -417,22 +424,34 @@ void cEditor::updatePoint(int start, int count){
switch (points[id]->type){
case CDR_X_P:
position.X = (nodes[curId]->getCurrentNodeBox()->size.X / 2) + nodes[curId]->getCurrentNodeBox()->position.X;
position.X = nodes[curId]->getCurrentNodeBox()->position.X + ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2);
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
break;
case CDR_X_N:
position.X = -((nodes[curId]->getCurrentNodeBox()->size.X / 2) + nodes[curId]->getCurrentNodeBox()->position.X);
position.X = nodes[curId]->getCurrentNodeBox()->position.X - ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2);
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
break;
case CDR_Y_P:
position.Y = (nodes[curId]->getCurrentNodeBox()->size.Y /2) + nodes[curId]->getCurrentNodeBox()->position.Y;
position.X = nodes[curId]->getCurrentNodeBox()->position.X;
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y + ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2);
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
break;
case CDR_Y_N:
position.Y = -((nodes[curId]->getCurrentNodeBox()->size.Y / 2) + nodes[curId]->getCurrentNodeBox()->position.Y);
position.X = nodes[curId]->getCurrentNodeBox()->position.X;
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y - ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2);
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
break;
case CDR_Z_P:
position.Z = (nodes[curId]->getCurrentNodeBox()->size.Z /2) + nodes[curId]->getCurrentNodeBox()->position.Z;
position.X = nodes[curId]->getCurrentNodeBox()->position.X;
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z + ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2);
break;
case CDR_Z_N:
position.Z = -((nodes[curId]->getCurrentNodeBox()->size.Z / 2) + nodes[curId]->getCurrentNodeBox()->position.Z);
position.X = nodes[curId]->getCurrentNodeBox()->position.X;
position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
position.Z = nodes[curId]->getCurrentNodeBox()->position.Z - ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2);
break;
}

View File

@ -13,7 +13,7 @@ cNode::cNode(IrrlichtDevice* mdevice, ed_data* n_ed){
}
}
const sBox* cNode::addNodeBox(){
sBox* cNode::addNodeBox(){
// Set up structure
boxes[number]=new sBox();
@ -57,11 +57,6 @@ void cNode::changeID(int n_id){
}
void cNode::update(){
for (int a=0;a<number;a++){
if (boxes[a] && boxes[a]->model)
checkScaling(boxes[a]);
}
updateTexts();
}
@ -117,49 +112,6 @@ void cNode::resize(int side,f32 dir){
updateTexts();
}
void cNode::checkScaling(sBox* input){
// Load / Prerequistes
irr::core::vector3df extent = input->size;
bool tmp_change=false;
// Check X Axis scale
if (extent.X>1){
std::cout << "--auto correct: x" << std::endl;
input->size.X = 1;
tmp_change=true;
}else if(extent.X < NODE_THIN){
std::cout << "--auto correct: x" << std::endl;
input->size.X = NODE_THIN;
tmp_change=true;
}
// Check Y Axis scale
if (extent.Y > 1){
std::cout << "--auto correct: y" << std::endl;
input->size.Y = 1;
tmp_change=true;
}else if(extent.Y < NODE_THIN){
std::cout << "--auto correct: y" << std::endl;
input->size.Y = NODE_THIN;
tmp_change=true;
}
// Check Z Axis scale
if (extent.Z>1){
std::cout << "--auto correct: z" << std::endl;
input->size.Z = 1;
tmp_change=true;
}else if(extent.Z < NODE_THIN){
std::cout << "--auto correct: z" << std::endl;
input->size.Z = NODE_THIN;
tmp_change=true;
}
// Resize if required
if (tmp_change==true)
setsizeObject(input,input->size.X,input->size.Y,input->size.Z);
}
void cNode::setsizeObject(sBox* input,f32 px,f32 py,f32 pz){
// Check limits
if (px > 1 || px < NODE_THIN || py > 1 || py < NODE_THIN || pz > 1 || pz < NODE_THIN){
@ -174,7 +126,7 @@ void cNode::setsizeObject(sBox* input,f32 px,f32 py,f32 pz){
input->model=NULL;
// Read the node
input->model=smgr->addCubeSceneNode(1,0,-1,vector3df(0,0,0));
input->model=smgr->addCubeSceneNode(1,0,-1,input->position);
input->model->setMaterialTexture(0, driver->getTexture("texture_box.png"));
input->model->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
input->model->setName(nb);
@ -194,17 +146,31 @@ void cNode::setsizeObject(sBox* input,f32 px,f32 py,f32 pz){
input->model->setScale(core::vector3df(sx, sy, sz));
}
const sBox* cNode::getCurrentNodeBox(){
sBox* cNode::getCurrentNodeBox(){
return boxes[id];
}
void cNode::resizeNodeBoxFace(const sBox* nodebox,CDR_TYPE face, vector3df target){
// stuff to do here
// NOTES: the node ingame stretches from -0.55 to 0.45
void cNode::resizeNodeBoxFace(sBox* nodebox,CDR_TYPE face, vector3df target){
// Enter switch
// Print stuff
printf("Resizing to (%f,",target.X);
printf(" %f,",target.Y);
printf(" %f)\n",target.Z);
switch (face){
case CDR_X_P:
f32 opp = (((float)nodebox->size.X / (float)2) + nodebox->position.X);
nodebox->size.X = target.X - opp;
if (nodebox->size.X <= 0)
nodebox->size.X=NODE_THIN;
if (nodebox->size.X > 1)
nodebox->size.X=1;
f32 change = (((float)nodebox->size.X / (float)2) + nodebox->position.X)-opp;
nodebox->position.X += change;
setsizeObject(nodebox,nodebox->size.X,nodebox->size.Y,nodebox->size.Z);
break;
}
return;
}

View File

@ -22,10 +22,10 @@ public:
bool save(wchar_t* output);
// NodeBox operation functions
const sBox* addNodeBox();
const sBox* getCurrentNodeBox();
sBox* addNodeBox();
sBox* getCurrentNodeBox();
void resize(int side, f32 dir); //0:Up 1:Left 2:Right 3:Down
void resizeNodeBoxFace(const sBox* nodebox,CDR_TYPE face, vector3df target);
void resizeNodeBoxFace(sBox* nodebox,CDR_TYPE face, vector3df target);
// Switch functions
bool switchFocus(ISceneNode* hit);
@ -45,7 +45,6 @@ private:
ISceneManager* smgr;
void setsizeObject(sBox* input,irr::f32 px,irr::f32 py,irr::f32 pz);
void checkScaling(sBox* input);
};
#endif

BIN
sky.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB