Made size getters and setters
This commit is contained in:
@@ -10,6 +10,7 @@ Color3 color;
|
||||
bool changed = true;
|
||||
Box itemBox = Box();
|
||||
|
||||
|
||||
PhysicalInstance::PhysicalInstance(void)
|
||||
{
|
||||
name = "Default PhysicalInstance";
|
||||
@@ -23,7 +24,38 @@ PhysicalInstance::PhysicalInstance(void)
|
||||
velocity = Vector3(0,0,0);
|
||||
rotVelocity = Vector3(0,0,0);
|
||||
}
|
||||
void PhysicalInstance::setSize(Vector3 newSize)
|
||||
{
|
||||
int minsize = 1;
|
||||
int maxsize = 512;
|
||||
changed = true;
|
||||
int sizex = (int)newSize.x;
|
||||
if(sizex <= 0)
|
||||
sizex = 1;
|
||||
if(sizex > 512)
|
||||
sizex = 512;
|
||||
|
||||
int sizey = (int)newSize.y;
|
||||
if(sizey <= 0)
|
||||
sizey = 1;
|
||||
if(sizey > 512)
|
||||
sizey = 512;
|
||||
|
||||
int sizez = (int)newSize.z;
|
||||
if(sizez <= 0)
|
||||
sizez = 1;
|
||||
if(sizez > 512)
|
||||
sizez = 512;
|
||||
|
||||
size = Vector3(sizex, sizey, sizez);
|
||||
|
||||
|
||||
|
||||
}
|
||||
Vector3 PhysicalInstance::getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
Vector3 PhysicalInstance::getPosition()
|
||||
{
|
||||
return position;
|
||||
|
||||
@@ -7,7 +7,7 @@ class PhysicalInstance :
|
||||
public:
|
||||
PhysicalInstance(void);
|
||||
~PhysicalInstance(void);
|
||||
Vector3 size;
|
||||
|
||||
Vector3 velocity;
|
||||
Vector3 rotvelocity;
|
||||
CoordinateFrame cFrame;
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
void setCFrame(CoordinateFrame);
|
||||
Box getBox();
|
||||
CoordinateFrame getCFrameRenderBased();
|
||||
Vector3 getSize();
|
||||
void setSize(Vector3);
|
||||
private:
|
||||
Vector3 position;
|
||||
Vector3 size;
|
||||
};
|
||||
|
||||
26
main.cpp
26
main.cpp
@@ -719,7 +719,7 @@ void Demo::onInit() {
|
||||
PhysicalInstance* test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(0.2F,0.3F,1);
|
||||
test->size = Vector3(24,1,24);
|
||||
test->setSize(Vector3(24,1,24));
|
||||
test->setPosition(Vector3(0,0,0));
|
||||
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
|
||||
//selectedInstance = test;
|
||||
@@ -729,54 +729,54 @@ void Demo::onInit() {
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setSize(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->setSize(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->setSize(Vector3(4,1,2));
|
||||
test->setPosition(Vector3(7,2,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setSize(Vector3(4,1,2));
|
||||
test->setPosition(Vector3(-7,2,0));
|
||||
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setSize(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->setSize(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->setSize(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->setSize(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->setSize(Vector3(4,1,2));
|
||||
test->setPosition(Vector3(-2,5,0));
|
||||
|
||||
|
||||
@@ -785,13 +785,13 @@ void Demo::onInit() {
|
||||
test = makePart();
|
||||
test->parent = dataModel;
|
||||
test->color = Color3::gray();
|
||||
test->size = Vector3(4,1,2);
|
||||
test->setSize(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->setSize(Vector3(4,1,2));
|
||||
test->setPosition(Vector3(2,7,0));
|
||||
|
||||
|
||||
@@ -1458,7 +1458,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
||||
if(selectedInstance == part)
|
||||
{
|
||||
Vector3 size = part->size;
|
||||
Vector3 size = part->getSize();
|
||||
Vector3 pos = part->getCFrame().translation;
|
||||
drawOutline(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), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user