About Store Forum Documentation Contact



Post Reply 
obj.vtxs()
Author Message
mystara Offline
Member

Post: #1
obj.vtxs()
I had some editor code that I used for multitexturing. Recently, after updating Xcode, the code seems to have stopped working, and I'm not sure if it's because my code was wrong or whether the new version of XCode has broken something.

Basically, I have a new object: EditMultiTexturedObj

In the void create(Game::ObjParams &obj) function, if I do:
Int n = obj.mesh()->parts[0].base.vtxs();

I always get 0. However, in the model editor, the model seems to have numerous vertices.

Any thoughts?
12-03-2012 10:40 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #2
RE: obj.vtxs()
Right. It's something to do with my models.

According to the model editor, one of my models has 561 vertices.
But when I load it into this function:

Code:
void EditMultiTexturedObj::create(Game::ObjParams &obj)
{
    int n = 0;
    
    for (int i = 0; i < obj.mesh()->parts.elms(); i++)
    {
        n += obj.mesh()->parts[i].base.vtxs();
    }
}

n (the number of vertices) is 0.
12-05-2012 09:50 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: obj.vtxs()
Code:
n += obj.mesh()->parts[i].base.vtxs().elms();
12-06-2012 12:16 AM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #4
RE: obj.vtxs()
ehhh, unless I'm misreading the API, base.vtxs() (in MeshBase) returns the number of vertices?

So there is no vtxs().elms()

I should clarify that in some objects, this function works fine with some models. I returns exactly what you would expect. But for some models, it returns nothing.
(This post was last modified: 12-08-2012 08:48 PM by mystara.)
12-08-2012 08:47 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #5
RE: obj.vtxs()
Ah yes, that does work. In which case, I have absolutely no idea where my code is failing.

I'm doing:
Code:
mesh->parts[i].base.vtx.material(j).set(255-additionalMaterial1Amount, additionalMaterial1Amount, 0, 0);

on each vertex, in order to mix two materials.

and then:
Code:
mesh->parts[i].setRender();

In order to actually render the model, I do:
Code:
UInt EditMultiTexturedObj::drawPrepare()
{    
    mesh->drawBlend(matrix);
    
    return super::drawPrepare();
}

But the entire model just disappears. I'm really not sure what's going on. This never used to happen.

Any suggestions?
12-09-2012 03:25 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: obj.vtxs()
Editor may generate meshes with MeshBase (CPU) deleted, but MeshRender (GPU) present, that is to reduce file size and memory needed for mesh, and also loading time.
So you may want to make sure that MeshBase is created before creating MeshRender from it:
Code:
MeshPart& setBase      (Bool only_if_empty=true                                                        ); // set software  version, convert 'MeshRender' to 'MeshBase', 'only_if_empty'=perform conversion only if the MeshBase is empty (if set to false then conversion is always performed)
   MeshPart& setRender    (Bool optimize     =true                                                        ); // set rendering version, convert 'MeshBase'   to 'MeshRender'
12-09-2012 05:39 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #7
RE: obj.vtxs()
That may be the problem, though I don't understand how to fix it.
Regardless of whether I do setRender(false) or setRender(true), the model disappears.

I do not call setBase.
12-09-2012 06:19 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #8
RE: obj.vtxs()
I've continued to play around with this, without success.

It looks like I would need to change the editor to call setRender(false) when the model is loaded, in order to preserve base and allow me to edit the vertices, and then call setRender?

But I have no idea how to do that.
12-11-2012 02:21 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: obj.vtxs()
(12-09-2012 06:19 PM)mystara Wrote:  I do not call setBase.
I was hinting in my previous post that you should create MeshBase from MeshRender, so why not call the setBase to create it?
12-12-2012 05:51 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #10
RE: obj.vtxs()
Hurray!

Excellent. That works fantastically. Thank you.
12-13-2012 12:08 PM
Find all posts by this user Quote this message in a reply
Post Reply