begin process at 2010 02 10 04:37:41
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

question de collisions


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

question de collisions

jeudi 22 juillet 2004 à 08:31:20 | question de collisions

laulau10

hello j'essaie de creer une dll de collision pour un moteur 3d qui est relativement lent. mais elle ne foinctionne pas et je ne trouve pas le pourquoi.

alors pour la dll je travail avec un tutoriel que j'ai trouve sur le net
voici le code de la dll avec mes modifications

alors je la compile sous devc++

merci si quelqu'un peu m'aider un eptit peu laulau
----------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <math.h>
#include <time.h>

#define PLANE_BACKSIDE 0x000001
#define PLANE_FRONT 0x000010
#define ON_PLANE 0x000100
#define EPSILON 0.05f
#define PI 3.1415f

#define DLL __declspec (dllexport)

BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
{return TRUE;}
// ----------------------------------------------------------------------------
// Descr : Structure keeping track of the collisions as we find them.
// Note : Somewhat simplified from what is needed if you deside to implement
// the features described in the section of dynamic geometry.
// ----------------------------------------------------------------------------
//--------------------------
// 3D Vector
//--------------------------

struct D3DVECTOR
{
float x;
float y;
float z;
};

struct TCollisionPacket {
// data about player movement
struct D3DVECTOR velocity;
struct D3DVECTOR sourcePoint;

// radius of ellipsoid.
struct D3DVECTOR eRadius;

// for error handling
struct D3DVECTOR lastSafePosition;
BOOL stuck;

// data for collision response
BOOL foundCollision;
double nearestDistance; // nearest distance to hit
struct D3DVECTOR nearestIntersectionPoint; // on sphere
struct D3DVECTOR nearestPolygonIntersectionPoint; // on polygon
} collision;

/*
struct D3DVECTOR GetPosition(struct D3DVECTOR position, struct D3DVECTOR velocity);
struct D3DVECTOR collideWithWorld(struct D3DVECTOR position, struct D3DVECTOR velocity);
void CheckCollision(struct Mesh *pCollisionData, TCollisionPacket *colPackage);
*/
struct Mesh
{
// variables
int numero;
int m_dwNumFaces;
struct D3DVECTOR *m_pIndexedVertices;
struct Mesh *pNext;
// fonctions
} *pData; // pData; variable global

// basic vector operations (inlined)
float dot(struct D3DVECTOR v1, struct D3DVECTOR v2)
{
return ( (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z) );
}


void normalizeVector(struct D3DVECTOR *v) {
float len;
len = (float) sqrt( (v->x * v->x) + (v->y * v->y) + (v->z * v->z) );
v->x /= len;
v->y /= len;
v->z /= len;
}

double lengthOfVector(struct D3DVECTOR v) {
return (sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
}

void setLength(struct D3DVECTOR *v, float l) {
float len = sqrt( (v->x * v->x) + (v->y * v->y) + (v->z * v->z) );
v->x /= len;
v->y /= len;
v->z /= len;
}

BOOL isZeroVector(struct D3DVECTOR *v)
{
if (((*v).x == 0.0f) && ((*v).y == 0.0f) && ((*v).z == 0.0f))
{return TRUE;}

return FALSE;
}

struct D3DVECTOR wedge(struct D3DVECTOR v1, struct D3DVECTOR v2) {
struct D3DVECTOR result;

result.x = (v1.y * v2.z) - (v2.y * v1.z);
result.y = (v1.z * v2.x) - (v2.z * v1.x);
result.z = (v1.x * v2.y) - (v2.x * v1.y);

return (result);
}

// ----------------------------------------------------------------------
// Name : intersectRayPlane()
// Input : rOrigin - origin of ray in world space
// rVector - vector describing direction of ray in world space
// pOrigin - Origin of plane
// pNormal - Normal to plane
// Notes : Normalized directional vectors expected
// Return: distance to plane in world units, -1 if no intersection.
// -----------------------------------------------------------------------
double intersectRayPlane(struct D3DVECTOR rOrigin, struct D3DVECTOR rVector, struct D3DVECTOR pOrigin, struct D3DVECTOR pNormal)
{
double d = - (dot(pNormal,pOrigin));
double numer = dot(pNormal,rOrigin) + d;
double denom = dot(pNormal,rVector);

if (denom == 0) // normal is orthogonal to vector, cant intersect
return (-1.0f);

return -(numer / denom);
}

// ----------------------------------------------------------------------
// Name : intersectRaySphere()
// Input : rO - origin of ray in world space
// rV - vector describing direction of ray in world space
// sO - Origin of sphere
// sR - radius of sphere
// Notes : Normalized directional vectors expected
// Return: distance to sphere in world units, -1 if no intersection.
// -----------------------------------------------------------------------

double intersectRaySphere(struct D3DVECTOR rO, struct D3DVECTOR rV, struct D3DVECTOR sO, double sR) {

struct D3DVECTOR Q;
Q.x = sO.x-rO.x;
Q.y = sO.y-rO.y;
Q.z = sO.z-rO.z;

double c = lengthOfVector(Q);
double v = dot(Q,rV);
double d = sR*sR - (c*c - v*v);

// If there was no intersection, return -1
if (d < 0.0) return (-1.0f);

// Return the distance to the [first] intersecting point
return (v - sqrt(d));
}




// ----------------------------------------------------------------------
// Name : CheckPointInTriangle()
// Input : point - point we wish to check for inclusion
// a - first vertex in triangle
// b - second vertex in triangle
// c - third vertex in triangle
// Notes : Triangle should be defined in clockwise order a,b,c
// Return: TRUE if point is in triangle, FALSE if not.
// -----------------------------------------------------------------------

BOOL CheckPointInTriangle(struct D3DVECTOR point, struct D3DVECTOR a, struct D3DVECTOR b, struct D3DVECTOR c) {

double total_angles = 0.0f;

// make the 3 vectors
struct D3DVECTOR v1;
struct D3DVECTOR v2;
struct D3DVECTOR v3;

// make the 3 vectors
v1.x = point.x - a.x;
v2.x = point.x - b.x;
v3.x = point.x - c.x;
// make the 3 vectors
v1.y = point.y - a.y;
v2.y = point.y - b.y;
v3.y = point.y - c.y;
// make the 3 vectors
v1.z = point.z - a.z;
v2.z = point.z - b.z;
v3.z = point.z - c.z;

normalizeVector(&v1);
normalizeVector(&v2);
normalizeVector(&v3);

total_angles += acos(dot(v1,v2));
total_angles += acos(dot(v2,v3));
total_angles += acos(dot(v3,v1));

if (fabs(total_angles-2*PI) <= 0.005)
return (TRUE);

return(FALSE);
}



// ----------------------------------------------------------------------
// Name : closestPointOnLine()
// Input : a - first end of line segment
// b - second end of line segment
// p - point we wish to find closest point on line from
// Notes : Helper function for closestPointOnTriangle()
// Return: closest point on line segment
// -----------------------------------------------------------------------

struct D3DVECTOR closestPointOnLine(struct D3DVECTOR a, struct D3DVECTOR b, struct D3DVECTOR p)
{
// Determine t (the length of the vector from ?a? to ?p?)
struct D3DVECTOR c;
c.x = p.x - a.x;
c.y = p.y - a.y;
c.z = p.z - a.z;
struct D3DVECTOR V;
V.x = b.x - a.x;
V.y = b.y - a.y;
V.z = b.z - a.z;

struct D3DVECTOR tmp;

double d = lengthOfVector(V);

normalizeVector(&V);
double t = dot(V,c);


// Check to see if ?t? is beyond the extents of the line segment
if (t < 0.0f)
{
tmp.x = a.x;
tmp.y = a.y;
tmp.z = a.z;
return (tmp);
}
if (t > d)
{
tmp.x = b.x;
tmp.y = b.y;
tmp.z = b.z;
return (tmp);
}


// Return the point between ?a? and ?b?
//set length of V to t. V is normalized so this is easy
V.x *= (float) t;
V.y *= (float) t;
V.z *= (float) t;

tmp.x = a.x + V.x;
tmp.y = a.y + V.y;
tmp.z = a.z + V.z;

return (tmp);
}

// ----------------------------------------------------------------------
// Name : closestPointOnTriangle()
// Input : a - first vertex in triangle
// b - second vertex in triangle
// c - third vertex in triangle
// p - point we wish to find closest point on triangle from
// Notes :
// Return: closest point on line triangle edge
// -----------------------------------------------------------------------

struct D3DVECTOR closestPointOnTriangle(struct D3DVECTOR a, struct D3DVECTOR b, struct D3DVECTOR c, struct D3DVECTOR p) {

struct D3DVECTOR Rab = closestPointOnLine(a, b, p);
struct D3DVECTOR Rbc = closestPointOnLine(b, c, p);
struct D3DVECTOR Rca = closestPointOnLine(c, a, p);

struct D3DVECTOR tmp;

tmp.x = p.x - Rab.x; tmp.y = p.y - Rab.y; tmp.z = p.z - Rab.z;
double dAB = lengthOfVector(tmp);

tmp.x = p.x - Rbc.x; tmp.y = p.y - Rbc.y; tmp.z = p.z - Rbc.z;
double dBC = lengthOfVector(tmp);

tmp.x = p.x - Rca.x; tmp.y = p.y - Rca.y; tmp.z = p.z - Rca.z;
double dCA = lengthOfVector(tmp);


double min = dAB;
struct D3DVECTOR result = Rab;

if (dBC < min) {
min = dBC;
result = Rbc;
}

if (dCA < min)
result = Rca;


return (result);
}

// ----------------------------------------------------------------------
// Name : CheckPointInTriangle()
// Input : point - point we wish to check for inclusion
// sO - Origin of sphere
// sR - radius of sphere
// Notes :
// Return: TRUE if point is in sphere, FALSE if not.
// -----------------------------------------------------------------------

BOOL CheckPointInSphere(struct D3DVECTOR point, struct D3DVECTOR sO, double sR) {
struct D3DVECTOR tmp;
tmp.x = point.x - sO.x;
tmp.y = point.y - sO.y;
tmp.z = point.z - sO.z;
float d = lengthOfVector(tmp);

if(d<= sR) return TRUE;
return FALSE;
}




// ----------------------------------------------------------------------
// Name : tangentPlaneNormalOfEllipsoid()
// Input : point - point we wish to compute normal at
// eO - Origin of ellipsoid
// eR - radius vector of ellipsoid
// Notes :
// Return: a unit normal vector to the tangent plane of the ellipsoid in the point.
// -----------------------------------------------------------------------
struct D3DVECTOR tangentPlaneNormalOfEllipsoid(struct D3DVECTOR point, struct D3DVECTOR eO, struct D3DVECTOR eR) {

struct D3DVECTOR p;
p.x = point.x - eO.x;
p.y = point.y - eO.y;
p.z = point.z - eO.z;

double a2 = eR.x * eR.x;
double b2 = eR.y * eR.y;
double c2 = eR.z * eR.z;


struct D3DVECTOR res;
res.x = p.x / (float) a2;
res.y = p.y / (float) b2;
res.z = p.z / (float) c2;

normalizeVector(&res);
return (res);
}



// ----------------------------------------------------------------------
// Name : classifyPoint()
// Input : point - point we wish to classify
// pO - Origin of plane
// pN - Normal to plane
// Notes :
// Return: One of 3 classification codes
// -----------------------------------------------------------------------

DWORD classifyPoint(struct D3DVECTOR point, struct D3DVECTOR pO, struct D3DVECTOR pN) {

struct D3DVECTOR dir;
dir.x = pO.x - point.x;
dir.y = pO.y - point.y;
dir.z = pO.z - point.z;

double d = dot(dir, pN);

if (d<-0.001f)
return PLANE_FRONT;
else
if (d>0.001f)
return PLANE_BACKSIDE;

return ON_PLANE;
}

//====================================================================//
//====================================================================//
/*
DLL int Main(float ptPosAnglePer[], int MouseMoveX, int MouseMoveY, float MouseSpeed, int Click, int Clavier,float MoveSpeed, short int deplacement[])
*/

//-----------------------------------------------------------------------------
// File: Collision.cpp
//
// Desc: Implementation of the collision detection
//
// Copyright (c) 2000 Telemachos of Peroxide
// www.peroxide.dk
//-----------------------------------------------------------------------------

// ----------------------------------------------------------------------
// Name : CheckCollision()
// Descr : Checks one mesh for collision
// Return: updated collision structure.
// -----------------------------------------------------------------------

void CheckCollision(struct Mesh *Object, struct TCollisionPacket *colPackage) {

// plane data
int A, B, C;
struct D3DVECTOR p1,p2,p3;
struct D3DVECTOR pNormal;
struct D3DVECTOR pOrigin;
struct D3DVECTOR v1, v2;

// from package
struct D3DVECTOR source = colPackage->sourcePoint;
struct D3DVECTOR eRadius = colPackage->eRadius;
struct D3DVECTOR velocity = colPackage->velocity;

// keep a copy of this as it's needed a few times
struct D3DVECTOR normalizedVelocity = velocity;
normalizeVector(&normalizedVelocity);

// intersection data
struct D3DVECTOR sIPoint; // sphere intersection point
struct D3DVECTOR pIPoint; // plane intersection point
struct D3DVECTOR polyIPoint; // polygon intersection point

// how long is our velocity
double distanceToTravel = lengthOfVector(velocity);

double distToPlaneIntersection;
double distToEllipsoidIntersection;
int i;
// loop through all faces in mesh
for (i=0; i<Object->m_dwNumFaces; i++)
{

// A = vertexIndices[i*3];
// B = vertexIndices[i*3+1];
// C = vertexIndices[i*3+2];

A = i*3;
B = i*3+1;
C = i*3+2;

// Get the data for the triangle in question and scale to ellipsoid space
p1.x = Object->m_pIndexedVertices[A].x / eRadius.x;
p1.y = Object->m_pIndexedVertices[A].y / eRadius.y;
p1.z = Object->m_pIndexedVertices[A].z / eRadius.z;

p2.x = Object->m_pIndexedVertices[B].x / eRadius.x;
p2.y = Object->m_pIndexedVertices[B].y / eRadius.y;
p2.z = Object->m_pIndexedVertices[B].z / eRadius.z;

p3.x = Object->m_pIndexedVertices[C].x / eRadius.x;
p3.y = Object->m_pIndexedVertices[C].y / eRadius.y;
p3.z = Object->m_pIndexedVertices[C].z / eRadius.z;


// Make the plane containing this triangle.
pOrigin = p1;
v1.x = p2.x - p1.x;
v1.y = p2.y - p1.y;
v1.z = p2.z - p1.z;

v2.x = p3.x - p1.x;
v2.y = p3.y - p1.y;
v2.z = p3.z - p1.z;


// You might not need this if you KNOW all your triangles are valid
if (!(isZeroVector(&v1) || isZeroVector(&v2))) {

// determine normal to plane containing polygon
pNormal = wedge(v1, v2);
normalizeVector(&pNormal);



// calculate sphere intersection point
sIPoint.x = source.x - pNormal.x;
sIPoint.y = source.y - pNormal.y;
sIPoint.z = source.z - pNormal.z;

// classify point to determine if ellipsoid span the plane
DWORD pClass = classifyPoint(sIPoint, pOrigin, pNormal);


// find the plane intersection point
if (pClass == PLANE_BACKSIDE) { // plane is embedded in ellipsoid

// find plane intersection point by shooting a ray from the
// sphere intersection point along the planes normal.
distToPlaneIntersection = intersectRayPlane(sIPoint, pNormal, pOrigin, pNormal);

// calculate plane intersection point
pIPoint.x = sIPoint.x + (float) distToPlaneIntersection * pNormal.x;
pIPoint.y = sIPoint.y + (float) distToPlaneIntersection * pNormal.y;
pIPoint.z = sIPoint.z + (float) distToPlaneIntersection * pNormal.z;

}
else {

// shoot ray along the velocity vector
distToPlaneIntersection = intersectRayPlane(sIPoint, normalizedVelocity, pOrigin, pNormal);

// calculate plane intersection point
pIPoint.x = sIPoint.x + (float) distToPlaneIntersection * normalizedVelocity.x;
pIPoint.y = sIPoint.y + (float) distToPlaneIntersection * normalizedVelocity.y;
pIPoint.z = sIPoint.z + (float) distToPlaneIntersection * normalizedVelocity.z;

}



// find polygon intersection point. By default we assume its equal to the
// plane intersection point

polyIPoint = pIPoint;
distToEllipsoidIntersection = distToPlaneIntersection;

if (!CheckPointInTriangle(pIPoint,p1,p2,p3)) { // if not in triangle

polyIPoint = closestPointOnTriangle(p1, p2, p3, pIPoint);

normalizedVelocity.x=normalizedVelocity.x*(-1);
normalizedVelocity.y=normalizedVelocity.y*(-1);
normalizedVelocity.z=normalizedVelocity.z*(-1);

distToEllipsoidIntersection = intersectRaySphere(polyIPoint, normalizedVelocity, source, 1.0f);

if (distToEllipsoidIntersection > 0) {
// calculate true sphere intersection point
sIPoint.x = polyIPoint.x + (float) distToEllipsoidIntersection * normalizedVelocity.x;
sIPoint.y = polyIPoint.y + (float) distToEllipsoidIntersection * normalizedVelocity.y;
sIPoint.z = polyIPoint.z + (float) distToEllipsoidIntersection * normalizedVelocity.z;
}

}


// Here we do the error checking to see if we got ourself stuck last frame
if (CheckPointInSphere(polyIPoint, source, 1.0f))
colPackage->stuck = TRUE;


// Ok, now we might update the collision data if we hit something
if ((distToEllipsoidIntersection > 0) && (distToEllipsoidIntersection <= distanceToTravel)) {
if ((colPackage->foundCollision == FALSE) || (distToEllipsoidIntersection < colPackage->nearestDistance)) {

// if we are hit we have a closest hit so far. We save the information
colPackage->nearestDistance = distToEllipsoidIntersection;
colPackage->nearestIntersectionPoint = sIPoint;
colPackage->nearestPolygonIntersectionPoint = polyIPoint;
colPackage->foundCollision = TRUE;
}
}
} // if a valid plane
} // for all faces
}

//-----------------------------------------------------------------------------
// Name: collideWithWorld()
// Desc: Recursive part of the collision response. This function is the
// one who actually calls the collision check on the meshes
//-----------------------------------------------------------------------------
struct D3DVECTOR collideWithWorld(struct D3DVECTOR position, struct D3DVECTOR velocity)
{

struct D3DVECTOR pos;

// do we need to worry ?
if (lengthOfVector(velocity) < EPSILON)
return position;

// get a pointer to your meshes in some way
struct Mesh *pCollisionData;
pCollisionData = pData; // pData; variable global

struct D3DVECTOR destinationPoint;
destinationPoint.x = position.x + velocity.x;
destinationPoint.y = position.y + velocity.y;
destinationPoint.z = position.z + velocity.z;

// reset the collision package we send to the mesh
collision.velocity = velocity;
collision.sourcePoint = position;
collision.foundCollision = FALSE;
collision.stuck = FALSE;
collision.nearestDistance = -1;

// Check all meshes
while(pCollisionData != 0)
{
CheckCollision(pCollisionData, &collision);
pCollisionData = pCollisionData->pNext;
}

// check return value here, and possibly call recursively
if (collision.foundCollision == FALSE)
{
// if no collision move very close to the desired destination.
float l = lengthOfVector(velocity);
struct D3DVECTOR V = velocity;
setLength(&V, l-EPSILON);

// update the last safe position for future error recovery
collision.lastSafePosition = position;

// return the final position
struct D3DVECTOR Tmp;
Tmp.x = position.x + V.x;
Tmp.y = position.y + V.y;
Tmp.z = position.z + V.z;
return Tmp;
}
else
{

// There was a collision
// If we are stuck, we just back up to last safe position
if (collision.stuck)
return collision.lastSafePosition;

// OK, first task is to move close to where we hit something :
struct D3DVECTOR newSourcePoint;

// only update if we are not already very close
if (collision.nearestDistance >= EPSILON)
{
struct D3DVECTOR V = velocity;
setLength(&V, collision.nearestDistance-EPSILON);
newSourcePoint.x = collision.sourcePoint.x + V.x;
newSourcePoint.y = collision.sourcePoint.y + V.y;
newSourcePoint.z = collision.sourcePoint.z + V.z;
}
else
newSourcePoint = collision.sourcePoint;

// Now we must calculate the sliding plane
struct D3DVECTOR slidePlaneOrigin = collision.nearestPolygonIntersectionPoint;
struct D3DVECTOR slidePlaneNormal;
slidePlaneNormal.x = newSourcePoint.x - collision.nearestPolygonIntersectionPoint.x;
slidePlaneNormal.y = newSourcePoint.y - collision.nearestPolygonIntersectionPoint.y;
slidePlaneNormal.z = newSourcePoint.z - collision.nearestPolygonIntersectionPoint.z;

// We now project the destination point onto the sliding plane
double l = intersectRayPlane(destinationPoint, slidePlaneNormal,slidePlaneOrigin, slidePlaneNormal);

// We can now calculate a new destination point on the sliding plane
struct D3DVECTOR newDestinationPoint;
newDestinationPoint.x = destinationPoint.x + (float) l * slidePlaneNormal.x;
newDestinationPoint.y = destinationPoint.y + (float) l * slidePlaneNormal.y;
newDestinationPoint.z = destinationPoint.z + (float) l * slidePlaneNormal.z;

// Generate the slide vector, which will become our new velocity vector
// for the next iteration
struct D3DVECTOR newVelocityVector;
newVelocityVector.x = newDestinationPoint.x - collision.nearestPolygonIntersectionPoint.x;
newVelocityVector.y = newDestinationPoint.y - collision.nearestPolygonIntersectionPoint.y;
newVelocityVector.z = newDestinationPoint.z - collision.nearestPolygonIntersectionPoint.z;

// now we recursively call the function with the new position and velocity
collision.lastSafePosition = position;
return collideWithWorld(newSourcePoint, newVelocityVector);
} // fin de else pour collisions
}

//-----------------------------------------------------------------------------
// Name: GetPosition()
// Desc: Main collision detection function. This is what you call to get
// a position.
//-----------------------------------------------------------------------------
DLL void GetPosition(float PtXYZ[], int Vitesse)
{

struct D3DVECTOR scaledPosition, scaledVelocity;
struct D3DVECTOR finalPosition, position, velocity;
position.x = PtXYZ[0];
position.y = PtXYZ[1];
position.z = PtXYZ[2];
velocity.x = (float) Vitesse;
velocity.y = (float) Vitesse;
velocity.z = (float) Vitesse;

// the first thing we do is scale the player and his velocity to
// ellipsoid space
scaledPosition.x = position.x / collision.eRadius.x;
scaledPosition.y = position.y / collision.eRadius.y;
scaledPosition.z = position.z / collision.eRadius.z;

scaledVelocity.x = velocity.x / collision.eRadius.x;
scaledVelocity.y = velocity.y / collision.eRadius.y;
scaledVelocity.z = velocity.z / collision.eRadius.z;

// call the recursive collision response function
finalPosition = collideWithWorld(scaledPosition, scaledVelocity);

// when the function returns the result is still in ellipsoid space, so
// we have to scale it back to R3 before we return it
finalPosition.x = finalPosition.x * collision.eRadius.x;
finalPosition.y = finalPosition.y * collision.eRadius.y;
finalPosition.z = finalPosition.z * collision.eRadius.z;

PtXYZ[0] = finalPosition.x;
PtXYZ[1] = finalPosition.y;
PtXYZ[2] = finalPosition.z;
}

DLL void Main (float vecteur, float boxe)
{
collision.eRadius.x = boxe;
collision.eRadius.y = boxe;
collision.eRadius.z = boxe;
collision.velocity.x = vecteur;
collision.velocity.y = vecteur;
collision.velocity.z = vecteur;
}

DLL void AddObject(int Id, float PtrMesh[], int max)
{
int j, i;
struct Mesh *Travail;
Travail = (struct Mesh*) malloc(sizeof(struct Mesh) + (sizeof(struct D3DVECTOR) * max));
if (Travail!=0)
{
// id pour object
Travail->numero = Id;
// numbre max de point
Travail->m_dwNumFaces = max;
// tableau contenant les points
Travail->m_pIndexedVertices = malloc(sizeof(struct D3DVECTOR) * Travail->m_dwNumFaces);

for (j=3,i=0;i<Travail->m_dwNumFaces/3;i++,j+=6)
{
Travail->m_pIndexedVertices[i].x = PtrMesh[j];
Travail->m_pIndexedVertices[i].y = PtrMesh[j+1];
Travail->m_pIndexedVertices[i].z = PtrMesh[j+2];
}

Travail->pNext = pData;
pData=Travail;
}
// ajout de mesh pour les collisions
}

DLL void FreeObject(int Id)
{
// eleve un objet de la selection
}



Cette discussion est classée dans : float, struct, collision, velocity, d3dvector


Répondre à ce message

Sujets en rapport avec ce message

Probleme de redéfinition dans une structure [ par Manubbosse ] Bonjour à tous.Je suis stagiaire dans une entreprise et je dois (entre autre) programmer un coeur de calcul (en C++) à intégrer dans un logiciel.Malhe Conversion chaine binaire en float, double... [ par renyone ] Bonjour, j'ai une chaine binaire (de 32 bits par exemple) et j'aimerais obtenir le float (ou double...) qu 'elle représente; Y a-t-il des fonctions dé ou est l'erreur : boucles imbriquées [ par pausecpp ] le compilateur ne mentionne aucune "error" ni "warning" pourtant j'ai fait le programme pour que le valeur de S[N][M] changent!!!voici le code ( merci incrémentation de float [ par hacker_mt ] Bonjour tout le monde, voici mon probleme c'est surement assez débile mais je n'arrive pas a trouver comment faire, voici mon code :main(){       floa aidez moi svp langage c [ par psfansub ] j' ecrit ce code la et le compilateur me dit :   line 15 error: expected ')' before 'r'voila le code :#include #define PI 3.14159 \*definition de nom pointeur de structure contenant un pointeur [ par PADYVEN ] bonjour; voila  je voudrait progresser un peu en pointeur donc j'ai une structure disont toto struct toto { printf et float [ par shintaa ] Bonjour,Nous avons un problème avec la fonction printf.En déclarant un float 42.42 et en demandant à printf de nous l'écrire avec printf("%f\n", myFlo Debutant cherche comment fait opperation sur "float" [ par chris37000 ] Bonjour a vous tousOn a un TP a faire au lycée pour simuler une guirlande de noël.Un petit truc tout simple qui commande une boite avec 8 leds et il y Erreur structure, redéfinition [ par unikaz ] Bonjour à tous,Je me trouve (en tant que débutant) confronté à un problème que je n'arrive pas à résoudre (malgrès de longues recherches sur les forum Problème de tabeau dans un code orienté objet [ par Guiiil ] Bonsoir, je débute actuellement en C++ orienté objet et je suis bloqué avec ce programme qui doit réaliser un tableau d'élèves, prendre leur moyenne e


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,390 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales