Exemplo n.º 1
0
void VFSPlugin_LWO::read_face(long length)
{
	short		numvertex;
	short		flags;
	short		mask		= 1023;
	TempPolygon	*p	= NULL;
	int			ctr			= 0;

	//	Read all the polygon indices
	while(length != 0){
		//	Read the polygon data
		numvertex			=		ReadShort();
		length				-=	sizeof(numvertex);
		
		//	extract the flags and numvertex from the polygon data
		flags					=		!mask & numvertex;
		numvertex			&=	mask;

		//	Create a temporary polygon, and an array of indices for this polygon
		p							=		new TempPolygon;		
		p->numvertex	=		numvertex;
		p->index			=		new int[p->numvertex];

		long vxlength;

		//	Read all the indices for this polygon
		for(int a=0;a<p->numvertex;a++){
			p->index[a] = (unsigned long)ReadVariableLength(&vxlength);
			length-=vxlength;
		}

		//	Store the polygon indices
		polygons.push_back(p);
	}
}
Exemplo n.º 2
0
void VFSPlugin_LWO::read_ptag(long length)
{
	//	Read what type the tags are	(SURF/PART/SMGP)
	long type = ReadLong();
	length-=sizeof(long);

	long polygonid;
	long tag;
	long vxlength;

	//	Read until there are no more tags
	while(length>0)
	{
		//	Read what polygon this tag belongs to and what tag to apply to the polygon
		polygonid	=	ReadVariableLength(&vxlength);
		tag				=	ReadShort();

		//	Store the polygon id and tag data
		polygontags.push_back(tag);
		polygontags.push_back(polygonid);

		length-=(vxlength+sizeof(short));

		//	types:
		//	SURF	Surface
		//	PART	Part
		//	SMGP	Smoothing Group
	}
}
Exemplo n.º 3
0
static dboolean ReadEvent(midi_event_t *event, unsigned int *last_event_type, FILE *stream)
{
    byte        event_type;

    if (!ReadVariableLength(&event->delta_time, stream))
        return false;

    if (!ReadByte(&event_type, stream))
        return false;

    // All event types have their top bit set. Therefore, if
    // the top bit is not set, it is because we are using the "same
    // as previous event type" shortcut to save a byte. Skip back
    // a byte so that we read this byte again.
    if (!(event_type & 0x80))
    {
        event_type = *last_event_type;

        if (fseek(stream, -1, SEEK_CUR) < 0)
            return false;
    }
    else
        *last_event_type = event_type;

    // Check event type:
    switch (event_type & 0xF0)
    {
        // Two parameter channel events:
        case MIDI_EVENT_NOTE_OFF:
        case MIDI_EVENT_NOTE_ON:
        case MIDI_EVENT_AFTERTOUCH:
        case MIDI_EVENT_CONTROLLER:
        case MIDI_EVENT_PITCH_BEND:
            return ReadChannelEvent(event, event_type, true, stream);

        // Single parameter channel events:
        case MIDI_EVENT_PROGRAM_CHANGE:
        case MIDI_EVENT_CHAN_AFTERTOUCH:
            return ReadChannelEvent(event, event_type, false, stream);

        default:
            break;
    }

    // Specific value?
    switch (event_type)
    {
        case MIDI_EVENT_SYSEX:
        case MIDI_EVENT_SYSEX_SPLIT:
            return ReadSysExEvent(event, event_type, stream);

        case MIDI_EVENT_META:
            return ReadMetaEvent(event, stream);

        default:
            break;
    }

    return false;
}
Exemplo n.º 4
0
void VFSPlugin_LWO::read_bump(long length)
{
	//	Get a ptr to the last surface (hence the current one)
	Material *m = m_vb->GetMaterial();

	//	Read the bump intensity of the surface
	m->bump = ReadFloat();

	//	Read the envelope
	long vxlength;
	long envelope = ReadVariableLength(&vxlength);
	length -= (vxlength + sizeof(float)*3);
}
Exemplo n.º 5
0
void VFSPlugin_LWO::read_shrp(long length)
{
	//	Get a ptr to the last surface (hence the current one)
	Material *m = m_vb->GetMaterial();

	//	Read how sharp the surface is
	m->sharpness = ReadFloat();

	//	Read the envelope
	long vxlength;
	long envelope = ReadVariableLength(&vxlength);
	length -= (vxlength + sizeof(float)*3);
}
Exemplo n.º 6
0
void VFSPlugin_LWO::read_diff(long length)
{
	//	Get a ptr to the last surface (hence the current one)
	Material *m = m_vb->GetMaterial();

	//	Read the diffuse value
	m->diffuse = ReadFloat();

	//	Read the envelope
	long vxlength;
	long envelope = ReadVariableLength(&vxlength);
	length -= (vxlength + sizeof(float)*3);
}
Exemplo n.º 7
0
// Read sysex event:
static dboolean ReadSysExEvent(midi_event_t *event, int event_type, FILE *stream)
{
    event->event_type = (midi_event_type_t)event_type;

    if (!ReadVariableLength(&event->data.sysex.length, stream))
        return false;

    // Read the byte sequence:
    event->data.sysex.data = (byte *)ReadByteSequence(event->data.sysex.length, stream);

    if (!event->data.sysex.data)
        return false;

    return true;
}
Exemplo n.º 8
0
void VFSPlugin_LWO::read_colr(long length)
{
	//	Read the base colour of the surface and store it in the material object
	Colour4f *c = ReadColour(3);

	m_vb->SetColour(c);

	//	Read the envelope
	long vxlength;
	long envelope = ReadVariableLength(&vxlength);

	length -= (vxlength + sizeof(float)*3);

	//	Delete all temporary memory
	delete c;
}
Exemplo n.º 9
0
static boolean ReadSysExEvent(midi_event_t *event, int event_type, FILE *stream)
{
    event->event_type = (midi_event_type_t)event_type;

    if (!ReadVariableLength(&event->data.sysex.length, stream))
    {
        fprintf(stderr, "ReadSysExEvent: Failed to read length of SysEx block\n");
        return false;
    }

    // Read the byte sequence:

    event->data.sysex.data = (byte *)ReadByteSequence(event->data.sysex.length, stream);

    if (event->data.sysex.data == NULL)
    {
        fprintf(stderr, "ReadSysExEvent: Failed while reading SysEx event\n");
        return false;
    }

    return true;
}
Exemplo n.º 10
0
static boolean ReadMetaEvent(midi_event_t *event, FILE *stream)
{
    byte b;

    event->event_type = MIDI_EVENT_META;

    // Read meta event type:

    if (!ReadByte(&b, stream))
    {
        fprintf(stderr, "ReadMetaEvent: Failed to read meta event type\n");
        return false;
    }

    event->data.meta.type = b;

    // Read length of meta event data:

    if (!ReadVariableLength(&event->data.meta.length, stream))
    {
        fprintf(stderr, "ReadSysExEvent: Failed to read length of "
                                        "SysEx block\n");
        return false;
    }

    // Read the byte sequence:

    event->data.meta.data = ReadByteSequence(event->data.meta.length, stream);

    if (event->data.meta.data == NULL)
    {
        fprintf(stderr, "ReadSysExEvent: Failed while reading SysEx event\n");
        return false;
    }

    return true;
}
Exemplo n.º 11
0
// Read meta event:
static dboolean ReadMetaEvent(midi_event_t *event, FILE *stream)
{
    byte        b;

    event->event_type = MIDI_EVENT_META;

    // Read meta event type:
    if (!ReadByte(&b, stream))
        return false;

    event->data.meta.type = b;

    // Read length of meta event data:
    if (!ReadVariableLength(&event->data.meta.length, stream))
        return false;

    // Read the byte sequence:
    event->data.meta.data = (byte *)ReadByteSequence(event->data.meta.length, stream);

    if (!event->data.meta.data)
        return false;

    return true;
}