第5讲 基本图元(上)

前言

视频地址

一 Geode

  1. Geode 继承关系
    Node
    |–Geode
    a.Geode 直接继承与Node 是末段节点
    b.没有Group属性,所以不能再添加其他节点
    c.主要功能 ①包围盒 ②持有Drawable(Geometry)
    d.实际上就是一个壳类型

  2. Geode的设置

Geode
GeomtryNode
Drawable
Geometry
其他可画
setColor
透明度
顶点
材质
纹理
  1. Drawable
Vertex
Shape
CLASS
addDrawable
addDrawable
构造
vertex
osg::Geometry
color
osg::Shap
osg::ShapeDrawable
osg::Box
osg::Capsule
osg::Sphere
osg::Cylinder
Drawable
Geode

解释:
1.代码如下
Geode->addDrawable(ShapDrawable* )
new ShapeDrawable(new osg::Box);

二 创建简单box

osg::Geode*  CreateGeode()
{
	osg::Geode* node = new osg::Geode;

	osg::ref_ptr<osg::Box> box = new osg::Box;

	osg::ref_ptr<osg::ShapeDrawable> shap = new osg::ShapeDrawable(box.get());

	shap->setColor(osg::Vec4f(1.f,0.f,0.f,1.f));
	
	node->addDrawable(shap.get());

	return node;

}

1. 颜色

  1. shapeDrawable 设置颜色
    shap->setColor(osg::Vec4f(1.f,0.f,0.f,1.f));

2. 材质

3. 纹理

texture2d 和 image 要配合使用

	osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
	osg::ref_ptr<osg::Image> image   = osgDB::readImageFile("screen_shot_0_0.jpg");
	 
	texture->setImage(image.get());
	node->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture.get(),osg::StateAttribute::ON);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值