Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBJ Support For MD3 Tags For Attachment Tutorial #181

Open
Baker7 opened this issue Jun 1, 2024 · 2 comments
Open

OBJ Support For MD3 Tags For Attachment Tutorial #181

Baker7 opened this issue Jun 1, 2024 · 2 comments

Comments

@Baker7
Copy link

Baker7 commented Jun 1, 2024

Tutorial for OBJ supporting MD3 Tags For Attachment

Step 1: Open model_brush.c
Step 2: Copy the following code and press CTRL-V in appropriate place in Mod_OBJ_Load(model_t *mod, void *buffer, void *bufferend)
Step 3: Declare the int idx I didn't mention
Step 4:

helicopter20

		// Baker: modification "tagname"
		else if (String_Match(argv[0], "tagname")) {
		// tagname propellor_topz -50.2 0.0 26.8
		// tagname propellor_rear 102.8 0.7 20.6
			loadmodel->num_tagframes = 1; // loadmodel->numframes; // Just 1 right?
			idx = loadmodel->num_tags ++;
			loadmodel->data_tags = 
				(aliastag_t *)Mem_Realloc(loadmodel->mempool, loadmodel->data_tags, 
					loadmodel->num_tagframes * loadmodel->num_tags * sizeof(aliastag_t));

			c_strlcpy (loadmodel->data_tags[idx].name, argv[1]);

			loadmodel->data_tags[idx].matrixgl[9] = atof(argv[2]);
			loadmodel->data_tags[idx].matrixgl[10] = atof(argv[3]);
			loadmodel->data_tags[idx].matrixgl[11] = atof(argv[4]);

			// Baker: Throw an identity matrix in there for now, is this right?
			loadmodel->data_tags[idx].matrixgl[0] = 1;
			loadmodel->data_tags[idx].matrixgl[1] = 0;
			loadmodel->data_tags[idx].matrixgl[2] = 0;

			loadmodel->data_tags[idx].matrixgl[3] = 0;
			loadmodel->data_tags[idx].matrixgl[4] = 1;
			loadmodel->data_tags[idx].matrixgl[5] = 0;

			loadmodel->data_tags[idx].matrixgl[6] = 0;
			loadmodel->data_tags[idx].matrixgl[7] = 0;
			loadmodel->data_tags[idx].matrixgl[8] = 1;


OBJS: The main one is helicopter_less_2.obj which uses "tagname propellor_rear 102.8 0.7 20.6" to indicate attachment point.

helicopter.zip

In QuakeC you have do something like:

	entity xt = spawn();	
	setattachment (xt, self, "propellor_topz");
	xt.model = "models/vehicles/helicopter_propellor.obj";

Eventually I'll do a little QuakeC demo with the model.

@hemebond
Copy link
Contributor

@Baker7 Does one add the tagname lines manually to the .obj file or is it already supported by the editor/exporter?

@Baker7
Copy link
Author

Baker7 commented Sep 22, 2024

@Baker7 Does one add the tagname lines manually to the .obj file or is it already supported by the editor/exporter?

Manually. OBJ files are text files.

Note: To self, release something with that helicopter in it so a working example is out in the real world.

Might add -- I have .mdl with attachments also ... you pick a specific triangle of the model and can make it an attachment point ... when the .mdl is loaded, the attachment data is generated for indicated triangles.

backpack_attachment

qmeselecttriangle

qmeselecttriangle1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants