0
0

<solved> [url=http://www.fmod.org/forum/viewtopic.php?p=33881#33881:5sqsvt50]See a few posts down[/url:5sqsvt50]

Does anyone have an example on how to load up a cube into a geometry object that does not involve loading it from a bin file?

I need to translate simplied information passed to my api into a cube and I have no clue how a cube is set up in FMOD… There is no specific information in the help on the subject and the geometry example loads it from file so it give little clue on how to set it up. I’m sure it’s obvioulsy simple… But the simplicity excapes me at the moment.

My api recieves the cube data as
x,y,z (the word coords of the origins of the cube)
xs,ys,zs (the word coords of the start of the cube)
xe,ye,ze (the word coords of the end of the cube)

0,0,0
-1,-1,-1
1,1,1
would give a 2x2x2 cube, centered on 0,0,0

10,10,10
5,5,5
15,15,15
would give a 10x10x10 cube, centered on 10,10,10

10,5,5
5,5,5
15,15,15
would give a 10x10x10 cube where x is centered at 10 and y and z are at the starting edge of the cube.

I do hope a kind soul will lend a hand.

• You must to post comments
0
0

OK ben, I added it in…

I think I found a bad vertex on one of the zplanes.

[code:3ahijc62]
export double FMODBlockerAdd(double x, double y, double z, double xs, double ys, double zs, double xe, double ye, double ze)
{
if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
if(geometry == NULL) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
FMOD_GEOMETRY *g = NULL;
if(curgeometry >= maxgeometry) {FMODASSERT(FMOD_ERR_MEMORY);}
FMODASSERT(FMOD_System_CreateGeometry(mainsystem, 6, 4, &g));
*(geometry + curgeometry) = (DWORD)g;
curgeometry++;

//Hi,
//For a 2x2x2 cube centred on (0, 0, 0), I'd do something like:
//FMOD_VECTOR cube[24] = //6 faces times 4 verts = 24
//{
//    { 1, -1, -1}, { 1, -1,  1}, { 1,  1,  1}, { 1,  1, -1}, //+X face
//    {-1, -1, -1}, {-1, -1,  1}, {-1,  1,  1}, {-1,  1, -1}, //-X face
//    {-1,  1, -1}, { 1,  1, -1}, { 1,  1,  1}, {-1,  1,  1}, //+Y face
//    {-1, -1, -1}, { 1, -1, -1}, { 1, -1,  1}, {-1, -1,  1}, //-Y face
//    {-1, -1,  1}, {-1,  1,  1}, { 1,  1,  1}, { 1,  -1 /*1*/, 1 /*-1*/}, //+Z face
//    //{-1, -1,  1}, {-1,  1,  1}, { 1,  1,  1}, { 1,  1, -1}, //+Z face
//    {-1, -1, -1}, {-1,  1, -1}, { 1,  1, -1}, { 1, -1, -1}, //-Z face
//};

float dxs,dxe,dys,dye,dzs,dze;
dxs = xs-x;
dxe = xe-x;
dys = ys-y;
dye = ye-y;
dzs = zs-z;
dze = ze-z;

FMOD_VECTOR cube[24] = //6 faces times 4 verts = 24
{
{ dxe, dys, dzs}, { dxe, dys,  dze}, { dxe,  dye,  dze}, { dxe,  dye, dzs}, //+X face
{dxs, dys, dzs}, {dxs, dys,  dze}, {dxs,  dye,  dze}, {dxs,  dye, dzs}, //-X face
{dxs,  dye, dzs}, { dxe,  dye, dzs}, { dxe,  dye,  dze}, {dxs,  dye,  dze}, //+Y face
{dxs, dys, dzs}, { dxe, dys, dzs}, { dxe, dys,  dze}, {dxs, dys,  dze}, //-Y face
{dxs, dys,  dze}, {dxs,  dye,  dze}, { dxe,  dye,  dze}, { dxe,  dys, dze}, //+Z face
{dxs, dys, dzs}, {dxs,  dye, dzs}, { dxe,  dye, dzs}, { dxe, dys, dzs}, //-Z face
};

int pi = 0;
for(int i = 0; i &lt; 5; ++i)
{
//int i = 5;
FMOD_Geometry_AddPolygon(g, 1, 1, 1, 4, cube +(4 * i), &amp;pi); // pointer arithmetic to get face i
}

FMOD_VECTOR v = {x,y,z};
FMODASSERT(FMOD_Geometry_SetPosition(g, &amp;v));
return (double) (DWORD)g;

}
[/code:3ahijc62]

As you can see, I converted my simplified params (discussed in prior post) to the vertices.

It’s almost working… I can almost taste, I mean hear it…

Dealing with sounds, it’s difficult to tell if it’s working or not but my test bench allows moving the sound with the mouse so I can tell you it’s only working a little.

On the y axis, it’s not working at all. On the x axis, the blocking seems to only work at the right edge of the cube. That is, if I move the sound in the cube from the right side of the cube, and the listener is on the left of the cube, the sound starts… It should, in theory, not play when in the cube and beyond.

I have not tested the zaxis (nor do I plan to)

I think its related to my listener settings wich is
FMOD_VECTOR forward = { 0.0f, 0.0f, -1.0f };
FMOD_VECTOR up = { 0.0f, -1.0f, 0.0f };
or
FMOD_VECTOR forward = { 0.0f, 0.0f, -1.0f };
FMOD_VECTOR up = { 0.0f, 0.0f, 0.0f };

Depending on the situation….

Wich I have to match with the listenner??? There is only 27 possible settings I can try for matching the cube orientation… I assume I have to… the documentation only hints you should unless it’s a copy and paste error in the doc.

[quote:3ahijc62]
Geometry::getRotation
Retrieves the orientation of the geometry object.

Syntax

FMOD_RESULT Geometry::getRotation(
FMOD_VECTOR * forward,
FMOD_VECTOR * up
);

Parameters

forward

[u:3ahijc62]Address of a variable that receives the forwards orientation of the listener. Specify 0 or NULL to ignore. [/u:3ahijc62]

up

[u:3ahijc62]Address of a variable that receives the upwards orientation of the listener. Specify 0 or NULL to ignore. [/u:3ahijc62]

Return Values

If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.

Remarks

See remarks in System::set3DListenerAttributes for more description on forward and up vectors.

Platforms Supported

Win32, Win64, Linux, Linux64, Macintosh, Xbox, Xbox360, PlayStation 2, GameCube, PlayStation Portable, PlayStation 3, Wii

Geometry::setRotation
System::set3DListenerAttributes
FMOD_VECTOR

[/quote:3ahijc62]

I already tried setting the rotation to the lsitener settings… Some changes but not the desired effect.

Any help is welcomed.

• You must to post comments
0
0

IT WORKS!

I woke up this morning with a fresh head

[code:2ai2qn00]
if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
if(geometry == NULL) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
FMOD_GEOMETRY *g = NULL;
if(curgeometry >= maxgeometry) {FMODASSERT(FMOD_ERR_MEMORY);}
FMODASSERT(FMOD_System_CreateGeometry(mainsystem, 6, 24, &g));
*(geometry + curgeometry) = (DWORD)g;
curgeometry++;

float dxs,dxe,dys,dye,dzs,dze;
dxs = xs-x;
dxe = xe-x;
dys = ys-y;
dye = ye-y;
dzs = zs-z;
dze = ze-z;

FMOD_VECTOR cube[24] = //6 faces times 4 verts = 24
{
{ dxe, dys, dzs}, { dxe, dys,  dze}, { dxe,  dye,  dze}, { dxe,  dye, dzs}, //+X face
{dxs, dys, dzs}, {dxs, dys,  dze}, {dxs,  dye,  dze}, {dxs,  dye, dzs}, //-X face
{dxs,  dye, dzs}, { dxe,  dye, dzs}, { dxe,  dye,  dze}, {dxs,  dye,  dze}, //+Y face
{dxs, dys, dzs}, { dxe, dys, dzs}, { dxe, dys,  dze}, {dxs, dys,  dze}, //-Y face
{dxs, dys,  dze}, {dxs,  dye,  dze}, { dxe,  dye,  dze}, { dxe,  dys, dze}, //+Z face
{dxs, dys, dzs}, {dxs,  dye, dzs}, { dxe,  dye, dzs}, { dxe, dys, dzs}, //-Z face
};

int pi = 0;
for(int i = 0; i &lt; 5; ++i)
{
FMOD_Geometry_AddPolygon(g, 1, 1, 1, 4, &amp;cube [4 * i], &amp;pi);
}

FMOD_VECTOR v = {x,y,z};
FMODASSERT(FMOD_Geometry_SetPosition(g, &amp;v));
return (double) (DWORD)g;

[/code:2ai2qn00]

FMODASSERT(FMOD_System_CreateGeometry(mainsystem, 6, 4, &g));
was the problem… It was 24 originally but I changed it at one point while trying to figure why the addpoly was returning bad param error.
And I changed
FMOD_Geometry_AddPolygon(g, 1, 1, 1, 4, cube +(4 * i), &pi);
for good measure.

Looks like the rotation is unrelated, though I would like to know if the doc is wrong.

• You must to post comments
0
0

Hi,
Good to see you got it working. You’re right, there was an error in the documentation for Geometry::setRotation – it shouldn’t have been talking about listeners at all. This is now fixed.

Thanks,
Ben

• You must to post comments
0
0

This is how we do it:

[code:bxhovcig]
polygons.resize(6, IGeometry::SDesc::CPolygon());
CreatePlaneXZ(polygons[0], x0, z0, x1, z1, y0);
CreatePlaneXY(polygons[1], x0, y0, x1, y1, z0);
CreatePlaneYZ(polygons[2], y0, z0, y1, z1, x0);
CreatePlaneXZ(polygons[3], x1, z1, x0, z0, y1);
CreatePlaneXY(polygons[4], x1, y1, x0, y0, z1);
CreatePlaneYZ(polygons[5], y1, z1, y0, z0, x1);
[/code:bxhovcig]

where CreatePlaneAB does: (C is the dim of the plane)

[code:bxhovcig]
polygon.resize(4, CVector3f());
polygon[0] = CVector3f(C, A0, B0);
polygon[1] = CVector3f(C, A0, B1);
polygon[2] = CVector3f(C, A1, B1);
polygon[3] = CVector3f(C, A1, B0);
[/code:bxhovcig]

With this container of geometric data I create the FMOD geometry by using FMOD::Geometry::addPolygon for each polygon.

• You must to post comments
0
0

[quote="ben":hso51k9p]Hi,
Good to see you got it working. You’re right, there was an error in the documentation for Geometry::setRotation – it shouldn’t have been talking about listeners at all. This is now fixed.

Thanks,
Ben[/quote:hso51k9p]

Coolcool

Thanks to you, my dll is 99.99% complete! Now all I need to fix is the multi-channel playing the same unstreamed sound bug.

Regards.
icuurd12b42.

• You must to post comments
0
0

[quote="Frohagen":jqczn7ds]This is how we do it:

[code:jqczn7ds]
polygons.resize(6, IGeometry::SDesc::CPolygon());
CreatePlaneXZ(polygons[0], x0, z0, x1, z1, y0);
CreatePlaneXY(polygons[1], x0, y0, x1, y1, z0);
CreatePlaneYZ(polygons[2], y0, z0, y1, z1, x0);
CreatePlaneXZ(polygons[3], x1, z1, x0, z0, y1);
CreatePlaneXY(polygons[4], x1, y1, x0, y0, z1);
CreatePlaneYZ(polygons[5], y1, z1, y0, z0, x1);
[/code:jqczn7ds]

where CreatePlaneAB does: (C is the dim of the plane)

[code:jqczn7ds]
polygon.resize(4, CVector3f());
polygon[0] = CVector3f(C, A0, B0);
polygon[1] = CVector3f(C, A0, B1);
polygon[2] = CVector3f(C, A1, B1);
polygon[3] = CVector3f(C, A1, B0);
[/code:jqczn7ds]

With this container of geometric data I create the FMOD geometry by using FMOD::Geometry::addPolygon for each polygon.[/quote:jqczn7ds]

Thanks for the help though I’m looking for a straight C example…
I dont have the classes you are using.

• You must to post comments
0
0

Well, it is rather straight since I don’t think I need to describe how to set up the vector, polygon and stl classes

• You must to post comments
0
0

[quote="Frohagen":3ioi8c9s]Well, it is rather straight since I don’t think I need to describe how to set up the vector, polygon and stl classes :)[/quote:3ioi8c9s]

Well, it’s not… Resurface from the depth of your knowledge and enlighten me a little.

FMOD_RESULT F_API FMOD_Geometry_AddPolygon (FMOD_GEOMETRY *geometry, float directocclusion, float reverbocclusion, FMOD_BOOL doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex);

I’m thinking

[code:3ioi8c9s]
FMOD_VECTOR cube[] =
{
{0,1,0},
{1,0,1},
{1,1,0},
{and the list goes on.... This I what I have no clue on setting up}
};
int pi = 0;
FMOD_Geometry_AddPolygon (geometry, 1, 1, 1, <noclue>, cube, &pi);
[/code:3ioi8c9s]

It’s a simple matter of setting up a cube (that is compatible with FMOD), really.

It sounds rather idiotic that I don’t know but I have no 3D training and, believe it or not, the scarse web resources I found on the subject, though very descriptive, are more peer to peer documents… Useless as learning documents.

• You must to post comments
0
0

Hi,
For a 2x2x2 cube centred on (0, 0, 0), I’d do something like:

[code:3neg5a10]
FMOD_VECTOR cube[24] = //6 faces times 4 verts = 24
{
{ 1, -1, -1}, { 1, -1, 1}, { 1, 1, 1}, { 1, 1, -1}, //+X face
{-1, -1, -1}, {-1, -1, 1}, {-1, 1, 1}, {-1, 1, -1}, //-X face
{-1, 1, -1}, { 1, 1, -1}, { 1, 1, 1}, {-1, 1, 1}, //+Y face
{-1, -1, -1}, { 1, -1, -1}, { 1, -1, 1}, {-1, -1, 1}, //-Y face
{-1, -1, 1}, {-1, 1, 1}, { 1, 1, 1}, { 1, 1, -1}, //+Z face
{-1, -1, -1}, {-1, 1, -1}, { 1, 1, -1}, { 1,- 1, -1}, //-Z face
};

int pi = 0;
for(int i = 0; i < 6; ++i)
{
FMOD_Geometry_AddPolygon(geometry, 1, 1, 1, 4, cube + (4 * i), &pi); // pointer arithmetic to get face i
}
[/code:3neg5a10]

Note that this is just off the top of my head – I haven’t actually tested it. Maybe you can let me know if it works

Ben

• You must to post comments
0
0

[quote="ben":1zdazccv]Hi,
For a 2x2x2 cube centred on (0, 0, 0), I’d do something like:

[code:1zdazccv]
FMOD_VECTOR cube[24] = //6 faces times 4 verts = 24
{
{ 1, -1, -1}, { 1, -1, 1}, { 1, 1, 1}, { 1, 1, -1}, //+X face
{-1, -1, -1}, {-1, -1, 1}, {-1, 1, 1}, {-1, 1, -1}, //-X face
{-1, 1, -1}, { 1, 1, -1}, { 1, 1, 1}, {-1, 1, 1}, //+Y face
{-1, -1, -1}, { 1, -1, -1}, { 1, -1, 1}, {-1, -1, 1}, //-Y face
{-1, -1, 1}, {-1, 1, 1}, { 1, 1, 1}, { 1, 1, -1}, //+Z face
{-1, -1, -1}, {-1, 1, -1}, { 1, 1, -1}, { 1,- 1, -1}, //-Z face
};

int pi = 0;
for(int i = 0; i < 6; ++i)
{
FMOD_Geometry_AddPolygon(geometry, 1, 1, 1, 4, cube + (4 * i), &pi); // pointer arithmetic to get face i
}
[/code:1zdazccv]

Note that this is just off the top of my head – I haven’t actually tested it. Maybe you can let me know if it works

Ben[/quote:1zdazccv]

Thanks, I’ll give it a shot.
Though, can’t I simply combine all the vertices into one 3d Poligon by saying
FMOD_Geometry_AddPolygon(geometry, 1, 1, 1, 24, cube, &pi);
??

Because I need to move the set in the 3d world once I’ve added it in with
FMOD_Geometry_SetPosition(geometry, positionvectors);

I guess I can keep track of the 6 polygons for each cube…

Thanks… Just in time too!

• You must to post comments
0
0

Hi,
A polygon is a 2D plane, so no, you can’t just do one AddPolygon call – you have to create one polygon for each face.

All the polygons created by my example will be attached to the same geometry object, so you should be able to move the entire cube with a single SetPosition call (which will set the centre of the cube).

HTH,
Ben

• You must to post comments
0
0

[quote="ben":1zlu82yj]Hi,
A polygon is a 2D plane, so no, you can’t just do one AddPolygon call – you have to create one polygon for each face.

All the polygons created by my example will be attached to the same geometry object, so you should be able to move the entire cube with a single SetPosition call (which will set the centre of the cube).

HTH,
Ben[/quote:1zlu82yj]

Thanks… I’ll get on it as soon as I solve my other issue…

• You must to post comments
Showing 12 results