Attempted to make duplicate

This commit is contained in:
andreja6
2018-10-21 15:36:17 -07:00
parent 2725f6da58
commit e0ba49a03c
7 changed files with 58 additions and 41 deletions

View File

@@ -169,7 +169,6 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib"
OutputFile="./G3DTest-Debug.exe" OutputFile="./G3DTest-Debug.exe"
LinkIncremental="2" LinkIncremental="2"
SuppressStartupBanner="true" SuppressStartupBanner="true"

View File

@@ -14,6 +14,13 @@ Instance::Instance(void)
className = "BaseInstance"; className = "BaseInstance";
} }
Instance::Instance(const Instance &oinst)
{
parent = oinst.parent;
name = oinst.name;
className = "BaseInstance";
}
void Instance::render(RenderDevice* rd) void Instance::render(RenderDevice* rd)
{ {
for(size_t i = 0; i < children.size(); i++) for(size_t i = 0; i < children.size(); i++)

View File

@@ -5,6 +5,7 @@ class Instance
{ {
public: public:
Instance(void); Instance(void);
Instance(const Instance&);
virtual ~Instance(void); virtual ~Instance(void);
std::string name; std::string name;
virtual void render(RenderDevice*); virtual void render(RenderDevice*);
@@ -17,6 +18,7 @@ public:
void addChild(Instance*); void addChild(Instance*);
void removeChild(Instance*); void removeChild(Instance*);
Instance* getParent(); Instance* getParent();
Instance* clone() const { return new Instance(*this); }
protected: protected:
std::string className; std::string className;
Instance* parent; // Another pointer. Instance* parent; // Another pointer.

View File

@@ -1,43 +1,48 @@
#include "PhysicalInstance.h" #include "PhysicalInstance.h"
#include "Globals.h" #include "Globals.h"
bool canCollide = true;
bool anchored = false;
Vector3 size;
Vector3 position;
Vector3 velocity;
Vector3 rotVelocity;
GLfloat vertecies[96]; GLfloat vertecies[96];
Surface top;
Surface front;
Surface right;
Surface back;
Surface left;
Surface bottom;
CoordinateFrame cFrame;
Color3 color;
bool changed = true; bool changed = true;
Box itemBox = Box(); Box itemBox = Box();
PhysicalInstance::PhysicalInstance(void) PhysicalInstance::PhysicalInstance(void)
{ {
name = "Default PhysicalInstance"; name = "Default PhysicalInstance";
className = "Part"; className = "Part";
canCollide = true; canCollide = true;
anchored = true; anchored = true;
size = Vector3(2,1,4); size = Vector3(2,1,4);
position = Vector3(0,0,0); setCFrame(CoordinateFrame(Vector3(0,0,0)));
cFrame = CoordinateFrame(position);
color = Color3::gray(); color = Color3::gray();
velocity = Vector3(0,0,0); velocity = Vector3(0,0,0);
rotVelocity = Vector3(0,0,0); rotVelocity = Vector3(0,0,0);
top = Snaps; top = Surface::Smooth;
front = Smooth; front = Surface::Smooth;
right = Smooth; right = Surface::Smooth;
back = Smooth; back = Surface::Smooth;
left = Smooth; left = Surface::Smooth;
bottom = Inlets; bottom = Surface::Smooth;
} }
PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst)
{
name = oinst.name;
className = "Part";
canCollide = oinst.canCollide;
anchored = oinst.anchored;
size = oinst.size;
setCFrame(oinst.cFrame);
color = oinst.color;
velocity = oinst.velocity;
rotVelocity = oinst.rotVelocity;
top = oinst.top;
front = oinst.front;
right = oinst.right;
back = oinst.back;
left = oinst.left;
bottom = oinst.bottom;
}
void PhysicalInstance::setSize(Vector3 newSize) void PhysicalInstance::setSize(Vector3 newSize)
{ {
int minsize = 1; int minsize = 1;
@@ -127,6 +132,11 @@ Box PhysicalInstance::getBox()
return itemBox; return itemBox;
} }
bool PhysicalInstance::collides(Box box)
{
return CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), box);
}
void PhysicalInstance::render(RenderDevice* rd) void PhysicalInstance::render(RenderDevice* rd)
{ {
if(changed) if(changed)
@@ -143,29 +153,17 @@ void PhysicalInstance::render(RenderDevice* rd)
double add = 0.8; double add = 0.8;
Surface face; Surface face;
if(i == 0)//Back if(i == 0)//Back
{
face = back; face = back;
}
else if(i == 16)//Right else if(i == 16)//Right
{
face = right; face = right;
}
else if(i == 32)//Front else if(i == 32)//Front
{
face = front; face = front;
}
else if(i == 48)//Top else if(i == 48)//Top
{
face = top; face = top;
}
else if(i == 64)//Left else if(i == 64)//Left
{
face = left; face = left;
}
else if(i == 80)//Bottom else if(i == 80)//Bottom
{
face = bottom; face = bottom;
}
/*if(face == Snaps) /*if(face == Snaps)
add = 0.0; add = 0.0;

View File

@@ -7,10 +7,11 @@ class PhysicalInstance :
{ {
public: public:
PhysicalInstance(void); PhysicalInstance(void);
PhysicalInstance(const PhysicalInstance &oinst);
Instance* clone() const { return new PhysicalInstance(*this); }
~PhysicalInstance(void); ~PhysicalInstance(void);
virtual void render(RenderDevice*); virtual void render(RenderDevice*);
Vector3 velocity; Vector3 velocity;
Vector3 rotvelocity;
Surface top; Surface top;
Surface front; Surface front;
Surface right; Surface right;
@@ -28,6 +29,10 @@ public:
CoordinateFrame getCFrameRenderBased(); CoordinateFrame getCFrameRenderBased();
Vector3 getSize(); Vector3 getSize();
void setSize(Vector3); void setSize(Vector3);
bool canCollide;
bool anchored;
Vector3 rotVelocity;
bool collides(Box);
private: private:
Vector3 position; Vector3 position;
Vector3 size; Vector3 size;

View File

@@ -1,4 +1,4 @@
#ifndef SURFACE_H #ifndef SURFACE_H
#define SURFACE_H #define SURFACE_H
enum Surface {Smooth, Snaps, Inlets, Glue, Weld, Hinge, Motor}; static enum Surface {Smooth, Snaps, Inlets, Glue, Weld, Hinge, Motor};
#endif #endif

View File

@@ -249,10 +249,16 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
AudioPlayer::playSound(dingSound); AudioPlayer::playSound(dingSound);
if(button->name == "Duplicate") if(button->name == "Duplicate")
{ {
std::vector<Instance*> newinst;
for(size_t i = 0; i < selectedInstances.size(); i++)
{
Instance* inst = selectedInstances.at(i)->clone();
newinst.push_back(inst);
inst->setParent(selectedInstances.at(i)->getParent());
}
selectedInstances = newinst;
} }
} }
} }
class RotateButtonListener : public ButtonListener { class RotateButtonListener : public ButtonListener {