Important information: this site is currently scheduled to go offline indefinitely by end of the year.

[Need Advice] Looking for help (Scripts)

Post questions about game models here, or help out others!
Post Reply
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

[Need Advice] Looking for help (Scripts)

Post by Valerian »

Hey guys, i like this forum it helped me already alot but i got a few things where i got stuck.
I want to write a script (MAXscript, from 3dsmax 9) to import a model from a game.
I can see the face/vertex sections when i open the model in a HEX-Editor but i dont know how should i continue in the script.
Are there any tutorials to write such a script? I have used the search and i found a tutorial to write a script to reverse a model but it didnt help me much.
I take every help i get, Tutorials/Videos/ or anything else
Thank you
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: [Need Advice] Looking for help (Scripts)

Post by finale00 »

Where exactly are you stuck? You don't know the syntax? You don't know how to read the data? Not sure how to store them? Not sure how to pass the data to MAX?
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by Valerian »

finale00 wrote:Where exactly are you stuck? You don't know the syntax? You don't know how to read the data? Not sure how to store them? Not sure how to pass the data to MAX?

the syntax is quite okay, the MAXscript manual helps me, but the loop maybe for-loop? makes me stuck there, and im not sure to store or how to get the data (model) displayed in 3dsmax
i was looking for tutorials also outside of youtube but i havent found anything, i had a 6 part big tutorial to write a script but the user deleted the videos
Acewell
VIP member
VIP member
Posts: 1330
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2710 times
Been thanked: 884 times

Re: [Need Advice] Looking for help (Scripts)

Post by Acewell »

mariokart64n made some 3dsMax scripting videos but he made them private for some reason. :?

viewtopic.php?f=16&t=5644
WRS
ultra-veteran
ultra-veteran
Posts: 603
Joined: Fri Nov 06, 2009 12:13 am
Has thanked: 74 times
Been thanked: 137 times

Re: [Need Advice] Looking for help (Scripts)

Post by WRS »

there are many examples in the manual on for loops.

to create the mesh object from the vertex/face index data you need to store them in an array before you can create the 3ds 'mesh' object:

Code: Select all

arr_v = #()
for i = 1 to vertCount do
(
	append arr_v [readfloat(f), readfloat(f), readfloat(f)]
)
note face indices need to start from 1 (not 0)

you can create a mesh like so:

Code: Select all

mesh vertices:arr_v faces:arr_f
Useful tool links:
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by Valerian »

AceWell wrote:mariokart64n made some 3dsMax scripting videos but he made them private for some reason. :?

viewtopic.php?f=16&t=5644
the bad thing is, i cant see them, even if i login with my youtube account.
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by Valerian »

WRS wrote:there are many examples in the manual on for loops.

to create the mesh object from the vertex/face index data you need to store them in an array before you can create the 3ds 'mesh' object:

Code: Select all

arr_v = #()
for i = 1 to vertCount do
(
	append arr_v [readfloat(f), readfloat(f), readfloat(f)]
)
note face indices need to start from 1 (not 0)

you can create a mesh like so:

Code: Select all

mesh vertices:arr_v faces:arr_f

okay this start looking good, but for example the section for face indices or vertices start at offset 0x26CA, how do i tell the script to skip the other things and start from there?
WRS
ultra-veteran
ultra-veteran
Posts: 603
Joined: Fri Nov 06, 2009 12:13 am
Has thanked: 74 times
Been thanked: 137 times

Re: [Need Advice] Looking for help (Scripts)

Post by WRS »

Valerian wrote:
WRS wrote:there are many examples in the manual on for loops.

to create the mesh object from the vertex/face index data you need to store them in an array before you can create the 3ds 'mesh' object:

Code: Select all

arr_v = #()
for i = 1 to vertCount do
(
	append arr_v [readfloat(f), readfloat(f), readfloat(f)]
)
note face indices need to start from 1 (not 0)

you can create a mesh like so:

Code: Select all

mesh vertices:arr_v faces:arr_f

okay this start looking good, but for example the section for face indices or vertices start at offset 0x26CA, how do i tell the script to skip the other things and start from there?
you might be familiar with fseek from other languages - the 3ds syntax is:

Code: Select all

fseek f 0x26CA #seek_set
(to skip data, use #seek_cur)
Useful tool links:
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by Valerian »

WRS wrote:
Valerian wrote:
WRS wrote:there are many examples in the manual on for loops.

to create the mesh object from the vertex/face index data you need to store them in an array before you can create the 3ds 'mesh' object:

Code: Select all

arr_v = #()
for i = 1 to vertCount do
(
	append arr_v [readfloat(f), readfloat(f), readfloat(f)]
)
note face indices need to start from 1 (not 0)

you can create a mesh like so:

Code: Select all

mesh vertices:arr_v faces:arr_f

okay this start looking good, but for example the section for face indices or vertices start at offset 0x26CA, how do i tell the script to skip the other things and start from there?
you might be familiar with fseek from other languages - the 3ds syntax is:

Code: Select all

fseek f 0x26CA #seek_set
(to skip data, use #seek_cur)
thank you so much! Now i can try more :P
when i need more help i will post it here but first i want to try it :)
Valerian
beginner
Posts: 20
Joined: Tue Jul 19, 2011 11:25 pm
Location: Germany
Has thanked: 1 time
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by Valerian »

so guys, my script looks like this:

Code: Select all

fseek f 0x26CA #seek_cur

vx = float
vy = float
vz = float

i = float
arr_v = #()
for i = 1 to 177 do
(
	vx = readfloat f
	vy = readfloat f
	vz = readfloat f
	append (arr_v) [readfloat(f), readfloat(f), readfloat(f)]
	print arr_v 

)
	mesh vertices:arr_v faces:arr_f
when i want to execute it i get the error:
-- Error occurred in i loop; filename: C:\Users\Admin\Desktop\test.ms; position: 329
-- Frame:
-- i: 1
-- Error occurred during fileIn in <File:C:\Users\Admin\Desktop\test.ms>
>> MAXScript FileIn Exception: -- Unable to convert: undefined to type: Float <<

what am i doing wrong?
also whats this:
for i = 1 to "vertCount" do
what is the vertCount or any explanation?
MichaelDarkAngel
mega-veteran
mega-veteran
Posts: 267
Joined: Thu Nov 04, 2010 11:25 pm
Location: Somewhere, out there... But, not quite here...
Has thanked: 133 times
Been thanked: 165 times
Contact:

Re: [Need Advice] Looking for help (Scripts)

Post by MichaelDarkAngel »

Valerian wrote:so guys, my script looks like this:

Code: Select all

fseek f 0x26CA #seek_cur

vx = float
vy = float
vz = float

i = float
arr_v = #()
for i = 1 to 177 do
(
	vx = readfloat f
	vy = readfloat f
	vz = readfloat f
	append (arr_v) [readfloat(f), readfloat(f), readfloat(f)]
	print arr_v 

)
	mesh vertices:arr_v faces:arr_f
when i want to execute it i get the error:
-- Error occurred in i loop; filename: C:\Users\Admin\Desktop\test.ms; position: 329
-- Frame:
-- i: 1
-- Error occurred during fileIn in <File:C:\Users\Admin\Desktop\test.ms>
>> MAXScript FileIn Exception: -- Unable to convert: undefined to type: Float <<

what am i doing wrong?
also whats this:
for i = 1 to "vertCount" do
what is the vertCount or any explanation?
Your variables should be defined as follows

Code: Select all

vx = 0
vy = 0
vz = 0
i = 0
Generally you can find the number of vertices somewhere else in the file. Because not every model is created equal "vertCount" is a variable so that your script can work with more than one model. If you can't pinpoint the number of vertices in the file, but you know that the number you are using is correct, then it's fine to hard-code that for testing your script.

The reading of the vertices I would do in this fashion

Code: Select all

for i = 1 to 177 do
(
     vx = readFloat f
     vy = readFloat f
     vz = readFloat f

     arr_v[i] = (point3 vx vy vz)
)
From there move on to reading your faces in a similar manor.
Image
MDA

Like TBotR on Facebook
ARchive_neXt v4.03.27.0 Now Available!

"I intend to leave a memory of myself in the minds of others."
Leonardo da Vinci,
disciple of experience
Post Reply