<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[GMan's Mods & Stuff — How do MeshBuffers work?]]></title>
		<link>https://gprogs.com/viewtopic.php?id=361</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=361&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How do MeshBuffers work?.]]></description>
		<lastBuildDate>Tue, 03 Mar 2009 21:58:22 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1388#p1388</link>
			<description><![CDATA[<p>Here&#039;s a very simple sample of how to use MeshBuffers, just in case somebody else is trying to figure this out.</p><div class="codebox"><pre><code>&#039; basic Irrlich stuff for setting up the engine
    Local device:IrrlichtDevice = ..
    IrrlichtDevice.Create(EDT_OPENGL, _DIMENSION2DI(640, 480), 16, False)
    If Not device Return
    Local Driver:IVideoDriver = device.getVideoDriver()
    Local smgr:ISceneManager = device.getSceneManager()
    smgr.addCameraSceneNode(Null, _VECTOR3DF(0, 5, - 40), _VECTOR3DF(0, 10, 0))

&#039; the vertex array
Local lVert:S3DVertex[] = New S3DVertex[4]
    &#039; setup the array
    lVert[0] = S3DVertexDefault.Create()
    lVert[1] = S3DVertexDefault.Create()
    lVert[2] = S3DVertexDefault.Create()
    lVert[3] = S3DVertexDefault.Create()
    
    &#039; only position, color and normals for each vertex
    &#039; we don&#039;t need texture coordinates this time        
    lVert[0].setPos(_VECTOR3DF(0, 0, 10))
    lVert[0].SetColor(_SCOLOR(255, 0, 255, 255))
    lVert[0].setNormal(_VECTOR3DF(1, 1, 0))
    
    lVert[1].setPos(_VECTOR3DF(10, 0, - 10))
    lVert[1].SetColor(_SCOLOR(255, 255, 0, 255))
    lVert[1].setNormal(_VECTOR3DF(1, 0, 0))
    
    lVert[2].setPos(_VECTOR3DF(0, 20, 0))
    lVert[2].SetColor(_SCOLOR(255, 255, 255, 0))
    lVert[2].setNormal(_VECTOR3DF(0, 1, 1))
    
    lVert[3].setPos(_VECTOR3DF(- 10, 0, - 10))
    lVert[3].SetColor(_SCOLOR(255, 0, 255, 0))
    lVert[3].setNormal(_VECTOR3DF(0, 0, 1))
    
&#039; the index array - creates polygons from our vertex array
Local lInd:Short[] = New Short[9]
    lInd[0] = 1 &#039; equals lVert[1]
    lInd[1] = 2 &#039; equals lVert[2]
    lInd[2] = 0 &#039; equals lVert[0]...
    
    lInd[3] = 3
    lInd[4] = 2
    lInd[5] = 1

    lInd[6] = 0
    lInd[7] = 2
    lInd[8] = 3
      
&#039; the mesh buffer
Local lSMB:SMeshBuffer = SMeshBuffer.Create()
    &#039; make it use our vertex and index buffers
    lSMB.append(lVert, lInd)
    lSMB.recalculateBoundingBox()
    
&#039; the mesh
Local lM:SMesh = SMesh.Create()
    &#039; make it use our mesh buffer
    lM.addMeshBuffer(lSMB)
    lM.recalculateBoundingBox()
    &#039; turn off lightning so we can see the colors
    lM.setMaterialFlag(EMF_LIGHTING, False)
    
&#039; the actual scene that connects the mesh to the scene
Local IMSN:IMeshSceneNode = smgr.addMeshSceneNode(lM)
    &#039; show debug stuff, that white wireframe cube
    IMSN.setDebugDataVisible(True)

Print &quot;sizes of our buffers are:&quot;
    Print lSMB.getIndexCount()
    Print lSMB.getVertexCount()
    Print lM.getMeshBufferCount()
 
&#039; fancy eye candy - make our mesh rotate!
Local anim:ISceneNodeAnimator = ..
    smgr.createRotationAnimator(_VECTOR3DF(0.0, 0.8, 0.0))
    IMSN.addAnimator(anim)

    
&#039; normal sample app logic follows
Local frames:Int=0

While(device.run())
    
    Driver.beginScene(True, True, _SCOLOR(0, 200, 100, 100))

    smgr.drawAll()

    driver.endScene()
    frames:+1
    
    If (frames=100)
        Local str:String = &quot;Testi [&quot;
        str :+ driver.getName()
        str :+ &quot;] FPS: &quot;
        str :+ driver.getFPS()

        device.setWindowCaption(str)
        frames=0
    EndIf
Wend

device.drop()</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (irrigator)]]></author>
			<pubDate>Tue, 03 Mar 2009 21:58:22 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1388#p1388</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1387#p1387</link>
			<description><![CDATA[<p>S3DVertex has no create method, but there&#039;s a S3DVertexDefault which a create method that returns S3DVertex. Those other Sxxxx structures had a create() method of their own. Now the counts return something! Yippee! Nothing on screen yet, must be the data on my buffers. But in theory it&#039;s already working.</p><p>Thanks a ton for quick and good replies! Very good support! <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (irrigator)]]></author>
			<pubDate>Tue, 03 Mar 2009 20:13:42 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1387#p1387</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1386#p1386</link>
			<description><![CDATA[<p>greetings <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; try changing:<br /></p><div class="codebox"><pre><code>New S3DVertex</code></pre></div><p>to<br /></p><div class="codebox"><pre><code>S3DVertex.create()</code></pre></div><p>since all types in the irrlicht mod are wrappers for C++ objects, for types that can be created on their own (ie S3DVertex) there is a .create() method instead of New.</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Tue, 03 Mar 2009 17:36:11 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1386#p1386</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1384#p1384</link>
			<description><![CDATA[<p>Still no work. I am new to Irrlich so I guess I just don&#039;t know how to create those structures or interfaces properly.</p><p>Here is my failing code:</p><br /><div class="codebox"><pre><code>SuperStrict
Framework irrlicht.core
Local device:IrrlichtDevice = IrrlichtDevice.create(EDT_DIRECT3D9, _DIMENSION2DI(640, 480), 16, False, False, False, Null)
Local driver:IVideoDriver = device.getVideoDriver()
Local smgr:ISceneManager = device.getSceneManager()
smgr.addCameraSceneNode(Null, _VECTOR3DF(0,10,-10), _VECTOR3DF(0,5,0))


Local ver:S3DVertex[] = New S3DVertex[3]
    Local uv:Vector2df = New Vector2df
        uv.set(0,0)
    ver[0] = New S3DVertex
    ver[0].setPos(_VECTOR3DF(0,5,10))
    ver[0].SetColor(_SCOLOR(255,255,0,0))
    ver[0].setNormal(_VECTOR3DF(0,1,0))
    ver[0].setTCoords(uv)
    
    ver[1] = New S3DVertex
    ver[1].setPos(_VECTOR3DF(10,5,10))
    ver[1].SetColor(_SCOLOR(255,255,0,255))
    ver[1].setNormal(_VECTOR3DF(0,1,0))
    ver[1].setTCoords(uv)
    
    ver[2] = New S3DVertex
    ver[2].setPos(_VECTOR3DF(10,0,0))
    ver[2].SetColor(_SCOLOR(255,255,0,0))
    ver[2].setNormal(_VECTOR3DF(0,1,0))
    ver[2].setTCoords(uv)

Local ind:Short[] = New Short[3]
    ind[0] = 0
    ind[1] = 1
    ind[2] = 2

Local mb:SMeshBuffer = New SMeshBuffer
    mb.append(ver,ind)
    mb.recalculateBoundingBox()

print mb.getIndexCount()
Print mb.getVertexCount()

Local me:SMesh = New SMesh
    me.addMeshBuffer(mb)

Local msc:IMeshSceneNode = smgr.addMeshSceneNode(me)


While(device.run())
    driver.beginScene(True, True, _SCOLOR(255,100,100,100))
    smgr.drawAll()
    driver.endScene()
Wend
device.drop()</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (irrigator)]]></author>
			<pubDate>Tue, 03 Mar 2009 16:11:28 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1384#p1384</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1383#p1383</link>
			<description><![CDATA[<p>Woohoo, what a quick reply! <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I&#039;ll test it later today when I get home.</p><p>Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (irrigator)]]></author>
			<pubDate>Tue, 03 Mar 2009 12:40:08 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1383#p1383</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1382#p1382</link>
			<description><![CDATA[<p>greetings <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; i think i found the problem with append.&nbsp; please download the new mod and try your code.</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Tue, 03 Mar 2009 02:10:15 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1382#p1382</guid>
		</item>
		<item>
			<title><![CDATA[Re: How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1380#p1380</link>
			<description><![CDATA[<p>greetings <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; sounds like you are approaching it correctly.&nbsp; do you have a quick sample?</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Tue, 03 Mar 2009 01:32:28 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1380#p1380</guid>
		</item>
		<item>
			<title><![CDATA[How do MeshBuffers work?]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1379#p1379</link>
			<description><![CDATA[<p>Hi,</p><p>First of all thanks for your module!</p><p>I am trying to make meshes with code and more specifically by using MeshBuffers. I am trying to do it like this:</p><p>- Make an S3DVertex array and fill with vertices<br />- Make an short array and fill with indices<br />- Make a new sMeshBuffer and .append vertices and indices and call RecalculateBoundingBox<br />- Make a new sMesh and .addMeshBuffer(my sMeshBuffer)<br />- Make a new iMeshSceneNode with smgr.addMeshSceneNode(my sMesh)</p><p>But getIndexCount() and getVertexCount() on sMeshBuffer return zero, like does getMeshBufferCount() on sMesh. Nothing on screen.</p><p>I also tried with the interface versions (IMesh.getMeshBuffer(0).appendFromOther(my IMeshBuffer)) but no luck.</p><p>I also tried with fillIndicesPtr and fillS3DVertexVerticesPtrs but still no luck.</p><p>How should I do it?</p>]]></description>
			<author><![CDATA[null@example.com (irrigator)]]></author>
			<pubDate>Mon, 02 Mar 2009 22:35:53 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1379#p1379</guid>
		</item>
	</channel>
</rss>
