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 

2 .dmf format questions

 
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
colt527
Member


Joined: 09 Mar 2005
Posts: 9

PostPosted: Sat Mar 12, 2005 7:10 pm    Post subject: 2 .dmf format questions Reply with quote

I saw the other thread about this and it didn't answer my questions, so rather then interuppting that conversation, i'll start a new one.

Question 1:
Is there any way to take a level in DeleD with lots of seperate objects and convert it into 1 very large object. For now my parser is just doing 1 object and I figure that will make everything simpler.

Question 2:
When u get to the lines with the Polygon information: # of vertices,materialID,vertice index values,uv values. What order are the UV values? Like: u1, v1, u2, v2, u3,v3? or something else?

Thanks!
Back to top
View user's profile Send private message
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Sat Mar 12, 2005 7:23 pm    Post subject: Reply with quote

1.) The "merge" function, select all objects and press merge.
2.) As far as i can remember, it is like this, u1, v1, u2, v2 etc.
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
Jeroen
Site Admin


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

PostPosted: Sat Mar 12, 2005 9:24 pm    Post subject: Reply with quote

Fletcher is right. Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Daaark
DeleD PRO user


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

PostPosted: Sun Mar 13, 2005 9:33 am    Post subject: Reply with quote

What language are you writing your parser in? Turning your whole map into one object won't be doing the program any favours for a few reason... is it c++? I can share my parser code with you if you want?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
colt527
Member


Joined: 09 Mar 2005
Posts: 9

PostPosted: Sun Mar 13, 2005 10:57 pm    Post subject: Reply with quote

Yes, its in c++, I just wanted to turn it into 1 object to test my progress and make sure it can handle a large object with a lot of polygons. It will be able to handle multiple objects and ill probably have a system where a certain object prefix on the name will make it a certain entity. Thanks for the offer though, Very Happy but I'de rather poke through it myself, might be a good learning experiance.

btw, what file IO library did u use, I used stdio only because I know it best and its worked pretty good so far, I've loaded the vertex and index information into the buffers and rendered the object in wireframe, I'm currently working on getting the textures on. But, if you know of a better file IO system, ill check it out.
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 Mar 14, 2005 3:33 am    Post subject: Reply with quote

I used fstream, stringstream and a char array. Smile It's not done, but it's really easy to switch things up. Since I wasn't making an fps, it doesn't handle the lights, or materials with mulitple layers or stuff, but it's really easy to modify. I'll post it for you.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Daaark
DeleD PRO user


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

PostPosted: Mon Mar 14, 2005 3:36 am    Post subject: Reply with quote

You woulc have to play with this abit.. but I think it's easy to remove my stuff, and just plug in your own classes and arrays, it's commented what every line does. basically I grab a line of the file at a time, and I strtok() what I need outof it.

Code:
//DMF Loader
int c_map::LoadDMF(char *cFileName)
{

    fstream         fMap;
    stringstream    ss;
    char            ca[256];
    char            cMsg[256];

    fMap.open(cFileName);
    if (!fMap.is_open())
    {
        RichTextAppend("\nERROR: File not found.");
        return false;
    }

    ss << fMap.rdbuf(); fMap.close();

    //make sure this is a Deled map file
    ss.getline(ca,256);
    if (strstr(ca,"DeleD Map File") == NULL)
    {
        RichTextAppend("\nERROR: File not valid.");
        return false;
    }

    //make sure this a 1.1 file
    ss.getline(ca,256);
    if (strstr(ca,"Version 1.1") == NULL)
    {
        RichTextAppend("\nERROR: Unsupported file version.");
        return false;
    }

    //grab the map title, the ambient colour and the shadow opacity
    ss.getline(ca,256);
    strcpy(m_Name,strtok(ca,";"));
    MakeAmbientFromHex(strtok(NULL,";"));
    m_ShadowOpacity = atof(strtok(NULL,";")) /100;

    //output the room name, ambient color and shadow opacity
    sprintf(cMsg,"\nRoom Name: %s",m_Name);
    RichTextAppend(cMsg);
    sprintf(cMsg,"\nAmbient Colour: %f %f %f",m_LightAmbient[0],m_LightAmbient[1],m_LightAmbient[2]);
    RichTextAppend(cMsg);
    sprintf(cMsg,"\nShadow Opacity: %f",m_ShadowOpacity);
    RichTextAppend(cMsg);

    //get the number of materials in the file
    ss.getline(ca,256);
    m_NumMaterials = atoi(ca);

    sprintf(cMsg,"\n%s contains %d Materials",m_Name, m_NumMaterials);
    RichTextAppend(cMsg);

    //allocate the materials
    m_mat = new c_mapmat[m_NumMaterials];

    //grab alll the materials
    for (int i = 0; i < m_NumMaterials; ++i)
    {
        ss.getline(ca,256);

        //grab the id and the name
        //and construct a file name to point to a tga
        m_mat[i].ID = atoi(strtok(ca,";"));
        strcpy(m_mat[i].Name,strtok(NULL,";"));
        strcpy(m_mat[i].FileName,m_mat[i].Name);
        strcat(m_mat[i].FileName,".tga");

        strtok(NULL,";");   //category -- unused
        strtok(NULL,";");   //reserved -- unused
        m_mat[i].Layers = atoi(strtok(NULL,";"));

        sprintf(cMsg,"\nMaterial ID: %d Name: %s",m_mat[i].ID,m_mat[i].FileName);
        RichTextAppend(cMsg);

    }

    //get the number of objects in the file
    ss.getline(ca,256);
    m_NumObjects = atoi(ca);

    sprintf(cMsg,"\n%s contains %d object(s).",m_Name, m_NumObjects);
    RichTextAppend(cMsg);

    m_obj = new c_mapobj[m_NumObjects];

    for (int i = 0; i < m_NumObjects; ++i)
    {
        ss.getline(ca,256);

        //grab the name and id
        strcpy(m_obj[i].Name,strtok(ca,";")); //object name
        m_obj[i].ID = atoi(strtok(NULL,";")); //id

        ss.getline(ca,256);

        //get the number of vertices in the object,
        //and allocate space for them
        m_obj[i].NumVertices = atoi(ca);
        m_obj[i].vtx = new vector3[m_obj[i].NumVertices];

        //read in all the vertice info
        for (int j = 0; j < m_obj[i].NumVertices; ++j)
        {
            ss.getline(ca,256);

            m_obj[i].vtx[j].x = atof(strtok(ca,";"));
            m_obj[i].vtx[j].y = atof(strtok(NULL,";"));
            m_obj[i].vtx[j].z = atof(strtok(NULL,";"));
        }

        ss.getline(ca,256);

        //get the number of triangles in this object,
        //and allocate space for them

        m_obj[i].NumTriangles = atoi(ca);
        m_obj[i].tri = new c_triangle[m_obj[i].NumTriangles];

        //read in all the triangle info
        for (int j = 0; j < m_obj[i].NumTriangles; ++j)
        {
            ss.getline(ca,256);

            //get the number of vertices... if this is anything
            //other than 3... the file will not be loaded, all
            //objects must be triangles
            if (atoi(strtok(ca,";")) != 3)
            {
                RichTextAppend("\nERROR: This file contains objects that are not triangulated!");
                return false;
            }

            //store the material ID
            m_obj[i].tri[j].MatID = atoi(strtok(NULL,";"));

            /*
            //read in the vertex indices
            //clockwise winding
            m_obj[i].tri[j].vtx[0] = atoi(strtok(NULL,";"));
            m_obj[i].tri[j].vtx[1] = atoi(strtok(NULL,";"));
            m_obj[i].tri[j].vtx[2] = atoi(strtok(NULL,";"));
            */

            //counter clockwise winding
            m_obj[i].tri[j].vtx[2] = atoi(strtok(NULL,";"));
            m_obj[i].tri[j].vtx[1] = atoi(strtok(NULL,";"));
            m_obj[i].tri[j].vtx[0] = atoi(strtok(NULL,";"));

            //read in the uvw.. assume for now it's always 3
            m_obj[i].tri[j].uvw[0] = atof(strtok(NULL,";"));
            m_obj[i].tri[j].uvw[1] = atof(strtok(NULL,";"));
            m_obj[i].tri[j].uvw[2] = atof(strtok(NULL,";"));
        }

        m_obj[i].CreateFaceNormals();
    }

   

    return true;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
colt527
Member


Joined: 09 Mar 2005
Posts: 9

PostPosted: Sun Mar 27, 2005 12:58 am    Post subject: Reply with quote

I'de just like to let you guys know my parser is FINALLY complete. After taking a break for a while, I dedicated some hours from yesterday and today to get it done. It supports multiple objects, textures, lightmaps, you name it, it can probably do it. So thanks to all of you guys for answering my questions. Very Happy There really is a great community here. I also have the source (poorly annotated and highly inefficient) but it works. Razz

Heres one question I have:
In Direct3D, as far as I know you have to put UV information inside of the Vertex structure that you use. So if 2 faces share a vertex and that vertex needs different UV information for each face, how would you do that?

I took the easy way out I guess and made each triangle its own Vertex Buffer and filled in the UV information. I KNOW that is not efficient at all, but it was the easyest way out.

Screen Shots:





As you can tell, I'm using DeleD LITE to make the lightmaps so the quality ... isn't quite what I expected, but what can you do. There are no other free lightmapping programs out there.

There wouldn't possibly be a way to get rid of the jaggedy edges w/o getting Pro with higher resoltion light maps would there?
Back to top
View user's profile Send private message
Jeroen
Site Admin


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

PostPosted: Sun Mar 27, 2005 8:03 am    Post subject: Reply with quote

colt527 wrote:

Heres one question I have:
In Direct3D, as far as I know you have to put UV information inside of the Vertex structure that you use. So if 2 faces share a vertex and that vertex needs different UV information for each face, how would you do that?
I took the easy way out I guess and made each triangle its own Vertex Buffer and filled in the UV information. I KNOW that is not efficient at all, but it was the easyest way out.
There wouldn't possibly be a way to get rid of the jaggedy edges w/o getting Pro with higher resoltion light maps would there?


Glad to see you got things working, screenshots are cool! Very Happy

To answer your questions:

- You need to duplicate your vertices in order to get multiple UV's for one vertice working. I'm guessing this is already what you're doing. Smile
- Indeed, PRO solves the jagged edges for lighting, feel free to buy it! Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Paul-Jan
Site Admin


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

PostPosted: Sun Mar 27, 2005 9:18 am    Post subject: Reply with quote

I agree the screenshots are pretty cool, good job!

About the jagged edges: PRO doesn't neccesary render higher resolution lightmaps, as much as filtered lightmaps with smart (adaptive) individual per-face size. Giving you better lightmaps with a smaller total size.

Lite lighting really only is preview-functionality, in my opinion it is in no way suitable for any release, not only because of the jagged edges, but also because with any decent-size map the total lightmap size becomes huge pretty fast.

However, (and I am sharing some tricks of the trade here Wink), you might want to try setting the shadow opacity (scene properties) a lot lower, leaving you with barely any shadows at all and only subtle lighting, but no more jaggy edges.
Back to top
View user's profile Send private message Visit poster's website
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
Page 1 of 1

 
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