本文整理汇总了C++中ModelNode::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::setPosition方法的具体用法?C++ ModelNode::setPosition怎么用?C++ ModelNode::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::setPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModelNode
ModelNode *Md2Importer::getModelNode() {
// retrieves the main md2 frame
Md2Frame *mainMd2Frame = this->getMainMd2Frame();
// creates a new model node
ModelNode *modelNode = new ModelNode();
// sets the model node position
modelNode->setPosition(0.0, 0.0, 0.0);
// sets the mesh list in the model node
modelNode->setMeshList(&mainMd2Frame->meshList);
// returns the model node
return modelNode;
}
示例2: update
void AnimNode::update(Model *model, float lastFrame, float nextFrame, float scale) {
if (!_nodedata)
return;
ModelNode *target = model->getNode(_name);
if (!target)
return;
// Determine the corresponding keyframes
float posX, posY, posZ;
_nodedata->interpolatePosition(nextFrame, posX, posY, posZ);
float oX, oY, oZ, oA;
_nodedata->interpolateOrientation(nextFrame, oX, oY, oZ, oA);
// Update the position/orientation of corresponding modelnode
target->setPosition(posX * scale, posY * scale, posZ * scale);
target->setOrientation(oX, oY, oZ, oA);
}
示例3: giter
void
KML_Placemark::build( xml_node<>* node, KMLContext& cx )
{
Style masterStyle;
std::string styleUrl = getValue(node, "styleurl");
if (!styleUrl.empty())
{ // process a "stylesheet" style
const Style* ref_style = cx._sheet->getStyle( styleUrl, false );
if (ref_style)
{
masterStyle = masterStyle.combineWith(*ref_style);
}
}
xml_node<>* style = node->first_node("style", 0, false);
if ( style )
{ // process an "inline" style
KML_Style kmlStyle;
kmlStyle.scan(style, cx);
masterStyle = masterStyle.combineWith(cx._activeStyle);
}
// parse the geometry. the placemark must have geometry to be valid. The
// geometry parse may optionally specify an altitude mode as well.
KML_Geometry geometry;
geometry.build(node, cx, masterStyle);
Geometry* allGeom = geometry._geom.get();
if ( allGeom )
{
GeometryIterator giter( allGeom, false );
while( giter.hasMore() )
{
Geometry* geom = giter.next();
Style style = masterStyle;
AltitudeSymbol* alt = style.get<AltitudeSymbol>();
if ( geom && geom->getTotalPointCount() > 0 )
{
// resolve the proper altitude mode for the anchor point
AltitudeMode altMode = ALTMODE_RELATIVE;
if (alt &&
!alt->clamping().isSetTo( alt->CLAMP_TO_TERRAIN ) &&
!alt->clamping().isSetTo( alt->CLAMP_RELATIVE_TO_TERRAIN ) )
{
altMode = ALTMODE_ABSOLUTE;
}
GeoPoint position(cx._srs.get(), geom->getBounds().center(), altMode);
bool isPoly = geom->getComponentType() == Geometry::TYPE_POLYGON;
bool isPoint = geom->getComponentType() == Geometry::TYPE_POINTSET;
// check for symbols.
ModelSymbol* model = style.get<ModelSymbol>();
IconSymbol* icon = style.get<IconSymbol>();
TextSymbol* text = style.get<TextSymbol>();
// the annotation name:
std::string name = getValue(node, "name");
AnnotationNode* featureNode = 0L;
AnnotationNode* iconNode = 0L;
AnnotationNode* modelNode = 0L;
// one coordinate? It's a place marker or a label.
if ( (model || icon || text) && geom->getTotalPointCount() == 1 )
{
// load up the default icon if there we don't have one.
if ( !model && !icon )
{
icon = cx._options->defaultIconSymbol().get();
if ( icon )
style.add( icon );
}
// if there's a model, render that - models do NOT get labels.
if ( model )
{
ModelNode* node = new ModelNode( cx._mapNode, style, cx._dbOptions );
node->setPosition( position );
// model scale:
if ( cx._options->modelScale() != 1.0f )
{
float s = *cx._options->modelScale();
node->setScale( osg::Vec3f(s,s,s) );
}
// model local tangent plane rotation:
if ( !cx._options->modelRotation()->zeroRotation() )
{
node->setLocalRotation( *cx._options->modelRotation() );
}
modelNode = node;
}
//.........这里部分代码省略.........
示例4: giter
void
KML_Placemark::build( xml_node<>* node, KMLContext& cx )
{
Style masterStyle;
std::string styleUrl = getValue(node, "styleurl");
if (!styleUrl.empty())
{ // process a "stylesheet" style
const Style* ref_style = cx._sheet->getStyle( styleUrl, false );
if (ref_style)
{
masterStyle = masterStyle.combineWith(*ref_style);
}
}
xml_node<>* style = node->first_node("style", 0, false);
if ( style )
{ // process an "inline" style
KML_Style kmlStyle;
kmlStyle.scan(style, cx);
masterStyle = masterStyle.combineWith(cx._activeStyle);
}
// parse the geometry. the placemark must have geometry to be valid. The
// geometry parse may optionally specify an altitude mode as well.
KML_Geometry geometry;
geometry.build(node, cx, masterStyle);
Geometry* allGeom = geometry._geom.get();
if ( allGeom )
{
GeometryIterator giter( allGeom, false );
while( giter.hasMore() )
{
Geometry* geom = giter.next();
Style style = masterStyle;
AltitudeSymbol* alt = style.get<AltitudeSymbol>();
if ( geom && geom->getTotalPointCount() > 0 )
{
// resolve the proper altitude mode for the anchor point
AltitudeMode altMode = ALTMODE_RELATIVE;
if (alt &&
!alt->clamping().isSetTo( alt->CLAMP_TO_TERRAIN ) &&
!alt->clamping().isSetTo( alt->CLAMP_RELATIVE_TO_TERRAIN ) )
{
altMode = ALTMODE_ABSOLUTE;
}
GeoPoint position(cx._srs.get(), geom->getBounds().center(), altMode);
// check for symbols.
ModelSymbol* model = style.get<ModelSymbol>();
IconSymbol* icon = style.get<IconSymbol>();
TextSymbol* text = style.get<TextSymbol>();
// for a single point placemark, apply the default icon and text symbols
// if none are specified in the KML.
if (geom->getTotalPointCount() == 1)
{
if (!model && !icon && cx._options->defaultIconSymbol().valid())
{
icon = cx._options->defaultIconSymbol().get();
style.add(icon);
}
if (!text && cx._options->defaultTextSymbol().valid())
{
text = cx._options->defaultTextSymbol().get();
style.add(text);
}
}
// the annotation name:
std::string name = getValue(node, "name");
if (!name.empty())
{
OE_INFO << LC << "Placemark: " << name << std::endl;
}
AnnotationNode* featureNode = 0L;
AnnotationNode* iconNode = 0L;
AnnotationNode* modelNode = 0L;
// one coordinate? It's a place marker or a label.
if ( (model || icon || text) && geom->getTotalPointCount() == 1 )
{
// if there's a model, render that - models do NOT get labels.
if ( model )
{
ModelNode* node = new ModelNode( cx._mapNode, style, cx._dbOptions.get() );
node->setPosition( position );
// model scale:
if ( cx._options->modelScale() != 1.0f )
{
float s = *cx._options->modelScale();
//.........这里部分代码省略.........
示例5: if
void
KML_Placemark::build( const Config& conf, KMLContext& cx )
{
Style masterStyle;
if ( conf.hasValue("styleurl") )
{
// process a "stylesheet" style
const Style* ref_style = cx._sheet->getStyle( conf.value("styleurl"), false );
if ( ref_style )
masterStyle = *ref_style;
}
else if ( conf.hasChild("style") )
{
// process an "inline" style
KML_Style kmlStyle;
kmlStyle.scan( conf.child("style"), cx );
masterStyle = cx._activeStyle;
}
// parse the geometry. the placemark must have geometry to be valid. The
// geometry parse may optionally specify an altitude mode as well.
KML_Geometry geometry;
geometry.build(conf, cx, masterStyle);
Geometry* allGeom = geometry._geom.get();
if ( allGeom )
{
GeometryIterator giter( allGeom, false );
while( giter.hasMore() )
{
Geometry* geom = giter.next();
Style style = masterStyle;
// KML's default altitude mode is clampToGround.
AltitudeMode altMode = ALTMODE_RELATIVE;
AltitudeSymbol* altSym = style.get<AltitudeSymbol>();
if ( !altSym )
{
altSym = style.getOrCreate<AltitudeSymbol>();
altSym->clamping() = AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN;
altSym->technique() = AltitudeSymbol::TECHNIQUE_SCENE;
}
else if ( !altSym->clamping().isSetTo(AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN) )
{
altMode = ALTMODE_ABSOLUTE;
}
if ( geom && geom->getTotalPointCount() > 0 )
{
GeoPoint position(cx._srs.get(), geom->getBounds().center(), altMode);
bool isPoly = geom->getComponentType() == Geometry::TYPE_POLYGON;
bool isPoint = geom->getComponentType() == Geometry::TYPE_POINTSET;
// check for symbols.
ModelSymbol* model = style.get<ModelSymbol>();
IconSymbol* icon = style.get<IconSymbol>();
TextSymbol* text = style.get<TextSymbol>();
if ( !text && cx._options->defaultTextSymbol().valid() )
text = cx._options->defaultTextSymbol().get();
// the annotation name:
std::string name = conf.hasValue("name") ? conf.value("name") : "";
if ( text && !name.empty() )
{
text->content()->setLiteral( name );
}
AnnotationNode* featureNode = 0L;
AnnotationNode* iconNode = 0L;
AnnotationNode* modelNode = 0L;
// one coordinate? It's a place marker or a label.
if ( model || icon || text || geom->getTotalPointCount() == 1 )
{
// load up the default icon if there we don't have one.
if ( !model && !icon )
{
icon = cx._options->defaultIconSymbol().get();
if ( icon )
style.add( icon );
}
// if there's a model, render that - models do NOT get labels.
if ( model )
{
ModelNode* node = new ModelNode( cx._mapNode, style, cx._dbOptions );
node->setPosition( position );
if ( cx._options->modelScale() != 1.0f )
{
float s = *cx._options->modelScale();
node->setScale( osg::Vec3f(s,s,s) );
}
if ( !cx._options->modelRotation()->zeroRotation() )
{
//.........这里部分代码省略.........