コード例 #1
0
ファイル: update3do.c プロジェクト: cplhenshaw/3doobj
void update3do(MODL *model, OBJ *obj)
{
    if(model == NULL)
    {
        fprintf(stderr, "update3do() passed NULL MODL structure\n");
        return;
    }
    if(obj == NULL)
    {
        fprintf(stderr, "update3do() passed NULL OBJ structure\n");
        return;
    }

    //need to recursively step through the node hierarchy, maintaining an
    //offset to subtract from each vertices
    //(reverse of writeObj)
    if(model->numNodes != 0)
    {
        float startingOffset[3] = {0.0, 0.0, 0.0};
        //start it off with the first node
        updateMeshes(model, obj, model->nodes[0], startingOffset);
    }

    //scale all the textures back from the .obj specification
    scaleTexVerts(model, 1);

    return;
}
コード例 #2
0
ファイル: update3do.c プロジェクト: cplhenshaw/3doobj
//recursively step trhough node hierarchy, updating meshes
void updateMeshes(MODL *model, OBJ *obj, NODE *node, float parentOffset[3])
{
    //accumulate this node's offset to pass further on
    float nodeOffset[3];
    for(int i=0; i<3; i++) nodeOffset[i] = parentOffset[i] + node->position[i];
    //may not be needed, add the further mesh offset
    float meshOffset[3];
    for(int i=0; i<3; i++) meshOffset[i] = nodeOffset[i] + node->pivot[i];

    //if this has a mesh
    if(node->meshID != -1)
    {
        //if the OBJ structure has an equivalent, update the mesh
        MESH *mesh = model->meshes[node->meshID];
        int found = 0;
        for(int i=0; i<obj->numGroups; i++)
        {
            GROUP *group = obj->groups[i];
            //if the group name has the mesh name as a substring
            if(strstr(group->groupName, mesh->meshName) != NULL)
            {
                //update
                updateMesh(model, mesh, group, meshOffset);
                found = 1;
                //stop searching
                break;
            }
        }
        if(found == 0) fprintf(stderr, "Found no group corresponding to %s\n", mesh->meshName);
    }

    //recurse on any child nodes (if it has any)
    if(node->hasChildren != 0)
    {
        //just recurse on the first child, which itself will recurse on any siblings (see below)
        updateMeshes(model, obj, model->nodes[node->childID], nodeOffset);
    }

    //recurse on any sibling nodes (if it has any)
    if(node->hasSibling != 0)
    {
        //siblings share the same offset of their parents
        updateMeshes(model, obj, model->nodes[node->siblingID], parentOffset);
    }

    return;
}
コード例 #3
0
//------------------------------------------- update.
void ofxAssimpModelLoader::update() {
    updateAnimations();
    updateMeshes(scene->mRootNode, ofMatrix4x4());
    if(hasAnimations() == false) {
        return;
    }
    updateBones();
    updateGLResources();
}
コード例 #4
0
ファイル: StencilWaves.cpp プロジェクト: ofZach/funkyForms
// -------------- update
void StencilWaves::update(){
    updateContours();
    updateWaveParameters();
    updateWaves();
    updateMeshes();
    updateFbos();
    updateMasks();
    updateRefract();
}
コード例 #5
0
//since we're only updating on component at a time, get the delta that 
//is at this vertex and stage, and just replace the exisitng delta component with the 
//new compnent in change. change will always have 2 zero components and 1 non-zero component
void MeshManager::adjustVertex(int stage, int id, ofVec3f change){


	Delta* d = getOrMakeVertexDelta(stage, id);
	ofVec3f existing = d->getChange();

	if(change.x == 0) change.x = existing.x;
	if(change.y == 0) change.y = existing.y;
	if(change.z == 0) change.z = existing.z;

	d->setChange(change);

	//printChanges();

	updateMeshes(stage);

}
コード例 #6
0
ファイル: model.cpp プロジェクト: whztt07/Magic3D-2
bool Magic3D::Model::update()
{
    bool needUpdate = Scene::getInstance()->getUniqueUpdateFlag() != uniqueUpdate;
    bool result = Object::update();
    if (needUpdate && (isInParentFrustum() || isInEffectFrustum()) && getSkeleton())
    {
        uniqueUpdate = !uniqueUpdate;
        result = getSkeleton()->update() && result;
        if (result)
        {
            result = updateMeshes() && result;
        }
        Object::updateBoundingBox(false);
        box = Object::getBoundingBox();
    }
    return result;
}
コード例 #7
0
ファイル: Trails.cpp プロジェクト: Towerthousand/GGJ
void Trails::addTrailSegment(Color color, Trails::Direction dir, float x1, float x2, int y, float width)
{
	if(x2 < x1) std::swap(x1, x2);
    x1 -= width;
    x2 += width;

    Map* map = (Map*)getGame()->getObjectByName("map");
    map->clipTrail(color, dir == Direction::HORIZONTAL, y - (dir != Direction::VERTICAL_RIGHT ? 1 : 0), x1, x2);
    if (x2 < x1) return;

	std::map<float, Color>& mp = segments[dir][y];

	auto left = mp.lower_bound(x1);
	Color leftc = Color::WHITE;
	if(left != mp.begin())
	{
		auto left2 = left;
		left2--;
		leftc = left2->second;
	}

	auto right = mp.upper_bound(x2);
	Color rightc = Color::WHITE;
	if(right != mp.begin())
	{
		auto right2 = right;
		right2--;
		rightc = right2->second;
	}

	while(left != right)
	{
		auto left2 = left;
		left2++;
		mp.erase(left);
		left = left2;
	}

	if(leftc != color)
		mp[x1] = color;

	if(rightc != color)
		mp[x2] = rightc;

	updateMeshes();
}
コード例 #8
0
void ofxAssimpModelLoader::updateMeshes(aiNode * node, ofMatrix4x4 parentMatrix) {
    
    aiMatrix4x4 m = node->mTransformation;
    m.Transpose();
	ofMatrix4x4 matrix(m.a1, m.a2, m.a3, m.a4,
                       m.b1, m.b2, m.b3, m.b4,
                       m.c1, m.c2, m.c3, m.c4,
                       m.d1, m.d2, m.d3, m.d4);
    matrix *= parentMatrix;
    
    for(unsigned int i=0; i<node->mNumMeshes; i++) {
        int meshIndex = node->mMeshes[i];
        ofxAssimpMeshHelper & mesh = modelMeshes[meshIndex];
        mesh.matrix = matrix;
    }
    
    for(unsigned int i=0; i<node->mNumChildren; i++) {
        updateMeshes(node->mChildren[i], matrix);
    }
}
コード例 #9
0
void MeshManager::applyMirroring(vector<int> faces){
	getOrMakeSymDelta(current, faces);
	updateMeshes(current);

}