Ported GroupInstance

This commit is contained in:
Vulpovile
2023-11-05 19:14:06 -08:00
parent cab66d1152
commit 8a1a457f4b
2 changed files with 78 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
#pragma once
#include "PartInstance.h"
namespace B3D{
class GroupInstance : public PVInstance
{
public:
GroupInstance(void);
~GroupInstance(void);
GroupInstance(const GroupInstance &oinst);
std::vector<Instance *> unGroup();
PartInstance * primaryPart;
//This is used to render the controllerflag, we may want to move it elsewhere?
void render(RenderDevice * r);
protected:
GroupInstance(std::string className);
};
}

View File

@@ -1,3 +1,63 @@
#include "DataModelV3/GroupInstance.h"
using namespace B3D;
GroupInstance::GroupInstance(std::string className)
{
PVInstance::PVInstance(className);
name = "Model";
primaryPart = NULL;
}
GroupInstance::GroupInstance(void)
{
GroupInstance::GroupInstance("Model");
}
GroupInstance::~GroupInstance(void)
{
}
std::vector<Instance *> GroupInstance::unGroup()
{
while(children.size() > 0)
{
children[0]->setParent(parent);
}
return std::vector<Instance *>();
}
void GroupInstance::render(RenderDevice * rd)
{
Instance::render(rd);
//Controllerflag!
if(primaryPart != NULL && controllerFlagShown.getValue() && getControllerColor(controller.getValue()) != Color3::gray())
{
rd->disableLighting();
Vector3 vec = Vector3(0,0,0);
Vector3 up = Vector3(0,8,0);
rd->setColor(getControllerColor(controller.getValue()));
rd->setObjectToWorldMatrix(primaryPart->getCFrame());
rd->beforePrimitive();
glBegin(GL_LINES);
glVertex3f(vec.x, vec.y, vec.z);
glVertex3f(up.x, up.y, up.z);
glEnd();
glBegin( GL_TRIANGLES );
glVertex3f(up.x, up.y-2, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y-2, up.z);
glEnd();
rd->afterPrimitive();
rd->setColor(Color3::white());
rd->enableLighting();
}
}