Example #1
0
void
ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
{
  file->d->headerExtensionObject = this;
  file->seek(18, File::Current);
  long long dataSize = file->readDWORD();
  long long dataPos = 0;
  while(dataPos < dataSize) {
    ByteVector guid = file->readBlock(16);
    long long size = file->readQWORD();
    BaseObject *obj;
    if(guid == metadataGuid) {
      obj = new MetadataObject();
    }
    else if(guid == metadataLibraryGuid) {
      obj = new MetadataLibraryObject();
    }
    else {
      obj = new UnknownObject(guid);
    }
    obj->parse(file, size);
    objects.append(obj);
    dataPos += size;
  }
}
Example #2
0
Map::Map(char* filename, bool isBright, Game* game)
{
	int ID;
	int a[30000], n;
	srand((unsigned)time(NULL));
	FILE *outf = fopen(filename, "r");
	if (outf == NULL)
	{

		return;
	}

	int x, y;
	n = 0;
	BaseObject* obj = NULL;
	while (fscanf(outf, "%d" "%d" "%d", &ID, &x, &y) > 0)
	{
		switch (ID)
		{
		case 10:
			//obj = new Pipe(x, y, 80, 80, ID, game->_sprites[S_PIPE]);
			break;
		}
	}
	fclose(outf);
	obj = new Pipe(10, 10, 80, 80, 1010, game->_sprites[S_PIPE]);
	obj->Render();
	BaseObject* obj1 = NULL;
	obj1 = new BackGround(0, 0, 300, 300, 2000, game->_sprites[S_BACKGROUND]);
	obj1->Render();
}
Example #3
0
    void checkAttributes()
    {
        std::stringstream scene ;
        scene << "<?xml version='1.0'?>"
                 "<Node 	name='Root' gravity='0 -9.81 0' time='0' animate='0' >               \n"
                 "  <OglLabel name='label1'/>                                                    \n"
                 "</Node>                                                                        \n" ;

        Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
                                                          scene.str().c_str(),
                                                          scene.str().size()) ;

        ASSERT_NE(root.get(), nullptr) ;
        root->init(ExecParams::defaultInstance()) ;

        BaseObject* lm = root->getObject("label1") ;
        ASSERT_NE(lm, nullptr) ;

        /// List of the supported attributes the user expect to find
        /// This list needs to be updated if you add an attribute.
        vector<string> attrnames = {
            "prefix", "label", "suffix", "x", "y", "fontsize", "color",
            "selectContrastingColor", "updateLabelEveryNbSteps",
            "visible"};

        for(auto& attrname : attrnames)
            EXPECT_NE( lm->findData(attrname), nullptr ) << "Missing attribute with name '" << attrname << "'." ;
    }
Example #4
0
void Node::load()
{
	//create this node if a subclass hasn't created one already
	if(!node)
	{
		node = cocos2d::CCNode::create();
		node->retain();
	}
	
	//now that we have the node, make sure that all of the properties have been set
	refreshAllAttributes();
	
	//set up a reference to this object on the node
	node->setUserData(this);
	
	//walk up the object graph until we find a parent node
	BaseObject* parentObj = dynamic_cast<BaseObject*>(parent);
	while(parentObj)
	{
		Node* parentNode = dynamic_cast<Node*>(parentObj);
		if(parentNode)
		{
			//we've found the closest parent node, add to this node
			parentNode->getCCNode()->addChild(node);
			break;
		}
		
		parentObj = dynamic_cast<BaseObject*>(parentObj->getParent());
	}
	
	Node_Base::load();
}
Example #5
0
BaseData* deriveTypeFromParentValue(Base* obj, const std::string& value)
{
    BaseObject* o = dynamic_cast<BaseObject*>(obj);
    if (!o)
        return nullptr;

    // if data is a link
    if (value.length() > 0 && value[0] == '@')
    {
        std::string componentPath = value.substr(1, value.find('.') - 1);
        std::string parentDataName = value.substr(value.find('.') + 1);

        if (!o->getContext())
        {
	    msg_warning("SofaPython") << "No context created. Cannot find data link to derive input type.";
            return nullptr;
        }
        BaseObject* component;
        component = o->getContext()->get<BaseObject>(componentPath);
        if (!component)
	    msg_warning("SofaPython") << "No object with path " << componentPath << " in scene graph.";
        BaseData* parentData = component->findData(parentDataName);
        return parentData->getNewInstance();
    }
    return nullptr;
}
Example #6
0
std::string BaseLink::CreateStringPath(Base* dest, Base* from)
{
    if (!dest || dest == from) return std::string("[]");
    BaseObject* o = dest->toBaseObject();
    BaseObject* f = from->toBaseObject();
    BaseContext* ctx = from->toBaseContext();
    if (!ctx && f) ctx = f->getContext();
    if (o)
    {
        std::string objectPath = o->getName();
        BaseObject* master = o->getMaster();
        while (master)
        {
            objectPath = master->getName() + std::string("/") + objectPath;
            master = master->getMaster();
        }
        BaseNode* n = o->getContext()->toBaseNode();
        if (f && o->getContext() == ctx)
            return objectPath;
        else if (n)
            return n->getPathName() + std::string("/") + objectPath; // TODO: compute relative path
        else
            return objectPath; // we could not determine destination path, specifying simply its name might be enough to find it back
    }
    else // dest is a context
    {
        if (f && ctx == dest)
            return std::string("./");
        BaseNode* n = dest->toBaseNode();
        if (n) return n->getPathName(); // TODO: compute relative path
        else return dest->getName(); // we could not determine destination path, specifying simply its name might be enough to find it back
    }
}
Example #7
0
void Voxelify::DoRecursion(BaseObject *op, BaseObject *child, GeDynamicArray<Vector> &points, Matrix ml) {
	BaseObject *tp;
	if (child){
		tp = child->GetDeformCache();
		ml = ml * child->GetMl();
		if (tp){
			DoRecursion(op,tp,points,ml);
		}
		else{
			tp = child->GetCache(NULL);
			if (tp){
				DoRecursion(op,tp,points,ml);
			}
			else{
				if (!child->GetBit(BIT_CONTROLOBJECT)){
					if (child->IsInstanceOf(Opoint)){
						PointObject * pChild = ToPoint(child);
						LONG pcnt = pChild->GetPointCount();
						const Vector *childVerts = pChild->GetPointR();
						for(LONG i=0; i < pcnt; i++){
							points.Push(childVerts[i] * ml * parentMatrix);
						}
					}
				}
			}
		}
		for (tp = child->GetDown(); tp; tp=tp->GetNext()){
			DoRecursion(op,tp,points,ml);
		}
	}
}
Example #8
0
	void print(int level, FILE *file)
	{
		int count = 0;

		fprintf (file, "{");

		for (map<StringObject *, BaseObject *>::iterator iter = m_map.begin(); iter != m_map.end(); iter ++)
		{
			if (count > 0)
			{
				fprintf (file, ", ");
			}

			StringObject *key = iter->first;
			BaseObject *obj = iter->second;

			key->print(level, file);
			fprintf (file, ": ");
			obj->print(level + 1, file);
			count ++;
		}

		fprintf (file, "}");

	}
Example #9
0
void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/)
{
  file->d->headerExtensionObject = this;
  file->seek(18, File::Current);
  long long dataSize = readDWORD(file);
  long long dataPos = 0;
  while(dataPos < dataSize) {
    ByteVector guid = file->readBlock(16);
    if(guid.size() != 16) {
      file->setValid(false);
      break;
    }
    bool ok;
    long long size = readQWORD(file, &ok);
    if(!ok) {
      file->setValid(false);
      break;
    }
    BaseObject *obj;
    if(guid == metadataGuid) {
      obj = new MetadataObject();
    }
    else if(guid == metadataLibraryGuid) {
      obj = new MetadataLibraryObject();
    }
    else {
      obj = new UnknownObject(guid);
    }
    obj->parse(file, (unsigned int)size);
    objects.append(obj);
    dataPos += size;
  }
}
Example #10
0
BOOL CMDLook::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    BaseObject* obj = nullptr;
    ObjectContainer* location = mobile->GetLocation();

//look at environment:
    if (!args.size())
        {
            if (location->IsRoom())
                {
                    mobile->Message(MSG_INFO, ((Room*)mobile->GetLocation())->DoLook(mobile));
                    return true;
                }
        }

    obj =world->MatchObject(args[0],mobile);
    if (obj==NULL)
        {
            mobile->Message(MSG_ERROR,"You don't see that here.");
            return false;
        }

    mobile->Message(MSG_INFO,obj->DoLook(mobile));
    return true;
}
Example #11
0
IRes* ResMgr::CreateRes(const char* name)
{
    BaseObject* pBaseObject = GetMgr()->Create(name);
	throw_assert(pBaseObject->IsInstanceOf("IRes"), "type check:"<<name);
    IRes* pRes = (IRes*)pBaseObject;
    pRes->SetResMgr(this);
    return pRes;
}
Example #12
0
  Bool AddForceCycleElement(Int32 id)
  {
    BaseObject* obj = BaseObject::Alloc(id);
    if (!obj) return false;

    AddChild(CMB_FORCE, id, obj->GetName() + "&i" + String::IntToString(id));
    BaseObject::Free(obj);
    return true;
  }
Example #13
0
void Region::draw()
{
	BaseObject* object = NULL;
	for(List<BaseObject*>::Iterator it = objects.begin(); !it; it++)
	{
		object = it.value();
		object->draw();
	}
}
Example #14
0
void Region::update(double interval)
{
	BaseObject* object = NULL;
	for(List<BaseObject*>::Iterator it = objects.begin(); !it; it++)
	{
		object = it.value();
		object->update(interval);
	}
}
Example #15
0
Bool VoxelGenerator::Init(GeListNode* node)
{
	BaseObject*		 op = (BaseObject*)node;
	BaseContainer* data = op->GetDataInstance();
	
	data->SetFloat(VGEN_SCALE, 0.95);
	data->SetFloat(VGEN_THRESHOLD,0.01);
	return true;
}
Example #16
0
BaseObject * BaseObject::LoadFromArchive(KeyedArchive * archive)
{
    String name = archive->GetString("##name");
    BaseObject * object = ObjectFactory::Instance()->New(name);
    if (object)
    {
        object->Load(archive);
    }
    return object;
}
Example #17
0
BaseObject* BaseObject::create(cocos2d::Point position) {
	BaseObject* ret = new BaseObject();
	if (ret != nullptr && ret->init(position)) {
		ret->autorelease();
		return ret;
	}

	CC_SAFE_DELETE(ret);
	return nullptr;
}
Example #18
0
Bool Objectify::Init(GeListNode *node)
{
    BaseObject    *op   = (BaseObject*)node;
    BaseContainer *data = op->GetDataInstance();
    
    data->SetReal(TRIANGULATION_MAX_SEARCH_RADIUS,30.);

    GePrint("Objectify by http://twitter.com/eight_io for Cinema 4D r14");
    prevFrame = 0;
    return TRUE;
}
Example #19
0
BaseObject* BaseObject::create(std::string fileName)
{
	BaseObject *sprite = new (std::nothrow) BaseObject();
	if (sprite && sprite->initWithFile(fileName) && sprite->init())
	{
		sprite->autorelease();
		return sprite;
	}
	CC_SAFE_DELETE(sprite);
	return nullptr;
}
Example #20
0
BaseObject* BaseObject::create(const std::string& filename, const Rect& rect)
{
	BaseObject *sprite = new (std::nothrow) BaseObject();
	if (sprite && sprite->initWithFile(filename, rect))
	{
		sprite->autorelease();
		return sprite;
	}
	CC_SAFE_DELETE(sprite);
	return nullptr;
}
Example #21
0
// initialize settings
Bool AtomObject::Init(GeListNode *node)
{
	BaseObject		*op		= (BaseObject*)node;
	BaseContainer *data = op->GetDataInstance();

	data->SetReal(ATOMOBJECT_SRAD,5.0);
	data->SetReal(ATOMOBJECT_CRAD,2.0);
	data->SetLong(ATOMOBJECT_SUB,8);
	data->SetBool(ATOMOBJECT_SINGLE,FALSE);

	return TRUE;
}
Example #22
0
Bool Voxelify::Init(GeListNode *node)
{
	BaseObject		*op   = (BaseObject*)node;
	BaseContainer *data = op->GetDataInstance();
    
	//data->SetReal(CTTSPOBJECT_MAXSEG,1000.);
	//data->SetReal(CTTSPOBJECT_MINSEG,0.1);
    data->SetLong(SPLINEOBJECT_INTERPOLATION,SPLINEOBJECT_INTERPOLATION_ADAPTIVE);
    GePrint("Voxelify by http://twitter.com/eight_io for Cinema 4D r14");
    
    return TRUE;
}
Example #23
0
void BaseObject::setSrc(const std::string &valueString, const BaseObject *loader, std::vector< std::string > *attributeList)
{
    BaseObject* obj = this;

    std::multimap < std::string, BaseData*> dataLoaderMap(loader->m_aliasData);
    std::multimap < std::string, BaseData*>::iterator it_map;

    //for (unsigned int j = 0; j<loader->m_fieldVec.size(); ++j)
    //{
    //	dataLoaderMap.insert (std::pair<std::string, BaseData*> (loader->m_fieldVec[j].first, loader->m_fieldVec[j].second));
    //}

    if (attributeList != 0)
    {
        for (unsigned int j = 0; j<attributeList->size(); ++j)
        {
            it_map = dataLoaderMap.find ((*attributeList)[j]);
            if (it_map != dataLoaderMap.end())
                dataLoaderMap.erase (it_map);
        }
    }

    // -- Temporary patch, using exceptions. TODO: use a flag to set Data not to be automatically linked. --
    //{
    it_map = dataLoaderMap.find ("type");
    if (it_map != dataLoaderMap.end())
        dataLoaderMap.erase (it_map);

    it_map = dataLoaderMap.find ("filename");
    if (it_map != dataLoaderMap.end())
        dataLoaderMap.erase (it_map);
    //}


    for (it_map = dataLoaderMap.begin(); it_map != dataLoaderMap.end(); ++it_map)
    {
        BaseData* data = obj->findData( (*it_map).first );
        if (data != NULL)
        {
            if (!(*it_map).second->isAutoLink())
            {
                sout << "Disabling autolink for Data " << data->getName() << sendl;
            }
            else
            {
                //serr << "Autolinking Data " << data->getName() << sendl;
                std::string linkPath = valueString+"."+(*it_map).first;
                data->setParent( (*it_map).second, linkPath);
            }
        }
    }
}
Example #24
0
void GPUMemory::dump() const
{
    cout << "------ GPUMemory allocated objects ------\n\n";
    map<BaseObject*,BaseObjectInfo>::const_iterator it = maps.begin();
    for ( ; it != maps.end(); it++ )
    {
        BaseObject* bo = it->first;
        BaseObjectInfo boi = it->second;

        cout << "State: ";
        
        BaseObject::State state = bo->getState();
        switch(state)
        {
            case BaseObject::ReAlloc: cout << "ReAlloc"; break;
            case BaseObject::NotSync: cout << "NotSync"; break;
            case BaseObject::Sync: cout << "Sync"; break;
            case BaseObject::Blit: cout << "Blit"; break;
            default:
                panic("GPUMemory","dump","Unknown state");
        }
        
        cout << endl;
        
        //cout << "ID_STRING: " << bo->toString().c_str() << " :\n";
        cout << "   md's: ";
        
        for (u32bit i = 0; i < boi.md.size(); i++ )
        {
            
            cout << boi.md[i] << endl;
            
            driver->dumpMD(boi.md[i]);
            
            if ( i < boi.md.size() - 1 )
                cout << ", ";
        }
        cout << "\n   size's: ";
        for (u32bit i = 0; i < boi.size.size(); i++ )
        {
            cout << boi.size[i];
            if ( i < boi.size.size() - 1 )
                cout << ", ";
        }
        cout << "\n   Number of portions: " << bo->getNumberOfPortions() << endl << endl;
        
    }
    
    //driver->dumpMemoryAllocation();
    
    cout << "\n-----------------------------------------" << endl;
}
Example #25
0
bool GPUMemory::allocate(BaseObject& bo)
{
    GPUMemory::BaseObjectInfo* boInfo = _find(&bo);    
    BaseObject::State state = bo.getState();
    if ( boInfo )
    {
        if ( state == BaseObject::ReAlloc )
        {
            //  reallocate
            _dealloc(&bo, boInfo);
            _alloc(&bo);
        }
        else if ( state == BaseObject::NotSync )
        {
            _update(&bo, boInfo);
        }
        else // { ( state == BaseObject::Sync ) -> already synchronized } ||
            //  { ( state == BaseObject::Blit ) -> updated data is already and exclusively in memory  }
        {
            return false;
        }
    }
    else
    {
        if ( state != BaseObject::ReAlloc )
            panic("GPUMemory", "allocate", "Should not happen."
                                           "GPUMemory internal info not found for an allocated BaseObject");
        _alloc(&bo);
    }
    return true;
}
Example #26
0
Bool DropEffector::InitEffector(GeListNode* node)
{
	if (!rcol || !node)
		return false;

	BaseObject* op = (BaseObject*)node;
	if (!op)
		return false;

	BaseContainer* bc = op->GetDataInstance();
	if (!bc)
		return false;

	bc->SetFloat(DROPEFFECTOR_DISTANCE, 1000.0);

	return true;
}
Example #27
0
// main routine: build virtual atom objects
BaseObject *AtomObject::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
{
	BaseObject *orig = op->GetDown();

	// return if no input object is available
	if (!orig) return NULL;

	Bool dirty = FALSE;

	// generate polygonalized clone of input object
	BaseObject *main=NULL,*res=op->GetAndCheckHierarchyClone(hh,orig,HIERARCHYCLONEFLAGS_ASPOLY,&dirty,NULL,FALSE);

	// if !dirty object is already cached and doesn't need to be rebuilt
	if (!dirty) return res;
	if (!res)   return NULL;

	LONG sub;
	Bool single;
	Real srad,crad;

	// get object container
	BaseContainer *bc=op->GetDataInstance();
	BaseThread    *bt=hh->GetThread();

	// group all further objects with this null object
	main = BaseObject::Alloc(Onull);
	if (!main) goto Error;

	// get object settings
	srad   = bc->GetReal(ATOMOBJECT_SRAD);
	crad   = bc->GetReal(ATOMOBJECT_CRAD);
	sub    = bc->GetLong(ATOMOBJECT_SUB);
	single = bc->GetBool(ATOMOBJECT_SINGLE);

	// go through all child hierarchies
	if (!Recurse(hh,bt,main,res,orig->GetMl(),srad,crad,sub,single)) goto Error;
	blDelete(res);

	return main;

Error:
	blDelete(res);
	blDelete(main);
	return NULL;
}
Example #28
0
void ASF::File::read(bool /*readProperties*/, Properties::ReadStyle /*propertiesStyle*/)
{
  if(!isValid())
    return;

  ByteVector guid = readBlock(16);
  if(guid != headerGuid) {
    debug("ASF: Not an ASF file.");
    return;
  }

  d->tag = new ASF::Tag();
  d->properties = new ASF::Properties();

  d->size = readQWORD();
  int numObjects = readDWORD();
  seek(2, Current);

  for(int i = 0; i < numObjects; i++) {
    ByteVector guid = readBlock(16);
    long size = (long)readQWORD();
    BaseObject *obj;
    if(guid == filePropertiesGuid) {
      obj = new FilePropertiesObject();
    }
    else if(guid == streamPropertiesGuid) {
      obj = new StreamPropertiesObject();
    }
    else if(guid == contentDescriptionGuid) {
      obj = new ContentDescriptionObject();
    }
    else if(guid == extendedContentDescriptionGuid) {
      obj = new ExtendedContentDescriptionObject();
    }
    else if(guid == headerExtensionGuid) {
      obj = new HeaderExtensionObject();
    }
    else {
      obj = new UnknownObject(guid);
    }
    obj->parse(this, size);
    d->objects.append(obj);
  }
}
Example #29
0
	void print(int level, FILE *file)
	{
		int count = 0;

		fprintf (file, "[");

		for (list<BaseObject *>::iterator iter = m_list.begin(); iter != m_list.end(); iter ++)
		{
			if (count > 0)
			{
				fprintf (file, ", ");
			}
			BaseObject *obj = *iter;
			obj->print(level + 1, file);
			count ++;
		}

		fprintf (file, "]");
	}
Example #30
0
/// ***************************************************************************
/// This function hides or unhides all materials used by the object *op*.
/// If *doc* is not \c nullptr, undos will be added.
/// ***************************************************************************
static void HideMaterials(BaseObject* op, Bool hide, BaseDocument* doc)
{
  BaseTag* tag = op->GetFirstTag();
  GeData data;
  while (tag)
  {
    if (tag->GetType() == Ttexture && tag->GetParameter(TEXTURETAG_MATERIAL, data, DESCFLAGS_GET_0))
    {
      BaseMaterial* mat = static_cast<BaseMaterial*>(data.GetLink(doc, Mbase));
      if (mat) HideHierarchy(mat, hide, doc, false);
    }
    tag = tag->GetNext();
  }
  BaseObject* child = op->GetDown();
  while (child) {
    HideMaterials(child, hide, doc);
    child = child->GetNext();
  }
}