Skip to main content
gamedev.net
🔒 Locked

Prob loading model > scanning variable

Started by RaptorZero 6 replies 500+ views
Original Post
RaptorZero
RaptorZero
Hi everyone, I'm not sure this is the right forum but here it is: I'm creating a little OpenGl game and I programmed the whole model loading module from scratch. I could load up my own .smd models(half-life models before they are compiled to .mdl ones) perfectly but when i tried to load original counter-strike models i got access violation errors! I debugged my app and found that the problem was this: Model file: ... 0 "Bip01" -1 // JointID JointName ParentJoint 1 "Bip01 Pelvis" 0 ... Loading code: ... fgets(StrBuf, 100, File); ... sscanf(StrBuf, "%d %s %d", &pSkel.ID, &pSkel[i].Name, &pSkel[i].ParentID); ... - The 1st line would get parsed ok but when it got to the second line (1 "Bip01 Pelvis" 0) the sscanf would get: pSkel[i].ID = 1 pSkel[i].Name = "Bip01 (int!)pSkel[i].ParentID = Pelvis" Did you understand? The space in the joint's name is messing the .ParentID so when i load up its Parent Joint i would get an access violation! Does anyone knows how can I fix this? Hoh can I assign to the JointName everything thats in ""? Is fgets and sscanf a good way of parsing a model file (it's a text based model)? If anyone has a clue please post it here. Thanx in advance for your help! help! Heeeeelp! [edited by - RaptorZero on May 4, 2004 9:35:09 AM]
error C2065: 'signature' : undeclared identifier
mightyjebus
mightyjebus
maybe this?

sscanf(StrBuf, "%d \"%s\" %d", &pSkel[ i ].ID, &pSkel[ i ].Name, &pSkel[ i ].ParentID);

jebus

[edited by - mightyjebus on May 4, 2004 9:36:26 AM]
RaptorZero
RaptorZero
Sorry didn''t work out...
Using that even the names with no spaces got messed up
.Name = Bip01"
.ParentID = -4825896... (something like this)
Anyway thanxs, i''ll play arround a little more with your idea
error C2065: 'signature' : undeclared identifier
mightyjebus
mightyjebus
ok .. try this:

sscanf(StrBuf, "%d \"%[a-zA-Z0-9 \n\t]\" %d", &pSkel[ i ].ID, &pSkel[ i ].Name, &pSkel[ i ].ParentID);

the %[] input field allows for specific character string reads. i''m guessing you won''t have any other characters in the file besides alphanumerics and whitespace
RaptorZero
RaptorZero
Ok, thank you i''ll try it right away and I''ll post back the results!

Oh, and in case the name has "-" characteres, it would get a little more dificult wouldn''t it?
Sorry for being a pain in the ass but it would be interesting to know it ... if it gets too complicated forget it ...

Thanxs again!
error C2065: 'signature' : undeclared identifier
mightyjebus
mightyjebus
include any other possible characters inside the []. for instance, you mentioned the ''-'' character. add it in like this:

[a-zA-Z0-9 \n\t-]

you may have to use the escape sequence on the dash (like this: \- )
RaptorZero
RaptorZero
Wow you''re fast! Hehe...
Ok, got it, I''ll try it tonight since I''m out of time now if everything goes fine I''ll post back...
And if my "game" ever gets somewhere you''ll be on the credits haha...
Thanks again and again...
error C2065: 'signature' : undeclared identifier
RaptorZero
RaptorZero
Hey mightyjebus, it works perfectly with names containing
spaces, dashes(or hyphens i don''t know how do you call that), numbers, everything!

Thanks a lot man, you saved my life I won''t forget it...

Cya around...
error C2065: 'signature' : undeclared identifier

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.