Added surface selector, made faces reflect G3D faces
This commit is contained in:
@@ -50,6 +50,7 @@ public:
|
||||
void setSize(Vector3);
|
||||
void setShape(Enum::Shape::Value shape);
|
||||
void setChanged();
|
||||
void setSurface(int face, Enum::SurfaceType::Value surface);
|
||||
|
||||
//Collision
|
||||
bool collides(PartInstance * part);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef FACES_H
|
||||
#define FACES_H
|
||||
#define TOP 0
|
||||
#define BOTTOM 1
|
||||
#define LEFT 2
|
||||
#define RIGHT 3
|
||||
#define FRONT 4
|
||||
#define BACK 5
|
||||
#define TOP 3
|
||||
#define BOTTOM 5
|
||||
#define LEFT 1
|
||||
#define RIGHT 4
|
||||
#define FRONT 0
|
||||
#define BACK 2
|
||||
#endif
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
bool isMouseOnScreen();
|
||||
bool isMouseDown();
|
||||
void setMouseDown(bool mouseDown);
|
||||
G3D::Ray * getRay();
|
||||
G3D::Ray getLastRay();
|
||||
private:
|
||||
bool mouseDown;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ class SurfaceTool :
|
||||
public Tool
|
||||
{
|
||||
public:
|
||||
SurfaceTool(Enum::SurfaceType::Value surface, int extraParam); //OnSelect?
|
||||
SurfaceTool(int surface, int extraParam); //OnSelect?
|
||||
~SurfaceTool(void); //OnDeselect?
|
||||
void onButton1MouseDown(Mouse);
|
||||
void onButton1MouseUp(Mouse);
|
||||
@@ -15,6 +15,6 @@ public:
|
||||
void onKeyDown(int key);
|
||||
void onKeyUp(int key);
|
||||
private:
|
||||
Enum::SurfaceType::Value surface;
|
||||
int surface;
|
||||
int param;
|
||||
};
|
||||
|
||||
@@ -618,6 +618,8 @@ void Application::exitApplication()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Application::onGraphics(RenderDevice* rd) {
|
||||
|
||||
G3D::uint8 num = 0;
|
||||
|
||||
@@ -18,12 +18,12 @@ PartInstance::PartInstance(void)
|
||||
color = Color3::gray();
|
||||
velocity = Vector3(0,0,0);
|
||||
rotVelocity = Vector3(0,0,0);
|
||||
top = Enum::SurfaceType::Bumps;
|
||||
top = Enum::SurfaceType::Smooth;
|
||||
front = Enum::SurfaceType::Bumps;
|
||||
right = Enum::SurfaceType::Bumps;
|
||||
back = Enum::SurfaceType::Bumps;
|
||||
left = Enum::SurfaceType::Bumps;
|
||||
bottom = Enum::SurfaceType::Bumps;
|
||||
right = Enum::SurfaceType::Smooth;
|
||||
back = Enum::SurfaceType::Smooth;
|
||||
left = Enum::SurfaceType::Smooth;
|
||||
bottom = Enum::SurfaceType::Smooth;
|
||||
shape = Enum::Shape::Block;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,31 @@ void PartInstance::setChanged()
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void PartInstance::setSurface(int face, Enum::SurfaceType::Value surface)
|
||||
{
|
||||
switch(face)
|
||||
{
|
||||
case TOP:
|
||||
top = surface;
|
||||
break;
|
||||
case BOTTOM:
|
||||
bottom = surface;
|
||||
break;
|
||||
case LEFT:
|
||||
left = surface;
|
||||
break;
|
||||
case RIGHT:
|
||||
right = surface;
|
||||
break;
|
||||
case FRONT:
|
||||
front = surface;
|
||||
break;
|
||||
default:
|
||||
back = surface;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void PartInstance::setParent(Instance* prnt)
|
||||
{
|
||||
Instance * cparent = getParent();
|
||||
|
||||
@@ -61,10 +61,10 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
|
||||
return E_NOTIMPL;
|
||||
int j = pDispParams->rgvarg->intVal;
|
||||
int i = (pDispParams->rgvarg+1)->intVal;
|
||||
printf("Got values %d and %d", i, j);
|
||||
//printf("Got values %d and %d", i, j);
|
||||
if(i > 5 || i < 0)
|
||||
return E_NOTIMPL;
|
||||
g_usableApp->changeTool(new SurfaceTool((Enum::SurfaceType::Value)i, j));
|
||||
g_usableApp->changeTool(new SurfaceTool(i, j));
|
||||
/*VARIANT val1;
|
||||
VARIANT val2;
|
||||
unsigned int puArgErr;
|
||||
|
||||
@@ -34,6 +34,16 @@ PartInstance * Mouse::getTarget()
|
||||
return selectedInstance;
|
||||
}
|
||||
|
||||
G3D::Ray * Mouse::getRay()
|
||||
{
|
||||
return &g_usableApp->cameraController.getCamera()->worldRay(x, y, g_usableApp->getRenderDevice()->getViewport());
|
||||
}
|
||||
|
||||
G3D::Ray Mouse::getLastRay()
|
||||
{
|
||||
return testRay;
|
||||
}
|
||||
|
||||
|
||||
double getVectorDistance(Vector3 vector1, Vector3 vector2)
|
||||
{
|
||||
|
||||
@@ -414,7 +414,6 @@ void renderSurface(const char face, const Enum::SurfaceType::Value& surface, con
|
||||
{
|
||||
case Enum::SurfaceType::Motor:
|
||||
{
|
||||
printf("MOTOR\n");
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor(getControllerColor(controller));
|
||||
GLUquadric * q = gluNewQuadric();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "Tool/SurfaceTool.h"
|
||||
#include "Application.h"
|
||||
|
||||
SurfaceTool::SurfaceTool(Enum::SurfaceType::Value theSurface, int extraParam)
|
||||
SurfaceTool::SurfaceTool(int theSurface, int extraParam)
|
||||
{
|
||||
surface = theSurface;
|
||||
param = extraParam;
|
||||
@@ -11,9 +10,53 @@ SurfaceTool::~SurfaceTool(void)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<G3D::Box> getSurfaces(PartInstance * part)
|
||||
{
|
||||
std::vector<G3D::Box> planes;
|
||||
G3D::Box box = part->getBox();
|
||||
G3D::Vector3 v0;
|
||||
G3D::Vector3 v1;
|
||||
G3D::Vector3 v2;
|
||||
G3D::Vector3 v3;
|
||||
box.getFaceCorners(0,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
box.getFaceCorners(1,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
box.getFaceCorners(2,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
box.getFaceCorners(3,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
box.getFaceCorners(4,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
box.getFaceCorners(5,v0,v1,v2,v3);
|
||||
planes.push_back(G3D::Box(v0, v2));
|
||||
return planes;
|
||||
}
|
||||
|
||||
void SurfaceTool::onButton1MouseDown(Mouse mouse)
|
||||
{
|
||||
|
||||
AudioPlayer::playSound(dingSound);
|
||||
PartInstance * target = mouse.getTarget();
|
||||
G3D::Ray ray = mouse.getLastRay();
|
||||
std::vector<G3D::Box> surfacesHit = getSurfaces(target);
|
||||
int closest;
|
||||
float nearValue = G3D::inf();
|
||||
for(size_t i = 0; i < surfacesHit.size(); i++)
|
||||
{
|
||||
float newTime = ray.intersectionTime(surfacesHit[i]);
|
||||
if(nearValue > newTime)
|
||||
{
|
||||
nearValue = newTime;
|
||||
closest = (int)i;
|
||||
}
|
||||
}
|
||||
if(G3D::isFinite(nearValue))
|
||||
{
|
||||
|
||||
printf("\n%d\n", closest);
|
||||
target->setSurface(closest, Enum::SurfaceType::Value(surface));
|
||||
}
|
||||
g_usableApp->changeTool(NULL);
|
||||
}
|
||||
void SurfaceTool::onButton1MouseUp(Mouse mouse)
|
||||
{
|
||||
@@ -25,6 +68,7 @@ void SurfaceTool::onMouseMoved(Mouse mouse)
|
||||
}
|
||||
void SurfaceTool::onSelect(Mouse mouse)
|
||||
{
|
||||
AudioPlayer::playSound(dingSound);
|
||||
}
|
||||
|
||||
void SurfaceTool::onKeyDown(int key)
|
||||
|
||||
Reference in New Issue
Block a user