Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
811ac871a3 |
120
main.cpp
120
main.cpp
@@ -41,7 +41,6 @@ static int SCOREVAL = 0;
|
|||||||
static G3D::TextureRef go = NULL;
|
static G3D::TextureRef go = NULL;
|
||||||
static G3D::TextureRef go_ovr = NULL;
|
static G3D::TextureRef go_ovr = NULL;
|
||||||
static G3D::TextureRef go_dn = NULL;
|
static G3D::TextureRef go_dn = NULL;
|
||||||
VARAreaRef varStatic = NULL;
|
|
||||||
static float mousex = 0;
|
static float mousex = 0;
|
||||||
static float mousey = 0;
|
static float mousey = 0;
|
||||||
static int cursorid = 0;
|
static int cursorid = 0;
|
||||||
@@ -162,7 +161,6 @@ HWND App::getMainHWND()
|
|||||||
|
|
||||||
|
|
||||||
Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
||||||
varStatic = VARArea::create(1024 * 1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -262,6 +260,29 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
if(selectedInstance != NULL)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances.at(i) == selectedInstance)
|
||||||
|
{
|
||||||
|
Instance* deleting = instances.at(i);
|
||||||
|
instances.erase(instances.begin() + i);
|
||||||
|
delete deleting;
|
||||||
|
selectedInstance == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ModeSelectionListener : public ButtonListener {
|
class ModeSelectionListener : public ButtonListener {
|
||||||
public:
|
public:
|
||||||
void onButton1MouseClick(BaseButtonInstance*);
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
@@ -483,15 +504,8 @@ void initGUI()
|
|||||||
instance->size = Vector2(40,46);
|
instance->size = Vector2(40,46);
|
||||||
instance->position = Vector2(20, 284);
|
instance->position = Vector2(20, 284);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Delete";
|
||||||
instance = makeImageButton(
|
instance->setButtonListener(new DeleteListener());
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_ovr.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_dn.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
|
|
||||||
instance->size = Vector2(40,46);
|
|
||||||
instance->position = Vector2(20, 284);
|
|
||||||
instance->parent = dataModel;
|
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
|
||||||
@@ -705,6 +719,19 @@ void Demo::onCleanup() {
|
|||||||
|
|
||||||
void Demo::onLogic() {
|
void Demo::onLogic() {
|
||||||
// Add non-simulation game logic and AI code here
|
// Add non-simulation game logic and AI code here
|
||||||
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances_2D.at(i)->name == "Delete")
|
||||||
|
{
|
||||||
|
ImageButtonInstance* button = (ImageButtonInstance*)instances_2D.at(i);
|
||||||
|
if(selectedInstance == NULL)
|
||||||
|
button->disabled = true;
|
||||||
|
else
|
||||||
|
button->disabled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -903,6 +930,27 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
right = true;
|
right = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ui->keyPressed(SDL_LEFT_MOUSE_KEY))
|
||||||
|
{
|
||||||
|
bool onGUI = false;
|
||||||
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton")
|
||||||
|
{
|
||||||
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
||||||
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
||||||
|
{
|
||||||
|
onGUI = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!onGUI)
|
||||||
|
{
|
||||||
|
selectedInstance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1062,25 +1110,7 @@ void Demo::exitApplication()
|
|||||||
app->endProgram = true;
|
app->endProgram = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeBeveledBox(Box box, RenderDevice* rd, Color4 color, CoordinateFrame cFrame)
|
|
||||||
{
|
|
||||||
Vector3 v0, v1, v2, v3;
|
|
||||||
//glDiffuse();
|
|
||||||
rd->setColor(color);
|
|
||||||
rd->setObjectToWorldMatrix(CoordinateFrame());
|
|
||||||
rd->beginPrimitive(RenderDevice::QUADS);
|
|
||||||
for (int f = 0; f < 6; ++f) {
|
|
||||||
box.getFaceCorners(f, v0, v1, v2, v3);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
//rd->setNormal((v1 - v0).cross(v3 - v0).direction());
|
|
||||||
rd->sendVertex(v0);
|
|
||||||
rd->sendVertex(v1);
|
|
||||||
rd->sendVertex(v2);
|
|
||||||
rd->sendVertex(v3);
|
|
||||||
}
|
|
||||||
rd->setColor(Color3::white());
|
|
||||||
rd->endPrimitive();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Demo::onGraphics(RenderDevice* rd) {
|
void Demo::onGraphics(RenderDevice* rd) {
|
||||||
@@ -1121,7 +1151,6 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
// Setup lighting
|
// Setup lighting
|
||||||
app->renderDevice->enableLighting();
|
app->renderDevice->enableLighting();
|
||||||
|
|
||||||
app->renderDevice->setShadeMode(RenderDevice::SHADE_SMOOTH);
|
|
||||||
app->renderDevice->setAmbientLightColor(Color3(1,1,1));
|
app->renderDevice->setAmbientLightColor(Color3(1,1,1));
|
||||||
Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice);
|
Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice);
|
||||||
|
|
||||||
@@ -1149,33 +1178,6 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
Vector3 pos3 = Vector3((pos.x+size.x/2)/2,(pos.y+size.y/2)/2,(pos.z+size.z/2)/2);
|
Vector3 pos3 = Vector3((pos.x+size.x/2)/2,(pos.y+size.y/2)/2,(pos.z+size.z/2)/2);
|
||||||
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
||||||
CoordinateFrame c = CoordinateFrame(part->getCFrame().rotation,Vector3(part->getCFrame().translation.x/2, part->getCFrame().translation.y/2, part->getCFrame().translation.z/2));
|
CoordinateFrame c = CoordinateFrame(part->getCFrame().rotation,Vector3(part->getCFrame().translation.x/2, part->getCFrame().translation.y/2, part->getCFrame().translation.z/2));
|
||||||
//Box wsb = c.toWorldSpace(box);
|
|
||||||
//makeBeveledBox(c.toWorldSpace(box), app->renderDevice, part->color, part->getCFrame());
|
|
||||||
//G3D::MeshBuilder builder = G3D::MeshBuilder();
|
|
||||||
//for(int i = 0; i < 6; i++)
|
|
||||||
//{
|
|
||||||
// Vector3 v1, v2, v3, v4;
|
|
||||||
// wsb.getFaceCorners(i, v1, v2, v3, v4);
|
|
||||||
// builder.addQuad(v1, v2, v3, v4);
|
|
||||||
//}
|
|
||||||
//std::string str;
|
|
||||||
//G3D::Array<int> arrayInd;
|
|
||||||
//G3D::Array<Vector3> arrayVector;
|
|
||||||
//builder.commit(str, arrayInd, arrayVector);
|
|
||||||
|
|
||||||
|
|
||||||
//IFSModel::save(ExePath() + "/content/model.ifs", str, arrayInd, arrayVector, NULL);
|
|
||||||
//IFSModelRef model = IFSModel::create(ExePath() + "/content/model.ifs");
|
|
||||||
//app->renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
|
||||||
|
|
||||||
//app->renderDevice->beginIndexedPrimitives();
|
|
||||||
//{
|
|
||||||
// app->renderDevice->setNormalArray(G3D::VAR(arrayVector, varStatic));
|
|
||||||
//app->renderDevice->setVertexArray(G3D::VAR(arrayVector, varStatic));
|
|
||||||
//app->renderDevice->sendIndices(RenderDevice::TRIANGLES, arrayInd);
|
|
||||||
//}
|
|
||||||
//app->renderDevice->endIndexedPrimitives();
|
|
||||||
|
|
||||||
Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear());
|
Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear());
|
||||||
if(selectedInstance == part)
|
if(selectedInstance == part)
|
||||||
{
|
{
|
||||||
@@ -1410,7 +1412,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
GAppSettings settings;
|
GAppSettings settings;
|
||||||
settings.window.resizable = true;
|
settings.window.resizable = true;
|
||||||
//settings.window.fsaaSamples = 8;
|
settings.window.fsaaSamples = 8;
|
||||||
settings.writeLicenseFile = false;
|
settings.writeLicenseFile = false;
|
||||||
settings.window.center = true;
|
settings.window.center = true;
|
||||||
//Using the damned SDL window now
|
//Using the damned SDL window now
|
||||||
|
|||||||
Reference in New Issue
Block a user