本文整理汇总了C++中SCENENODE类的典型用法代码示例。如果您正苦于以下问题:C++ SCENENODE类的具体用法?C++ SCENENODE怎么用?C++ SCENENODE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SCENENODE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unload
bool SPRITE2D::Load(
SCENENODE & parent,
const std::string & texturepath,
const std::string & texturename,
ContentManager & content,
float draworder)
{
Unload(parent);
assert(!draw.valid());
assert(!node.valid());
TEXTUREINFO texinfo;
texinfo.mipmap = false;
texinfo.repeatu = false;
texinfo.repeatv = false;
texinfo.npot = false;
std::tr1::shared_ptr<TEXTURE> texture;
if (!content.load(texturepath, texturename, texinfo, texture)) return false;
node = parent.AddNode();
SCENENODE & noderef = parent.GetNode(node);
draw = noderef.GetDrawlist().twodim.insert(DRAWABLE());
DRAWABLE & drawref = GetDrawableFromNode(noderef);
drawref.SetDiffuseMap(texture);
drawref.SetVertArray(&varray);
drawref.SetDrawOrder(draworder);
drawref.SetCull(false, false);
drawref.SetColor(r,g,b,a);
//std::cout << "Sprite draworder: " << draworder << std::endl;
return true;
}
示例2: AddRacinglineScenenode
void ROADPATCH::AddRacinglineScenenode(
SCENENODE & node,
const ROADPATCH & nextpatch,
std::tr1::shared_ptr<TEXTURE> racingline_texture)
{
//Create racing line scenenode
keyed_container <DRAWABLE>::handle drawhandle = node.GetDrawlist().normal_blend.insert(DRAWABLE());
DRAWABLE & draw = node.GetDrawlist().normal_blend.get(drawhandle);
draw.SetDiffuseMap(racingline_texture);
draw.SetDecal(true);
draw.SetVertArray(&racingline_vertexarray);
const MATHVECTOR <float, 3> & r0 = patch.GetRacingLine();
const MATHVECTOR <float, 3> & r1 = nextpatch.patch.GetRacingLine();
MATHVECTOR <float, 3> v0 = r0 + (patch.GetPoint(0,0) - r0).Normalize()*0.1;
MATHVECTOR <float, 3> v1 = r0 + (patch.GetPoint(0,3) - r0).Normalize()*0.1;
MATHVECTOR <float, 3> v2 = r1 + (nextpatch.GetPatch().GetPoint(0,3) - r1).Normalize()*0.1;
MATHVECTOR <float, 3> v3 = r1 + (nextpatch.GetPatch().GetPoint(0,0) - r1).Normalize()*0.1;
float trackoffset = 0.1;
v0[2] += trackoffset;
v1[2] += trackoffset;
v2[2] += trackoffset;
v3[2] += trackoffset;
float vcorners[12];
float uvs[8];
int bfaces[6];
vcorners[0] = v0[0]; vcorners[1] = v0[1]; vcorners[2] = v0[2];
vcorners[3] = v1[0]; vcorners[4] = v1[1]; vcorners[5] = v1[2];
vcorners[6] = v2[0]; vcorners[7] = v2[1]; vcorners[8] = v2[2];
vcorners[9] = v3[0]; vcorners[10] = v3[1]; vcorners[11] = v3[2];
uvs[0] = 0;
uvs[1] = 0;
uvs[2] = 1;
uvs[3] = 0;
uvs[4] = 1;
uvs[5] = (v2-v1).Magnitude();
uvs[6] = 0;
uvs[7] = (v2-v1).Magnitude();
bfaces[0] = 0;
bfaces[1] = 2;
bfaces[2] = 1;
bfaces[3] = 0;
bfaces[4] = 3;
bfaces[5] = 2;
racingline_vertexarray.SetFaces(bfaces, 6);
racingline_vertexarray.SetVertices(vcorners, 12);
racingline_vertexarray.SetTexCoordSets(1);
racingline_vertexarray.SetTexCoords(0, uvs, 8);
}
示例3: ConfigureDrawable
void ConfigureDrawable(keyed_container <DRAWABLE>::handle & ref, SCENENODE & topnode, float r, float g, float b)
{
if (!ref.valid())
{
ref = topnode.GetDrawlist().normal_noblend.insert(DRAWABLE());
DRAWABLE & d = topnode.GetDrawlist().normal_noblend.get(ref);
d.SetColor(r,g,b,1);
d.SetDecal(true);
}
}
示例4: SetupText
static keyed_container <DRAWABLE>::handle SetupText(
SCENENODE & parent, FONT & font,
TEXT_DRAW & textdraw, const std::string & str,
float x, float y, float scalex, float scaley,
float r, float g , float b, float zorder = 0)
{
keyed_container<DRAWABLE>::handle draw = parent.GetDrawlist().text.insert(DRAWABLE());
DRAWABLE & drawref = parent.GetDrawlist().text.get(draw);
textdraw.Set(drawref, font, str, x, y, scalex, scaley, r, g, b);
drawref.SetDrawOrder(zorder);
return draw;
}
示例5: SetupDrawable
void GUILABEL::SetupDrawable(
SCENENODE & scene,
const FONT & font,
int align,
float scalex, float scaley,
float x, float y,
float w, float h, float z)
{
m_font = &font;
m_x = x;
m_y = y;
m_w = w;
m_h = h;
m_scalex = scalex;
m_scaley = scaley;
m_align = align;
m_draw = scene.GetDrawlist().text.insert(DRAWABLE());
DRAWABLE & drawref = GetDrawable(scene);
drawref.SetDrawOrder(z);
float textw = 0;
if (align == -1) x -= w * 0.5;
else if (align == 0) x -= textw * 0.5;
else if (align == 1) x -= (textw - w * 0.5);
m_text_draw.Set(drawref, font, m_text, x, y, scalex, scaley, m_r, m_g, m_b);
}
示例6: SetupDrawable
void WIDGET_LABEL::SetupDrawable(
SCENENODE & scene,
const FONT & font,
const std::string & text,
float x, float y,
float scalex, float scaley,
float nr, float ng, float nb,
float z, bool centered)
{
savedfont = &font;
r = nr;
b = nb;
g = ng;
saved_x = x;
saved_y = y;
saved_scalex = scalex;
saved_scaley = scaley;
saved_centered = centered;
draw = scene.GetDrawlist().text.insert(DRAWABLE());
DRAWABLE & drawref = GetDrawable(scene);
drawref.SetDrawOrder(z);
if (centered) x = x - savedfont->GetWidth(text) * saved_scalex * 0.5;
text_draw.Set(drawref, font, text, x, y, scalex, scaley, r, g, b);
}
示例7: EraseTextDrawable
static void EraseTextDrawable(SCENENODE & node, keyed_container<DRAWABLE>::handle & drawhandle)
{
if (drawhandle.valid())
{
node.GetDrawlist().twodim.erase(drawhandle);
drawhandle.invalidate();
}
}
示例8: Set
void HUDBAR::Set(
SCENENODE & parent,
std::tr1::shared_ptr<TEXTURE> bartex,
float x, float y, float w, float h,
float opacity,
bool flip)
{
draw = parent.GetDrawlist().twodim.insert(DRAWABLE());
DRAWABLE & drawref = parent.GetDrawlist().twodim.get(draw);
drawref.SetDiffuseMap(bartex);
drawref.SetVertArray(&verts);
drawref.SetCull(false, false);
drawref.SetColor(1,1,1,opacity);
drawref.SetDrawOrder(1);
verts.SetTo2DButton(x, y, w, h, h*0.75, flip);
}
示例9: GetNode
void SPRITE2D::Unload(SCENENODE & parent)
{
if (node.valid())
{
SCENENODE & noderef = GetNode(parent);
noderef.GetDrawlist().twodim.erase(draw);
parent.Delete(node);
}
node.invalidate();
draw.invalidate();
varray.Clear();
}
示例10: SetupDrawable
void GUIIMAGE::SetupDrawable(
SCENENODE & scene,
ContentManager & content,
const std::string & imagepath,
float x, float y, float w, float h, float z)
{
m_content = &content;
m_imagepath = imagepath;
m_varray.SetToBillboard(x - w * 0.5f, y - h * 0.5f, x + w * 0.5f, y + h * 0.5f);
m_draw = scene.GetDrawlist().twodim.insert(DRAWABLE());
DRAWABLE & drawref = GetDrawable(scene);
drawref.SetVertArray(&m_varray);
drawref.SetCull(false, false);
drawref.SetDrawOrder(z);
}
示例11: AddDrawable
static keyed_container<DRAWABLE>::handle AddDrawable(SCENENODE & node)
{
return node.GetDrawlist().twodim.insert(DRAWABLE());
}
示例12: LoadWheel
static bool LoadWheel(
const PTree & cfg_wheel,
struct LoadDrawable & loadDrawable,
SCENENODE & topnode,
std::ostream & error_output)
{
keyed_container<SCENENODE>::handle wheelnode = topnode.AddNode();
ContentManager & content = loadDrawable.content;
const std::string& path = loadDrawable.path;
std::string meshname;
std::vector<std::string> texname;
if (!cfg_wheel.get("mesh", meshname, error_output)) return false;
if (!cfg_wheel.get("texture", texname, error_output)) return false;
std::string tiredim;
const PTree * cfg_tire;
if (!cfg_wheel.get("tire", cfg_tire, error_output)) return false;
if (!cfg_tire->get("size", tiredim, error_output)) return false;
MATHVECTOR<float, 3> size(0);
cfg_tire->get("size", size);
float width = size[0] * 0.001;
float diameter = size[2] * 0.0254;
// get wheel disk mesh
std::tr1::shared_ptr<MODEL> mesh;
if (!content.load(path, meshname, mesh)) return false;
// gen wheel mesh
if (!content.get(path, meshname+tiredim, mesh))
{
VERTEXARRAY rimva, diskva;
MESHGEN::mg_rim(rimva, size[0], size[1], size[2], 10);
diskva = mesh->GetVertexArray();
diskva.Translate(-0.75 * 0.5, 0, 0);
diskva.Scale(width, diameter, diameter);
content.load(path, meshname+tiredim, rimva + diskva, mesh);
}
// load wheel
if (!loadDrawable(meshname+tiredim, texname, cfg_wheel, topnode, &wheelnode))
{
return false;
}
// tire (optional)
texname.clear();
if (!cfg_tire->get("texture", texname, error_output)) return true;
// gen tire mesh
if (!content.get(path, "tire"+tiredim, mesh))
{
VERTEXARRAY tireva;
MESHGEN::mg_tire(tireva, size[0], size[1], size[2]);
content.load(path, "tire"+tiredim, tireva, mesh);
}
// load tire
if (!loadDrawable("tire"+tiredim, texname, *cfg_tire, topnode.GetNode(wheelnode)))
{
return false;
}
// brake (optional)
texname.clear();
std::string brakename;
const PTree * cfg_brake;
if (!cfg_wheel.get("brake", cfg_brake, error_output)) return true;
if (!cfg_brake->get("texture", texname)) return true;
float radius;
std::string radiusstr;
cfg_brake->get("radius", radius);
cfg_brake->get("radius", radiusstr);
// gen brake disk mesh
if (!content.get(path, "brake"+radiusstr, mesh))
{
float diameter_mm = radius * 2 * 1000;
float thickness_mm = 0.025 * 1000;
VERTEXARRAY brakeva;
MESHGEN::mg_brake_rotor(brakeva, diameter_mm, thickness_mm);
content.load(path, "brake"+radiusstr, brakeva, mesh);
}
// load brake disk
if (!loadDrawable("brake"+radiusstr, texname, *cfg_brake, topnode.GetNode(wheelnode)))
{
return false;
}
return true;
}
示例13: SetVisible
void HUDBAR::SetVisible(SCENENODE & parent, bool newvis)
{
DRAWABLE & drawref = parent.GetDrawlist().twodim.get(draw);
drawref.SetDrawEnable(newvis);
}
示例14: Erase
inline void Erase(SCENENODE & node, keyed_container <DRAWABLE>::handle & drawhandle)
{
if (drawhandle.valid()) node.GetDrawlist().twodim.erase(drawhandle);
}
示例15: AddRacinglineScenenode
void ROADPATCH::AddRacinglineScenenode(
SCENENODE & node,
const ROADPATCH & nextpatch,
std::tr1::shared_ptr<TEXTURE> racingline_texture)
{
//Create racing line scenenode
keyed_container <DRAWABLE>::handle drawhandle = node.GetDrawlist().normal_blend.insert(DRAWABLE());
DRAWABLE & draw = node.GetDrawlist().normal_blend.get(drawhandle);
draw.SetDiffuseMap(racingline_texture);
draw.SetDecal(true);
draw.SetVertArray(&racingline_vertexarray);
MATHVECTOR <float, 3> v0 = racing_line + (patch.GetPoint(0,0) - racing_line).Normalize()*0.1;
MATHVECTOR <float, 3> v1 = racing_line + (patch.GetPoint(0,3) - racing_line).Normalize()*0.1;
MATHVECTOR <float, 3> v2 = nextpatch.racing_line + (nextpatch.GetPatch().GetPoint(0,3) - nextpatch.racing_line).Normalize()*0.1;
MATHVECTOR <float, 3> v3 = nextpatch.racing_line + (nextpatch.GetPatch().GetPoint(0,0) - nextpatch.racing_line).Normalize()*0.1;
//transform from bezier space into world space
v0.Set(v0[2],v0[0],v0[1]);
v1.Set(v1[2],v1[0],v1[1]);
v2.Set(v2[2],v2[0],v2[1]);
v3.Set(v3[2],v3[0],v3[1]);
float trackoffset = 0.1;
v0[2] += trackoffset;
v1[2] += trackoffset;
v2[2] += trackoffset;
v3[2] += trackoffset;
float vcorners[12];
float uvs[8];
int bfaces[6];
//std::cout << v0 << std::endl;
vcorners[0] = v0[0]; vcorners[1] = v0[1]; vcorners[2] = v0[2];
vcorners[3] = v1[0]; vcorners[4] = v1[1]; vcorners[5] = v1[2];
vcorners[6] = v2[0]; vcorners[7] = v2[1]; vcorners[8] = v2[2];
vcorners[9] = v3[0]; vcorners[10] = v3[1]; vcorners[11] = v3[2];
//std::cout << v0 << endl;
//std::cout << racing_line << endl;
uvs[0] = 0;
uvs[1] = 0;
uvs[2] = 1;
uvs[3] = 0;
uvs[4] = 1;
uvs[5] = (v2-v1).Magnitude();
uvs[6] = 0;
uvs[7] = (v2-v1).Magnitude();
bfaces[0] = 0;
bfaces[1] = 2;
bfaces[2] = 1;
bfaces[3] = 0;
bfaces[4] = 3;
bfaces[5] = 2;
racingline_vertexarray.SetFaces(bfaces, 6);
racingline_vertexarray.SetVertices(vcorners, 12);
racingline_vertexarray.SetTexCoordSets(1);
racingline_vertexarray.SetTexCoords(0, uvs, 8);
}