File importer now supports shapes, camera pan is now locked to 45 degree increments

this was a massive pain in the ass :)
This commit is contained in:
DirtPiper
2019-11-10 22:59:08 -05:00
parent 1f4147fd90
commit 98f4246f17
4 changed files with 61 additions and 5 deletions

View File

@@ -136,7 +136,7 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this); SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
_propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance); _propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance);
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox); IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
webBrowser->navigateSyncURL(L"http://androdome.com/g3d/toolbox/"); webBrowser->navigateSyncURL(L"http://androdome.com/res/ClientToolbox.php");
} }

View File

@@ -57,6 +57,35 @@ void CameraController::refreshZoom(const CoordinateFrame& frame)
void CameraController::pan(CoordinateFrame* frame,float spdX, float spdY) void CameraController::pan(CoordinateFrame* frame,float spdX, float spdY)
{ {
yaw+=spdX;
pitch+=spdY;
if (pitch>1.4f) pitch=1.4f;
if (pitch<-1.4f) pitch=-1.4f;
frame->translation = Vector3(sin(-yaw)*zoom*cos(pitch),sin(pitch)*zoom,cos(-yaw)*zoom*cos(pitch))+focusPosition;
frame->lookAt(focusPosition);
}
void CameraController::panLock(CoordinateFrame* frame,float spdX, float spdY)
{
int sign = 0;
yaw = toDegrees(yaw);
if((((yaw - fmod(yaw, 45)) / 45) * 45) < 0)
{
sign = 1;
}
yaw = fabs(yaw);
yaw = ((yaw - fmod(yaw, 45)) / 45) * 45;
yaw = toRadians(yaw);
if(sign==1)
{
yaw = yaw * -1;
}
yaw+=spdX; yaw+=spdX;
pitch+=spdY; pitch+=spdY;
@@ -105,14 +134,14 @@ void CameraController::Zoom(short delta)
void CameraController::panLeft() void CameraController::panLeft()
{ {
CoordinateFrame frame = g3dCamera.getCoordinateFrame(); CoordinateFrame frame = g3dCamera.getCoordinateFrame();
pan(&frame,toRadians(-45),0); panLock(&frame,toRadians(-45),0);
setFrame(frame); setFrame(frame);
} }
void CameraController::panRight() void CameraController::panRight()
{ {
CoordinateFrame frame = g3dCamera.getCoordinateFrame(); CoordinateFrame frame = g3dCamera.getCoordinateFrame();
pan(&frame,toRadians(45),0); panLock(&frame,toRadians(45),0);
setFrame(frame); setFrame(frame);
} }

View File

@@ -19,6 +19,7 @@ class CameraController {
void lookAt(const Vector3& position); void lookAt(const Vector3& position);
void refreshZoom(const CoordinateFrame& frame); void refreshZoom(const CoordinateFrame& frame);
void pan(CoordinateFrame* frame,float spdX,float spdY); void pan(CoordinateFrame* frame,float spdX,float spdY);
void panLock(CoordinateFrame* frame,float spdX,float spdY);
void update(Application* app); void update(Application* app);
void centerCamera(Instance* selection); void centerCamera(Instance* selection);
void panLeft(); void panLeft();

View File

@@ -257,6 +257,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
xml_node<> *propNode = node->first_node(); xml_node<> *propNode = node->first_node();
xml_node<> *cFrameNode=0; xml_node<> *cFrameNode=0;
xml_node<> *sizeNode=0; xml_node<> *sizeNode=0;
xml_node<> *shapeNode=0;
xml_node<> *colorNode=0; xml_node<> *colorNode=0;
xml_node<> *brickColorNode=0; xml_node<> *brickColorNode=0;
xml_node<> *nameNode=0; xml_node<> *nameNode=0;
@@ -276,6 +277,11 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
{ {
nameNode = partPropNode; nameNode = partPropNode;
} }
if (xmlValue=="shape")
{
shapeNode = partPropNode;
_legacyLoad=false;
}
if (xmlValue=="Color") if (xmlValue=="Color")
{ {
colorNode=partPropNode; colorNode=partPropNode;
@@ -297,6 +303,11 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
{ {
std::string xmlName = attr->name(); std::string xmlName = attr->name();
std::string xmlValue = attr->value(); std::string xmlValue = attr->value();
if (xmlValue=="shape")
{
shapeNode = featureNode;
_legacyLoad=true;
}
if (xmlValue=="size") if (xmlValue=="size")
{ {
sizeNode=featureNode; sizeNode=featureNode;
@@ -328,6 +339,20 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
B = getFloatValue(colorNode,"B"); B = getFloatValue(colorNode,"B");
} }
Enum::Shape::Value partshape = Enum::Shape::Block;
std::string pshape = shapeNode->value();
if (shapeNode)
{
if(pshape == "0" || pshape == "Ball"){
partshape = Enum::Shape::Ball;
}
if(pshape == "1" || pshape == "Block"){
partshape = Enum::Shape::Block;
}
if(pshape == "2" || pshape == "Cylinder"){
partshape = Enum::Shape::Cylinder;
}
}
std::string newName = nameNode->value(); std::string newName = nameNode->value();
float X = getFloatValue(cFrameNode,"X"); float X = getFloatValue(cFrameNode,"X");
@@ -353,6 +378,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
PartInstance* test = makePart(); PartInstance* test = makePart();
test->setParent(getWorkspace()); test->setParent(getWorkspace());
test->color = Color3(R,G,B); test->color = Color3(R,G,B);
test->shape = partshape;
if(brickColorNode) if(brickColorNode)
{ {
test->color = bcToRGB(atoi(brickColorNode->value())); test->color = bcToRGB(atoi(brickColorNode->value()));