drawing models (lines ?)

Posted By: 3run

drawing models (lines ?) - 05/28/18 23:20

Hi guys!

What would be the best way to draw models with a mouse? I mean some basic ones, like drawing primitives with lines.

As an example, you can take a look at those games like:
Quote:
-Crayon Physics Deluxe
-Love balls

And a small video:
Crayon Trailer

Best regards!
Posted By: MasterQ32

Re: drawing models (lines ?) - 05/29/18 06:37

Store line segments in a list and create mesh at runtime with DirectX functions
Posted By: 3run

Re: drawing models (lines ?) - 05/29/18 12:37

What you meant by line segments? Can you please explain a bit more? Do I need to separate what user has drawn into the segments?
Posted By: Superku

Re: drawing models (lines ?) - 05/29/18 14:59

Check this out:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=464687#Post464687

The following should work as a code base for setting up the mesh:

Code:
ENTITY* createCoolMesh( polygon input )
{
	D3DVERTEX *vertexBuffer;
	short *indexBuffer;
	long *attributeBuffer;
	LPD3DXMESH newMesh = NULL;
	
	int numVertices = polygon vertices;
	int numTriangles = polygon triangles;
	D3DXCreateMesh(numTriangles, numVertices, D3DXMESH_MANAGED , pvertexdecl, pd3ddev, &newMesh);

	newMesh->LockVertexBuffer(0, &vertexBuffer);
	newMesh->LockIndexBuffer(0, &indexBuffer);
	newMesh->LockAttributeBuffer(0, &attributeBuffer);

	set up vertexBuffer[i] (at least the xyz position) for every i < numVertices;
	set up indexBuffer[i] for every i < numTriangles*3;
	set attributeBuffer[i] to 0 for every i < numTriangles;

	newMesh->UnlockVertexBuffer();
	newMesh->UnlockIndexBuffer();
	newMesh->UnlockAttributeBuffer();
	D3DXComputeNormals(newMesh,0);

	ENTITY* ent = ent_create, ent_clone, ent_setmesh
	
	return ent;
}

Posted By: 3run

Re: drawing models (lines ?) - 05/29/18 15:48

Wow! Thank you Superku, I don't know how I even missed that txesmi's awesome contribution! And for your code as well, thank you. laugh

Best regards!
© 2024 lite-C Forums