当前位置: 首页>>代码示例>>C++>>正文


C++ Primitive类代码示例

本文整理汇总了C++中Primitive的典型用法代码示例。如果您正苦于以下问题:C++ Primitive类的具体用法?C++ Primitive怎么用?C++ Primitive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Primitive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: atoi

bool Commands::prmSetPatch(int argc, char** argv) {
    const Line* cur_state = CommandLine::getState();

    // if state is blank we have nothing selected
    // print error message and skip
    if (cur_state) {
        if (cur_state->toCommandID() == Commands::primitive_get_cmd_id) {
            int patch_x = atoi(argv[1]);
            int patch_y = atoi(argv[2]);
            float patch_x_f = atof(argv[1]);
            float patch_y_f = atof(argv[2]);
            if (patch_x_f > 0.0 && patch_y_f > 0.0 &&
                patch_x_f - patch_x == 0 && patch_y_f - patch_y == 0)
            {
                Primitive* prm = dynamic_cast<Primitive*>(
                    Renderable::get(cur_state->tokens[1]));
                prm->setPatch(patch_x, patch_y);
                return true;
            } else {
                fprintf(stderr, "ERROR input values for %s must be 2 non negative integers\n",
                    argv[0]);
            }
        } else {
            fprintf(stderr, "ERROR %s requires that you have a Primitive selected\n",
                argv[0]);
        }
    } else {
        fprintf(stderr, "ERROR %s requires that you have a Primitive selected\n",
            argv[0]);
    }
    return false;
}
开发者ID:jjoo172,项目名称:CS171,代码行数:32,代码来源:commands.cpp

示例2: atof

bool Commands::prmSetSpecular(int argc, char** argv) {
    const Line* cur_state = CommandLine::getState();

    // if state is blank we have nothing selected
    // print error message and skip
    if (cur_state) {
        if (cur_state->toCommandID() == Commands::primitive_get_cmd_id) {
            float specular = atof(argv[1]);
            if (specular >= 0.0 && specular <= 1.0) {
                Primitive* prm = dynamic_cast<Primitive*>(
                    Renderable::get(cur_state->tokens[1]));
                prm->setSpecular(specular);
                return true;
            } else {
                fprintf(stderr, "ERROR input values for %s must be 1 numerical value between 0.0 and 1.0 (inclusive)\n",
                    argv[0]);
            }
        } else {
            fprintf(stderr, "ERROR %s requires that you have a Primitive selected\n",
                argv[0]);
        }
    } else {
        fprintf(stderr, "ERROR %s requires that you have a Primitive selected\n",
            argv[0]);
    }
    return false;
}
开发者ID:jjoo172,项目名称:CS171,代码行数:27,代码来源:commands.cpp

示例3: tick

int Tween::tick(double time) {
    if(!active) return 0;

    Primitive *prim = (Primitive*) primitives.edit(idx);
    if(!prim) return 1;

    passed += time;
    if(passed >= duration) passed = duration;

    if(reverse) {
        value = to - (to - from) * passed / duration;        
    } else {
        value = from + (to - from) * passed / duration;
    }

    prim->change(name, (int)rint(value));

    if(passed == duration) {
        if(repeat) {
            passed = 0.0;
            reverse = !reverse;
        } else {
            return 1;
        }
    }

    return 0;
}
开发者ID:randrews,项目名称:scribble,代码行数:28,代码来源:effect.cpp

示例4: createSegment

  Primitive* PlattfussSchlange::createSegment(int index, const OdeHandle& odeHandle){
    Primitive* p;

    /////////// MIDDLE SEGMENT (BODY)
    if ( index*2 == conf.segmNumber-1) {
      //p = new Box(conf.segmLength*1.5,conf.segmLength*1.5, conf.segmLength*.6);
      //p = new Capsule(conf.segmDia*.8/*2.8*/ , conf.segmLength*1);

       //  p = new Capsule(conf.segmLength/2 , conf.segmLength*2);
      p = new Sphere(conf.segmLength*.8);
      p->setTexture("Images/wood.rgb");
      p->init(odeHandle, conf.segmMass*2, osgHandle);
      // p->setPose( osg::Matrix::rotate(M_PI/2, 0, 1, 0)*osg::Matrix::translate( conf.segmDia, 0, 0) );
    } /////// FEED
    else if( (index == 0) | (index== conf.segmNumber-1)) {
      // p = new Capsule(conf.segmDia*.8/*2.8*/ , conf.segmLength*1);
       // p = new Sphere(conf.segmLength/2*2);
      p = new Box(1.8*conf.segmLength,3*conf.segmLength, conf.segmLength*.3);
      p->setTexture("Images/whitemetal_farbig_small.rgb");
      p->init(odeHandle, conf.segmMass*3, osgHandle);
    } /////// NORMAL SEGMENT
    else {
      p = SchlangeServo2::createSegment(index, odeHandle);
    }
    return p;
  }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:26,代码来源:plattfussschlange.cpp

示例5: MyRectangle

void scene::generateDefaultScene()
{

    //add bounding box

    MyRectangle *roomFloor = new MyRectangle(vector3(-70, 0, 0), vector3(-70, 0, -201), vector3(70, 0, -201),  materialConstants (0.7f,1.0f,1.0f, Rgb(0.9, 0.9, 0.3), 0));

  //Utils::rotateFloorMyRectangle(roomFloor, pii/13);
   float roomHeight = 130;
   vector<Primitive *> parallelogramSides = getParrallelogramSides(roomFloor, roomHeight);
   Primitive *leftSide = parallelogramSides[2];
   Primitive *rightSide = parallelogramSides[3];
   leftSide->setMaterial(materialConstants (1.0f,1.0f,1.0f, Rgb(1, 0.2, 0.2)));
   rightSide->setMaterial(materialConstants (1.0f,1.0f,1.0f, Rgb(0.2, 1, 0.2)));


   primitives.insert( primitives.end(), parallelogramSides.begin(), parallelogramSides.end() );

   //add box
   MyRectangle *base = new MyRectangle(vector3(-15, 0, -20), vector3(-45, 0, -20), vector3(-40, 0, -50),  materialConstants (1.0f,1.0f,1.0f, Rgb(0.9, 0.9, 0.3), 0));
   rotateFloorMyRectangle(base, pii/10);
  float boxHeight = 50;

  vector<Primitive *> baseSides = getParrallelogramSides(base, boxHeight);

   primitives.insert( primitives.end(), baseSides.begin(), baseSides.end() );



//add sphere----------------------------------------

  // Sphere *sp = new Sphere(20, vector3(-30, -20, -50), materialConstants (1.0f,0.2f, 1.0f,  Rgb(0.9, 0.8, 0.3), 1, 0.9));//glossy
 //  Sphere *sp = new Sphere(20, vector3(-30, -20, -50), materialConstants (1.0f,0.2f, 1.0f,  Rgb(0.9, 0.8, 0.3), 3, 0.9, 1.5));//refraction

   Sphere *spMirror = new Sphere(12, vector3(-30, -boxHeight-12, -35), materialConstants (1.0f,0.2f, 1.0f,  Rgb(0.8, 0.8, 0.8), 2, 0));//mirror
   primitives.push_back(spMirror);

//add light----------------------------------------
  MyRectangle *lightSource = new MyRectangle(vector3(-50, -roomHeight + 0.5f, -20), vector3(-50, -roomHeight + 0.5f, -150), vector3(50, -roomHeight + 0.5f, -150),  materialConstants (Rgb(0.8, 1, 1)));
 //  MyRectangle *lightSource = new MyRectangle(vector3(-30, -roomHeight + 0.5f, -30), vector3(-30, -roomHeight + 0.5f, -110), vector3(30, -roomHeight + 0.5f, -110),  materialConstants (Rgb(0.8, 1, 1)));

   lightSource->setIslightSource(true);
   cout << " LIGHT : " << lightSource->ifIsLightSource() << endl;

   primitives.push_back(lightSource);
//cylindre-------------------------------------------
   cylindre * cy = new cylindre(50, vector3(0,-1,0), vector3(37, 0, -30),17, materialConstants(1.0f,0.4f,1.0f, Rgb(1, 1, 1) , 1, 2.5));
   QImage fanta = QImage("fanta.jpg");
   cout << "height :"<< fanta.height() << endl;
   cout << "width : "<< fanta.width() << endl;

   cy->setTexture(fanta);

   primitives.push_back(cy);
   //refracting----------------------------------------------
   Sphere *sp = new Sphere(12, vector3(10, -12, -72), materialConstants (1.0f,0.2f, 1.0f,  Rgb(0.9, 0.8, 0.3), 3, 0.9, 1.2));//refraction
   primitives.push_back(sp);

   cout << "  i'm alive " << endl;
}
开发者ID:madiken,项目名称:image_synth,代码行数:60,代码来源:scene.cpp

示例6: srcParameter

void ToHoudiniCortexObjectConverter::transferAttribs( GU_Detail *geo, const GA_Range &points, const GA_Range &prims ) const
{
	GA_Primitive *hPrim = geo->getPrimitiveList().get( prims.begin().getOffset() );
	if ( hPrim->getTypeId() != GU_CortexPrimitive::typeId() )
	{
		return;
	}
	
	const Primitive *input = IECore::runTimeCast<const Primitive>( srcParameter()->getValue() );
	Primitive *output = IECore::runTimeCast<Primitive>( ((GU_CortexPrimitive *)hPrim)->getObject() );
	if ( !input || !output )
	{
		return;
	}
	
	const char *filter = attributeFilterParameter()->getTypedValue().c_str();
	for ( PrimitiveVariableMap::const_iterator it = input->variables.begin() ; it != input->variables.end(); ++it )
	{
		if ( !UT_String( it->first ).multiMatch( filter ) )
		{
			continue;
		}
		
		if ( output->isPrimitiveVariableValid( it->second ) )
		{
			output->variables[it->first] = it->second;
		}
	}
	
	if ( UT_String( "P" ).multiMatch( filter ) )
	{
		geo->setPos3( points.begin().getOffset(), IECore::convert<UT_Vector3>( input->bound().center() ) );
	}
}
开发者ID:UIKit0,项目名称:cortex,代码行数:34,代码来源:ToHoudiniCortexObjectConverter.cpp

示例7: volumeLightSample

Vec3f TraceBase::volumeLightSample(PathSampleGenerator &sampler,
                    MediumSample &mediumSample,
                    const Primitive &light,
                    const Medium *medium,
                    int bounce,
                    const Ray &parentRay)
{
    LightSample lightSample;
    if (!light.sampleDirect(_threadId, mediumSample.p, sampler, lightSample))
        return Vec3f(0.0f);

    Vec3f f = mediumSample.phase->eval(parentRay.dir(), lightSample.d);
    if (f == 0.0f)
        return Vec3f(0.0f);

    Ray ray = parentRay.scatter(mediumSample.p, lightSample.d, 0.0f);
    ray.setPrimaryRay(false);

    IntersectionTemporary data;
    IntersectionInfo info;
    Vec3f e = attenuatedEmission(sampler, light, medium, lightSample.dist, data, info, bounce, false, ray, nullptr);
    if (e == 0.0f)
        return Vec3f(0.0f);

    Vec3f lightF = f*e/lightSample.pdf;

    if (!light.isDirac())
        lightF *= SampleWarp::powerHeuristic(lightSample.pdf, mediumSample.phase->pdf(parentRay.dir(), lightSample.d));

    return lightF;
}
开发者ID:tunabrain,项目名称:tungsten,代码行数:31,代码来源:TraceBase.cpp

示例8: Ng_CreatePrimitive

  int Ng_CreatePrimitive (ClientData clientData,
			  Tcl_Interp * interp,
			  int argc, tcl_const char *argv[])
  {
    CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry.Ptr());
    if (!geometry)
      {
	Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
	return TCL_ERROR;
      }


    tcl_const char * classname = argv[1];
    tcl_const char * name = argv[2];

    cout << "Create primitive, class = " << classname
	 << ", name = " << name << endl;

    Primitive * nprim = Primitive::CreatePrimitive (classname);
    Solid * nsol = new Solid (nprim);

    char sname[100];
    for (int j = 1; j <= nprim->GetNSurfaces(); j++)
      {
	sprintf (sname, "%s,%d", name, j);
	geometry -> AddSurface (sname, &nprim->GetSurface(j));
	nprim -> SetSurfaceId (j, geometry->GetNSurf());
      }

    geometry->SetSolid (name, nsol);

    return TCL_OK;
  }
开发者ID:AlexanderToifl,项目名称:viennamesh-dev,代码行数:33,代码来源:csgpkg.cpp

示例9: attenuatedEmission

Vec3f TraceBase::attenuatedEmission(PathSampleGenerator &sampler,
                         const Primitive &light,
                         const Medium *medium,
                         float expectedDist,
                         IntersectionTemporary &data,
                         IntersectionInfo &info,
                         int bounce,
                         bool startsOnSurface,
                         Ray &ray,
                         Vec3f *transmittance)
{
    CONSTEXPR float fudgeFactor = 1.0f + 1e-3f;

    if (light.isDirac()) {
        ray.setFarT(expectedDist);
    } else {
        if (!light.intersect(ray, data) || ray.farT()*fudgeFactor < expectedDist)
            return Vec3f(0.0f);
    }
    info.p = ray.pos() + ray.dir()*ray.farT();
    info.w = ray.dir();
    light.intersectionInfo(data, info);

    Vec3f shadow = generalizedShadowRay(sampler, ray, medium, &light, startsOnSurface, true, bounce);
    if (transmittance)
        *transmittance = shadow;
    if (shadow == 0.0f)
        return Vec3f(0.0f);

    return shadow*light.evalDirect(data, info);
}
开发者ID:tunabrain,项目名称:tungsten,代码行数:31,代码来源:TraceBase.cpp

示例10: Trace

/*!
	@brief		トレース
	@param[o]	out: 出力輝度
	@param[i]	ray: 光線
	@param[i]	depth: 深度
 */
void Renderer::Trace(Color& out, const Ray& ray, std::size_t depth)
{
	Primitive* prim = NULL;
	Primitive::Param param;

	if((depth >= max_depth) || !FindNearest(&prim, param, ray))
	{
		out = scene->GetBGColor();
		return;
	}

	Vertex v;
	prim->CalcVertex(v, param, ray);
	Material* mtrl = prim->GetMaterial();

	// emittance
	out = mtrl->e;
 #ifdef USE_LOCAL_ILLUMINATION
	// direct lighting
	Color direct;
	DirectLighting(direct, ray, v, *mtrl);
	ColorAdd3(&out, &out, &direct);
 #endif // USE_LOCAL_ILLUMINATION
 #ifdef USE_GLOBAL_ILLUMINATION
	// indirect lighting
	Color indirect;
	IndirectLighting(indirect, ray, v, *mtrl, depth);
	ColorAdd3(&out, &out, &indirect);
 #endif // USE_GLOBAL_ILLUMINATION
}
开发者ID:Hasenpfote,项目名称:MonteCarloPathTracing,代码行数:36,代码来源:renderer.cpp

示例11: assert

Primitive*
PAPER_DOLL::build_primitive(CBface_list& o_faces)
{
   LMESHptr skel_mesh = dynamic_pointer_cast<LMESH>(o_faces.mesh());
   assert(skel_mesh);
   LMESHptr mesh = get_inflate_mesh(skel_mesh);
   assert(mesh);

   // create vertices for top and bottom parts:
   Bvert_list o_verts = o_faces.get_verts();            // original verts
   Bvert_list t_verts = copy_verts(o_verts, mesh);      // top verts
   Bvert_list b_verts = copy_verts(o_verts, mesh);      // bottom verts

   // set up mappings:
   //   original --> top
   //   original --> bottom
   VertMapper t_map(o_verts, t_verts, true);
   VertMapper b_map(o_verts, b_verts, true);

   Primitive* ret = new Primitive(mesh, skel_mesh);

   // build dependencies
   Bsurface_list surfs = Bsurface::get_surfaces(o_faces);
   for (int i = 0; i < surfs.num(); i++)
      ret->absorb_skel(surfs[i]);

   // generate top faces and bottom faces
   Bface_list t_faces = copy_faces(o_faces, t_map, ret, false);
   Bface_list b_faces = copy_faces(o_faces, b_map, ret, true);

   // create the sides:
   create_sides(o_faces, t_map, b_map, ret);

   Wvec n = o_faces.avg_normal();
   if (1) {
      define_offsets(o_verts, t_map, b_map, n, ret);
   } else {
      // under construction...
      //  for now just offset the top and bottom uniformly for testing...
      const double k = Config::get_var_dbl("PAPER_DOLL_OFFSET_SCALE",1.0);
      double       h = o_faces.get_edges().strong_edges().avg_len();
      t_verts.transform(Wtransf::translation( 0.5*k*h*n));
      b_verts.transform(Wtransf::translation(-0.5*k*h*n));
   }


   // make it all undoable:
   MULTI_CMDptr cmd = make_shared<MULTI_CMD>();

   // finish build
   ret->finish_build(cmd);

   //cmd->add(hide_surfs_cmd(Bsurface::get_surfaces(o_faces)));
   cmd->add(make_shared<SHOW_BBASE_CMD>(ret));
   WORLD::add_command(cmd);

   return _prim = ret;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:58,代码来源:paper_doll.cpp

示例12: Renderer

//////////////////////////////////////////////////////////
//
// RayTracer implementation
// =========
RayTracer::RayTracer(Scene& scene, Camera* camera) :
Renderer(scene, camera),
maxRecursionLevel(6),
minWeight(MIN_WEIGHT)
//[]---------------------------------------------------[]
//|  Constructor                                        |
//[]---------------------------------------------------[]
{
	// TODO: UNCOMMENT THE CODE BELOW

	int n = scene.getNumberOfActors();

	printf("Building aggregates for %d actors...\n", n);

	clock_t t = clock();
	Array<ModelPtr> models(n);
	map<uint, ModelPtr> aggregates;
	string actorNames;
	int totalNodes = 0;
	int i = 1;

	for (ActorIterator ait(scene.getActorIterator()); ait; i++)
	{
		const Actor* a = ait++;

		printf("Processing actor %d/%d...\n", i, n);
		if (!a->isVisible())
			continue;

		Primitive* p = dynamic_cast<Primitive*>(a->getModel());
		const TriangleMesh* mesh = p->triangleMesh();
		// checking if the id already exists in idList

		if (mesh != 0)	
		{
			ModelPtr& a = aggregates[mesh->id];

			BVH* bvh = new BVH(std::move(p->refine()));

			totalNodes += bvh->size();
			a = bvh;

			models.add(new ModelInstance(*a, *p));
			
		}
	}
	printf("Building scene aggregate...\n");
	{
		BVH* bvh = new BVH(std::move(models));

		totalNodes += bvh->size();
		aggregate = bvh;
	}
	printf("BVH(s) built: %d (%d nodes)\n", aggregates.size() + 1, totalNodes);
	printElapsedTime("", clock() - t);

}
开发者ID:marcostx,项目名称:RayTracer2016,代码行数:61,代码来源:RayTracer.cpp

示例13: Add

void Primitive::Add( Primitive& primitive ) {
	const std::vector<Vertex>& vertices( primitive.GetVertices() );
	const std::vector<GLuint>& indices( primitive.GetIndices() );

	std::size_t index_count = indices.size();

	for( std::size_t index_index = 0; index_index < index_count; ++index_index ) {
		AddVertex( vertices[ indices[index_index] ] );
	}
}
开发者ID:ksandison,项目名称:sfgui,代码行数:10,代码来源:Primitive.cpp

示例14: glLineWidth

void Connections::paintGL()
{
    glLineWidth(1);
    for (int i = 0; i < prims.length(); i++){
        Primitive* p = prims.at(i);
        p->paintGL();
    }
    //paintPoints();
    glDisable(GL_DEPTH_TEST);
    if (selected) selected->paintGL();
}
开发者ID:satra,项目名称:brainbundler,代码行数:11,代码来源:connections.cpp

示例15: CHILD_DEFINE_NATIVE_METHOD

CHILD_DEFINE_NATIVE_METHOD(Alias, init) {
    CHILD_FIND_LAST_MESSAGE;
    CHILD_CHECK_INPUT_SIZE(1);
    Primitive *primitive = message->firstInput()->value();
    while(primitive) {
        Message *msg = Message::dynamicCast(primitive->value());
        if(!msg) CHILD_THROW(ArgumentException, "expected 'Message'");
        names().append(msg->name());
        primitive = primitive->next();
    }
    return this;
}
开发者ID:mvila,项目名称:child,代码行数:12,代码来源:alias.cpp


注:本文中的Primitive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。