<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=734574413-31072008><FONT face=Arial
size=2>You have the source code for ShapeDrawable; why not simply look at it to
see how it generates the texture coordinates?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=734574413-31072008><FONT face=Arial
size=2> -Paul</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=734574413-31072008></SPAN> </DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
osg-users-bounces@lists.openscenegraph.org
[mailto:osg-users-bounces@lists.openscenegraph.org] <B>On Behalf Of
</B>Franclin Foping<BR><B>Sent:</B> Thursday, July 31, 2008 6:24
AM<BR><B>To:</B> OpenSceneGraph Users<BR><B>Subject:</B> Re: [osg-users]
Converting a Drawable object to a Geometry object<BR></FONT><BR></DIV>
<DIV></DIV>Hi Matthew,<BR> Thanks a lot for your reply. Anyway, I have
posted another similar issue. Maybe my algorithm was wrong. The idea behind
this thing is to get the texture coordinates of a loaded model. A loaded model
is made up several Drawable objects and I thought it could be possible to turn
them into a Geometry object to get texture coordinates but I was wrong!
<BR> Do you have any other algorithm to do it? <BR> Find the
pseudo-code in the previous post.<BR> Thanks for your
help.<BR> Franclin.<BR><BR><B><I>"Fuesz, Matthew"
<matthew.fuesz@lmco.com></I></B> a écrit :
<BLOCKQUOTE class=replbq
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">
<META content="Microsoft Word 11 (filtered medium)" name=Generator><!--[if !mso]>
<STYLE> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:*
{behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </STYLE>
<![endif]--><O:SMARTTAGTYPE name="PostalCode"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="State"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="City"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="place"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="Street"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="address"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"><O:SMARTTAGTYPE
name="PersonName" namespaceuri="urn:schemas-microsoft-com:office:smarttags"><!--[if !mso]>
<STYLE> st1\:*{behavior:url(#default#ieooui) } </STYLE>
<![endif]-->
<STYLE> <!-- /* Font Definitions */ @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in;
margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:blue; text-decoration:underline;} p {mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; font-size:12.0pt; font-family:"Times New Roman";} span.EmailStyle18 {mso-style-type:personal-reply; font-family:Arial; color:navy;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </STYLE>
<DIV class=Section1>
<DIV class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">The problem is that
you are trying to cast a pointer to a base class to a pointer to a subclass.
This would only work if the actual object being pointed to is an instance of
that subclass (or a further subclass of that subclass). Geometry is derived
from Drawable, not the other way around – which seems to be the mistake that
you are making.<O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Please refer to the
inheritance diagrams for osg::Drawable and
osg::Geometry.<O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><O:P></O:P></SPAN></FONT></DIV>
<DIV>
<DIV class=MsoNormal><B><FONT face=Arial color=navy size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Matthew
W. Fuesz<O:P></O:P></SPAN></FONT></B></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">Software Engineer
Asc.<O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">Lockheed Martin
STS</SPAN></FONT><FONT color=navy><SPAN
style="COLOR: navy"><O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><ST1:STREET w:st="on"><ST1:ADDRESS w:st="on"><FONT
face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">1210 Massillon
Road</SPAN></FONT></ST1:ADDRESS></ST1:STREET><FONT face=Arial color=navy
size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial"><O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><ST1:PLACE w:st="on"><ST1:CITY w:st="on"><FONT
face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">Akron</SPAN></FONT></ST1:CITY><FONT
face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">, <ST1:STATE
w:st="on">OH</ST1:STATE> <ST1:POSTALCODE
w:st="on">44315</ST1:POSTALCODE></SPAN></FONT></ST1:PLACE><FONT face=Arial
color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial"><O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=1><SPAN
style="FONT-SIZE: 7.5pt; COLOR: navy; FONT-FAMILY: Arial">matthew.fuesz@lmco.com<O:P></O:P></SPAN></FONT></DIV></DIV>
<DIV class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><O:P></O:P></SPAN></FONT></DIV>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<DIV class=MsoNormal><B><FONT face=Tahoma size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">
osg-users-bounces@lists.openscenegraph.org
[mailto:osg-users-bounces@lists.openscenegraph.org] <B><SPAN
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Franclin
Foping<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Thursday, July
31, 2008 7:17 AM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B>
<ST1:PERSONNAME w:st="on">OpenSceneGraph Users</ST1:PERSONNAME><BR><B><SPAN
style="FONT-WEIGHT: bold">Subject:</SPAN></B> [osg-users] RE : Re: RE : Re:
Converting a Drawable object to a Geometry
object</SPAN></FONT><O:P></O:P></DIV></DIV>
<DIV class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Hi Ulrich,<BR> I don't think you get the trick,
from what you said, the only thing wrong is the ShapeDrawable. <BR> I
will post a new issue in a short while which is not different from this post
and you will see that even without using ShapeDrawable objects, the same
issue still hang around.<BR> Just bear with me.<BR> Thanks for
your help.<BR> Franclin.<BR><BR><B><I><SPAN
style="FONT-WEIGHT: bold; FONT-STYLE: italic">Ulrich Hertlein
<u.hertlein@sandbox.de></SPAN></I></B> a
écrit :<O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Hi Franclin,<BR><BR>> Downcasting from a derived
class to a parent class is possible with the <BR>> dynamic_cast operator.
From what you have written in your mail, it looks like<BR>> the snippet
won't compile at all, I can bet something it will as I tried it a<BR>>
couple of hours ago. Try it yourself and let me know.<BR><BR>The code is
correct and will compile, it's just that the casts won't work as you
<BR>expect.<BR><BR>Okay, let's see:<BR>>> osg::Geode myGeode = new
osg::Geode;<BR>>> myGeode->addDrawable(new osg::ShapeDrawable(new
osg::Box(osg::Vec3(),1,1,1)));<BR>>> osg::Drawable* myDrawable =
myGeode->getDrawable(0);<BR><BR>myDrawable is a Drawable* to a
ShapeDrawable<BR>This is fine since Drawable is a base class of
ShapeDrawable.<BR>(I assume there aren't any other Drawables in myGeode and
the first one is <BR>actually the ShapeDrawable you added.)<BR><BR>>
osg::Geometry* myGeom = myDrawable->asGeometry();<BR><BR>If you take a
look at 'osg::Drawable' you'll see that this actually *always* <BR>returns 0
and ShapeDrawable doesn't override it (Geometry is the only class that
<BR>overrides it).<BR><BR>However, even doing what the comment says (and
what you're doing for 'myGeom2'):<BR><BR>osg::Geometry* geom =
dynamic_cast<OSG:_X003A_GEOMETRY_X002A_>(this)<BR><BR>This cannot succeed
since the *object* is-a ShapeDrawable (even though the <BR>pointer is
Drawable*).<BR><BR>> Of course, downcasting from shapedrawable to
geometry would have not worked<BR>> and even worse would have not
compiled at all.<BR><BR>Agreed. But introducing a Drawable* doesn't help
because it doesn't change the <BR>type of the object the pointer is pointing
to.<BR><BR>ShapeDrawable* shape = new ShapeDrawable(...)<BR>Drawable*
drawable = dynamic_cast<DRAWABLE*>(shape); // OK, is a base
class<BR>Geometry* geom = dynamic_cast<GEOMETRY*>(drawable); // is always
0<BR><BR>I'm probably not explaining this as clearly as possible but try to
think of it <BR>this way: you have a base class 'Vehicle' and two derived
classes 'Car' and <BR>'Plane'. You can create a 'Plane' and have a 'Vehicle'
pointer to it but you <BR>can't cast that pointer to a 'Car'.<BR><BR>Hope
this
helps.<BR><BR>Cheers,<BR>/ulrich<BR><BR>_______________________________________________<BR>osg-users
mailing
list<BR>osg-users@lists.openscenegraph.org<BR>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org<BR><BR><O:P></O:P></GEOMETRY*></DRAWABLE*></OSG:_X003A_GEOMETRY_X002A_></SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><O:P></O:P></SPAN></FONT></DIV>
<DIV><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <O:P></O:P></SPAN></FONT></DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR align=center width="100%" SIZE=1>
</SPAN></FONT></DIV>
<DIV class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Envoyé avec <A
href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http:/us.rd.yahoo.com/evt=52423/*http:/fr.docs.yahoo.com/mail/overview/index.html">Yahoo!
Mail</A>.<BR>Une boite mail plus intelligente.
<O:P></O:P></SPAN></FONT></DIV></DIV>_______________________________________________<BR>osg-users
mailing
list<BR>osg-users@lists.openscenegraph.org<BR>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org<BR></O:SMARTTAGTYPE></O:SMARTTAGTYPE></O:SMARTTAGTYPE></O:SMARTTAGTYPE></O:SMARTTAGTYPE></O:SMARTTAGTYPE></O:SMARTTAGTYPE></BLOCKQUOTE><BR>
<P>
<HR SIZE=1>
Envoyé avec <A
href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html">Yahoo!
Mail</A>.<BR>Une boite mail plus intelligente. </A></BLOCKQUOTE></BODY></HTML>