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
Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib"
OutputFile="./G3DTest-Debug.exe"
LinkIncremental="2"
SuppressStartupBanner="true"

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
#ifndef 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

View File

@@ -249,10 +249,16 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
AudioPlayer::playSound(dingSound);
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 {