Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Phillip Schuster

Adding Stages to Materials ???

This topic is 6957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi !

I am writing a PRO-Editor based on Power Render and it's using MFC. It has a real-time preview and combines 3ds2pro, editmat and setstage and includes a lot of other stuff. I can edit the materials and see the changes immediately in the 3D Object shown in the real time preview window.

I have a problem. I want to add Multitexturing in it. I did it like that:
- When the object gets loaded, I read out of Material->num_stages to find out how many stages there are already in there.
- When the user clicks on "New Stage", the programm adds one to material->num_stages (material->num_stages++) and sets the texture-number of the material to the first texture (The user can then change the texture of the second stage). This is done (material->texture_number[material->numstages-1] = texture_number.
- Then the program adds a new texture_coords-array to the object (like in setstage).

The problem I have:
When I add a new stage all controls (Combo, buttons and so on) do reflect the state of the material and are working fine. But the object does not show any change. (I have changed the render-method to a multitexturing render-method (T_TEX_MODULATE for example) but it does not work).
When I select another material the program takes the material and reads out all information editable in order to fill the combo-boxes, setting the sliders for color and alpha, and it also reads out material->num_stages. So, when I add a new stage to the material, select another one and then select the new-stage-material again, it just has one stage, although I have added a stage ???????

Here is my source:

This is what happens when the user clicks on "New Stage":
m_Materials is the combo-box showing all materials of the object
m_Stage is the combo with all stages (read from material->num_stages)
m_Texture is the combo displaying all loaded textures.

void CTextures::OnNewstage()
int mat = m_Materials.GetCurSel();
if (mat == -1) return;
int tex = m_Texture.GetCurSel();
if (tex == -1) return;

PR_MATERIAL *material;
material = &PR_ObjectMaterialList[mat];

material->texture_number[0] = tex;
material->texture_number[material->num_stages-1] = tex;
material->environment_map[material->num_stages-1] = FALSE;
material->environment_axis[material->num_stages-1] = XAXIS;
CMainFrame* pFrame;
pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
CPowerRenderView* pView = (CPowerRenderView*)pFrame->GetActiveView();
if (pView->m_Object != NULL) {

int numStages = material->num_stages;
int i;
for (i=0;i CString strNum;


This function(s) are called from OnNewstage and are allocating new tex-coords:

void C3DObject::InsertNewStage(long NumStages)
long numsegs, seg;
long stage;
numsegs = m_PRObject->num_segments;

for (seg=0;seg if (m_PRObject->segment_list[seg].num_tex_coords > 0) {
for (stage = 0; stage < m_PRObject->segment_list[seg].num_tex_coords; stage++) {
PR_free (m_PRObject->segment_list[seg].tex_coords[stage]);

m_PRObject->segment_list[seg].num_tex_coords = NumStages-1;

if (NumStages > 0)
for (stage = 0; stage < m_PRObject->segment_list[seg].num_tex_coords; stage++)
m_PRObject->segment_list[seg].tex_coords[stage] = (PR_TEX_COORD*)PR_malloc (m_PRObject->segment_list[seg].num_faces * sizeof (PR_TEX_COORD));
CopyTexCoords (&m_PRObject->segment_list[seg], stage);

void C3DObject::CopyTexCoords(PR_SEGMENT *seg, PR_DWORD stage)
PR_DWORD facenum;
PR_FACE *face;
PR_TEX_COORD *texcoord;

texcoord = seg->tex_coords[stage];

for (facenum = 0; facenum < seg->num_faces; facenum++)
face = &seg->face_list[facenum];
fd = (PR_FACE_DATA_REAL *)&face->face_data;
for (i = 0; i < 3; i++)
//BUG texscale !
texcoord->u[i] = fd->u[i] * 1.0f;
texcoord->v[i] = fd->v[i] * 1.0f;

I don't see any errors here, can someone please tell me what's wrong.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!