• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

How to build mesh position Matrix from COLLADA file?

5 posts in this topic



I write a converter from COLLADA to binary now and I faced with the problem:

I want to get mesh matrix from visual scenes to know how to set object in the world, but when I export mesh from 3ds max without triangulating than instead of matrix element I get only this:

<node name="Box001" id="Box001" sid="Box001">
	  <translate sid="translate">11.348564 0.000000 0.590027</translate>
	  <rotate sid="jointOrientX">1 0 0 -90.000000</rotate>
	  <instance_geometry url="#Box001-lib"/><extra><technique profile="FCOLLADA"><visibility>1.000000</visibility></technique></extra></node>


or this if I rotate this mesh before export:


<node name="Torus001" id="Torus001" sid="Torus001">
	  <translate sid="translate">5.463669 0.000000 -20.828049</translate>
	  <rotate sid="jointOrientX">1 0 0 -90.000000</rotate>
	  <rotate sid="rotateX">1 0 0 90.739616</rotate><instance_geometry url="#Torus001-lib"/><extra><technique profile="FCOLLADA"><visibility>1.000000</visibility></technique></extra></node>

Does some one know how to build from this values matrix 4*4 for DirectX?

And another question I ask, I think, in wrong thread - http://www.gamedev.net/topic/640322-issue-with-fbx-collada-exporter-in-3ds-max/#entry5043330

Who now answer for those questions, please help me with it. 


Share this post

Link to post
Share on other sites


try this : 


Matrix Trans = Matrix.Translation(5.463,0,-20);

Matrix RotX = Matrix.RotateX(DegreeToRadian(90.7396));

Matrix RotY = Matrix.RotateY(DegreeToRadian(0));

Matrix RotZ = Matrix.RotateZ(DegreeToRadian(0));

Matrix Scale = Matrix.Scaling(1,1,1);


TransformMatrix = Scale * RotX * RotY * RotZ * Trans;


This worked for me with XSI exporetd Collada.

Edited by hossainiir

Share this post

Link to post
Share on other sites
You just need to be able to parse the translate/rotate elements and build from them translation matrices and axis-angle rotation matrices, then multiply them all together in order. My parsing code for collada node transforms looks like:
            Matrix4 matrix = Matrix4.identity.Clone();
            XmlNodeList transforms = node.SelectNodes("c:rotate | c:translate | c:scale | c:skew | c:matrix | c:lookat", nsm);
            foreach (XmlNode transform in transforms)
                string type = transform.Name;
                switch (type)
                    case "rotate":
                        Vector4 rotation = Vector4.Parse(transform.InnerText);
                    case "translate":
                        Vector4 translation = Vector4.Parse(transform.InnerText);
                    case "scale":
                        Vector4 scaling = Vector4.Parse(transform.InnerText);
                    case "matrix":
                        Matrix4 transformMatrix = Matrix4.ParseRowMajor(transform.InnerText);
                    case "skew":
                    case "lookat":
                        throw new ApplicationException(String.Format("The {0} transform type isn't implemented!", type));
            newNode.local = matrix;
            newNode.global = Matrix4.Multiply(global, newNode.local);

Share this post

Link to post
Share on other sites

Hello to all again.

At last I implement taking out all rotations, translation and scaling. and do as said hossainiir, but It doesn`t work correctly.


If I use single matrix - scene load correctly, but if not - meshes displays not on their places as they was in 3d max originally.


On screen I use can see original 3s max scene in front.


on screen2 - scene after loading without single matrix


on screen3 displays the same scene WITH single matrix


on screen4 - you can see another one problem which I didn`t mention yet. When I begin rotation of mesh it loose its scaling and became exactly the same as it was before I use scaling in 3ds max and in addition it becomes very small. I actually export with millimeters, but I think that small size is not the real problem . Real problem is that mesh loose its form.


So, I have 2 problems.


Here is some code to show how I use matrices.

float x = 0;
float y = 0;
float z = 0;
XMMATRIX scale = XMMatrixScaling(x, y, z);


XMMATRIX rotationX = XMMatrixRotationX(x);
XMMATRIX rotationY = XMMatrixRotationY(y);
XMMATRIX rotationZ = XMMatrixRotationZ(z);


XMMATRIX translation = XMMatrixTranslation(x, y, z);
meshInfo->meshPosition = scale * rotationX * rotationY * rotationZ * translation;

After that I made the following to translate Y_UP 3s max right hand coordinate system to Y_UP left hand coordinate system in DirectX


	cm._11 = 1;
	cm._12 = 0;
	cm._13 = 0;
	cm._14 = 0;
	cm._21 = 0;
	cm._22 = 0;
	cm._23 = 1;
	cm._24 = 0;
	cm._31 = 0;
	cm._32 = 1;
	cm._33 = 0;
	cm._34 = 0;
	cm._41 = 0;
	cm._42 = 0;
	cm._43 = 0;
	cm._44 = 1;
	XMMATRIX axisZ_UPtoY_UP = XMLoadFloat4x4(&cm);

XMMATRIX scale = XMMatrixScaling(1.0f, 1.0f, -1.0f);
meshInfo->meshPosition = axisZ_UPtoY_UP*meshInfo->meshPosition;
meshInfo->meshPosition = meshInfo->meshPosition*scale;

and then I load geometry


for (int i = 0; i<meshesList[index]->vertexCount; i++)
vertices[i].position = XMFLOAT3(meshesList[index]->meshType[i].x, meshesList[index]->meshType[i].z, -meshesList[index]->meshType[i].y);
vertices[i].texture = XMFLOAT2(1-meshesList[index]->meshType[i].tu, 1-meshesList[index]->meshType[i].tv);
vertices[i].normal = XMFLOAT3(meshesList[index]->meshType[i].nx, meshesList[index]->meshType[i].nz, -meshesList[index]->meshType[i].ny);

Thats all. Could anyone tell me what I am doing wrong here?



Share this post

Link to post
Share on other sites

Update: I fix issue with positioning. I just forgot to convert values to radians, but issue with scaling is still present.

Update 2: issue 2 was also fixed.

Edited by BlackJoker

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0