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:
@@ -136,7 +136,7 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
|
||||
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
|
||||
_propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance);
|
||||
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
|
||||
webBrowser->navigateSyncURL(L"http://androdome.com/g3d/toolbox/");
|
||||
webBrowser->navigateSyncURL(L"http://androdome.com/res/ClientToolbox.php");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,35 @@ void CameraController::refreshZoom(const CoordinateFrame& frame)
|
||||
|
||||
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;
|
||||
pitch+=spdY;
|
||||
|
||||
@@ -105,14 +134,14 @@ void CameraController::Zoom(short delta)
|
||||
void CameraController::panLeft()
|
||||
{
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
pan(&frame,toRadians(-45),0);
|
||||
panLock(&frame,toRadians(-45),0);
|
||||
setFrame(frame);
|
||||
|
||||
}
|
||||
void CameraController::panRight()
|
||||
{
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
pan(&frame,toRadians(45),0);
|
||||
panLock(&frame,toRadians(45),0);
|
||||
setFrame(frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class CameraController {
|
||||
void lookAt(const Vector3& position);
|
||||
void refreshZoom(const CoordinateFrame& frame);
|
||||
void pan(CoordinateFrame* frame,float spdX,float spdY);
|
||||
void panLock(CoordinateFrame* frame,float spdX,float spdY);
|
||||
void update(Application* app);
|
||||
void centerCamera(Instance* selection);
|
||||
void panLeft();
|
||||
|
||||
@@ -257,6 +257,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||
xml_node<> *propNode = node->first_node();
|
||||
xml_node<> *cFrameNode=0;
|
||||
xml_node<> *sizeNode=0;
|
||||
xml_node<> *shapeNode=0;
|
||||
xml_node<> *colorNode=0;
|
||||
xml_node<> *brickColorNode=0;
|
||||
xml_node<> *nameNode=0;
|
||||
@@ -276,6 +277,11 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||
{
|
||||
nameNode = partPropNode;
|
||||
}
|
||||
if (xmlValue=="shape")
|
||||
{
|
||||
shapeNode = partPropNode;
|
||||
_legacyLoad=false;
|
||||
}
|
||||
if (xmlValue=="Color")
|
||||
{
|
||||
colorNode=partPropNode;
|
||||
@@ -297,11 +303,16 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||
{
|
||||
std::string xmlName = attr->name();
|
||||
std::string xmlValue = attr->value();
|
||||
if (xmlValue=="shape")
|
||||
{
|
||||
shapeNode = featureNode;
|
||||
_legacyLoad=true;
|
||||
}
|
||||
if (xmlValue=="size")
|
||||
{
|
||||
sizeNode=featureNode;
|
||||
_legacyLoad=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +339,21 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||
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();
|
||||
float X = getFloatValue(cFrameNode,"X");
|
||||
float Y = getFloatValue(cFrameNode,"Y");
|
||||
@@ -353,6 +378,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||
PartInstance* test = makePart();
|
||||
test->setParent(getWorkspace());
|
||||
test->color = Color3(R,G,B);
|
||||
test->shape = partshape;
|
||||
if(brickColorNode)
|
||||
{
|
||||
test->color = bcToRGB(atoi(brickColorNode->value()));
|
||||
|
||||
Reference in New Issue
Block a user