Updates to the slideshow3D app.
This commit is contained in:
parent
2bce4dda75
commit
00e7e10a26
@ -59,7 +59,6 @@ void ReaderWriterSS3D::parseModel(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
float rotation = 0.0f;
|
||||
float position = 0.5f;
|
||||
|
||||
printf(" new model\n");
|
||||
xmlChar *key;
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL)
|
||||
@ -67,25 +66,25 @@ void ReaderWriterSS3D::parseModel(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"filename")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" filename: %s\n", key);
|
||||
if (key) filename = (const char*)key;
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scale")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" scale: %s\n", key);
|
||||
if (key) scale = atoi((const char*)key);
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"rotation")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" rotation: %s\n", key);
|
||||
if (key) rotation = atoi((const char*)key);
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"position")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" position: %s\n", key);
|
||||
if (key) position = atoi((const char*)key)/100.0f;
|
||||
xmlFree(key);
|
||||
}
|
||||
cur = cur->next;
|
||||
@ -98,7 +97,6 @@ void ReaderWriterSS3D::parseLayer(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
{
|
||||
constructor.addLayer();
|
||||
|
||||
printf(" new layer\n");
|
||||
xmlChar *key;
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL)
|
||||
@ -106,15 +104,13 @@ void ReaderWriterSS3D::parseLayer(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"bullet")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.addBullet((const char*)key);
|
||||
printf(" bullet: %s\n", key);
|
||||
if (key) constructor.addBullet((const char*)key);
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"paragraph")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" paragraph: %s\n", key);
|
||||
constructor.addParagraph((const char*)key);
|
||||
if (key) constructor.addParagraph((const char*)key);
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"image")))
|
||||
@ -123,19 +119,14 @@ void ReaderWriterSS3D::parseLayer(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
float height = 1.0f;
|
||||
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
printf(" image: %s\n", key);
|
||||
filename = (const char*)key;
|
||||
if (key) filename = (const char*)key;
|
||||
xmlFree(key);
|
||||
|
||||
key = xmlGetProp (cur, (const xmlChar *)"height");
|
||||
if (key)
|
||||
{
|
||||
printf(" height: %s\n", key);
|
||||
height = atoi((const char*)key);
|
||||
xmlFree(key);
|
||||
}
|
||||
if (key) height = atoi((const char*)key);
|
||||
xmlFree(key);
|
||||
|
||||
constructor.addImage(filename,height);
|
||||
if (!filename.empty()) constructor.addImage(filename,height);
|
||||
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"model")))
|
||||
@ -150,8 +141,6 @@ void ReaderWriterSS3D::parseLayer(SlideShowConstructor& constructor, xmlDocPtr d
|
||||
void ReaderWriterSS3D::parseSlide (SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur)
|
||||
{
|
||||
|
||||
printf("new slide\n");
|
||||
|
||||
constructor.addSlide();
|
||||
|
||||
xmlChar *key;
|
||||
@ -161,15 +150,15 @@ void ReaderWriterSS3D::parseSlide (SlideShowConstructor& constructor, xmlDocPtr
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"title")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.setSlideTitle((const char*)key);
|
||||
printf(" title: %s\n", key);
|
||||
if (key) constructor.setSlideTitle((const char*)key);
|
||||
else constructor.setSlideTitle("");
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"background")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.setSlideBackground((const char*)key);
|
||||
printf(" background: %s\n", key);
|
||||
if (key) constructor.setSlideBackground((const char*)key);
|
||||
else constructor.setSlideBackground("");
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"layer")))
|
||||
@ -223,22 +212,20 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSS3D::readNode(const std::string& fi
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"name")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.setPresentationName((const char*)key);
|
||||
printf("name: %s\n", key);
|
||||
if (key) constructor.setPresentationName((const char*)key);
|
||||
else constructor.setPresentationName("");
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"bgcolor")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.setBackgroundColor(mapStringToColor((const char*)key));
|
||||
printf("bgcolor: %s\n", key);
|
||||
if (key) constructor.setBackgroundColor(mapStringToColor((const char*)key));
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"textcolor")))
|
||||
{
|
||||
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
constructor.setTextColor(mapStringToColor((const char*)key));
|
||||
printf("textcolor: %s\n", key);
|
||||
if (key) constructor.setTextColor(mapStringToColor((const char*)key));
|
||||
xmlFree(key);
|
||||
}
|
||||
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"slide")))
|
||||
|
@ -130,8 +130,7 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
nextLayerOrSlide();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='p' ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Up ||
|
||||
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Up ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up)
|
||||
{
|
||||
_autoSteppingActive = false;
|
||||
@ -148,8 +147,7 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
nextSlide();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='P' ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
|
||||
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Page_Up ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Page_Up)
|
||||
|
@ -26,9 +26,11 @@ SlideShowConstructor::SlideShowConstructor()
|
||||
void SlideShowConstructor::createPresentation()
|
||||
{
|
||||
_titleHeight = _slideHeight*0.08f;
|
||||
_titleWidth = _slideWidth*0.8f;
|
||||
_titleOrigin = _slideOrigin + osg::Vec3(_slideWidth*0.5f,0.0f,_slideHeight*0.98f-_titleHeight);
|
||||
|
||||
_textHeight = _slideHeight*0.05f;
|
||||
_textWidth = _slideWidth*0.8f;
|
||||
|
||||
_textOrigin = _slideOrigin + osg::Vec3(_slideWidth*0.1f,0.0f,_titleOrigin.z()-2*_textHeight);
|
||||
_imageOrigin = _slideOrigin + osg::Vec3(_slideWidth*0.7f,0.0f,_titleOrigin.z()*0.5f);
|
||||
@ -124,6 +126,7 @@ void SlideShowConstructor::addLayer()
|
||||
text->setFont(_textFont);
|
||||
text->setColor(_textColor);
|
||||
text->setCharacterSize(_titleHeight);
|
||||
text->setMaximumWidth(_titleWidth);
|
||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
text->setAlignment(osgText::Text::CENTER_BASE_LINE);
|
||||
text->setPosition(_titleOrigin);
|
||||
@ -158,6 +161,7 @@ void SlideShowConstructor::addBullet(const std::string& bullet)
|
||||
text->setFont(_textFont);
|
||||
text->setColor(_textColor);
|
||||
text->setCharacterSize(_textHeight);
|
||||
text->setMaximumWidth(_textWidth);
|
||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
text->setAlignment(osgText::Text::BASE_LINE);
|
||||
text->setPosition(_textCursor);
|
||||
@ -165,7 +169,7 @@ void SlideShowConstructor::addBullet(const std::string& bullet)
|
||||
text->setText(bullet);
|
||||
|
||||
osg::BoundingBox bb = text->getBound();
|
||||
_textCursor.z() = bb.zMin()-_textHeight;
|
||||
_textCursor.z() = bb.zMin()-_textHeight*1.5;
|
||||
|
||||
geode->addDrawable(text);
|
||||
|
||||
@ -184,6 +188,7 @@ void SlideShowConstructor::addParagraph(const std::string& paragraph)
|
||||
text->setFont(_textFont);
|
||||
text->setColor(_textColor);
|
||||
text->setCharacterSize(_textHeight);
|
||||
text->setMaximumWidth(_textWidth);
|
||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
text->setAlignment(osgText::Text::BASE_LINE);
|
||||
text->setPosition(_textCursor);
|
||||
@ -191,7 +196,7 @@ void SlideShowConstructor::addParagraph(const std::string& paragraph)
|
||||
text->setText(paragraph);
|
||||
|
||||
osg::BoundingBox bb = text->getBound();
|
||||
_textCursor.z() = bb.zMin()-_textHeight;
|
||||
_textCursor.z() = bb.zMin()-_textHeight*1.5;
|
||||
|
||||
geode->addDrawable(text);
|
||||
|
||||
@ -211,8 +216,9 @@ void SlideShowConstructor::addImage(const std::string& filename,float height)
|
||||
|
||||
float image_height = _slideHeight*0.6f;
|
||||
float image_width = image_height*s/t;
|
||||
float offset = height*image_height*0.1f;
|
||||
|
||||
osg::Vec3 pos = _imageCursor + osg::Vec3(-image_width*0.5f,-height*image_height*0.1f,-image_height*0.5f);
|
||||
osg::Vec3 pos = _imageCursor + osg::Vec3(-image_width*0.5f+offset,-offset,-image_height*0.5f-offset);
|
||||
|
||||
osg::Geometry* backgroundQuad = osg::createTexturedQuadGeometry(pos,
|
||||
osg::Vec3(image_width,0.0f,0.0f),
|
||||
@ -236,7 +242,7 @@ void SlideShowConstructor::addModel(const std::string& filename,float scale,floa
|
||||
if (!_currentLayer) addLayer();
|
||||
|
||||
osg::Node* model = osgDB::readNodeFile(filename);
|
||||
|
||||
|
||||
if (!model) return;
|
||||
|
||||
osg::Vec3 pos = _modelLeft*(1.0f-position) + _modelRight*position;
|
||||
|
@ -57,7 +57,9 @@ protected:
|
||||
osg::Vec4 _textColor;
|
||||
std::string _textFont;
|
||||
float _titleHeight;
|
||||
float _titleWidth;
|
||||
float _textHeight;
|
||||
float _textWidth;
|
||||
std::string _presentationName;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user