Re: [osg-users] exception with cullVisitor-traverse(*_camera) after manually creating a geode

2012-03-08 Thread Renato Oliveira
Hi,

i finaly solved the problem. I kind of feel stupid with this issue. I was 
creating the my mesh class with out allocating memory for it.

Mesh mesh; //wrong

Mesh* mesh = new Mesh; //right

thanks again for the advices

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46111#46111





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] exception with cullVisitor-traverse(*_camera) after manually creating a geode

2012-03-08 Thread Renato Oliveira
Hi,

awsome, thanks again for the advice. will do that from now on HAHA

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46113#46113





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] exception with cullVisitor-traverse(*_camera) after manually creating a geode

2012-03-07 Thread Renato Oliveira
Hi,

I am having a problem in which i get an exception when OSG is trying to render 
my manually created geode. The crash happens in sceneView.cpp when calling 
cullVisitor-traverse(*_camera). Does anyone have any ideias what might be?

... 

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46094#46094





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] exception with cullVisitor-traverse(*_camera) after manually creating a geode

2012-03-07 Thread Renato Oliveira
Hi,

sure i understand, sorry about that. i just wanted to know if someone already 
experienced the same issue before. what i am actually doing is i created a obj 
loader similar to the obj loader plugin from openscenegraph (the mojoraity of 
the code of copied directly just for test). once i have loaded the file, i 
create a mesh using all the information loaded and set the vertices, normals, 
texture cordinates, and primitive set. no problem there. than i attache my mesh 
to the a viewer like anyother example of the osg and run. like i said before, 
the crash happens when the cullvisitor's traverse function gets called when its 
building the sceneview.

i have attached my mesh generator file to the post.

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46096#46096



// Alice - (C) Copyright 1993 Michel Gysen
#pragma hdrfile owlsys.csm
#pragma hdrstop

#include Mesh.h
//--
Mesh::Mesh():geometry(NULL),vertices(NULL),normals(NULL),texture(NULL),
nullValue(0xf000),currentElementList(0)
{
  geometry = new osg::Geometry;
}
//--
Mesh::~Mesh()
{
  if(!geometry-empty()) geometry-unref();
}
//--
PCChar Mesh::SetPath(PCChar pathIn,PCChar fileName,PCChar extName)
 {
  Char dev[4],dir[256],name[64],ext[64];
  *dev = *dir = *name = *ext = 0;
  if(fileName) _splitpath(fileName,dev,dir,name,ext);
  _splitpath(pathIn,(*dev ? 0 : dev),(*dir ? 0 : dir),(*name ? 0 : name),(*ext 
? 0 : ext));
  if(!extName) extName  = ext;
  _makepath(filePath,dev,dir,name,extName);
  return filePath;
 }
//--
Int Mesh::addVertices(PCReal arr)
{
  if(arr)
  {
Real x = arr[0];
Real y = arr[1];
Real z = arr[2];

vertices.push_back(osg::Vec3(x,y,z));

return 0;
  }
  else
return -1;
}
//--
Int Mesh::addNormals(PCReal arr)
{
  if(arr)
  {
Real x = arr[0];
Real y = arr[1];
Real z = arr[2];

normals.push_back(osg::Vec3(x,y,z));

return 0;
  }
  else
return -1;
}
//--
Int Mesh::addTexture(PCReal arr)
{
  if(arr)
  {
Real x = arr[0];
Real y = arr[1];

texture.push_back(osg::Vec2(x,y));

return 0;
  }
  else
return -1;
}
//--
/*
 * will add the primitive set beased on the element list data
 */
Int Mesh::addFace(PLong iworkSpace,Int nf)
{
  if(iworkSpace)
  {
//Elements array that will store our faces indexes
Element* element = new Element(Element::POLYGON);

//loop the number of entrires (v/vt/vn) in a line and
//push the indexes into the element table.
for(Int i = 0; i  nf; i++)
{
  element-vertexIndices.push_back(remapVertexIndex(iworkSpace[3*i]));
  element-texCoordIndices.push_back(remapTexCoordIndex(iworkSpace[3*i+1]));
  element-normalIndices.push_back(remapNormalIndex(iworkSpace[3*i+2]));
}

if (!element-normalIndices.empty()  element-normalIndices.size() != 
element-vertexIndices.size())
  element-normalIndices.clear();
if (!element-texCoordIndices.empty()  element-texCoordIndices.size() != 
element-vertexIndices.size())
  element-texCoordIndices.clear();
if (!element-vertexIndices.empty())
{
  Element::CoordinateCombination coordateCombination = 
element-getCoordinateCombination();
  if (coordateCombination!=currentElementState.coordinateCombination)
  {
currentElementState.coordinateCombination = coordateCombination;
currentElementList = 0; // reset the element list to force a recompute 
of which ElementList to use
  }
  if (!currentElementList)
  {
currentElementList =  (elementStateMap[currentElementState]);
  }
  //push the elements previoulsy set to the main element list
  currentElementList-push_back(element);
}
else
{
  // empty element, don't both adding, just unref to delete it.
  element-unref();
}
//push the elements previoulsy set to the main element list
return 0;
  }
  else
return -1;
}
//--
/*
 * Convert the element list indices into primitive sets to build the faces
 * All of the code was copied from the openscenegraph obj plugin
 */
Int Mesh::convertElementListToGeometry(ElementList elem)
{
  UInt numVertexIndices = 0;
  UInt numNormalIndices = 0;
  UInt numTexCoordIndices = 0;

  UInt numPointElements = 0;
  UInt numPolylineElements = 0;
  UInt 

[osg-users] indices

2012-03-01 Thread Renato Oliveira
Hi,

Sorry for this question, but i want to know exaclty what is an indice and what 
is used for. the way that i understood is basicly an ID number to the vertexes? 
i am a completly noob in 3D graphics programming and some terms i quite dont 
understand yet.


Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45936#45936





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] indices

2012-03-01 Thread Renato Oliveira
Hi,

Wow, thanks guys for the quick and helpfull response. these information will 
definitely help. I am kind of lost with 3D but i will get there.

Thanks again.

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45942#45942





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] getFirstIntersection() causes an excpetion

2012-03-01 Thread Renato Oliveira
Hi,

Forget about everything writing above. This is a problem due to the code 
generation of openscenegraph not mathching the applicaiton code generation for 
example, openscenegraph was generated as multi-threaded debug DLL (/MDd) while 
my code was being generated as Multi-threaded debug (/MT). Even though 
opensencegraph was built as static, the code generation was set to use the 
Dynamic C runtime while my code was using the Static C runtime. At first, this 
did not cause any issue since the functions has the same name, the problem is 
when you call new or delete. If i call new to create an openscenegraph object 
from my code which is using the static runtime lib (LIBCMTD.lib) and then 
destroyed that same object which will call the destructor whitin openscenegraph 
which is using the Dynamic C runtime (MSVCRTD.lib), this  
would cause the exception because the new and delete will be 
allocation/deallocating from diffrents memory block. so you would allocate 
memmory for a geode for exemple and endup deleting a unkown block of memory.

sorry if i not clear enough

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45944#45944





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] more than 1 object in the same viewer

2012-02-28 Thread Renato Oliveira
Hi,

I am wondering if i can load 2 object files and have them share the same scene 
or viewer as a whole object? i was thinking the same way as the geode work when 
you add a Drawable (addDrawable())

if it is possible? can someone can give me an exemple? much appreciated.

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45845#45845





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] more than 1 object in the same viewer

2012-02-28 Thread Renato Oliveira
i guess i really dont know how to use it. i very new to openscenegraph and i 
was just able to learn how to load a single obj file for 1 viewer only. i also 
saw that that i can split the viewer into views so that the objects can have 
diffrent cameras but my real goal is just to have shapes loaded that will be 1 
whole object att the end.

do you have any exemples or hints in how to use the grope with childrens?

i have a root node and i add the loaded objects to it, but only the last object 
add will display.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45847#45847





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] more than 1 object in the same viewer

2012-02-28 Thread Renato Oliveira
Got it working after setting the scales. but possitioning and scalling properly 
will be a challenge.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45851#45851





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Missing ot12-OpenThreadsd.dll when building staticlly

2012-02-22 Thread Renato Oliveira
Hi,

I am having an issue when building my code staticlly. when the applicaiton 
runs, i get the error that the ot12-OpenThreadsd.dll is missing. I am using 
openscenegraph staticlly and also osgNV and osgNVPhysx staticlly. using only 
openscenegraph static libs does not give me any problem in my code ( i followed 
the osgstaticviewer example ), however, including osgNV and osgNVPhysx, which 
is also build staticlly, complains about the DLL missing.

Is anyone familiar with osgNV and is there a setting that i am missing?

Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45683#45683





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] getFirstIntersection() causes an excpetion

2012-02-20 Thread Renato Oliveira
Hi,
I am having a anyoing issue that i cannot figure out. Ive seen some post about 
similar issue but with no defenit fix. I writing a picker code to know the 
vertices of my object when i click in it following faitfully the example in 
picking in the samples, however, getFirstIntersection() is causing and 
exception when it returns from the pick function. the call stack shows that is 
trying to delete a vector in the ~Intersection() destructor.

I have both OSG 3.0.1 and OSG 2.8.5 sorce and have build them in VS(2008). Ive 
seen coments that this could be an issue related to code generation 
Debug/Release not matching the OSG generation which is usually MT debug DLL. 
Ive tried every generation on my code and on OSG itself (matching them of 
course) but they still gives the issue. the strange thing is that the samples 
does not have this problem of exception. Could it be a Compiler setting?

sorry for any misunderstanding. This is the first time im posting in this forum.

i would appreciate any help


Code:

 Void PickHandler::pick(const osgGA::GUIEventAdapter ea, osgViewer::Viewer* 
viewer)
 {
   osg::Node* scene = viewer-getSceneData();
   if(!scene) return;
   
   osg::Node* node = 0;
   osg::Group* parent = 0;

   //Our ray that
   osgUtil::LineSegmentIntersector* picker;

   // use window coordinates
   // remap the mouse x,y into viewport coordinates.
   osg::Viewport* viewport = viewer-getCamera()-getViewport();
   Real mx = viewport-x() + 
(Int)((Real)viewport-width()*(ea.getXnormalized()*0.5f+0.5f));
   Real my = viewport-y() + 
(Int)((Real)viewport-height()*(ea.getYnormalized()*0.5f+0.5f));
   picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, 
mx, my);

   //InteresectionVisitor is used to testing for intersections with the scene?
   osgUtil::IntersectionVisitor iv(picker);

   viewer-getCamera()-accept(iv);

   if(picker-containsIntersections())
   {
 Real x,y,z;
 [b]osgUtil::LineSegmentIntersector::Intersection intersection = 
picker-getFirstIntersection();[/b]
 x = intersection.getLocalIntersectPoint().x();
 y = intersection.getLocalIntersectPoint().y();
 z = intersection.getLocalIntersectPoint().z();

osg::NodePath nodePath = intersection.nodePath;
node = (nodePath.size()=1)?nodePath[nodePath.size()-1]:0;
parent = 
(nodePath.size()=2)?dynamic_castosg::Group*(nodePath[nodePath.size()-2]):0;

 char text[256];
 sprintf(text,intersection- x:%f y:%f z:%f\n Hits: %s, nodePath size: 
%d,x,y,z,node-className(),nodePath.size());
 ::MessageBox(NULL,text,,MB_OK);
   }
 }




Thank you!

Cheers,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=4#4





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] getFirstIntersection() causes an excpetion

2012-02-20 Thread Renato Oliveira
as i was looking when this error happen the _Myfirstiter is NULL when its going 
through the ~Interserction() destruction. could that be a possible cause of the 
issue? i mean trying to delete a null pointer?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45608#45608





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] getFirstIntersection() causes an excpetion

2012-02-20 Thread Renato Oliveira
one other thing also i noticed, my code is calling the ~Intersection() 
destructor while osg example (osgkeyboardmouse) is not when exiting the pick 
function()

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45609#45609





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org