Changed the way blocks are rendered
This commit is contained in:
@@ -25,6 +25,7 @@ void BaseButtonInstance::onMouseClick()
|
||||
if(listener != NULL)
|
||||
{
|
||||
listener->onButton1MouseClick(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
Dialogs.aps
BIN
Dialogs.aps
Binary file not shown.
@@ -6,6 +6,7 @@ Vector3 size;
|
||||
Vector3 position;
|
||||
Vector3 velocity;
|
||||
Vector3 rotVelocity;
|
||||
CoordinateFrame cFrame;
|
||||
Color3 color;
|
||||
|
||||
PhysicalInstance::PhysicalInstance(void)
|
||||
@@ -16,11 +17,32 @@ PhysicalInstance::PhysicalInstance(void)
|
||||
anchored = true;
|
||||
size = Vector3(2,1,4);
|
||||
position = Vector3(0,0,0);
|
||||
cFrame = CoordinateFrame(position);
|
||||
color = Color3::gray();
|
||||
velocity = Vector3(0,0,0);
|
||||
rotVelocity = Vector3(0,0,0);
|
||||
}
|
||||
|
||||
Vector3 PhysicalInstance::getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
void PhysicalInstance::setPosition(Vector3 pos)
|
||||
{
|
||||
position = pos;
|
||||
cFrame = CoordinateFrame(pos);
|
||||
}
|
||||
CoordinateFrame PhysicalInstance::getCFrame()
|
||||
{
|
||||
return cFrame;
|
||||
}
|
||||
void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
||||
{
|
||||
cFrame = coordinateFrame;
|
||||
position = coordinateFrame.translation;
|
||||
}
|
||||
|
||||
|
||||
PhysicalInstance::~PhysicalInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,8 +8,14 @@ public:
|
||||
PhysicalInstance(void);
|
||||
~PhysicalInstance(void);
|
||||
Vector3 size;
|
||||
Vector3 position;
|
||||
Vector3 velocity;
|
||||
Vector3 rotvelocity;
|
||||
CoordinateFrame cFrame;
|
||||
Color3 color;
|
||||
Vector3 getPosition();
|
||||
void setPosition(Vector3);
|
||||
CoordinateFrame getCFrame();
|
||||
void setCFrame(CoordinateFrame);
|
||||
private:
|
||||
Vector3 position;
|
||||
};
|
||||
|
||||
128
main.cpp
128
main.cpp
@@ -115,6 +115,7 @@ public:
|
||||
Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
||||
}
|
||||
|
||||
|
||||
void clearInstances()
|
||||
{
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
@@ -454,6 +455,7 @@ void initGUI()
|
||||
instance->parent = dataModel;
|
||||
}
|
||||
|
||||
|
||||
void Demo::onInit() {
|
||||
|
||||
// Called before Demo::run() beings
|
||||
@@ -470,76 +472,77 @@ void Demo::onInit() {
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(0.2F,0.3F,1);
|
||||
test->size = Vector3(24,1,24);
|
||||
|
||||
|
||||
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(10,1,0);
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(-10,1,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(-7,2,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(7,2,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(-4,3,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(5,3,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(-1,4,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(3,4,0);
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(2,5,0);
|
||||
|
||||
test->setCFrame(CoordinateFrame(Matrix3::fromEulerAnglesXYZ(toRadians(90),toRadians(45),toRadians(45)), Vector3(0,0,0)));
|
||||
selectedInstance = test;
|
||||
|
||||
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(10,1,0));
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(-10,1,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(0,6,0);
|
||||
test->setPosition(Vector3(-7,2,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->position = Vector3(-2,7,0);
|
||||
test->setPosition(Vector3(7,2,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(-4,3,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(5,3,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(-1,4,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(3,4,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(2,5,0));
|
||||
|
||||
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(0,6,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setPosition(Vector3(-2,7,0));
|
||||
|
||||
|
||||
|
||||
@@ -946,10 +949,13 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
{
|
||||
PhysicalInstance* part = (PhysicalInstance*)instance;
|
||||
Vector3 size = part->size;
|
||||
Vector3 pos = part->position;
|
||||
Vector3 pos = part->getCFrame().translation;
|
||||
rd->setObjectToWorldMatrix(CoordinateFrame());
|
||||
Vector3 pos2 = 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);
|
||||
Draw::box(Box(pos2 ,pos3), app->renderDevice, part->color, Color4::clear());
|
||||
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));
|
||||
Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear());
|
||||
if(selectedInstance == part)
|
||||
{
|
||||
drawOutline(pos2, pos3, rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2));
|
||||
|
||||
Reference in New Issue
Block a user