Exemplo n.º 1
0
void MeshSkin::setJointCount(unsigned int jointCount)
{
    // Erase the joints vector and release all joints.
    clearJoints();

    // Resize the joints vector and initialize to NULL.
    _joints.resize(jointCount);
    for (unsigned int i = 0; i < jointCount; i++)
    {
        _joints[i] = NULL;
    }

    // Rebuild the matrix palette. Each matrix is 3 rows of Vector4.
    SAFE_DELETE_ARRAY(_matrixPalette);

    if (jointCount > 0)
    {
        _matrixPalette = new Vector4[jointCount * PALETTE_ROWS];
        for (unsigned int i = 0; i < jointCount * PALETTE_ROWS; i+=PALETTE_ROWS)
        {
            _matrixPalette[i+0].set(1.0f, 0.0f, 0.0f, 0.0f);
            _matrixPalette[i+1].set(0.0f, 1.0f, 0.0f, 0.0f);
            _matrixPalette[i+2].set(0.0f, 0.0f, 1.0f, 0.0f);
        }
    }
}
Exemplo n.º 2
0
 void ProjectionEditor::gotMessage(ofMessage& msg) {
     if (msg.message == "surfaceSelected") {
         // refresh gui
         clearJoints();
         createJoints();
     }
 }
void GeometrySpringDynamic::setDynamicLinkTo( GeometryLinkDynamic * dynamicLink )
{
	m_DynamicLinks[1] = dynamicLink;
    setLinkTo( (const GeometryLink *)&dynamicLink->getGeometryObject() );

    clearJoints();
    initJoints();
}
Exemplo n.º 4
0
void Body::clearAllAttachedJoints() {
    // Clear joints we own.
    clearJoints();

    // Clear joints we are attached to.
    while (!mAttachedJoints.isEmpty()) {
        Joint* joint = mAttachedJoints.takeLast();
        delete joint;
    }
}
Exemplo n.º 5
0
C3DMeshSkin::~C3DMeshSkin()
{
	for (unsigned int i = 0; i < _partCount; ++i)
    {
		SAFE_DELETE(_parts[i]);        
    }
	SAFE_DELETE_ARRAY(_parts);

    clearJoints();

    SAFE_DELETE_ARRAY(_matrixPalette);
}
Exemplo n.º 6
0
void TextureEditor::createJoints() {
  if (surface == NULL) return;
  clearJoints();
  vector<ofVec2f>& texCoords = surface->getTexCoords();
  ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
                                surface->getSource()->getTexture()->getHeight());

  for (int i = 0; i < texCoords.size(); i++) {
    joints.push_back(new CircleJoint());
    joints.back()->position = texCoords[i] * textureSize;
  }
}
Exemplo n.º 7
0
void TextureEditorWidget::createJoints(){
	if(surface == 0){
		return;
	}
	
	clearJoints();
	std::vector<Vec2> texCoords = surface->getTexCoords();
	
	if(surface->getSource()->getTexture()->isAllocated()){
		_pollCreateJoints = false;
	}else{
		_pollCreateJoints = true;
		return;
	}
	
	Vec2 textureSize = Vec2(
		surface->getSource()->getTexture()->getWidth(),
		surface->getSource()->getTexture()->getHeight());
	
	// Select joints depending on the surface type
	std::vector<Vec2> tc;
	
	if(surface->getType() == SurfaceType::TRIANGLE_SURFACE){
		tc = texCoords;
	}else if(surface->getType() == SurfaceType::QUAD_SURFACE ||
			 surface->getType() == SurfaceType::CIRCLE_SURFACE){
		tc = texCoords;
	}else if(surface->getType() == SurfaceType::HEXAGON_SURFACE){
		tc = texCoords;
	}else if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){
		GridWarpSurface * s = (GridWarpSurface *)surface;
		
		int rows = s->getGridRows();
		int cols = s->getGridCols();
		int vertsPerRow = cols + 1;
		int vertsPerCol = rows + 1;
		
		int a = 0;
		int b = cols;
		int c = (rows * vertsPerRow) + (vertsPerRow - 1);
		int d = (rows * vertsPerRow);
		
		tc.push_back(texCoords[a]);
		tc.push_back(texCoords[b]);
		tc.push_back(texCoords[c]);
		tc.push_back(texCoords[d]);
	}

	for(int i = 0; i < tc.size(); i++){
		joints.push_back(new CircleJoint());
		joints.back()->position = tc[i] * textureSize;
	}
}
GeometrySpringDynamic::~GeometrySpringDynamic()
{
	clearJoints();

	if( 0 != m_Shape && true == cpSpaceContainsShape( m_Space, m_Shape ) )
	{
		cpSpaceRemoveShape( m_Space, m_Shape );
		cpShapeFree( m_Shape );
		m_Shape = 0;
	}
	if( 0 != m_Body && true == cpSpaceContainsBody( m_Space, m_Body ) )
	{
		cpSpaceRemoveBody( m_Space, m_Body );
		cpBodyFree( m_Body );
		m_Body = 0;
	}
}
Exemplo n.º 9
0
 void ProjectionEditor::createJoints() {
     if (surfaceManager == NULL) return;
     clearJoints();
     
     if (surfaceManager->getSelectedSurface() == NULL) {
         ofLog(OF_LOG_WARNING, "Trying to create joints while no surface selected.");
         return;
     }
     
     vector<ofVec3f>& vertices =
     surfaceManager->getSelectedSurface()->getVertices();
     
     for (int i = 0; i < vertices.size(); i++) {
         joints.push_back(new CircleJoint());
         joints.back()->position = ofVec2f(vertices[i].x, vertices[i].y);
     }
 }
Exemplo n.º 10
0
MeshSkin::~MeshSkin()
{
    clearJoints();

    SAFE_DELETE_ARRAY(_matrixPalette);
}
Exemplo n.º 11
0
void TextureEditor::clear() {
  surface = NULL;
  clearJoints();
}
Exemplo n.º 12
0
 ProjectionEditor::~ProjectionEditor() {
     clearJoints();
     surfaceManager = NULL;
     disable();
 }
Exemplo n.º 13
0
void TextureEditorWidget::clear(){
	surface = 0;
	clearJoints();
}