need help loading 3ds in cocoa

tyzerg
Unregistered
 
Post: #16
ok here's a newbie question: how would i do this for floats?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #17
Oh, that's tough. Well, just try the same code, it might just work (yeah right Wink)

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #18
load into a four-byte integer, do the swap as is, then get the float out like this:

Code:
float my_float = *(const float *)&my_four_byte_integer;

or like this:

Code:
typedef union
{
    uint32_t integer;
    float float;
}
four_byte_float;

four_byte_float f;
f.integer = my_four_byte_integer;
float my_float = f.float;
Quote this message in a reply
tyzerg
Unregistered
 
Post: #19
thanks
Quote this message in a reply
tyzerg
Unregistered
 
Post: #20
ok next question: why cant cocoa display the strings contained in the file properly? (it always says something like \\302)
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #21
How are you loading them
Quote this message in a reply
tyzerg
Unregistered
 
Post: #22
first i load the file into a char buffer, then i do something along the lines of this:

char *tempName;
tempName = new char[chunkLength];
for(int j = 0; j<chunkLength; j++)
tempName[j] = *(char*)(buffer+j);


chunkLength is the length of the string
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #23
What's the type of buffer?

How are you printing them?
Quote this message in a reply
tyzerg
Unregistered
 
Post: #24
the buffer is a pointer to char
i print with NSLog ex. NSLog(@"string:%c", tempName);
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #25
%c is for characters, right? There should be a separate conversion for strings. I'll look it up...

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #26
%s for regular char* strings, %S for unicode.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
tyzerg
Unregistered
 
Post: #27
ahhh stupid me
Quote this message in a reply
tyzerg
Unregistered
 
Post: #28
ok another stupid question: how do i get just one byte from the buffer and find the ascii value of it?

btw sorry for all these silly questions, im still getting used to weird cocoa and i was never really an expert in c/c++ anyway.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #29
buffer[i] if buffer's a const char* containing ascii, and i is the index of the character you want...
Quote this message in a reply
tyzerg
Unregistered
 
Post: #30
i meant the ascii number value
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Texture Loading in Cocoa... dave05 3 8,113 Dec 11, 2007 03:12 AM
Last Post: DoG
  Loading and using textures with alpha in OpenGL with Cocoa corporatenewt 4 6,401 Dec 8, 2007 02:06 PM
Last Post: Malarkey
  loading textures - cocoa openGL mDmarco 20 9,477 Aug 28, 2007 08:48 PM
Last Post: OneSadCookie
  Cocoa Texture Loading Code Problem Nick 1 3,085 Oct 28, 2005 11:44 PM
Last Post: OneSadCookie
  Quick texture loading in Cocoa? Fenris 20 8,213 Jun 10, 2003 03:18 AM
Last Post: Fenris