June 29, 2009

It lives!

Posted in Computer Graphics tagged , , , , , , , , , , , , , at 11:55 pm by sagito

The Conspiracy engine is already rendering stuff! 😀 Yesterday I managed to get a teapot (the CG Hello World thing) on the screen! Also, I have implemented input with DirectInput. To be quite honest, I was quite afraid of doing so because the DirectInput’s usual approach requires polling. Although I could wire it up to the WndProc and receive events through there, this is quite painful and not documented… However, the performance of DirectInput is nevertheless stunning at the moment!

Also, the Memory Management Layer (MML) has proved itself very useful as everything is being released as it should, obtaining a great memory performance too. Now I’m developing an importer of 3D files, exported directly from 3D Studio Max. However, I did not want to rely on Microsoft’s .X file because this format is now marked as deprecated and as far as I know, there is no substitute so far… So, I’m trying to build my very own MaxScript exporter for 3DS Max! So far it only exports geometry data, but I will try to make it export materials, textures and so on very soon! Also, I would like to make it export skeletal animations, but that does not seem easy at this moment…

For those of you who are interested or cannot find any example of how to do this, here is my (rather naive yet)  approach (the code is poorly structured, I didn’t had the time to organize it yet, I’m sorry):

–Start by selecting every darn thing
select $*

out_name = ((GetDir #export) + “/test.cmf”)
out_file = createfile out_name

–For every one of them
for obj in $ where superclassof obj == geometryclass do
(
–Convert every single one of them to poly
p = convertToPoly(obj)

–Get the number of faces
format “Name: %\n” p.name to:out_file
polyop.setFaceSelection p #all
faces = polyop.getFaceSelection p

format “Faces: %\n” faces.count to:out_file

–For every face
for i = 1 to faces.count do
(
–Why is this boolean?
if (faces[i]) then
(
faceVerts = polyop.getFaceVerts p i

if (faceVerts.count == 4) then
(
v1 = polyop.getVert p faceVerts[1]
v2 = polyop.getVert p faceVerts[2]
v3 = polyop.getVert p faceVerts[3]
v4 = polyop.getVert p faceVerts[4]

format “% % % %\n” v1 v2 v3 v4 to:out_file
outstr = (v1 as string) + ” ” + (v2 as string) + ” ” + (v3 as string) + ” ” + (v4 as string)
print outstr
)
)
)
)

More news will be coming very soon 😉