Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to render DMF maps in OpenGL
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition
View previous topic :: View next topic  
Author Message
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Sun Nov 06, 2005 10:03 pm    Post subject: Reply with quote

Vampyre_Dark wrote:
Mr.Fletcher wrote:
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop
That's only going to make it even slower than it already is.


He's not interested in fast code, he just wants to render it properly. Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Mon Nov 07, 2005 2:13 pm    Post subject: Reply with quote

Vampyre_Dark wrote:
Mr.Fletcher wrote:
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop
That's only going to make it even slower than it already is.

I think i see what you mean, but it's necessary here, because the GL has to know, where to begin and where to end the polygons. You cannot start the GL_POLYGONS - rendering with every object unless it exists of only one polygon. But yes, triangulating it would be a lot faster. And it's not that difficult, either.
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Mon Nov 07, 2005 5:49 pm    Post subject: Reply with quote

Mr.Fletcher wrote:
Vampyre_Dark wrote:
Mr.Fletcher wrote:
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop
That's only going to make it even slower than it already is.

I think i see what you mean, but it's necessary here, because the GL has to know, where to begin and where to end the polygons. You cannot start the GL_POLYGONS - rendering with every object unless it exists of only one polygon. But yes, triangulating it would be a lot faster. And it's not that difficult, either.


You are correct. That was a mistake on my part. Because GL_POLYGONS is difference and can have n sides. I forgot about that when I was posting. Embarassed

Ghost -- why are you rendering your DMF map out? Is it intended just for fun, or are you trying to make a real time application like a game? GL_POLYGON will get the job done, but it's going to be really slow.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
GhostManZero
Member


Joined: 05 Nov 2005
Posts: 10

PostPosted: Tue Nov 08, 2005 10:50 am    Post subject: Reply with quote

Yes, i am trying to make a real-time app, it will be my 1st attempt at making a 3D world, since DeleD seems to be very good at it. After this, i'll try to do some collision detection, and later, a game.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GhostManZero
Member


Joined: 05 Nov 2005
Posts: 10

PostPosted: Sun Nov 13, 2005 4:36 pm    Post subject: Reply with quote

I finally was able to draw a DeleD map's geometry well! Thanks to the creator of the delphi loader & renderer example! (i heard it was Mr. Fetcher, so i thank you, Mr. Fetcher!)
Note: i still wasnt able to place textures on it, working on it now.
For a screenshot-> http://www.ghostdev.gamedev-pt.net/Downloads/dmfload7.jpg
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Sun Nov 13, 2005 4:57 pm    Post subject: Reply with quote

Can you post your rendering code? Maybe we could help you then.

Quote:
i heard it was Mr. Fetcher, so i thank you, Mr. Fetcher!

I'm glad i could help someone Smile
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
GhostManZero
Member


Joined: 05 Nov 2005
Posts: 10

PostPosted: Sun Nov 13, 2005 8:58 pm    Post subject: Reply with quote

the source + bin-> http://www.ghostdev.gamedev-pt.net/Downloads/GhostEngineDMFLoaderTest.zip
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GhostManZero
Member


Joined: 05 Nov 2005
Posts: 10

PostPosted: Mon Nov 14, 2005 1:25 pm    Post subject: Reply with quote

Forgot to mention that the DMF drawing code itself is located @ DMFRender.h in the Tester folder.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Mon Nov 14, 2005 1:56 pm    Post subject: Reply with quote

Hi,
in dmfrender.h:
Code:
glBegin(GL_TRIANGLE_STRIP);
        for(int k=0; k < dmf.objectList[i].polygons[j].numVertices; k++)
        {
        glVertex3f(...);
        }
        glEnd();
        }

This is only correct when there are only triangles in the map, means polygons with three vertices. If you want to do it the right way, you should call glBegin(GL_POLYGON); instead of glBegin(GL_TRIANGLE_STRIP);

For the textures, you should bind the texture before every Polygon and with every vertex, you need to specify the texture coordinates with glTexCoord2f(dmf.objectList[i].polygons[j].texcoord[k][0],dmf.objectList[i].polygons[j].texcoord[k][1]);
(just an example, no guarantee for correctness. i don't really know how the texture coordinates are stored there)
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
CMe
Member


Joined: 30 Jun 2005
Posts: 72
Location: Ontario Canada

PostPosted: Mon Nov 14, 2005 11:42 pm    Post subject: Reply with quote

Hi all. It seems people are interested in using the dmf loading procedures I wrote and I can imagine understanding how to render with it can be a bit confusing. I wrote the routines in such as way to leave all the data exposed for maximum flexibility and not change the structure used by deled.

I'm going to write a small opengl rendering example and include it with the dmf.h / dmf.c code.

btw, if you want to ensure that all your geometry in the map are triangles, there is a function which will split all polygons down with TriangulateDMF.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Nov 17, 2005 10:02 am    Post subject: Reply with quote

Quote:
I'm going to write a small opengl rendering example and include it with the dmf.h / dmf.c code.


I think that's a great idea! Very Happy
Back to top
View user's profile Send private message Visit poster's website
banshee777
Member


Joined: 10 Feb 2005
Posts: 37

PostPosted: Sun Nov 20, 2005 4:10 am    Post subject: asd Reply with quote

Well this is mine. I hope it helps


int brushrender()
{
char crap;
int i = 0;
int j = 0;
int uv0 = 0;
int uv1 = 1;
int uv2 = 6;
int uv3 = 7;
char test;

glEnable(GL_TEXTURE_2D);
while (i < mapcore[0].boxes) // MAX OBJECTS etc box, pyramid, etc
{
//unsigned int twopasscount = 0;


for (int j = 0; j < box[i].polygons; j++) // render all faces
{
uv0 = 0;
uv1 = 1;
uv2 = 6;
uv3 = 7;

//unsigned int twopass[20];
for (int b = 0; b < twopasscount; b++)
{
if (twopass[b] == box[i].materialID[j])
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mtexture[b]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mtexture1[b]);
}
}

glBegin(GL_TRIANGLES);
//for (int z = 0; z < box[i].vertices[j] && box[i].visible == -1; z++)
for (int z = 0; z < box[i].vertices[j]; z++) //render face
{
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, box[i].uv_values0[j][uv0], box[i].uv_values0[j][uv1]); //texture stretch
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, box[i].uv_values0[j][uv2], box[i].uv_values0[j][uv3]);
glVertex3d(box[i].x[box[i].vertice_index_values0[j][z]],box[i].y[box[i].vertice_index_values0[j][z]],box[i].z[box[i].vertice_index_values0[j][z]]);
uv0 = uv0 + 2;
uv1 = uv1 + 2;
uv2 = uv2 + 2;
uv3 = uv3 + 2;
}
glEnd();
}
i++;
}
glDisable(GL_TEXTURE_2D);

}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum