Cube  Diff

Differences From Artifact [18fb7f56bd]:

To Artifact [4b55922953]:


50
51
52
53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
		delete[] _glCommands;
	if (_frames)
		delete[] _frames;
}

- (bool)loadWithIRI:(OFIRI *)IRI
{
	@autoreleasepool {
		OFSeekableStream *stream;
		@try {
			stream = (OFSeekableStream *)[[OFIRIHandler
			    handlerForIRI:IRI] openItemAtIRI:IRI mode:@"r"];

		} @catch (id e) {
			return false;
		}

		if (![stream isKindOfClass:OFSeekableStream.class])
			return false;

		md2_header header;
		[stream readIntoBuffer:&header exactLength:sizeof(md2_header)];
		endianswap(
		    &header, sizeof(int), sizeof(md2_header) / sizeof(int));

		if (header.magic != 844121161 || header.version != 8)
			return false;

		_frames = new char[header.frameSize * header.numFrames];
		if (_frames == NULL)
			return false;

		[stream seekToOffset:header.offsetFrames whence:OFSeekSet];
		[stream readIntoBuffer:_frames
		           exactLength:header.frameSize * header.numFrames];

		for (int i = 0; i < header.numFrames; ++i)
			endianswap(
			    _frames + i * header.frameSize, sizeof(float), 6);

		_glCommands = new int[header.numGlCommands];
		if (_glCommands == NULL)
			return false;

		[stream seekToOffset:header.offsetGlCommands whence:OFSeekSet];
		[stream readIntoBuffer:_glCommands
		           exactLength:header.numGlCommands * sizeof(int)];
		endianswap(_glCommands, sizeof(int), header.numGlCommands);

		_numFrames = header.numFrames;
		_numGlCommands = header.numGlCommands;
		_frameSize = header.frameSize;
		_numTriangles = header.numTriangles;
		_numVerts = header.numVertices;

		[stream close];

		_mverts = new OFVector3D *[_numFrames];
		loopj(_numFrames) _mverts[j] = NULL;

		return true;
	}
}

- (void)scaleWithFrame:(int)frame scale:(float)scale snap:(int)sn
{
	_mverts[frame] = new OFVector3D[_numVerts];
	md2_frame *cf = (md2_frame *)((char *)_frames + _frameSize * frame);
	float sc = 16.0f / scale;







<
|
|
|
|
>
|
|
|

|
|

|
|
<
|

|
|

|
|
|

|
|
|

|
<
|

|
|
|

|
|
|
|

|
|
|
|
|

|

|
|

|
<







50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
		delete[] _glCommands;
	if (_frames)
		delete[] _frames;
}

- (bool)loadWithIRI:(OFIRI *)IRI
{

	OFSeekableStream *stream;
	@try {
		stream = (OFSeekableStream *)[[OFIRIHandler handlerForIRI:IRI]
		    openItemAtIRI:IRI
		             mode:@"r"];
	} @catch (id e) {
		return false;
	}

	if (![stream isKindOfClass:OFSeekableStream.class])
		return false;

	md2_header header;
	[stream readIntoBuffer:&header exactLength:sizeof(md2_header)];

	endianswap(&header, sizeof(int), sizeof(md2_header) / sizeof(int));

	if (header.magic != 844121161 || header.version != 8)
		return false;

	_frames = new char[header.frameSize * header.numFrames];
	if (_frames == NULL)
		return false;

	[stream seekToOffset:header.offsetFrames whence:OFSeekSet];
	[stream readIntoBuffer:_frames
	           exactLength:header.frameSize * header.numFrames];

	for (int i = 0; i < header.numFrames; ++i)

		endianswap(_frames + i * header.frameSize, sizeof(float), 6);

	_glCommands = new int[header.numGlCommands];
	if (_glCommands == NULL)
		return false;

	[stream seekToOffset:header.offsetGlCommands whence:OFSeekSet];
	[stream readIntoBuffer:_glCommands
	           exactLength:header.numGlCommands * sizeof(int)];
	endianswap(_glCommands, sizeof(int), header.numGlCommands);

	_numFrames = header.numFrames;
	_numGlCommands = header.numGlCommands;
	_frameSize = header.frameSize;
	_numTriangles = header.numTriangles;
	_numVerts = header.numVertices;

	[stream close];

	_mverts = new OFVector3D *[_numFrames];
	loopj(_numFrames) _mverts[j] = NULL;

	return true;

}

- (void)scaleWithFrame:(int)frame scale:(float)scale snap:(int)sn
{
	_mverts[frame] = new OFVector3D[_numVerts];
	md2_frame *cf = (md2_frame *)((char *)_frames + _frameSize * frame);
	float sc = 16.0f / scale;