|
Cedric Moonen wrote: You need also to add the cpp file to your project.
Yes, I have done that. This is why I don't understand what the problem is...
EDIT:
The header file contains the function prototypes and the cpp contains all the function code. I have added them both (.h and .cpp file). The strange thing is that the IDE recognizes them, but during linking I get the unresolved token errors. I wonder if this is a problem with VC++ Express 2005?
Windows with no internet connection is safe, but that's not what Windows was built for.
|
|
|
|
|
For anyone interested:
I moved the contents of the .cpp file into the .h file and it seems to compile and work now. I suspect a problem with the Visual Studio express compiler...
Windows with no internet connection is safe, but that's not what Windows was built for.
|
|
|
|
|
The Apocalyptic Teacup wrote: I suspect a problem with the Visual Studio express compiler...
No, I hardly doubt that is the problem. How did you add the cpp file to your project ?
|
|
|
|
|
Cedric Moonen wrote: No, I hardly doubt that is the problem. How did you add the cpp file to your project ?
I have a Windows form application. In, say, Form1, I have code that performs some calculations. Previously I had written a large number of statistical functions in the aforementioned .h and .cpp files. I have included these files in several projects with no problems and I know they work. I moved them into the project directory for the form application (I'm on someone else's machine) and added them to the project (Using Add... on the solution explorer). I did a #include <statistics.h> in the code for Form1 and tried to build the solution. This gave me the unresolved symbol errors. It's a little strange. I removed them from Form1.h and included them in StdAfx.h with the same results. The only way to remove the unresolved symbols problem was to merge the .cpp file into the .h file. I'm baffled.
Windows with no internet connection is safe, but that's not what Windows was built for.
|
|
|
|
|
The Apocalyptic Teacup wrote: I moved the contents of the .cpp file into the .h file and it seems to compile and work now.
Is the header included in some namespace, and the code is not?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: Is the header included in some namespace, and the code is not?
No, not at all. I mean I've added these files to projects before with no problems. This is the first time I have used Visual Studio 2005 Express and I seem to be having "migration issues". Previously I was using VC6.
I don't have access to the code at the moment, but I will give you an example.
I have a Form application and on Form1 there is a button. In the button click event I calculate some statistics. In the statistics.cpp and statistics.h files I have my code. At the top of Form1.h I put
#include "statistics.h"
Let's say the function I want to use is NormalDistribution(x). This actually appears in the Solution Explorer as a global function. So, in the button click event handler I write something like:
double Result = NormalDistribution(x);
It compiles, but when it gets to the linking stage, I get the errors. The statistics.cpp and statistics.h show up in the solution explorer, etc... so this is quite strange.
Windows with no internet connection is safe, but that's not what Windows was built for.
|
|
|
|
|
heyhey
I've got a simple question. I read that you can dereference an vertex array like this:
<br />
int i;<br />
glBegin (mode);<br />
for (i = 0; i < count; i++)<br />
glArrayElement(indices[i]);<br />
glEnd();<br />
which should be equal to a glDrawElements()-call
but what if I want to get the normal which is related to this vertex-list. So I have a glNormalPointer()-call before???
<br />
...<br />
glNormalPointer(GL_FLOAT, 0, ModelToDraw.Objects[i].Normals);<br />
glVertexPointer(3, GL_FLOAT, 0, ModelToDraw.Objects[i].Vertexes);<br />
float *pNormal = ModelToDraw.Objects[i].Normals;<br />
float *pVertex = ModelToDraw.Objects[i].Vertexes;<br />
...<br />
for (int j=0; j < ModelToDraw.Objects[i].numMatFaces; j++)<br />
{<br />
{...}<- set up material here<br />
glDrawElements(GL_TRIANGLES, ModelToDraw.Objects[i].MatFaces[j].numSubFaces, GL_UNSIGNED_SHORT, ModelToDraw.Objects[i].MatFaces[j].subFaces);<br />
}<br />
I can simply extract the vertex from the glDrawElements or respectively 3 elements to draw a triangle. but how to extract the normal, so I don't need to recalculate it?
thx
zqueezy
-- modified at 10:41 Thursday 18th January, 2007
Adding: The problem is that the iteration here is through the materials and not in the correct order.
I replace the glDrawElements-Call with a call to my own function where I need the normal to each triangle. reading out the correct triangles from p.Vertex is no problem:
<br />
vector4 a,b,c;<br />
int i;
unsigned short index;<br />
float* _tempArray; <br />
glDisable(GL_LIGHTING);<br />
<br />
for(i=0; i < numSubFaces; i+=3)<br />
{<br />
index = subFaces[i];
_tempArray=(float*)(((char*)k) + index * 12);
<br />
a.x = _tempArray[0];<br />
a.y = _tempArray[1];<br />
a.z = _tempArray[2];<br />
a.w = 1.0f;<br />
<br />
index = subFaces[i+1]; <br />
_tempArray=(float*)(((char*)k) + index * 12);<br />
b.x = _tempArray[0];<br />
b.y = _tempArray[1];<br />
b.z = _tempArray[2];<br />
b.w = 1.0f;<br />
<br />
<br />
_tempArray=&(pNormal[i]);
<br />
d.x = _tempArray[0];<br />
d.y = _tempArray[1];<br />
d.z = _tempArray[2];<br />
d.w = 1.0f;<br />
Then I want to show the normal:
<br />
if (showNormal)<br />
{<br />
glColor3f(1.0, 0.0, 0.0);<br />
glBegin(GL_LINES);<br />
glVertex3f(a.x, a.y, a.z);<br />
glVertex3f(a.x + d.x, a.y + d.y, a.z + d.z);<br />
glEnd();<br />
}<br />
a little clearer what the problem is??
|
|
|
|
|
I thought your question was about arrays / pointers when I started, but it looks like its how to get a normal vector to a triangle that you have the corners for.
To get a normal, you need two vectors. Which you can get from your three points.
V1 = P2 - P1
V2 = P3 - P1
Then you can get the normal vector by getting the cross product of those two vectors.
N = V1 x V2.
The normal won't be a unit vector (magnitude of one), but it will give the direction. If you want a unit vector, divide it by its magnitude.
Nunit = N / |N|.
For code to do this maths, you can do a search for vectors, cross products, etc.
I won't pretend its the definitive work, but a lot of this maths is implemented in Warping Coordinates with Matrices [^] (written by me, so be nice)
Iain.
|
|
|
|
|
nonono the normals have been calculated already!!! (via SSE-asm)
I stored them in a group.
so iterating:
<br />
if (ModelToDraw.shownormals)<br />
{<br />
for (int k = 0; k < ModelToDraw.Objects[i].numVerts * 3; k += 3)<br />
{<br />
glBegin(GL_LINES);<br />
glVertex3f(ModelToDraw.Objects[i].Vertexes[k],<br />
ModelToDraw.Objects[i].Vertexes[k+1],<br />
ModelToDraw.Objects[i].Vertexes[k+2]);<br />
glVertex3f(ModelToDraw.Objects[i].Vertexes[k]+ModelToDraw.Objects[i].Normals[k],<br />
ModelToDraw.Objects[i].Vertexes[k+1]+ModelToDraw.Objects[i].Normals[k+1],<br />
ModelToDraw.Objects[i].Vertexes[k+2]+ModelToDraw.Objects[i].Normals[k+2]);<br />
glEnd();<br />
}<br />
}<br />
is no problem at all... just hopping around in the array like described above makes problems!
I don't want to calculate the normals again and again when I render the triangles!
|
|
|
|
|
have you considered using an interleved array? this allows you to put both vertexes and normals in the same grouping, color as well.
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/interleavedarrays.html[^]
are you having problems because of the slowdown on displaying normals? if so, you might consider moving the glBegin out of the loop. glBegin(GL_LINES) draws individual line segments every two vertices set. Which means you don't need to keep stopping and starting the set, you can group them all together.
<br />
glBegin(GL_LINES);<br />
for ()<br />
{<br />
glVertex3f();
glVertex3f();
}<br />
glEnd();<br />
if you don't mind loosing memory, keep paired buffers, one for vertex and normal separately, one for drawing the vertex normals as you referenced here. this is faster because you can use VBO buffers or vertex arrays to send the data in one unit down to the graphics card.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
zqueezy wrote: a little clearer what the problem is??
it looks relatively correct. the issue is actually in the storage structures of subfaces[] verses normals. Notice you are using an index offset to the vertex:
index = subFaces[i];
_tempArray=(float*)(((char*)k) + index * 12);
but when you get to the normal, you don't reference the fact that there is 3 floats
_tempArray=&(pNormal[i]);
you have a normal for every vertex, so you can reference it similarly to the vertex information from above:
index = subFaces[i];
_tempArray=(float*)(((char*)pNormal) + index * 12);
or if you don't like the pointer math you are using which is rather confusing, try this:
_tempArray=&pNormal[index*3]; // normals are 3 floats
and
_tempArray=&pVertex[index*3]; // vertexes are 3 floats
this reads much nicer and helps match the vertex/normal pairs. Generally speaking for vertex array buffers there is one normal per vertex. You can specify one normal per face, but not easily with a vertex array. A vertex array uses an interleaved or separate memory buffer to reference each color, vertex, normal in matching form. If you have 100 vertices, you have 100 color references, and you have 100 normals. Color reference can be 4 units, vertices 2,3 or 4 units, and normals are always 3 units. The units can be float, double, etc.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Jeffry J. Brickley, You are a genius
you saved my life!!!
thanx e^256 times!
|
|
|
|
|
zqueezy wrote: You are a genius
No... I only know OpenGL well, no more, no less. But thank you.
zqueezy wrote: you saved my life!!!
hehe, well, I doubt that... but thank you again.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi
I want to add a toolbar to my application but when I use 'standard' CToolBar class I can't load my 32x32 24-bit bitmaps into it (Visual Studio 2003 resource editor converts them to some ugly-looking 8-colors bitmaps...) Is it possible to create nice looking toolbars (ie. like those in IE6) with handle for changing its position and locking/unlocking feature just using CToolBar class??
I also want to create my app menu "File Edit ..." on a toolbar like IE6 does. Is it possible using this base MFC control? If not, could someone point me to the article where I could find some more informations?
Thanks for any help.
|
|
|
|
|
PatrykDabrowski wrote: (ie. like those in IE6)
Look up CReBar.
|
|
|
|
|
|
|
PatrykDabrowski wrote: I can't load my 32x32 24-bit bitmaps into it (Visual Studio 2003 resource editor converts them to some ugly-looking 8-colors bitmaps...)
When you create the image list for the toolbar control, try building it like this...
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
// (the '2' in the following call is the number of buttons in the bitmap)
m_ToolBarImageList.Create(32, 32, ILC_COLOR24|ILC_MASK, 2, 1);
// (RGB(0x00,0xFF,0x00) sets the transparent color to bright green)
m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
|
|
|
|
|
Hi,
I get an error while running the application but i don't get when i debug it..the error is:
the exception Breakpoint
A breakpoint has been reached.
(0X80000003) occured in the application at location 0X7c901230
can anyone help me out with this?
thnx,
Priya
|
|
|
|
|
this happens in an ASSERT() when the condition is false...
|
|
|
|
|
i created xml file need to read, the file read the data ( ??? might be !!
not sure ,
when i print that data in the messagebox it gives the square box like.
hFile=CreateFile ( L"c:\\FileProperty.XML"
, GENERIC_READ | GENERIC_WRITE
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
if(hFile == INVALID_HANDLE_VALUE)
{
MessageBox(0,_T("File is not created"),_T("Create File"),0);
}
else
{
MessageBox(0,_T("File is created"),_T("Create File"),0);
}
bool bSucced=ReadFile(hFile,&szBuff,5000,&dwRecvLen,NULL);
szBuff[dwRecvLen] = '\0';
MessageBox(0,LPCWSTR(szBuff),L"Message",0);
how can i print that data in the string form?.
amit
|
|
|
|
|
Well, there seems to be a some errors in the code you posted.
You seem to have made the memory allocation for szBuff out-commented.
You assume that the file size doesn't exceed 5000 bytes.
I don't exactly get what you mean by "square box like", but I guess that you have enabled unicode for your build configuration and the first bytes in the "string" you want to display evaluates to a token that doesn't match a writeable character.
You even type cast to a LPCWSTR , which in this case doesn't have any effect since the MessageBox parameter is dependant on whether you have enabled unicode support or not.
The bottom line is that you have to be consistant: if you have enabled unicode support then you have to make sure that the file data is converted unless the file is already in unicode format, which I suspect it's not and that's what I think gives the result you've described.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
ya exactly , i forget to write that thing its unicode thats why its come like
square box but how can do it in readable form?
because the messagebox show the unicode character so how to make that data to
read meaningful.
ok i made that file unicode then will it give me the data in the proper
readable form?
amit
|
|
|
|
|
amitmistry_petlad wrote: ok i made that file unicode then will it give me the data in the proper
readable form?
Technically: yes.
But, perhaps other applications that are supposed to use the file may no longer use it since you've changed the file format.
My suggestion:
Read the file as usual and then convert to unicode with ::MultiByteToWideChar() .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
But for that how can i convert my DWORD TO string look the following code:
std::string source(szBuff);
WCHAR w_Out[MAX_PATH];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source.c_str(),(int)(source.length() + 1),w_Out,MAX_PATH);
MessageBox(0,LPCWSTR(w_Out),L"Message",0);
amit
|
|
|
|
|