errors related to particles and constraint

hi i'm trying to create a cloth simulation. i have created the particle and now i want to create a constraint between them. i have my constraint class but i've got some errors which i didn't understand. can anyone help?? thanks

Constraint.h
#include <ngl/Vector.h>
#include "Particle.h"

class Constraint
{
public:
float distance; // length between two particles
Particle *p1, *p2;

Constraint(Particle *p1, Particle *p2);

Constraint();
~Constraint();

};

Constraint.cpp

#include "Particle.h"
#include "Constraint.h"
#include <ngl/Vector.h>

Constraint::Constraint(Particle *p1, *p2)
{
p1 = ngl::Vector p1;
p2 = ngl::Vector p2;
ngl::Vector pos = p1->getPosition()-p2->getposition();
distance = pos.Length();
}

Errors

Constraint.cpp:5: error: expected identifier before '*' token
Constraint.cpp:5: error: prototype for 'Constraint::Constraint(Particle*, int*)' does not match any in class 'Constraint'
Constraint.h:7: error: candidates are: Constraint::Constraint(const Constraint&)
Constraint.h:13: error: Constraint::Constraint()
Constraint.h:11: error: Constraint::Constraint(Particle*, Particle*)



Constraint::Constraint(Particle *p1, *p2)

You forgot a Particle before the second pointer.
Hi yeah that was a silly mistake I corrected it but have other errors too.

Constraint.cpp:5: error: 'Partcile' has not been declared
Constraint.cpp:5: error: prototype for 'Constraint::Constraint(Particle*, int*)' does not match any in class 'Constraint'
Constraint.h:7: error: candidates are: Constraint::Constraint(const Constraint&)
Constraint.h:14: error: Constraint::Constraint()
Constraint.h:12: error: Constraint::Constraint(Particle*, Particle*)
scons: *** [Constraint.o] Error 1
The first error is a spelling mistake: partcile.

You'll need to post code for us to show you where you're other mistakes are but it looks like you're passing the wrong arguments to your constructor.
Particle.h
#include <ngl/Vector.h>

class Particle
{
public :
ngl::Vector m_dir;
ngl::Vector m_pos;
GLfloat m_radius;
Particle(
ngl::Vector _pos,
ngl::Vector _dir,
GLfloat _rad
);
Particle();
~Particle();
void Draw();

void Set(
ngl::Vector _pos,
ngl::Vector _dir,
GLfloat _rad
);

ngl::Vector getPosition() {return m_pos;}
};

Particle.cpp

#include "Particle.h"

#include <ngl/VBOPrimitives.h>

Particle::Particle(
ngl::Vector _pos,
ngl::Vector _dir,
GLfloat _rad
)
{
m_pos=_pos;
m_dir=_dir;
m_radius=_rad;
}

Particle::Particle()
{
m_pos.Set(0,0,0);
m_dir.Set(0,0,0);
m_radius=1.0;
}
Particle::~Particle()
{
// do nothing
}

void Particle::Draw()
{
glPushMatrix();
m_pos.Translate();
//get an instance of the VBO primitives for drawing
ngl::VBOPrimitives *prim=ngl::VBOPrimitives::Instance();

prim->DrawVBO("sphere");

glPopMatrix();
}

void Particle :: Set(
ngl::Vector _pos,
ngl::Vector _dir,
GLfloat _rad
)
{
m_pos=_pos;
m_dir=_dir;
m_radius=_rad;
}

sphere is created as a particle.
errors

Constraint.cpp: In constructor 'Constraint::Constraint(Particle*, Particle*)':
Constraint.cpp:7: error: expected primary-expression before 'p1'
Constraint.cpp:7: error: expected `;' before 'p1'
Constraint.cpp:8: error: expected primary-expression before 'p2'
Constraint.cpp:8: error: expected `;' before 'p2'
Constraint.cpp:9: error: 'class Particle' has no member named 'getposition'

thanks a ton..
cudn't figure out error on line 7 and 8..
p1 = ngl::Vector p1;
p2 = ngl::Vector p2;
Topic archived. No new replies allowed.