<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13350" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2022-01-07T21:06:04+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13350</id>

		<entry>
		<author><name><![CDATA[Alastar]]></name></author>
		<updated>2022-01-07T21:06:04+00:00</updated>

		<published>2022-01-07T21:06:04+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43793#p43793</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43793#p43793"/>
		<title type="html"><![CDATA[Re: bvhTriangleMesh glitch]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43793#p43793"><![CDATA[
Stupid mistake, in all .obj models vertexes are indexed from 1, not 0, that caused this stupid behavior<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14200">Alastar</a> — Fri Jan 07, 2022 9:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Alastar]]></name></author>
		<updated>2022-01-07T20:04:47+00:00</updated>

		<published>2022-01-07T20:04:47+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43792#p43792</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43792#p43792"/>
		<title type="html"><![CDATA[bvhTriangleMesh glitch]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43792#p43792"><![CDATA[
I've got terrain data as heightmap and converted it to <strong class="text-strong">bvhTriangleMesh </strong>manually, and I also get some game models (as <strong class="text-strong">.obj</strong>) for game objects on scene and passed verts and tris to <strong class="text-strong">bvhTriangleMesh</strong>. <br>I've used demo application from github to vizualise physics world and get strange behaviour:<br>1) Manually generated terrain mesh looks fine, except strange alignment (looks like it's up axis is <strong class="text-strong">X</strong> or <strong class="text-strong">Z</strong>, not <strong class="text-strong">Y</strong>) and application renders it fine;<br>2) Game models looks totally messed and unrecognizable;<br>Both terrain and game objects meshes use same rendering code, there's no mistake in models itself, I've checked them with <strong class="text-strong">Noesis </strong>viewer. This also can't be bullet wrapper problem because terrain looks ok.<br>What am I doing wrong?<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1899" class="postimage" alt="Снимок.JPG" onclick="viewableArea(this);" /></dt></dl></div>I'm using latest BulletSharp from github (CSharp wrapper)<br>Creation of game objects in code (C#):<div class="codebox"><p>Code: </p><pre><code>            foreach (int key in FixtureInfos.Keys)            {                FixtureInfo info = FixtureInfos[key]; //getting info about game model                //safe checks                if (!ModelInfos.ContainsKey(info.NifID))                {                    Console.WriteLine($"Missing fixture info: {info.NifID} - {info.Name} in {path}");                    continue;                }                if (!BulletOcclusion.Fixtures.ContainsKey(ModelInfos[info.NifID].ModelName))                {                    Console.WriteLine($"Missing model: {ModelInfos[info.NifID].ModelName}");                    continue;                }                //                //creating bvh from pre loaded model                BvhTriangleMeshShape shape = BulletOcclusion.Fixtures[ModelInfos[info.NifID].ModelName];//translating it and rotating                Matrix startTransform = Matrix.Translation(new BulletSharp.Vector3( //translation                        (float)info.X,                        (float)info.Y,                        (float)info.Z                    ));                startTransform = Matrix.Add(startTransform, Matrix.RotationQuaternion(BulletSharp.Quaternion.RotationAxis(new BulletSharp.Vector3((float)info.XAxis, (float)info.YAxis, (float)info.ZAxis), info.Angle3D)));                //creating rigidbody itself                myMotionState = new DefaultMotionState(startTransform);                rbInfo = new RigidBodyConstructionInfo(0.0f, myMotionState, shape);                rigid = new FixtureRigidBody(rbInfo, info.ID, info.NifID, info.Name);                rigid.CollisionFlags |= CollisionFlags.StaticObject;                AddRigidBody(rigid);                rbInfo.Dispose();            }            FixtureInfos.Clear();</code></pre></div>Reading models and creating collision shapes for them:<div class="codebox"><p>Code: </p><pre><code>ObjModel model = new ObjModel();        model.Deserialize(bytes);        if (model.Vertices.Length &gt; 0 &amp;&amp; model.Polygons.Length &gt; 0)        {        TriangleIndexVertexArray indexVertexArray = new TriangleIndexVertexArray(model.Polygons, model.Vertices);        BvhTriangleMeshShape shape = new BvhTriangleMeshShape(indexVertexArray, true, true);        Fixtures.TryAdd(name, shape);        Console.WriteLine($"Loaded model: {name}");        }        else        {        Console.WriteLine($"Model {name} has no faces or polygons!");        }</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14200">Alastar</a> — Fri Jan 07, 2022 8:04 pm</p><hr />
]]></content>
	</entry>
	</feed>
