Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbLimbName

Author
Message
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 5th Oct 2010 06:39 Edited at: 5th Oct 2010 08:00
This probably a noob question..

if(dbLimbName(obj,limb)=="Chest"){print "something";}

It doesn't print. So pretty much I'm having troubles comparing limbname's.

In dbpro:
if limb name(obj,limb) = "Head" ; print "yourmom"; endif
totally works

my actual code is this :


[off subject] Anyone know a way to change a single face in code? like it's color or texure. Can you give an example? Can this be done by using code from augest 2007 directx sdk?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 5th Oct 2010 15:16 Edited at: 5th Oct 2010 15:17
you can'y compare strings to strings using '==', use strcmp instead

also note that strcmp returns ZERO if it succeeds, dunno why they made it like that, sounds dumb, but well that's it

@ your second question, what do you mean? character face?

[url][/url]
Nothing's impossible, it's just a matter of time...
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 5th Oct 2010 16:19
Is strcmp part of string.h? Should it look like this?

if(strcmp(dbLimbName(obj,limb),"Head")==0){something;}

The second question is on mesh face's, I was looking around in the direct "x files" and found STDMETHOD(SetFaceAttribute)(UINT iFace,DWORD Attribute) PURE; there where some comments about how you can set an id to a face and change it's material.
I don't know where to even start with this, so maybe it is too much for me but I am up for giving it a shot if someone wants to point me in a good direction

Thanks BTW Hassen
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 5th Oct 2010 17:35 Edited at: 5th Oct 2010 19:26
Yes i believe that's how it's done, but i think you need to free the pointer returned by dbLimbName, e.g.


the attribute is used for subsets, it has nothing to do with materials

the object has a vertex buffer and an index buffer, and optionally an attribute buffer, vertex buffer includes vertex data (position color uvs etc), index buffer describes how vertices are bound together to form triangles, the buffer is either a DWORD array or WORD, it's size is 3 * number of triangles, 3 indices for every triangle, now the attribute buffer contains info about faces, so face 0 for example (which is indices[0], indices[1] and indices[2]) might hold the value of 0 in the attribute buffer stating that the face 0 is in subset 0

it's far from anything to do with materials, what do you want to do anyway?



[url][/url]
Nothing's impossible, it's just a matter of time...
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 5th Oct 2010 19:14
Try this:

std::string str4;
std::string name2="Chest";
size_t found2;

for (int xxx2=1; xxx2<10; xxx2++)
{
for(int limbsint7=0; limbsint7<500;limbsint7++)
{
if(dbLimbExist(5,limbsint7)==1 )
{

str4=dbLimbName(5, limbsint7);
found2=str4.find(name2);
if(found2!=std::string::npos)
{

Code here


}

}
//}
}
}
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 6th Oct 2010 20:44
Quote: "i think you need to free the pointer returned by dbLimbName,"


Yes but use delete[] instead of delete.

The problem with assigning the returned value to an std::string directly is that the returned pointer cannot be deleted. Store the pointer and then it can still be assigned to a string.
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 13th Oct 2010 08:30
Are you saying dbLimbName(x,xx); makes somthing like a a variable and i need to delete it? Like it is in a funtion, I thought all variable's are free'd after the funtion returns to main, or maybe right before?

Quote: "it's far from anything to do with materials, what do you want to do anyway?
"


Idk something that look's sweet, lol changed in real-time.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 13th Oct 2010 15:22
it allocates new memory for the returned buffer on the heap (using new operator), so you must free it yourself

[url][/url]
Nothing's impossible, it's just a matter of time...
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th Oct 2010 17:48
@ Hassan,
Quote: "also note that strcmp returns ZERO if it succeeds, dunno why they made it like that, sounds dumb, but well that's it"

That's because strcmp() will give a lexicographical orientation of the strings in question. A negative value means the first string is, in "alphabetical" order before the second string and a positive means it's after. (I may have those reversed but you get the idea). And of course, a 0 means they are the same.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-06-30 11:48:10
Your offset time is: 2024-06-30 11:48:10