本文整理汇总了C++中Triangle::Prepare方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangle::Prepare方法的具体用法?C++ Triangle::Prepare怎么用?C++ Triangle::Prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Triangle
的用法示例。
在下文中一共展示了Triangle::Prepare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MultiCollide
void MultiCollide(const Triangle &tri0, const Triangle &tri1, const Triangle &tri2, const Triangle &tri3,
ShadowContext &ctx, int sidx, int firstA, int lastA) {
//TODO: ulozyc odpowiednio (wektorowo) i liczyc test RayInterval - 4 trojkaty
Vec3q tnrm[4], tvec0[4], tvec1[4];
floatq tmul[4], zero(0.0f), one(1.0f);
tri0.Prepare(ctx, tnrm[0], tvec0[0], tvec1[0], tmul[0]);
tri1.Prepare(ctx, tnrm[1], tvec0[1], tvec1[1], tmul[1]);
tri2.Prepare(ctx, tnrm[2], tvec0[2], tvec1[2], tmul[2]);
tri3.Prepare(ctx, tnrm[3], tvec0[3], tvec1[3], tmul[3]);
for(int q = firstA; q <= lastA; q++) {
Vec3q dir = ctx.rayDir[q];
floatq distance = ctx.distance[q];
floatq idet[4] = { Inv(dir | tnrm[0]), Inv(dir | tnrm[1]), Inv(dir | tnrm[2]), Inv(dir | tnrm[3]) };
floatq dist[4] = { idet[0] * tmul[0], idet[1] * tmul[1], idet[2] * tmul[2], idet[3] * tmul[3] };
floatq v[4] = {
(dir | tvec0[0]) * idet[0],
(dir | tvec0[1]) * idet[1],
(dir | tvec0[2]) * idet[2],
(dir | tvec0[3]) * idet[3],
};
floatq u[4] = {
(dir | tvec1[0]) * idet[0],
(dir | tvec1[1]) * idet[1],
(dir | tvec1[2]) * idet[2],
(dir | tvec1[3]) * idet[3],
};
f32x4b test[4] = {
Min(u[0], v[0]) >= zero && u[0] + v[0] <= one,
Min(u[1], v[1]) >= zero && u[1] + v[1] <= one,
Min(u[2], v[2]) >= zero && u[2] + v[2] <= one,
Min(u[3], v[3]) >= zero && u[3] + v[3] <= one,
};
test[0] = test[0] /*&& idet[0] > zero*/ && dist[0] >= zero;
test[1] = test[1] /*&& idet[1] > zero*/ && dist[1] >= zero;
test[2] = test[2] /*&& idet[2] > zero*/ && dist[2] >= zero;
test[3] = test[3] /*&& idet[3] > zero*/ && dist[3] >= zero;
f32x4 minDist = distance;
minDist = Condition(test[0] && dist[0] < minDist, dist[0], minDist);
minDist = Condition(test[1] && dist[1] < minDist, dist[1], minDist);
minDist = Condition(test[2] && dist[2] < minDist, dist[2], minDist);
minDist = Condition(test[3] && dist[3] < minDist, dist[3], minDist);
test[0] = test[0] && dist[0] <= minDist;
test[1] = test[1] && dist[1] <= minDist;
test[2] = test[2] && dist[2] <= minDist;
test[3] = test[3] && dist[3] <= minDist;
ctx.distance[q] = minDist;
}
}
示例2: Sphere
Scene::Scene()
: m_AmbientLight(0)
{
#if 0
#if 1
for (int i=0; i < 100; i++) {
DefaultShader *ds = new DefaultShader;
Sphere *s = new Sphere(Vector3d(Libvec::Random(-50, 50), Libvec::Random(-50, 50), Libvec::Random(-50, 50)), Libvec::Random(1, 20));
ds->SetDiffuseColor(colorf::RandColor());
ds->SetShinyness(0.0f);
s->SetShader(ShaderPtr(ds));
s->Prepare();
m_DrawableList.push_back(s);
}
#endif
Sphere *s = new Sphere(Vector3d(0.0, 0.0, 0.0), 50.0);
{
DefaultShader *ds = new DefaultShader;
ds->SetShinyness(0.0f);
s->SetShader(ShaderPtr(ds));
s->Prepare();
}
m_DrawableList.push_back(s);
Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, -50.0), Vector3d(0.0, 0.0, 1.0)));
{
DefaultShader *ds = new DefaultShader;
ds->SetShinyness(0.2f);
p->SetShader(ShaderPtr(ds));
p->Prepare();
}
m_DrawableList.push_back(p);
p = new Plane(Ray(Vector3d(-50.0, 0.0, 0.0), Vector3d(1.0, 0.0, 0.0)));
{
DefaultShader *ds = new DefaultShader;
ds->SetShinyness(0.0f);
p->SetShader(ShaderPtr(ds));
p->Prepare();
}
m_DrawableList.push_back(p);
m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 0.0, 100.0), colorf(1.0, 0.0, 0.0), 100));
m_SimpleLightList.push_back(new SimpleLight(Vector3d(100.0, 0.0, 5.0), colorf(0.0, 1.0, 0.0), 100));
m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 100.0, 5.0), colorf(0.0, 0.0, 1.0), 100));
m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 60.0, 60.0), colorf(1.0, 1.0, 1.0), 100));
#endif
#if 0
m_AmbientLight = colorf(0.0f, 0.0f, 0.0f);
{
Sphere *s = new Sphere(Vector3d(10.0, 10.0, 10.0), 8.0);
{
DefaultShader *ds = new DefaultShader;
ds->SetShinyness(0.8f);
s->SetShader(ShaderPtr(ds));
s->Prepare();
}
m_DrawableList.push_back(s);
}
// bottom
{
Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0)));
DefaultShader *ds = new DefaultShader;
ds->SetDiffuseColor(colorf(1.0, 0.2, 0.2));
ds->SetShinyness(0.5f);
p->SetShader(ShaderPtr(ds));
p->Prepare();
m_DrawableList.push_back(p);
}
{
Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 1.0, 0.0)));
DefaultShader *ds = new DefaultShader;
ds->SetDiffuseColor(colorf(0.2, 1.0, 0.2));
ds->SetShinyness(0.5f);
p->SetShader(ShaderPtr(ds));
p->Prepare();
m_DrawableList.push_back(p);
}
// back
{
Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(1.0, 0.0, 0.0)));
DefaultShader *ds = new DefaultShader;
ds->SetDiffuseColor(colorf(0.2, 0.2, 1.0));
ds->SetShinyness(0.5f);
p->SetShader(ShaderPtr(ds));
p->Prepare();
m_DrawableList.push_back(p);
}
// m_SimpleLightList.push_back(new SimpleLight(Vector3d(1.0, 1.0, 100.0), colorf(1.0, 0.0, 0.0), 100));
// m_SimpleLightList.push_back(new SimpleLight(Vector3d(100.0, 1.0, 5.0), colorf(0.0, 1.0, 0.0), 100));
// m_SimpleLightList.push_back(new SimpleLight(Vector3d(1.0, 100.0, 5.0), colorf(0.0, 0.0, 1.0), 100));
m_SimpleLightList.push_back(new SimpleLight(Vector3d(20.0, 10.0, 20), colorf(1.0, 1.0, 1.0), 100));
#endif
#if 1
m_AmbientLight = colorf(0.0f, 0.0f, 0.2f);
if (0) {
//.........这里部分代码省略.........