<?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 — Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
		<link>https://gprogs.com/viewtopic.php?id=236</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=236&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Converting Blitz3D calls to BMax for PhysX wrapper..]]></description>
		<lastBuildDate>Wed, 30 May 2007 08:33:27 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=971#p971</link>
			<description><![CDATA[<p>It now looks like it has nothing to do with your code, because the spheres and cubes also act strangly, I think it&#039;s to do with the Irrlicht Rotation function, I tried If pitch &gt; 360 Then pitch = pitch but that didn&#039;t seem to help, the teapot basically screws up when it goes upside down.&nbsp; And the spheres rotate very strangly, you&#039;ll probably find that this will also happen in your Irrlicht.B3D lib.</p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Wed, 30 May 2007 08:33:27 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=971#p971</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=967#p967</link>
			<description><![CDATA[<p>I&#039;m wondering if the teapot is the wrong way around in the collision world? trouble is, my 3D programming is pretty limited so I cant really debug your code.</p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Fri, 25 May 2007 08:15:17 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=967#p967</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=966#p966</link>
			<description><![CDATA[<div class="codebox"><pre><code>Import irrlicht.b3d
Import &quot;PhysX_func.bmx&quot;

&#039;Strict
Global irr:ib3d_engine = _g_ib3d_engine


Local width=640,height=480,depth=16,mode=2,shadows=True


irr.Graphics3D(width,height,depth,mode,shadows)

Global vertnun, facnum

Global plane:PLANE = irr.createPlane(200,200,1,1,0)
ib3d_EntityColor(plane,20,40,200)

Local cam:CAMERA = irr.CreateCamera()
cam.Position(0,10,-60)

Local light:LIGHT = irr.CreateLight(2)
light.Position(-15,30,-150)
ib3d_LightColor(light,200,200,200)
ib3d_AmbientLight(32,32,32)
ib3d_LightRange(light,1000)
ib3d_LightCastShadows(light,1)


&#039; used by camera code
Local mxs#=0
Local mys#=0
Local move#=0.5
MouseXSpeed() &#039; flush
MouseYSpeed() &#039; flush

&#039; used by fps code
Local old_ms=MilliSecs()
Local renders
Local fps

&#039;physic
dir$ = CurrentDir ()
dir = Replace$( dir$,&quot;/&quot;,&quot;\&quot; )
pxRegWriteDriverPath (dir.ToCString())
&#039;Create World
PxCreateWorld(0, &quot;key&quot;)
pxSetGravity(0, -1.5, 0)
pxRegWriteDriverPath (&quot;C:\Program Files\AGEIA Technologies&quot;.ToCString())

planeBody = PxBodyCreateCube(200,1,200, 0)
pxBodySetPosition(planeBody ,0,0,0)

Rem
&#039;Create TriMesh
Local ent:MESH = irr.LoadMesh(&quot;media/TriMesh.b3d&quot;)
ent.Position(0,0,0)
BodyCreateTriMesh(ent)
End Rem
&#039;Create Hull
Local teapot:MESH = irr.LoadMesh(&quot;media/teapot.b3d&quot;)
teapot_body = BodyCreateHull%(teapot)
pxBodySetPosition(teapot_body, 0, 60,0)


&#039;Create Sphere
Local sphere:PRIMITIVE = irr.CreateSphere()
sphere.Position(10,10,0)
ib3d_ScaleEntity(sphere,4,4,4)


&#039;create Cube
Local cube:PRIMITIVE = irr.CreateCube()
ib3d_EntityColor(cube,0,120,0)
cube.Position(-15,10,0)




Global sphereBody = PxBodyCreateSphere(4, 10)
pxBodySetPosition(sphereBody,10, 20,0)

Global cubeBody = PxBodyCreateCube(4,4,4, 10)
pxBodySetPosition(cubeBody,5,30,0)


planeBody = PxBodyCreateCube(25,1,25, 0)
pxBodySetPosition(planeBody ,0,-1,0)


While Not irr.KeyDown(KEY_ESCAPE)        

    If KeyHit(KEY_ENTER) Then DebugStop

    &#039;move camera forwards/backwards/Left/Right with cursor keys
    
    If irr.KeyDown(KEY_UP)=True Then cam.Move(0,0,move#) &#039; move camera forward
    If irr.KeyDown(KEY_DOWN)=True Then cam.Move(0,0,-move#) &#039; move camera back

    If irr.KeyDown(KEY_LEFT)=True Then cam.Move(-move#,0,0) &#039; move camera left
    If irr.KeyDown(KEY_RIGHT)=True Then cam.Move(move#,0,0) &#039; move camera right
    
    &#039;&#039;
    
    teapot.Position(pxBodyGetPositionX(teapot_body),pxBodyGetPositionY(teapot_body),pxBodyGetPositionZ(teapot_body))
    teapot.Rotate(pxBodyGetRotationPitch(teapot_body),pxBodyGetRotationYaw(teapot_body),pxBodyGetRotationRoll(teapot_body))
    
    sphere.Position(pxBodyGetPositionX(sphereBody),pxBodyGetPositionY(sphereBody),pxBodyGetPositionZ(sphereBody))
    sphere.Rotate(pxBodyGetRotationPitch(sphereBody),pxBodyGetRotationYaw(sphereBody),pxBodyGetRotationRoll(sphereBody))
    
    
    cube.Position(pxBodyGetPositionX(cubeBody),pxBodyGetPositionY(cubeBody),pxBodyGetPositionZ(cubeBody))
    cube.Rotate(pxBodyGetRotationPitch(cubeBody),pxBodyGetRotationYaw(cubeBody),pxBodyGetRotationRoll(cubeBody))
    
&#039;    surf:SURFACE = ent.GetSurface(1)
    
    pxRenderPhysic(30, 0)
    irr.RenderWorld()
    renders=renders+1
    
    Flip 

Wend
irr.EndGraphics()
End

Function BodyCreateHull%(mesh:MESH)

    Local nsurf% = mesh.CountSurfaces()
    Local nvert% = 0
    For ns = 0 Until nsurf
        Local surf:SURFACE = mesh.GetSurface(ns)
        nvert = nvert + ib3d_CountVertices(surf)
    Next
         vbank:TBank = CreateBank(nvert*4*3)
    nv = 0
    For ns = 0 Until nsurf
        surf:SURFACE = mesh.GetSurface(ns)
        nvv = ib3d_CountVertices(surf)
        For nvc = 0 To nvv - 1
             PokeFloat vbank,nv*12+0,ib3d_VertexX(surf,nvc)
             PokeFloat vbank,nv*12+4,ib3d_VertexY(surf,nvc)
             PokeFloat vbank,nv*12+8,ib3d_VertexZ(surf,nvc)
            nv = nv+1
        Next
    Next
    
    Local vbp:Byte Ptr
    vbp = vbank.Buf()

    Local bbb%= pxBodyCreateHull(vbp, nvert, 10)
    Return bbb
End Function</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Thu, 24 May 2007 17:44:11 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=966#p966</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=965#p965</link>
			<description><![CDATA[<p>hmmm.&nbsp; i just reliazed im inconsistant in 0 vs 1 based indexes when working with iB3D.&nbsp; gonna have to make a decision on that and work towards consistancy.&nbsp; probably will migrate towards 1 based since that is what B3D is founded on.</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Thu, 24 May 2007 17:34:26 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=965#p965</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=964#p964</link>
			<description><![CDATA[<p>your probably going out of bounds.&nbsp; iB3D is 0 based so your for loop should go from 0 Until nsurf<br /></p><div class="codebox"><pre><code>For ns = 0 Until nsurf</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Thu, 24 May 2007 17:25:41 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=964#p964</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=962#p962</link>
			<description><![CDATA[<p>Fantastic gman thanks, I am however getting a surface meshbuffer is invalid, here<br /></p><div class="codebox"><pre><code>For ns = 1 To nsurf
        Local surf:SURFACE = mesh.GetSurface(ns)
        nvert = nvert + ib3d_CountVertices(surf)    &#039;HERE
    Next</code></pre></div><p>Not sure what that is?</p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Thu, 24 May 2007 16:13:51 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=962#p962</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=960#p960</link>
			<description><![CDATA[<p>and here is counttriangles:<br /></p><div class="codebox"><pre><code>Method getTriangleCount:Int()
    If Not _mbuf Or Not _mbuf.isValid() Then RuntimeError &quot;Surface meshbuffer is invalid&quot;
    Return _mbuf.getIndexCount()/3
EndMethod</code></pre></div><div class="codebox"><pre><code>Function ib3d_CountTriangles:Int(surf:SURFACE)
    If Not surf Then RuntimeError &quot;Surface does not exist&quot;
    Return surf.getTriangleCount()
EndFunction</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Thu, 24 May 2007 14:59:47 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=960#p960</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=959#p959</link>
			<description><![CDATA[<p>havent tested yet...&nbsp; here is the method to add to SURFACE.&nbsp; also, we are getting into a pretty untested area of the core mod...&nbsp; i wouldnt be surprised if some bugs in core cropped up.<br /></p><div class="codebox"><pre><code>Method getTriangleVertex:Int(triangle_index:Int,corner:Short)
    If Not _mbuf Or Not _mbuf.isValid() Then RuntimeError &quot;Surface meshbuffer is invalid&quot;
    Return _mbuf.getIndices().ElementAt((triangle_index * 3) + corner)[0]
EndMethod</code></pre></div><p>and here is the ib3d function:<br /></p><div class="codebox"><pre><code>Function ib3d_TriangleVertex:Int(surf:SURFACE,triangle_index:Int,corner:Short)
    If Not surf Then RuntimeError &quot;Surface does not exist&quot;
    Return surf.getTriangleVertex(triangle_index,corner)
EndFunction</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Thu, 24 May 2007 14:52:01 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=959#p959</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=958#p958</link>
			<description><![CDATA[<p>I hope you dont mind but I&#039;ve been trying to make the Method myself, do you think I am on the right track?<br /></p><div class="codebox"><pre><code>Method TriangleVertex:SURFACE(index:Int,vert_no:Int,corner:Int)
        
        Local mb:SURFACE=IMesh.getMeshBuffer(index)
        
        mb._mbuf=IMesh.getMeshBuffer(index)

        mb_indices[]=mb._mbuf.getIndices()
        
        Local vertex_corner_A = mb_indices[(3*vert_no)]
        Local vertex_corner_B = mb_indices[(3*vert_no) +1]
        Local vertex_corner_c = mb_indices[(3*vert_no) +2]
        
        Return mb
    End Method</code></pre></div><p><img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Thu, 24 May 2007 12:16:17 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=958#p958</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=957#p957</link>
			<description><![CDATA[<p>Excellent!&nbsp; So there are only two functions now needed for the PhysX engine to work.<br />TriangleVertex()<br />CountTriangles()</p><p>Nice work <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Wed, 23 May 2007 15:13:02 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=957#p957</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=951#p951</link>
			<description><![CDATA[<p>hi Slaine.&nbsp; sorry i was a bit vague.&nbsp; i meant that the Irrlicht.B3D mod has many of those converted.&nbsp; for example, a surface in Irrlicht is an instance of imeshbuffer.&nbsp; so GetSurface would look something like:<br /></p><div class="codebox"><pre><code>Function GetSurface:IMeshBuffer(mesh:IMesh,index:Int,frame:Int = 0)
    Local surface:IMeshBuffer
    If IAnimatedMesh(mesh) Then 
        surface=IAnimatedMesh(mesh).getMesh(frame).getMeshBuffer(index)
    ElseIf IMesh(mesh) Then 
        surface=IMesh(mesh).getMeshBuffer(index)
    EndIf
EndFunction</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Tue, 22 May 2007 12:19:49 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=951#p951</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=950#p950</link>
			<description><![CDATA[<p>Thanks gman, I had a brief look at the MiniB3D and it said:<br /></p><div class="codebox"><pre><code>Function GetSurface()
        Return surfcount
End function</code></pre></div><p>So I gave up on that at the time, but now I&#039;ve realised that the surfcount would be in the TEntity, so I&#039;ll take another look today.&nbsp; I&#039;m also going to look at the Irrlicht Newton code, that may have some methods in there.</p><p>When you say it already has some converted, do you mean that the MiniB3D can be mixed with the Irrlicht? Or is that wishfull thinking on my behalf <img src="https://gprogs.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Tue, 22 May 2007 08:35:45 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=950#p950</guid>
		</item>
		<item>
			<title><![CDATA[Re: Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=948#p948</link>
			<description><![CDATA[<p>hi slaine.&nbsp; i dont have the time right now, but i think we can get all these.&nbsp; have you checked out the code to the B3D mod yet?&nbsp; it has most if not all these converted already in some form.&nbsp; i probably wont be able to get you a detailed message for a few days.</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Mon, 21 May 2007 17:13:56 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=948#p948</guid>
		</item>
		<item>
			<title><![CDATA[Converting Blitz3D calls to BMax for PhysX wrapper.]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=943#p943</link>
			<description><![CDATA[<p>I am currently trying to convert the PhysX functions from Blitz3D to BMax in order to handle solid and cloth objects to use with the Irrlicht Graphics engine, I&#039;m not even sure if it&#039;s possible yet, but if it is it would mean a much better visualisation of the PhysX engine in BlitzMax. MiniB3D is a bit dated and limited. Here is my attempt so far:<br /></p><div class="codebox"><pre><code>CountChildren = getChildren()
GetChild = either getLeftChild() or getRightChild(), need help here!
EntityName = getName()
MeshWidth = getScale().X
MeshHeight = getScale().Y
MeshDepth = getScale().Z
EntityPitch = getRotation().X
EntityYaw = getRotation().Y
EntityRoll = getRotation().Z
MoveEntity = setPosition()
EntityX = getPosition().X
EntityY = getPosition().Y
EntityZ = getPosition().Z
RotateEntity = setRotation()
CountSurfaces = getTriangleCount() &#039;Not sure?!&#039;
GetSurface = Dont Know!
CountVertices = getVertexCount()
VertexX = getVertex().X  &#039;I think this is right?&#039;
VertexY = getVertex().Y
VertexZ = getVertex().Z
CountTriangles = Not Sure? this is why I&#039;m not sure about CountSurface()
GetMatElement = Not sure, maybe something like getMatrix()?
VertexCoords = Don&#039;t know.</code></pre></div><p>I think that&#039;s it, once these functions are converted PhysX can be used with the Irrlicht engine in BlitzMax.<br />Any help here will be really appreciated.</p>]]></description>
			<author><![CDATA[null@example.com (Slaine)]]></author>
			<pubDate>Sun, 20 May 2007 19:58:46 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=943#p943</guid>
		</item>
	</channel>
</rss>
