Tue 15 Jun 2004 03:06:25 PM UTC, comment #15:
How to replace the depreacted istrstream class ?
void Object::Init (char* FileName)
{
//init PolyList
KillPolyList();
ifstream InputFile(FileName);
assert(InputFile);
const int BUFSIZE = 256;
char buf[BUFSIZE];
while (InputFile.getline(buf, BUFSIZE)) {
istrstream line(buf, BUFSIZE);
char function[BUFSIZE];
char throwaway[BUFSIZE];
char strval[BUFSIZE];
float fval1, fval2, fval3, fval4;
line >> function;
line >> throwaway;
if (strcmp(function, "shape") == 0) {
line >> strval;
fval1 = fval2 = fval3 = fval4 = 0.0f;
if (strcmp(strval, "QUADS") == 0) {
AddPolyList(SHAPE, QUADS, fval1, fval2, fval3, fval4);
}
if (strcmp(strval, "TRIANGLES") == 0) {
AddPolyList(SHAPE, TRIANGLES, fval1, fval2, fval3, fval4);
}
} else {
strval[0] = 0;
line >> fval1 >> throwaway >> fval2 >> throwaway >> fval3;
fval4 = 0.0f;
if (strcmp(function, "color3") == 0) {
AddPolyList(COLOR3, 0, fval1, fval2, fval3, fval4);
}
if (strcmp(function, "color4") == 0) {
line >> throwaway >> fval4;
AddPolyList(COLOR4, 0, fval1, fval2, fval3, fval4);
}
if (strcmp(function, "normal") == 0) {
AddPolyList(NORMAL, 0, fval1, fval2, fval3, fval4);
}
if (strcmp(function, "vertex") == 0) {
AddPolyList(VERTEX, 0, fval1, fval2, fval3, fval4);
}
}
}
}
Any alternative way to read those *.mdl file ?
// "Van"
// front bumper
shape = QUADS
color3 = 1.0, 1.0, 0.0
normal = 0.0, 0.0, 1.0
vertex = 0.000, 0.600, 0.000
vertex = 2.100, 0.600, 0.000
vertex = 2.100, 1.500, 0.000
vertex = 0.000, 1.500, 0.000
// right-rear panel
color3 = 0.8, 0.8, 0.0
normal = 1.0, 0.0, 0.0
vertex = 2.100, 0.600, -0.900
vertex = 2.100, 0.600, -3.600
vertex = 2.100, 2.400, -3.600
vertex = 2.100, 2.400, -0.900
// right-front lower panel
normal = 1.0, 0.0, 0.0
vertex = 2.100, 0.600, 0.000
vertex = 2.100, 0.600, -0.900
vertex = 2.100, 1.500, -0.900
vertex = 2.100, 1.500, 0.000
// right-front upper panel/window
shape = TRIANGLES
color3= 0.0, 0.0, 0.2
normal = 1.0, 0.0, 0.0
vertex = 2.100, 1.500, 0.000
vertex = 2.100, 1.500, -0.900
vertex = 2.100, 2.400, -0.900
// rear
shape = QUADS
color3 = 1.0, 1.0, 0.0
normal = 0.0, 0.0, -1.0
vertex = 2.100, 0.600, -3.600
vertex = 0.000, 0.600, -3.600
vertex = 0.000, 2.400, -3.600
vertex = 2.100, 2.400, -3.600
// left-back panel
color3 = 0.8, 0.8, 0.0
normal = -1.0, 0.0, 0.0
vertex = 0.000, 0.600, -3.600
vertex = 0.000, 0.600, -0.900
vertex = 0.000, 2.400, -0.900
vertex = 0.000, 2.400, -3.600
// left-front lower panel
normal = -1.0, 0.0, 0.0
vertex = 0.000, 0.600, -0.900
vertex = 0.000, 0.600, 0.000
vertex = 0.000, 1.500, 0.000
vertex = 0.000, 1.500, -0.900
// right-front upper panel/window
shape = TRIANGLES
color3= 0.0, 0.0, 0.2
normal = -1.0, 0.0, 0.0
vertex = 0.000, 1.500, -0.900
vertex = 0.000, 1.500, 0.000
vertex = 0.000, 2.400, -0.900
// roof
shape = QUADS
color3 = 0.8, 0.8, 0.0
normal = 0.0, -1.0, 0.0
vertex = 0.000, 2.400, -0.900
vertex = 0.000, 2.400, -3.600
vertex = 2.100, 2.400, -3.600
vertex = 2.100, 2.400, -0.900
// windshield
color3 = 0.0, 0.0, 0.2
normal = 0.0, 0.3, 0.3
vertex = 0.000, 1.500, 0.000
vertex = 2.100, 1.500, 0.000
vertex = 2.100, 2.400, -0.900
vertex = 0.000, 2.400, -0.900
|
Sun 06 Jun 2004 04:48:34 PM UTC, comment #11:
Is it possible to pass stream in kcontrol->private_value ?
static int
snd_vortex_hwmix_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
{
vortex_t * vortex = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
if ( VORTEX_IS_QUAD(vortex) )
uinfo->count = 4;
else
uinfo->count = 2;
uinfo->value.integer.min = 0x0000;
uinfo->value.integer.max = 0x7fff;
return 0;
}
static int
snd_vortex_hwmix_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
{
int i,j,dma;
int temp;
vortex_t *vortex;
stream_t *stream;
vortex = snd_kcontrol_chip(kcontrol);
dma=kcontrol->private_value;
stream= &vortex->dma_adb[dma];
if ( VORTEX_IS_QUAD(vortex) )
j = 4;
else
j = 2;
for (i=0; i<j; i++) {
temp=hwread(vortex->mmio,
VORTEX_MIX_INVOL_B + (((MIX_PLAYB(i) << 5) + stream->mix[i]) << 2));
ucontrol->value.integer.value[i]=temp;
};
return 0;
}
static int
snd_vortex_hwmix_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
{
vortex_t * vortex;
stream_t *stream;
int i,j,dma,temp;
vortex = snd_kcontrol_chip(kcontrol);
dma=kcontrol->private_value;
stream= &vortex->dma_adb[dma];
if ( VORTEX_IS_QUAD(vortex) )
j = 4;
else
j = 2;
for (i=0; i<j; i++) {
temp = ucontrol->value.integer.value[i];
vortex_mix_setinputvolumebyte(vortex, MIX_PLAYB(i), stream->mix[i], temp);
};
return 0;
}
static snd_kcontrol_new_t vortex_hwmix_kcontrol __devinitdata = {
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
.name = "Vortex HWMIXING",
.index = 0,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
.private_value = 0,
.info = snd_vortex_hwmix_info,
.get = snd_vortex_hwmix_get,
.put = snd_vortex_hwmix_put
};
static int vortex_dynamic_hwmix_kcontrol(vortex_t * vortex,stream_t *stream,int en)
{
snd_kcontrol_t *kcontrol;
int err;
err=0;
if ( en == 1 ) {
if ((kcontrol = snd_ctl_new1(&vortex_hwmix_kcontrol, vortex)) == NULL)
return -ENOMEM;
kcontrol->private_value =stream->dma;
sprintf(kcontrol->id.name,"Vortex HWMIX %.2d",stream->dma);
kcontrol->info = snd_vortex_hwmix_info;
kcontrol->put = snd_vortex_hwmix_put;
kcontrol->get=snd_vortex_hwmix_get;
if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
return err;
stream->hwmix=kcontrol;
}
else {
err=snd_ctl_remove(vortex->card,stream->hwmix);
};
return err;
}
|