Installing VC++ and Windows Platform SDK

Miscellaneous Forums/General Discussion/Installing VC++ and Windows Platform SDK

What a mess. I installed VC 2008 because it is the latest, but I can't figure out what the current version of the platform SDK is. MS's page says that the 2008 version is a prerelease...what am I supposed to use?

As far as I know, VC 2008 Express doesn't need the platform SDK (unlike VC 2005 Express, which was a pain).

In the VC2008 (E) Version the PSDK (Windows SDK) is included, in VC2005 Express not.

Also the VC2008 Express is final. : http://www.microsoft.com/express/vc/

cu

Then why won't my shit compile? See the Milkshape exporter thread.

This is the latest win32 sdk (ignore the server 2003 reference)

http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en

Open "Tools" and then OPTIONS.
Go to the menu "Projects and Solutions" -->VC++ Directories.

In the "Executable" tree look if $(PATH) is the last in the list, if not make it the last. After this add this three lines as first.

$(SystemRoot)
$(SystemRoot)\System32
$(SystemRoot)\System32\wbem

And look if this one is somewhere, if not make it behind :

$(WindowsSdkDir)\bin

Now to the INCLUDES, look if this line is there :

$(WindowsSdkDir)\include

If Yes its ok, else ask again and i will post them all.

Now look into Library Files for this one.

$(WindowsSdkDir)\lib

If this line isnt there post it, and i will post them all again.

After this try to compile and post me the errorlog of there is a problem.

bye

Here is what the includes data looks like:


The path to windows.h is "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include"

And now install the dx9 sdk again or add it's paths manually?

?

Have you used the online installer ore have you installed on a previous version? This is not a "complete" installation of VC++ 2008 Express and not the right pfad (PlatformSDK) of a VC2008 installation as this not longer use the term "PlatformSDK".

Uninstall all this, load here the complett ISO Image of the studio and install it offline.
http://download.microsoft.com/download/8/B/5/8B5804AD-4990-40D0-A6AA-CE894CBBB3DC/VS2008ExpressENUX1397868.iso

and you will be happy.

bye

I am using VC2005 because I have heard 2008 has problems.

I do not have a DVD burner, and that ISO is 800 mb.

I do not have a DVD burner, and that ISO is 800 mb.

You shouldn't have to download the ISO, the web installer of Visual Studio 2008 worked fine for me.

I am using VC2005 because I have heard 2008 has problems.

You're correct that 2008 can have problem with some libraries, but the fact that you're using VC2005 Express and not VC2008 means that you have to install the Windows Platform SDK yourself (unlike 2008 or any other edition of VC2005).

By "install the Windows Platform SDK" I don't just mean running through it's install program and letting it place it's files on your computer - there's a list of instructions you need to follow to actually link the SDK up with VS2005 express. Here's a page with the instructions:

http://msdn2.microsoft.com/en-us/library/ms235626(VS.80).aspx

Is the web installer of VC 2008 that thing where you download like 15 cab files?

No, you just download a exe from here:
http://www.microsoft.com/express/download/default.aspx#webInstall

And it works just like any other installer, except it takes a little longer since it has to download everything first (although I don't remember it taking especially long).

It worked in VC2008 with a fresh install. Thank you everyone for your help, and sorry for my short temper.

One more question before I go to bed...I built the project, and it created a lot of files in the Release folder, but I don't actually see a dll in there. How do I make the dll, which is the actual MilkShape plugin?

If it's a DLL project and it built successfully, the DLL should be there somewhere (there's no extra step to perform to make the DLL). It really depends on how the project is set up, but you may have been looking at the release object files (some projects have two release folders - one for the object files and another for the actual DLL or EXE). I'd try rebuilding (just to make sure) and using Windows search on your project folder for *.dll. Some projects go as far as moving the DLL straight into the target folder (which in this case would be Milkshape's plugin folder).

@Leadwerks.

Download the iso, mount the image with DAEMON TOOLS and start the installer, where is the problem? You dont need to burn a CD or DVD in the year 2008 to install something. ;)

Download the iso, mount the image with DAEMON TOOLS and start the installer, where is the problem? You dont need to burn a CD or DVD in the year 2008 to install something. ;)


You can also browse & extract a .ISO from within WinRAR without burning it to a disc.

Okay, I compiled the plugin and it works. I would really prefer to pay someone to do this, so the offer is still open.

Need help, please IM me on MSN under jklint at leadwerks dot com.

I have it started. This is MSPluginImpl.cpp:
/*

Milkshape3D exporter V1.2

This baby is Public Domain!

By Mark Sibly.

Enhanced by Mete Ciragan
*/

#include "stdafx.h"
#include "msPlugInImpl.h"
#include "msLib.h"

#include <math.h>

#include <map>
#include <vector>
#include <string>

using namespace std;

const float PI=3.14159265359f; //180 degrees
const float TWOPI=PI*2.0f; //360 degrees
const float HALFPI=PI*.5f; //90  degrees
const float QUARTERPI=PI*.25f; //45  degrees

static FILE *file;
static vector<int> chunk_stack;
static vector<int> vertex_bones;
static map<string,int> tex_map;
static vector< vector<int> > bone_vertices;
static vector< vector<int> > bone_weights;

static float pos0[]={0,0,0};
static float scl1[]={1,1,1};
static float rot0[]={0,0,0};

static void eulerToQuat( const float euler[3],float quat[4] ){
	float r=euler[0];
	float p=euler[1];
	float y=euler[2];
	float sp=sin(p/2),cp=cos(p/2);
	float sy=sin(y/2),cy=cos(y/2);
	float sr=sin(r/2),cr=cos(r/2);
	quat[0]=cr*cp*cy + sr*sp*sy;
	quat[1]=sr*cp*cy - cr*sp*sy;
	quat[2]=cr*sp*cy + sr*cp*sy;
	quat[3]=cr*cp*sy - sr*sp*cy;

	quat[3]=-quat[3];
}

static void mulQuats( const float a[4],const float b[4],float c[4] ){
	c[0]=a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
	c[1]=a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
	c[2]=a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
	c[3]=a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0];
}

static void quatToMat( const float q[4],float mat[9] ){
	float xx=q[1]*q[1],yy=q[2]*q[2],zz=q[3]*q[3];
	float xy=q[1]*q[2],xz=q[1]*q[3],yz=q[2]*q[3];
	float wx=q[0]*q[1],wy=q[0]*q[2],wz=q[0]*q[3];

	mat[0]=1-2*(yy+zz);mat[1]=  2*(xy-wz);mat[2]=  2*(xz+wy);
	mat[3]=  2*(xy+wz);mat[4]=1-2*(xx+zz);mat[5]=  2*(yz-wx);
	mat[6]=  2*(xz-wy);mat[7]=  2*(yz+wx);mat[8]=1-2*(xx+yy);
}

static void matMulVec( const float m[9],const float v[3],float t[3] ){
	t[0]=m[0] * v[0] + m[3] * v[1] + m[6] * v[2];
	t[1]=m[1] * v[0] + m[4] * v[1] + m[7] * v[2];
	t[2]=m[2] * v[0] + m[5] * v[1] + m[8] * v[2];
}

static int swap_endian( int n ){
	return ((n&0xff)<<24)|((n&0xff00)<<8)|((n&0xff0000)>>8)|((n&0xff000000)>>24);
}

static void write( const void *buf,int sz ){
	fwrite( buf,sz,1,file );
}

static void writeByte( char c ){
	write( &c,1 );
}

static void writeInt( int n ){
	write( &n,4 );
}

static void writeIntArray( int t[],int n ){
	for( int k=0;k<n;++k ) writeInt( t[k] );
}

static void writeFloat( float n ){
	write( &n,4 );
}

static void writeFloatArray( const float t[],int n ){
	for( int k=0;k<n;++k ) writeFloat( t[k] );
}

static void writeString( const string &t ){
	for( int k=0;k<(int)t.size() && t[k];++k ) writeByte( t[k] );
	writeByte( 0 );
}

static void writePos( const float pos[3] ){
	float t[]={ pos[0],pos[1],-pos[2] };
	writeFloatArray( t,3 );
}

static void writeScale( const float scl[3] ){
	writeFloatArray( scl,3 );
}

static void writeRot( const float rot[3] ){
	float t[4];
	eulerToQuat( rot,t );
	writeFloatArray( t,4 );
}

static void beginChunk( int tag ){
	writeInt( swap_endian( tag ) );
	writeInt( 0 );
	chunk_stack.push_back( ftell( file ) );
}

static void endChunk(){
	int n=ftell( file );
	fseek( file,chunk_stack.back()-4,SEEK_SET );
	writeInt( n-chunk_stack.back() );
	chunk_stack.pop_back();
	fseek( file,n,SEEK_SET );
}

static void writeMesh( msModel *model )
{

	beginChunk( 'MESH' );
	writeInt( -1 ); //entity brush_id

	//1 - byte
	//2 - word
	//3 - int
	//4 - float
	//5 - double

	beginChunk( 'VRTS' );
	writeInt( 4 );
	for( k=0;k<numMeshes;++k ){
		msMesh *mesh=msModel_GetMeshAt(model, k);
		int numVertices = msMesh_GetVertexCount(mesh);
		for( int j=0;j<numVertices;++j ){
			msVertex *vert=msMesh_GetVertexAt(mesh, j);
			msVertexEx *vert2=msMesh_GetVertexExAt(mesh, j);
			msVec3 pos;
			msVertex_GetVertex(vert, pos);
			writePos( pos );
		}
	}
	endChunk();

	beginChunk( 'VRTS' );
	writeInt( 0 ); //flags
	writeInt( 1 ); //1 tex coord set
	writeInt( 2 ); //2 tex coord components
	int k;
	int numMeshes = msModel_GetMeshCount(model);
	int first_vert=0;
	for( k=0;k<numMeshes;++k ){
		msMesh *mesh=msModel_GetMeshAt(model, k);
		int numVertices = msMesh_GetVertexCount(mesh);
		for( int j=0;j<numVertices;++j ){
			msVertex *vert=msMesh_GetVertexAt(mesh, j);
			msVertexEx *vert2=msMesh_GetVertexExAt(mesh, j);
			msVec3 pos;
			msVertex_GetVertex(vert, pos);
			writePos( pos );
			msVec2 st;
			msVertex_GetTexCoords(vert, st);
			writeFloat( st[0] );
			writeFloat( st[1] );
			int boneIndex = msVertex_GetBoneIndex(vert);
			int boneIndex2 = msVertexEx_GetBoneIndices(vert2, 0);
			int boneIndex3 = msVertexEx_GetBoneIndices(vert2, 1);
			int boneIndex4 = msVertexEx_GetBoneIndices(vert2, 2);
			int weight1 = msVertexEx_GetBoneWeights(vert2, 0);
			int weight2 = msVertexEx_GetBoneWeights(vert2, 1);
			int weight3 = msVertexEx_GetBoneWeights(vert2, 2);
			int weight4 = 100 - (weight1 + weight2 + weight3);
			if (boneIndex >= 0 && boneIndex < (int) bone_vertices.size())
			{
				bone_vertices[boneIndex].push_back(first_vert + j);
				bone_weights[boneIndex].push_back(weight1);
			}
			if (boneIndex2 >= 0 && boneIndex2 < (int) bone_vertices.size())
			{
				bone_vertices[boneIndex2].push_back(first_vert + j);
				bone_weights[boneIndex2].push_back(weight2);
			}
			if (boneIndex3 >= 0 && boneIndex3 < (int) bone_vertices.size())
			{
				bone_vertices[boneIndex3].push_back(first_vert + j);
				bone_weights[boneIndex3].push_back(weight3);
			}
			if (boneIndex4 >= 0 && boneIndex4 < (int) bone_vertices.size())
			{
				bone_vertices[boneIndex4].push_back(first_vert + j);
				bone_weights[boneIndex4].push_back(weight4);
			}
			//vertex_bones.push_back( boneIndex );
		}
		first_vert+=numVertices;
	}
	endChunk();

	first_vert=0;
	for( k=0;k<numMeshes;++k ){
		msMesh *mesh=msModel_GetMeshAt(model, k);
		beginChunk( 'TRIS' );
		int materialIndex = msMesh_GetMaterialIndex(mesh);
		writeInt( materialIndex );
		int numTriangles = msMesh_GetTriangleCount(mesh);
		for( int j=0;j<numTriangles;++j ){
			msTriangle *tri=msMesh_GetTriangleAt(mesh, j);
			word indices[3];
			msTriangle_GetVertexIndices(tri, indices);
			writeInt( first_vert+indices[0] );
			writeInt( first_vert+indices[2] );
			writeInt( first_vert+indices[1] );
		}
		int numVertices = msMesh_GetVertexCount(mesh);
		first_vert+=numVertices;
		endChunk();
	}

	endChunk();
}

static void writeKeys( msBone *bone ){
	int k;

	float bone_rot[4];
	msVec3 boneRot;
	msBone_GetRotation(bone, boneRot);
	eulerToQuat( boneRot,bone_rot );

	float bone_mat[9];
	quatToMat( bone_rot,bone_mat );

	int numPositionKeys = msBone_GetPositionKeyCount(bone);
	if( numPositionKeys > 0){
		beginChunk( 'KEYS' );
		writeInt( 1 );
		for( k=0;k<numPositionKeys;++k ){
			msPositionKey *key=msBone_GetPositionKeyAt(bone, k);

			float key_pos[]={
				key->Position[0],
				key->Position[1],
				-key->Position[2]
			};
			float t_pos[3];
			matMulVec( bone_mat,key_pos,t_pos );
			msVec3 bonePos;
			msBone_GetPosition(bone, bonePos);
			float pos[]={
				t_pos[0]+bonePos[0],
				t_pos[1]+bonePos[1],
				t_pos[2]-bonePos[2]
			};

			writeInt( (int) key->fTime );
			writeFloatArray( pos,3 );
		}
		endChunk();
	}
	int numRotationKeys = msBone_GetRotationKeyCount(bone);
	if( numRotationKeys > 0 ){
		beginChunk( 'KEYS' );
		writeInt( 4 );
		for( k=0;k<numRotationKeys;++k ){
			msRotationKey *key=msBone_GetRotationKeyAt(bone, k);

			float key_rot[4],rot[4];
			eulerToQuat( key->Rotation,key_rot );
			mulQuats( key_rot,bone_rot,rot );

			writeInt( (int) key->fTime );
			writeFloatArray( rot,4 );
		}
		endChunk();
	}
}

static void writeBones( msModel *model,const char *parent ){
	int k;
	int numBones = msModel_GetBoneCount(model);
	for( k=0;k<numBones;++k ){
		msBone *bone=msModel_GetBoneAt(model, k);
		char boneParentName[256];
		msBone_GetParentName(bone, boneParentName, 256);
		if( strcmp( boneParentName,parent ) ) continue;

		beginChunk( 'NODE' );
		char boneName[256];
		msBone_GetName(bone, boneName, 256);
		writeString( boneName );
		msVec3 bonePos;
		msBone_GetPosition(bone, bonePos);
		writePos( bonePos );
		writeScale( scl1 );
		msVec3 boneRot;
		msBone_GetRotation(bone, boneRot);
		writeRot( boneRot );
		beginChunk( 'BONE' );
		//for( int j=0;j<(int)vertex_bones.size();++j ){
		//	if( vertex_bones[j]==k ){
		//		writeInt( j );
		//		writeFloat( 1 );
		//	}
		//}
		for (size_t j = 0; j < bone_vertices[k].size(); j++)
		{
			writeInt(bone_vertices[k][j]);
			writeFloat((float) bone_weights[k][j] / 100.0f);
		}
		endChunk();
		writeKeys( bone );
		writeBones( model,boneName );
		endChunk();
	}
}

static void writeModel( msModel *model ){

	//write TEXS chunk...
	beginChunk( 'TEXS' );
	int k,n_texs=0;
	int numMaterials = msModel_GetMaterialCount(model);
	for( k=0;k<numMaterials;++k ){
		msMaterial *m=msModel_GetMaterialAt(model, k);
		char diffuseTexture[256];
		msMaterial_GetDiffuseTexture(m, diffuseTexture, 256);
		string t=diffuseTexture;
		if( !t.size() ) continue;
		if( tex_map.find( t )!=tex_map.end() ) continue;

		//write out the texture info
		writeString( t ); //file
		writeInt( 1 ); //flags (rgb)
		writeInt( 2 ); //blend (multiply)
		writeFloatArray( pos0,2 ); //position
		writeFloatArray( scl1,2 ); //scale
		writeFloat( 0 ); //rotation

		tex_map.insert( make_pair( t,n_texs ) );
		++n_texs;
	}
	endChunk();

	//write BRUS chunk...
	beginChunk( 'BRUS' );
	writeInt( 1 ); //one tex per brush
	for( k=0;k<numMaterials;++k ){
		msMaterial *m=msModel_GetMaterialAt(model, k);
		char matName[256];
		msMaterial_GetName(m, matName, 256);
		writeString(matName ); //name
		msVec4 matDiffuse;
		msMaterial_GetDiffuse(m, matDiffuse);
		writeFloatArray( matDiffuse,4 ); //color
		writeFloat( 0 ); //shininess
		writeInt( 1 );writeInt( 0 ); //blend/FX
		char diffuseTexture[256];
		msMaterial_GetDiffuseTexture(m, diffuseTexture, 256);
		string t=diffuseTexture;
		if( t.size() ) writeInt( tex_map.find( t )->second );
		else writeInt( -1 );
	}
	endChunk();

	//write geometry/anim...
	beginChunk( 'NODE' );
	writeString( "ROOT" );
	msVec3 modelPos;
	msModel_GetPosition(model, modelPos);
	writePos( modelPos );
	writeScale( scl1 );
	msVec3 modelRot;
	msModel_GetRotation(model, modelRot);
	writeRot( modelRot );
	writeMesh( model );
	int totalFrames = msModel_GetTotalFrames(model);
	if( totalFrames ){
		beginChunk( 'ANIM' );
		writeInt( 0 ); //flags
		writeInt( totalFrames ); //frames
		writeFloat( 0 ); //FPS
		endChunk();
	}
	writeBones( model,"" );
	endChunk();
}

BOOL APIENTRY DllMain( HANDLE hModule,DWORD  ul_reason_for_call,LPVOID lpReserved )
{
	return TRUE;
}

cMsPlugIn *CreatePlugIn()
{
	return new cPlugIn ();
}

void DestroyPlugIn(cMsPlugIn *plugin)
{
	delete plugin;
}

cPlugIn::cPlugIn()
{
}

cPlugIn::~cPlugIn()
{
}

int cPlugIn::GetType()
{
	return cMsPlugIn::eTypeExport;
}

const char *cPlugIn::GetTitle()
{
	//return "Blitz Basic 3D...";
	return "Game Model Format...";
}

int cPlugIn::Execute( msModel *model )
{

	if( !model ) return -1;

	int numMeshes = msModel_GetMeshCount(model);
	int numMaterials = msModel_GetMaterialCount(model);
	int numBones = msModel_GetBoneCount(model);
	if( numMeshes == 0 && numMaterials == 0 && numBones == 0)
	{
		//MessageBox(NULL ,"Nothing to export...", "Blitz3D Exporter", MB_OK|MB_ICONWARNING);
		MessageBox(NULL ,"Nothing to export...", "Game Model Format Exporter", MB_OK|MB_ICONWARNING);
		return 0;
	}

	OPENFILENAME ofn={0};
	char szFile[MS_MAX_PATH];
	char szFileTitle[MS_MAX_PATH];
	//char szDefExt[32] = "b3d";
	//char szFilter[128] = "Blitz3D (*.b3d)\0*.b3d\0All Files (*.*)\0*.*\0\0";
	char szDefExt[32] = "gmf";
	char szFilter[128] = "Game Model Format (*.gmf)\0*.gmf\0All Files (*.*)\0*.*\0\0";
	szFile[0] = '\0';
	szFileTitle[0] = '\0';
	ofn.lStructSize = sizeof (OPENFILENAME);
	ofn.lpstrDefExt = szDefExt;
	ofn.lpstrFilter = szFilter;
	ofn.lpstrFile = szFile;
	ofn.nMaxFile = MS_MAX_PATH;
	ofn.lpstrFileTitle = szFileTitle;
	ofn.nMaxFileTitle = MS_MAX_PATH;
	ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
	ofn.lpstrTitle = "Export Game Model Format";
	if (!GetSaveFileName(&ofn))
		return 0;

	file = fopen(szFile, "wb");
	if (!file)
		return -1;

	bone_vertices.resize(numBones);
	bone_weights.resize(numBones);

	//beginChunk( 'BB3D' );
	beginChunk( 'GMF ' );

	writeInt( 1 ); //version
	writeModel( model );
	endChunk();

	fclose( file );

	tex_map.clear();
	chunk_stack.clear();
	vertex_bones.clear();
	bone_vertices.clear();
	bone_weights.clear();

	//MessageBox( 0,"Successfully exported Blitz3D file","Blitz3D Exporter",MB_OK );

	msModel_Destroy( model );

	return 0;
}


This looks exciting.

I think I'll take it.